csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.8 KiB
71 lines
2.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using Avalonia.Controls.Platform;
|
|
using Avalonia.Input;
|
|
using Avalonia.Input.Platform;
|
|
using Avalonia.Platform;
|
|
using Avalonia.Remote.Protocol;
|
|
using Avalonia.Rendering;
|
|
|
|
namespace Avalonia.DesignerSupport.Remote
|
|
{
|
|
class PreviewerWindowingPlatform : IWindowingPlatform, IPlatformSettings
|
|
{
|
|
static readonly IKeyboardDevice Keyboard = new KeyboardDevice();
|
|
private static IAvaloniaRemoteTransportConnection s_transport;
|
|
private static DetachableTransportConnection s_lastWindowTransport;
|
|
private static PreviewerWindowImpl s_lastWindow;
|
|
public static List<object> PreFlightMessages = new List<object>();
|
|
|
|
public ITrayIconImpl CreateTrayIcon() => null;
|
|
|
|
public IWindowImpl CreateWindow() => new WindowStub();
|
|
|
|
public IWindowImpl CreateEmbeddableWindow()
|
|
{
|
|
if (s_lastWindow != null)
|
|
{
|
|
s_lastWindowTransport.Dispose();
|
|
try
|
|
{
|
|
s_lastWindow.Dispose();
|
|
}
|
|
catch
|
|
{
|
|
//Ignore
|
|
}
|
|
}
|
|
s_lastWindow =
|
|
new PreviewerWindowImpl(s_lastWindowTransport = new DetachableTransportConnection(s_transport));
|
|
foreach (var pf in PreFlightMessages)
|
|
s_lastWindowTransport.FireOnMessage(s_lastWindowTransport, pf);
|
|
return s_lastWindow;
|
|
}
|
|
|
|
public static void Initialize(IAvaloniaRemoteTransportConnection transport)
|
|
{
|
|
s_transport = transport;
|
|
var instance = new PreviewerWindowingPlatform();
|
|
var threading = new InternalPlatformThreadingInterface();
|
|
AvaloniaLocator.CurrentMutable
|
|
.Bind<IClipboard>().ToSingleton<ClipboardStub>()
|
|
.Bind<ICursorFactory>().ToSingleton<CursorFactoryStub>()
|
|
.Bind<IKeyboardDevice>().ToConstant(Keyboard)
|
|
.Bind<IPlatformSettings>().ToConstant(instance)
|
|
.Bind<IPlatformThreadingInterface>().ToConstant(threading)
|
|
.Bind<IRenderLoop>().ToConstant(new RenderLoop())
|
|
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
|
|
.Bind<IWindowingPlatform>().ToConstant(instance)
|
|
.Bind<IPlatformIconLoader>().ToSingleton<IconLoaderStub>()
|
|
.Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>();
|
|
|
|
}
|
|
|
|
public Size DoubleClickSize { get; } = new Size(2, 2);
|
|
public TimeSpan DoubleClickTime { get; } = TimeSpan.FromMilliseconds(500);
|
|
|
|
public Size TouchDoubleClickSize => new Size(16, 16);
|
|
|
|
public TimeSpan TouchDoubleClickTime => DoubleClickTime;
|
|
}
|
|
}
|
|
|