Abstracted RenderWindow for platform-specific implementations

This commit is contained in:
Yoshi Askharoun
2021-07-29 14:02:25 -05:00
parent 37d2410a51
commit 094a1d2efd
27 changed files with 1591 additions and 801 deletions
+3
View File
@@ -16,3 +16,6 @@ using System.Security.Permissions;
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyVersion("4.8.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
// Allow platform-specific extensions to access internals
[assembly: InternalsVisibleTo("UIX.RenderAPI.Skia.Uno")]
@@ -8,6 +8,6 @@ namespace Microsoft.Iris.Render.Graphics
{
internal interface ITreeOwner
{
TreeNode Root { get; }
internal TreeNode Root { get; }
}
}
@@ -18,7 +18,7 @@ namespace Microsoft.Iris.Render.Graphics
private RemoteSprite m_remoteSprite;
private Effect m_effect;
public Sprite(RenderSession session, RenderWindow window, object objOwnerData)
public Sprite(RenderSession session, RenderWindowBase window, object objOwnerData)
: base(session, window, objOwnerData)
{
this.m_remoteSprite = session.BuildRemoteSprite(this, window);
@@ -33,7 +33,7 @@ namespace Microsoft.Iris.Render.Graphics
public static readonly string RotationProperty = nameof(Rotation);
public static readonly string ScaleProperty = nameof(Scale);
public static readonly string SizeProperty = nameof(Size);
protected RenderWindow m_window;
protected RenderWindowBase m_window;
protected RemoteVisual m_remoteVisual;
private Vector3 m_vecPosition;
private Vector2 m_vecSize;
@@ -83,7 +83,7 @@ namespace Microsoft.Iris.Render.Graphics
s_sectionPropIDMap[9] = s_bvsNineGrid;
}
internal Visual(RenderSession session, RenderWindow window, object objOwnerData)
internal Visual(RenderSession session, RenderWindowBase window, object objOwnerData)
: base(window)
{
Debug2.Validate(session != null, typeof(ArgumentNullException), "Must have valid session");
@@ -25,7 +25,7 @@ namespace Microsoft.Iris.Render.Graphics
internal VisualContainer(
bool isRoot,
RenderSession session,
RenderWindow window,
RenderWindowBase window,
object objOwnerData,
out RemoteVisual remoteVisual)
: base(session, window, objOwnerData)
@@ -156,7 +156,7 @@ namespace Microsoft.Iris.Render.Internal
Interlaced = this.m_modeCurrent.fInterlaced
}, this.m_modeCurrent.fTvMode);
flag = true;
this.m_engine.Window.NotifyDisplayReconfigured();
//this.m_engine.Window.NotifyDisplayReconfigured();
}
return flag;
}
@@ -19,6 +19,7 @@ namespace Microsoft.Iris.Render.Internal
private RenderCaps m_renderCaps;
private GraphicsDeviceType m_typeGraphics;
private SoundDeviceType m_typeSound;
private RenderWindowBase m_renderWindow;
private InputSystem m_inputSystem;
private SoundDevice m_soundDevice;
private ContextID m_localContextId;
@@ -98,7 +99,9 @@ namespace Microsoft.Iris.Render.Internal
internal RenderSession Session => m_renderSession;
IRenderWindow IRenderEngine.Window => null;
IRenderWindow IRenderEngine.Window => m_renderWindow;
internal RenderWindowBase Window => m_renderWindow;
IDisplayManager IRenderEngine.DisplayManager => null;
@@ -307,7 +307,7 @@ namespace Microsoft.Iris.Render.Internal
internal RemoteVisualContainer BuildRemoteVisualContainer(Visual visual) => this.RenderingProtocol.BuildRemoteVisualContainer(visual);
internal RemoteSprite BuildRemoteSprite(Sprite sprite, RenderWindow window)
internal RemoteSprite BuildRemoteSprite(Sprite sprite, RenderWindowBase window)
{
switch (window.GraphicsDeviceType)
{
File diff suppressed because it is too large Load Diff
@@ -12,23 +12,26 @@ namespace Microsoft.Iris.Render
{
public sealed class IrisEngineInfo : EngineInfo
{
private RenderWindowBase m_renderWindow;
private SKSurface m_skSurface;
private ConnectionInfo m_connectionInfo;
public static EngineInfo CreateLocal(SKSurface skSurface) => new IrisEngineInfo(skSurface, true);
public static EngineInfo CreateLocal(SKSurface skSurface, RenderWindowBase renderWindow) => new IrisEngineInfo(skSurface, renderWindow, true);
public static EngineInfo CreateRemote(SKSurface skSurface) => new IrisEngineInfo(skSurface, true, TransportProtocol.TCP, "127.0.0.1", false);
public static EngineInfo CreateRemote(SKSurface skSurface, RenderWindowBase renderWindow) => new IrisEngineInfo(skSurface, renderWindow, true, TransportProtocol.TCP, "127.0.0.1", false);
internal IrisEngineInfo(SKSurface skSurface, bool isPrimary) : base(EngineType.Iris)
internal IrisEngineInfo(SKSurface skSurface, RenderWindowBase renderWindow, bool isPrimary) : base(EngineType.Iris)
{
if (!isPrimary)
throw new NotImplementedException("Local connections to an existing engine are not supported yet");
this.m_connectionInfo = new LocalConnectionInfo();
this.m_renderWindow = renderWindow;
this.m_skSurface = skSurface;
}
internal IrisEngineInfo(
SKSurface skSurface,
RenderWindowBase renderWindow,
bool isPrimary,
TransportProtocol protocol,
string sessionName,
@@ -38,10 +41,12 @@ namespace Microsoft.Iris.Render
if (!isPrimary)
throw new NotImplementedException("Local connections to an existing engine are not supported yet");
this.m_connectionInfo = new RemoteConnectionInfo(protocol, sessionName, swapByteOrder);
this.m_renderWindow = renderWindow;
this.m_skSurface = skSurface;
}
internal ConnectionInfo ConnectionInfo => this.m_connectionInfo;
internal RenderWindowBase Window => this.m_renderWindow;
internal SKSurface Surface => this.m_skSurface;
}
}
@@ -28,15 +28,15 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Rendering
RenderPort port = _priv_protocolInstance.Port;
RENDERHANDLE managerClassHandle = _priv_protocolInstance.AnimationManager_ClassHandle;
RemoteAnimationManager animationManager = new RemoteAnimationManager(port, _priv_owner);
uint num = (uint)sizeof(RemoteAnimationManager.Msg3_Create);
uint num = (uint)sizeof(Msg3_Create);
// ISSUE: untyped stack allocation
byte* pMem = stackalloc byte[(int)num];
RemoteAnimationManager.Msg3_Create* msg3CreatePtr = (RemoteAnimationManager.Msg3_Create*)pMem;
Msg3_Create* msg3CreatePtr = (Msg3_Create*)pMem;
msg3CreatePtr->_priv_size = num;
msg3CreatePtr->_priv_msgid = 3U;
msg3CreatePtr->_priv_idObjectSubject = animationManager.m_renderHandle;
if (port.ForeignByteOrder)
MarshalHelper.SwapByteOrder(pMem, ref s_priv_ByteOrder_Msg3_Create, typeof(RemoteAnimationManager.Msg3_Create), 0, 0);
MarshalHelper.SwapByteOrder(pMem, ref s_priv_ByteOrder_Msg3_Create, typeof(Msg3_Create), 0, 0);
port.CreateRemoteObject(managerClassHandle, animationManager.m_renderHandle, (Message*)msg3CreatePtr);
return animationManager;
}
@@ -0,0 +1,118 @@
using Microsoft.Iris.Input;
using Microsoft.Iris.Render.Graphics;
using Microsoft.Iris.Render.Internal;
using System;
namespace Microsoft.Iris.Render
{
public abstract class RenderWindowBase : IRenderWindow, ITreeOwner
{
public abstract int Left { get; }
public abstract int Top { get; }
public abstract int Right { get; }
public abstract int Bottom { get; }
public abstract int Width { get; }
public abstract int Height { get; }
public abstract HWND WindowHandle { get; }
public abstract Size ClientSize { get; set; }
public abstract Size InitialClientSize { get; set; }
public abstract FormPlacement InitialPlacement { set; }
public abstract FormPlacement FinalPlacement { get; }
public abstract int MinResizeWidth { get; set; }
public abstract int MaxResizeWidth { get; set; }
public abstract Point Position { get; set; }
public abstract string Text { get; set; }
public abstract Cursor Cursor { get; set; }
public abstract Cursor IdleCursor { get; set; }
public abstract bool Visible { get; set; }
public abstract bool IsLoaded { get; }
public abstract ColorF BackgroundColor { get; set; }
public abstract bool EnableExternalDragDrop { get; set; }
public abstract bool IsDragInProgress { get; set; }
public abstract IDisplay CurrentDisplay { get; set; }
public abstract bool FullScreenExclusive { get; set; }
public abstract bool ActivationState { get; }
public abstract WindowState WindowState { get; set; }
public abstract FormStyleInfo Styles { get; set; }
public abstract HWND AppNotifyWindow { set; }
public abstract IVisualContainer VisualRoot { get; }
TreeNode ITreeOwner.Root { get; }
public bool CatchCloseRequests => CloseRequestEvent != null;
internal abstract bool IsClosing { get; }
internal abstract bool IsSessionActive { get; }
internal abstract bool IsSessionRemote { get; }
internal abstract bool IsSpanningMonitors { get; }
internal abstract bool IsOnSecondaryMonitor { get; }
internal abstract ColorF OutlineAllColor { get; set; }
internal abstract ColorF OutlineMarkedColor { get; set; }
internal abstract GraphicsDevice GraphicsDevice { get; }
internal abstract RenderSession Session { get; }
internal abstract GraphicsDeviceType GraphicsDeviceType { get; }
internal abstract bool IsRightToLeft { get; }
public event LocationChangedHandler LocationChangedEvent;
public event SizeChangedHandler SizeChangedEvent;
public event MonitorChangedHandler MonitorChangedEvent;
public event WindowStateChangedHandler WindowStateChangedEvent;
public event SysCommandHandler SysCommandEvent;
public event MouseIdleHandler MouseIdleEvent;
public event ShowHandler ShowEvent;
public event ActivationChangeHandler ActivationChangeEvent;
public event SessionActivateHandler SessionActivateEvent;
public event SessionConnectHandler SessionConnectEvent;
public event SetFocusHandler SetFocusEvent;
public event LoadHandler LoadEvent;
public event CloseHandler CloseEvent;
public event CloseRequestHandler CloseRequestEvent;
public event ForwardMessageHandler ForwardMessageEvent;
public abstract void BringToTop();
public abstract void ClientToScreen(ref Point point);
public abstract void Close(FormCloseReason fcrCloseReason);
public abstract IHwndHostWindow CreateHwndHostWindow();
public abstract void ForceMouseIdle(bool fIdle);
public abstract void Initialize();
public abstract void LockMouseActive(bool fActive);
public abstract void RefreshHitTarget();
public abstract void Restore();
public abstract void ScreenToClient(ref Point point);
public abstract void SetCapture(IRawInputSite captureSite, bool state);
public abstract void SetCurrentDisplay(IDisplay inputIDisplay);
public abstract void SetDragDropResult(uint nDragOverResult, uint nDragDropResult);
public abstract void SetEdgeImages(bool fActiveEdges, ShadowEdgePart[] edges);
public abstract void SetFullScreenExclusive(bool fNewValue);
public abstract void SetIcon(string sModuleName, uint nResourceID, IconFlags nOptions);
public abstract void SetMouseIdleOptions(Size sizeMouseIdleTolerance, uint nMouseIdleDelay);
public abstract void SetWindowOptions(WindowOptions options, bool enable);
public abstract void TakeFocus();
public abstract void TakeForeground(bool fForce);
public abstract void TemporarilyExitExclusiveMode();
protected virtual void OnForwardWndMsg(uint msg, IntPtr wParam, IntPtr lParam) => ForwardMessageEvent?.Invoke(msg, wParam, lParam);
protected virtual void FireLoadEvent() => LoadEvent?.Invoke();
protected virtual void OnLocationChanged() => LocationChangedEvent?.Invoke(Position);
protected virtual void OnSizeChanged() => SizeChangedEvent?.Invoke();
protected virtual void OnMonitorChanged() => MonitorChangedEvent?.Invoke();
protected virtual void OnWindowStateChanged(bool fUnplanned) => WindowStateChangedEvent?.Invoke(fUnplanned);
protected virtual void OnSysCommand(IntPtr uParam1, IntPtr uParam2) => SysCommandEvent?.Invoke(uParam1, uParam2);
protected virtual void OnMouseIdle(bool fIdle) => MouseIdleEvent?.Invoke(fIdle);
protected virtual void OnShow(bool fShow, bool fFirstShow) => ShowEvent?.Invoke(fShow, fFirstShow);
protected virtual void OnActivationChange() => ActivationChangeEvent?.Invoke();
protected virtual void OnSessionActivate(bool fIsActive) => SessionActivateEvent?.Invoke(fIsActive);
protected virtual void FireSessionConnect(bool fIsConnected) => SessionConnectEvent?.Invoke(fIsConnected);
protected virtual void OnClose() => CloseEvent?.Invoke();
protected virtual void OnCloseRequest() => CloseRequestEvent?.Invoke();
protected virtual void OnSetFocus(bool focused) => SetFocusEvent?.Invoke(focused);
}
}
@@ -0,0 +1,316 @@
#if WPF
using Microsoft.Iris.Input;
using Microsoft.Iris.Render.Graphics;
using Microsoft.Iris.Render.Internal;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Media;
namespace Microsoft.Iris.Render
{
public sealed class WpfRenderWindow : RenderWindowBase
{
private bool isDragging;
private bool isFullscreen;
private Window WpfWindow { get; set; }
private WindowInteropHelper InteropHelper { get; set; }
public WpfRenderWindow(Window window)
{
WpfWindow = window;
InteropHelper = new WindowInteropHelper(window);
WpfWindow.SizeChanged += WpfWindow_SizeChanged;
WpfWindow.Activated += WpfWindow_Activated;
WpfWindow.GotFocus += WpfWindow_GotFocus;
WpfWindow.LostFocus += WpfWindow_LostFocus;
WpfWindow.Closed += WpfWindow_Closed;
WpfWindow.Closing += WpfWindow_Closing;
WpfWindow.DragEnter += WpfWindow_DragStarting;
//WpfWindow.DropCompleted += XamlWindowContent_DropCompleted;
WpfWindow.Loaded += WpfWindow_Loaded;
}
public override int Left => (int)WpfWindow.Left;
public override int Top => (int)WpfWindow.Top;
public override int Right => (int)(WpfWindow.Left + WpfWindow.Width);
public override int Bottom => (int)(WpfWindow.Left + WpfWindow.Height);
public override int Width => (int)WpfWindow.Width;
public override int Height => (int)WpfWindow.Height;
public override HWND WindowHandle => new HWND(InteropHelper.Handle);
public override Size ClientSize { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override Size InitialClientSize { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override FormPlacement InitialPlacement { set => throw new NotImplementedException(); }
public override FormPlacement FinalPlacement => throw new NotImplementedException();
public override int MinResizeWidth
{
get => (int)WpfWindow.MinWidth;
set => WpfWindow.MinWidth = value;
}
public override int MaxResizeWidth { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override Point Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override string Text
{
get => WpfWindow.Title;
set => WpfWindow.Title = value;
}
public override Cursor Cursor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override Cursor IdleCursor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override bool Visible
{
get => WpfWindow.IsVisible;
set
{
if (value)
WpfWindow.Show();
else
WpfWindow.Hide();
}
}
public override bool IsLoaded => WpfWindow.IsLoaded;
public override ColorF BackgroundColor
{
get
{
Color color = Colors.Transparent;
if (WpfWindow.Content is Control ctl && ctl.Background is SolidColorBrush brush)
color = brush.Color;
return new ColorF(color.A / 255, color.R / 255, color.G / 255, color.B / 255);
}
set
{
if (WpfWindow.Content is Control ctl)
{
ctl.Background = new SolidColorBrush(Color.FromArgb(
(byte)(value.A * 255),
(byte)(value.R * 255),
(byte)(value.G * 255),
(byte)(value.B * 255)
));
}
}
}
public override bool EnableExternalDragDrop
{
get => WpfWindow.AllowDrop;
set => WpfWindow.AllowDrop = true;
}
public override bool IsDragInProgress { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override IDisplay CurrentDisplay { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override bool FullScreenExclusive
{
get => isFullscreen;
set
{
isFullscreen = value;
if (isFullscreen)
{
WpfWindow.WindowStyle = WindowStyle.None;
WpfWindow.WindowState = System.Windows.WindowState.Maximized;
}
else
{
WpfWindow.WindowStyle = WindowStyle.SingleBorderWindow;
WpfWindow.WindowState = System.Windows.WindowState.Normal;
}
}
}
public override bool ActivationState => WpfWindow.IsActive;
public override WindowState WindowState
{
get
{
switch (WpfWindow.WindowState)
{
case System.Windows.WindowState.Normal:
return WindowState.Normal;
case System.Windows.WindowState.Minimized:
return WindowState.Minimized;
case System.Windows.WindowState.Maximized:
return WindowState.Maximized;
default:
throw new InvalidOperationException("Unknown window state");
}
}
set
{
switch (value)
{
case WindowState.Normal:
WpfWindow.WindowState = System.Windows.WindowState.Normal;
break;
case WindowState.Minimized:
WpfWindow.WindowState = System.Windows.WindowState.Minimized;
break;
case WindowState.Maximized:
WpfWindow.WindowState = System.Windows.WindowState.Maximized;
break;
}
}
}
public override FormStyleInfo Styles { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override HWND AppNotifyWindow { set => throw new NotImplementedException(); }
public override IVisualContainer VisualRoot => throw new NotImplementedException();
TreeNode Root => throw new NotImplementedException();
private bool _IsClosing = false;
internal override bool IsClosing => _IsClosing;
internal override bool IsSessionActive => throw new NotImplementedException();
internal override bool IsSessionRemote => false;
internal override bool IsSpanningMonitors => throw new NotImplementedException();
internal override bool IsOnSecondaryMonitor => throw new NotImplementedException();
internal override ColorF OutlineAllColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
internal override ColorF OutlineMarkedColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
internal override GraphicsDevice GraphicsDevice => throw new NotImplementedException();
internal override RenderSession Session => throw new NotImplementedException();
internal override GraphicsDeviceType GraphicsDeviceType => GraphicsDeviceType.Skia;
internal override bool IsRightToLeft => CultureInfo.CurrentCulture.TextInfo.IsRightToLeft;
private void WpfWindow_SizeChanged(object sender, EventArgs e) => OnSizeChanged();
private void WpfWindow_Activated(object sender, EventArgs e)
{
OnShow(true, WpfWindow.ShowActivated);
OnActivationChange();
}
private void WpfWindow_Loaded(object sender, RoutedEventArgs e) => FireLoadEvent();
private void WpfWindow_GotFocus(object sender, RoutedEventArgs e) => OnSetFocus(true);
private void WpfWindow_LostFocus(object sender, RoutedEventArgs e) => OnSetFocus(false);
private void WpfWindow_Closed(object sender, EventArgs e) => OnClose();
private void WpfWindow_Closing(object sender, EventArgs e) => _IsClosing = true;
private void XamlWindowContent_DropCompleted(object sender, EventArgs e) => isDragging = false;
private void WpfWindow_DragStarting(object sender, DragEventArgs args) => isDragging = true;
public override void BringToTop() => WpfWindow.Activate();
public override void ClientToScreen(ref Point point)
{
var p = WpfWindow.PointToScreen(new System.Windows.Point(point.X, point.Y));
point = new Point((int)p.X, (int)p.Y);
}
public override void Close(FormCloseReason fcrCloseReason) => WpfWindow.Close();
public override IHwndHostWindow CreateHwndHostWindow()
{
throw new NotImplementedException();
}
public override void ForceMouseIdle(bool fIdle)
{
throw new NotImplementedException();
}
public override void Initialize()
{
}
public override void LockMouseActive(bool fActive)
{
throw new NotImplementedException();
}
public override void RefreshHitTarget()
{
throw new NotImplementedException();
}
public override void Restore()
{
WpfWindow.WindowState = System.Windows.WindowState.Normal;
}
public override void ScreenToClient(ref Point point)
{
var p = WpfWindow.PointFromScreen(new System.Windows.Point(point.X, point.Y));
point = new Point((int)p.X, (int)p.Y);
}
public override void SetCapture(IRawInputSite captureSite, bool state)
{
if (state)
WpfWindow.CaptureMouse();
else
WpfWindow.ReleaseMouseCapture();
}
public override void SetDragDropResult(uint nDragOverResult, uint nDragDropResult)
{
throw new NotImplementedException();
}
public override void SetEdgeImages(bool fActiveEdges, ShadowEdgePart[] edges)
{
throw new NotImplementedException();
}
public override void SetIcon(string sModuleName, uint nResourceID, IconFlags nOptions)
{
WpfWindow.Icon = new System.Windows.Media.Imaging.BitmapImage(new Uri(sModuleName));
}
public override void SetMouseIdleOptions(Size sizeMouseIdleTolerance, uint nMouseIdleDelay)
{
throw new NotImplementedException();
}
public override void SetWindowOptions(WindowOptions options, bool enable)
{
if (options.HasFlag(WindowOptions.FreeformResize))
WpfWindow.ResizeMode = enable ? ResizeMode.CanResize : ResizeMode.NoResize;
if (options.HasFlag(WindowOptions.EnableCursor))
WpfWindow.Cursor = enable ? System.Windows.Input.Cursors.Arrow : System.Windows.Input.Cursors.None;
}
public override void TakeFocus() => WpfWindow.Focus();
public override void TakeForeground(bool fForce)
{
if (fForce)
WpfWindow.Activate();
}
public override void TemporarilyExitExclusiveMode()
{
throw new NotImplementedException();
}
public override void SetCurrentDisplay(IDisplay inputIDisplay) => CurrentDisplay = inputIDisplay;
public override void SetFullScreenExclusive(bool fNewValue) => FullScreenExclusive = fNewValue;
}
}
#endif
@@ -0,0 +1,297 @@
#if UWP
using Microsoft.Iris.Input;
using Microsoft.Iris.Render.Graphics;
using Microsoft.Iris.Render.Internal;
using System;
using System.Globalization;
using Windows.Foundation;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
namespace Microsoft.Iris.Render
{
public sealed class XamlRenderWindow : RenderWindowBase
{
private bool isDragging = false;
private Window XamlWindow { get; set; }
private ApplicationView CurrentView => ApplicationView.GetForCurrentView();
private Rect VisibleBounds => CurrentView.VisibleBounds;
public XamlRenderWindow(Window window)
{
XamlWindow = window;
XamlWindow.SizeChanged += XamlWindow_SizeChanged;
XamlWindow.Activated += XamlWindow_Activated;
XamlWindow.Content.GotFocus += XamlWindowContent_GotFocus;
XamlWindow.Content.LostFocus += XamlWindowContent_LostFocus;
XamlWindow.Closed += XamlWindow_Closed;
XamlWindow.Content.DragStarting += XamlWindowContent_DragStarting;
XamlWindow.Content.DropCompleted += XamlWindowContent_DropCompleted;
if (XamlWindow.Content is FrameworkElement elem)
{
elem.Loaded += XamlWindowContent_Loaded;
}
}
public override int Left => (int)VisibleBounds.Left;
public override int Top => (int)VisibleBounds.Top;
public override int Right => (int)VisibleBounds.Right;
public override int Bottom => (int)VisibleBounds.Bottom;
public override int Width => (int)VisibleBounds.Width;
public override int Height => (int)VisibleBounds.Height;
public override HWND WindowHandle => throw new PlatformNotSupportedException("UWP cannot use HWNDs directly");
public override Size ClientSize { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override Size InitialClientSize { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override FormPlacement InitialPlacement { set => throw new NotImplementedException(); }
public override FormPlacement FinalPlacement => throw new NotImplementedException();
public override int MinResizeWidth
{
get => (int)ApplicationView.PreferredLaunchViewSize.Width;
set => CurrentView.SetPreferredMinSize(new Windows.Foundation.Size(value, 320));
}
public override int MaxResizeWidth { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override Point Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override string Text
{
get => CurrentView.Title;
set => CurrentView.Title = value;
}
public override Cursor Cursor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override Cursor IdleCursor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override bool Visible
{
get => XamlWindow.Visible;
set => XamlWindow.Content.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
}
public override bool IsLoaded => XamlWindow != null;
public override ColorF BackgroundColor
{
get
{
Windows.UI.Color color = Windows.UI.Colors.Transparent;
if (XamlWindow.Content is Control ctl && ctl.Background is SolidColorBrush brush)
color = brush.Color;
return new ColorF(color.A / 255, color.R / 255, color.G / 255, color.B / 255);
}
set
{
if (XamlWindow.Content is Control ctl)
{
ctl.Background = new SolidColorBrush(new Windows.UI.Color
{
A = (byte)(value.A * 255),
R = (byte)(value.R * 255),
G = (byte)(value.G * 255),
B = (byte)(value.B * 255),
});
}
}
}
public override bool EnableExternalDragDrop
{
get => XamlWindow.Content.AllowDrop;
set => XamlWindow.Content.AllowDrop = true;
}
public override bool IsDragInProgress { get => isDragging; set => throw new NotImplementedException(); }
public override IDisplay CurrentDisplay { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override bool FullScreenExclusive
{
get => CurrentView.IsFullScreenMode;
set
{
if (value)
CurrentView.TryEnterFullScreenMode();
else
CurrentView.ExitFullScreenMode();
}
}
public override bool ActivationState => XamlWindow.CoreWindow.ActivationMode == CoreWindowActivationMode.ActivatedInForeground;
public override WindowState WindowState
{
get
{
if (CurrentView.ViewMode == ApplicationViewMode.CompactOverlay)
return WindowState.Normal;
else if (XamlWindow.CoreWindow.ActivationMode == CoreWindowActivationMode.ActivatedNotForeground
|| XamlWindow.CoreWindow.ActivationMode == CoreWindowActivationMode.Deactivated
|| !XamlWindow.Visible)
return WindowState.Minimized;
else if (CurrentView.AdjacentToLeftDisplayEdge && CurrentView.AdjacentToRightDisplayEdge)
return WindowState.Maximized;
return WindowState.Normal;
}
set
{
switch (value)
{
case WindowState.Normal:
XamlWindow.Content.Visibility = Visibility.Visible;
CurrentView.TryEnterViewModeAsync(ApplicationViewMode.Default);
break;
case WindowState.Minimized:
XamlWindow.Content.Visibility = Visibility.Collapsed;
break;
case WindowState.Maximized:
XamlWindow.Content.Visibility = Visibility.Visible;
break;
}
}
}
public override FormStyleInfo Styles { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override HWND AppNotifyWindow { set => throw new NotImplementedException(); }
public override IVisualContainer VisualRoot => throw new NotImplementedException();
TreeNode Root => throw new NotImplementedException();
internal override bool IsClosing => throw new NotImplementedException();
internal override bool IsSessionActive => throw new NotImplementedException();
internal override bool IsSessionRemote => false;
internal override bool IsSpanningMonitors => throw new NotImplementedException();
internal override bool IsOnSecondaryMonitor => throw new NotImplementedException();
internal override ColorF OutlineAllColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
internal override ColorF OutlineMarkedColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
internal override GraphicsDevice GraphicsDevice => throw new NotImplementedException();
internal override RenderSession Session => throw new NotImplementedException();
internal override GraphicsDeviceType GraphicsDeviceType => GraphicsDeviceType.Skia;
internal override bool IsRightToLeft => CultureInfo.CurrentCulture.TextInfo.IsRightToLeft;
private void XamlWindow_SizeChanged(object sender, WindowSizeChangedEventArgs e) => OnSizeChanged();
private void XamlWindow_Activated(object sender, WindowActivatedEventArgs e)
{
OnShow(true, e.WindowActivationState == CoreWindowActivationState.CodeActivated);
OnActivationChange();
}
private void XamlWindowContent_Loaded(object sender, RoutedEventArgs e) => FireLoadEvent();
private void XamlWindowContent_GotFocus(object sender, RoutedEventArgs e) => OnSetFocus(true);
private void XamlWindowContent_LostFocus(object sender, RoutedEventArgs e) => OnSetFocus(false);
private void XamlWindow_Closed(object sender, CoreWindowEventArgs e) => OnClose();
private void XamlWindowContent_DropCompleted(object sender, DropCompletedEventArgs e) => isDragging = false;
private void XamlWindowContent_DragStarting(UIElement sender, DragStartingEventArgs args) => isDragging = true;
public override void BringToTop() => XamlWindow.Activate();
public override void ClientToScreen(ref Point point)
{
throw new NotImplementedException();
}
public override void Close(FormCloseReason fcrCloseReason) => XamlWindow.Close();
public override IHwndHostWindow CreateHwndHostWindow()
{
throw new NotImplementedException();
}
public override void ForceMouseIdle(bool fIdle)
{
throw new NotImplementedException();
}
public override void Initialize()
{
}
public override void LockMouseActive(bool fActive)
{
throw new NotImplementedException();
}
public override void RefreshHitTarget()
{
throw new NotImplementedException();
}
public override void Restore()
{
throw new NotImplementedException();
}
public override void ScreenToClient(ref Point point)
{
throw new NotImplementedException();
}
public override void SetCapture(IRawInputSite captureSite, bool state)
{
if (state)
XamlWindow.CoreWindow.SetPointerCapture();
else
XamlWindow.CoreWindow.ReleasePointerCapture();
}
public override void SetDragDropResult(uint nDragOverResult, uint nDragDropResult)
{
throw new NotImplementedException();
}
public override void SetEdgeImages(bool fActiveEdges, ShadowEdgePart[] edges)
{
throw new NotImplementedException();
}
public override void SetIcon(string sModuleName, uint nResourceID, IconFlags nOptions)
{
throw new NotImplementedException();
}
public override void SetMouseIdleOptions(Size sizeMouseIdleTolerance, uint nMouseIdleDelay)
{
throw new NotImplementedException();
}
public override void SetWindowOptions(WindowOptions options, bool enable)
{
}
public override void TakeFocus() => XamlWindow.Activate();
public override void TakeForeground(bool fForce)
{
if (fForce)
XamlWindow.Activate();
}
public override void TemporarilyExitExclusiveMode()
{
throw new NotImplementedException();
}
public override void SetCurrentDisplay(IDisplay inputIDisplay) => CurrentDisplay = inputIDisplay;
public override void SetFullScreenExclusive(bool fNewValue) => FullScreenExclusive = fNewValue;
}
}
#endif
+37 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;uap10.0.19041;net5.0-windows</TargetFrameworks>
<ProjectGuid>{CB2B7609-C7B8-4E2A-82D8-DD631B70B621}</ProjectGuid>
<OutputType>Library</OutputType>
<AssemblyName>UIX.RenderApi.Skia</AssemblyName>
@@ -11,7 +11,42 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp" Version="2.80.3" />
<Compile Include="*.UWP.cs" Condition="$(TargetFramework.StartsWith('uap'))" />
<Compile Remove="*.UWP.cs" Condition="!$(TargetFramework.StartsWith('uap'))" />
<Compile Include="*.WPF.cs" Condition="$(TargetFramework.StartsWith('net5.0-windows'))" />
<Compile Remove="*.WPF.cs" Condition="!$(TargetFramework.StartsWith('net5.0-windows'))" />
</ItemGroup>
<!-- UWP -->
<PropertyGroup Condition="$(TargetFramework.StartsWith('uap'))">
<DefineConstants>$(DefineConstants);UWP</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('uap'))">
<PackageReference Include="Microsoft.UI.Xaml" Version="2.5.0" />
<PackageReference Include="SkiaSharp.Views.Uno" Version="2.80.3" />
<PackageReference Include="Uno.Core" Version="2.4.0" />
<PackageReference Include="Uno.UI" Version="3.8.11" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<!--
If, in the same solution, you are referencing a project that uses https://github.com/onovotny/MSBuildSdkExtras,
you need to make sure that the version provided here matches https://github.com/novotnyllc/MSBuildSdkExtras/blob/main/Source/MSBuild.Sdk.Extras/DefaultItems/ImplicitPackages.targets#L11.
This is not an issue when libraries are referenced through nuget packages. See https://github.com/unoplatform/uno/issues/446 for more details.
-->
<Version>6.2.11</Version>
</PackageReference>
</ItemGroup>
<!-- WPF -->
<PropertyGroup Condition="$(TargetFramework.StartsWith('net5.0-windows'))">
<DefineConstants>$(DefineConstants);WPF</DefineConstants>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net5.0-windows'))">
<PackageReference Include="SkiaSharp.Views.Wpf" Version="2.80.3" />
</ItemGroup>
</Project>