diff --git a/src/SamplesApp/UnoIslands.Shared/App.xaml.cs b/src/SamplesApp/UnoIslands.Shared/App.xaml.cs index 48fc07fa3786..860c438187b2 100644 --- a/src/SamplesApp/UnoIslands.Shared/App.xaml.cs +++ b/src/SamplesApp/UnoIslands.Shared/App.xaml.cs @@ -35,93 +35,8 @@ public App() InitializeLogging(); this.InitializeComponent(); - -#if HAS_UNO || NETFX_CORE - this.Suspending += OnSuspending; -#endif } - -// /// -// /// Invoked when the application is launched normally by the end user. Other entry points -// /// will be used such as when the application is launched to open a specific file. -// /// -// /// Details about the launch request and process. -// protected override void OnLaunched(LaunchActivatedEventArgs args) -// { -//#if DEBUG -// if (System.Diagnostics.Debugger.IsAttached) -// { -// // this.DebugSettings.EnableFrameRateCounter = true; -// } -//#endif - -//#if NET5_0 && WINDOWS -// _window = new Window(); -// _window.Activate(); -//#else -// _window = Windows.UI.Xaml.Window.Current; -//#endif - -// var rootFrame = _window.Content as Frame; - -// // Do not repeat app initialization when the Window already has content, -// // just ensure that the window is active -// if (rootFrame == null) -// { -// // Create a Frame to act as the navigation context and navigate to the first page -// rootFrame = new Frame(); - -// rootFrame.NavigationFailed += OnNavigationFailed; - -// if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) -// { -// // TODO: Load state from previously suspended application -// } - -// // Place the frame in the current Window -// _window.Content = rootFrame; -// } - -//#if !(NET5_0 && WINDOWS) -// if (args.PrelaunchActivated == false) -//#endif -// { -// if (rootFrame.Content == null) -// { -// // When the navigation stack isn't restored navigate to the first page, -// // configuring the new page by passing required information as a navigation -// // parameter -// rootFrame.Navigate(typeof(MainPage), args.Arguments); -// } -// // Ensure the current window is active -// _window.Activate(); -// } -// } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}"); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - private void OnSuspending(object sender, SuspendingEventArgs e) - { - var deferral = e.SuspendingOperation.GetDeferral(); - // TODO: Save application state and stop any background activity - deferral.Complete(); - } - + /// /// Configures global Uno Platform logging /// diff --git a/src/SamplesApp/UnoIslands.WPF/MainWindow.xaml b/src/SamplesApp/UnoIslands.WPF/MainWindow.xaml index 48682f23aef0..e2fee6ef85eb 100644 --- a/src/SamplesApp/UnoIslands.WPF/MainWindow.xaml +++ b/src/SamplesApp/UnoIslands.WPF/MainWindow.xaml @@ -3,10 +3,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:local="clr-namespace:UnoIslands.WPF" - xmlns:xamlHost="clr-namespace:Uno.UI.XamlHost.Skia.Wpf;assembly=Uno.UI.Runtime.Skia.Wpf" - mc:Ignorable="d" - Title="Uno with Skia# Backend" Height="450" Width="800"> + xmlns:xamlHost="clr-namespace:Uno.UI.XamlHost.Skia.Wpf;assembly=Uno.UI.Runtime.Skia.Wpf" + mc:Ignorable="d" + Title="Uno Islands Sample" Height="450" Width="800"> diff --git a/src/Uno.UI.XamlHost/AssemblyInfo.cs b/src/Uno.UI.XamlHost/Properties/AssemblyInfo.cs similarity index 100% rename from src/Uno.UI.XamlHost/AssemblyInfo.cs rename to src/Uno.UI.XamlHost/Properties/AssemblyInfo.cs diff --git a/src/Uno.UI.XamlHost/AssemblyInfo.skia.cs b/src/Uno.UI.XamlHost/Properties/AssemblyInfo.skia.cs similarity index 100% rename from src/Uno.UI.XamlHost/AssemblyInfo.skia.cs rename to src/Uno.UI.XamlHost/Properties/AssemblyInfo.skia.cs diff --git a/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Hosting/DesktopWindowXamlSourceGotFocusEventArgs.cs b/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Hosting/DesktopWindowXamlSourceGotFocusEventArgs.cs index 5dd29042d466..9efbcba0c2e4 100644 --- a/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Hosting/DesktopWindowXamlSourceGotFocusEventArgs.cs +++ b/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Hosting/DesktopWindowXamlSourceGotFocusEventArgs.cs @@ -2,12 +2,12 @@ #pragma warning disable 114 // new keyword hiding namespace Windows.UI.Xaml.Hosting { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented] #endif public partial class DesktopWindowXamlSourceGotFocusEventArgs { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public global::Windows.UI.Xaml.Hosting.XamlSourceFocusNavigationRequest Request { diff --git a/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Hosting/DesktopWindowXamlSourceTakeFocusRequestedEventArgs.cs b/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Hosting/DesktopWindowXamlSourceTakeFocusRequestedEventArgs.cs index fbbed4a7fd83..3b069b094984 100644 --- a/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Hosting/DesktopWindowXamlSourceTakeFocusRequestedEventArgs.cs +++ b/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Hosting/DesktopWindowXamlSourceTakeFocusRequestedEventArgs.cs @@ -2,12 +2,12 @@ #pragma warning disable 114 // new keyword hiding namespace Windows.UI.Xaml.Hosting { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented] #endif public partial class DesktopWindowXamlSourceTakeFocusRequestedEventArgs { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public global::Windows.UI.Xaml.Hosting.XamlSourceFocusNavigationRequest Request { diff --git a/src/Uno.UI/UI/Xaml/Hosting/DesktopWindowXamlSourceGotFocusEventArgs.cs b/src/Uno.UI/UI/Xaml/Hosting/DesktopWindowXamlSourceGotFocusEventArgs.cs new file mode 100644 index 000000000000..2f361a96104f --- /dev/null +++ b/src/Uno.UI/UI/Xaml/Hosting/DesktopWindowXamlSourceGotFocusEventArgs.cs @@ -0,0 +1,17 @@ +namespace Windows.UI.Xaml.Hosting; + +/// +/// Provides event data for the GotFocus event. +/// +public partial class DesktopWindowXamlSourceGotFocusEventArgs +{ + internal DesktopWindowXamlSourceGotFocusEventArgs(XamlSourceFocusNavigationRequest request) + { + Request = request; + } + + /// + /// Gets a XamlSourceFocusNavigationRequest object that specifies the reason and other info for the focus navigation. + /// + public XamlSourceFocusNavigationRequest Request { get; } +} diff --git a/src/Uno.UI/UI/Xaml/Hosting/DesktopWindowXamlSourceTakeFocusRequestedEventArgs.cs b/src/Uno.UI/UI/Xaml/Hosting/DesktopWindowXamlSourceTakeFocusRequestedEventArgs.cs new file mode 100644 index 000000000000..4c988e338f02 --- /dev/null +++ b/src/Uno.UI/UI/Xaml/Hosting/DesktopWindowXamlSourceTakeFocusRequestedEventArgs.cs @@ -0,0 +1,17 @@ +namespace Windows.UI.Xaml.Hosting; + +/// +/// Provides event data for the TakeFocusRequested event. +/// +public partial class DesktopWindowXamlSourceTakeFocusRequestedEventArgs +{ + internal DesktopWindowXamlSourceTakeFocusRequestedEventArgs(XamlSourceFocusNavigationRequest request) + { + Request = request; + } + + /// + /// Gets a XamlSourceFocusNavigationRequest object that specifies the reason and other info for the focus navigation. + /// + public XamlSourceFocusNavigationRequest Request { get; } +} diff --git a/src/Uno.UI/UI/Xaml/Hosting/ElementCompositionPreview.cs b/src/Uno.UI/UI/Xaml/Hosting/ElementCompositionPreview.cs index 27608a2fe45e..de5f1ad6ed95 100644 --- a/src/Uno.UI/UI/Xaml/Hosting/ElementCompositionPreview.cs +++ b/src/Uno.UI/UI/Xaml/Hosting/ElementCompositionPreview.cs @@ -3,49 +3,61 @@ using System.Linq; using Windows.UI.Composition; -namespace Windows.UI.Xaml.Hosting +namespace Windows.UI.Xaml.Hosting; + +/// +/// Enables access to composition visual objects that back XAML elements in the XAML composition tree. +/// +public partial class ElementCompositionPreview { - public partial class ElementCompositionPreview - { - private const string ChildVisualName = "childVisual"; + private const string ChildVisualName = "childVisual"; #if !__SKIA__ - static readonly Compositor _compositor = new Compositor(); + static readonly Compositor _compositor = new Compositor(); #endif - public static Visual GetElementVisual(UIElement element) - { + /// + /// Retrieves the Windows.UI.Composition.Visual object that backs a XAML element in the XAML composition tree. + /// + /// The element for which to retrieve the Visual. + /// The Windows.UI.Composition.Visual object that backs the XAML element. + public static Visual GetElementVisual(UIElement element) + { #if __SKIA__ - return element.Visual; + return element.Visual; #else - return new Composition.Visual(_compositor) { NativeOwner = element }; + return new Composition.Visual(_compositor) { NativeOwner = element }; #endif - } + } - public static void SetElementChildVisual(UIElement element, Visual visual) - { + /// + /// Sets a custom Windows.UI.Composition.Visual as the last child of the element’s visual tree. + /// + /// The element to add the child Visual to. + /// The Visual to add to the element's visual tree. + public static void SetElementChildVisual(UIElement element, Visual visual) + { #if __IOS__ element.Layer.AddSublayer(visual.NativeLayer); visual.NativeOwner = element; element.ClipsToBounds = false; - if (element is FrameworkElement fe) - { - fe.SizeChanged += - (s, e) => visual.NativeLayer.Frame = new CoreGraphics.CGRect(0, 0, element.Frame.Width, element.Frame.Height); - } + if (element is FrameworkElement fe) + { + fe.SizeChanged += + (s, e) => visual.NativeLayer.Frame = new CoreGraphics.CGRect(0, 0, element.Frame.Width, element.Frame.Height); + } #elif __SKIA__ - var container = new Composition.ContainerVisual(element.Visual.Compositor) { Comment = ChildVisualName }; - container.Children.InsertAtTop(visual); + var container = new Composition.ContainerVisual(element.Visual.Compositor) { Comment = ChildVisualName }; + container.Children.InsertAtTop(visual); - if (element.Visual.Children.FirstOrDefault(v => v.Comment == ChildVisualName) is Composition.ContainerVisual cv) - { - element.Visual.Children.Remove(cv); - } + if (element.Visual.Children.FirstOrDefault(v => v.Comment == ChildVisualName) is Composition.ContainerVisual cv) + { + element.Visual.Children.Remove(cv); + } - element.Visual.Children.InsertAtTop(container); + element.Visual.Children.InsertAtTop(container); #endif - } } } diff --git a/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationReason.cs b/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationReason.cs index 51c0bcdfe616..9513c500c523 100644 --- a/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationReason.cs +++ b/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationReason.cs @@ -1,56 +1,55 @@ -namespace Windows.UI.Xaml.Hosting +namespace Windows.UI.Xaml.Hosting; + +/// +/// Defines values that represent the reasons that the Windows.UI.Xaml.UIElement got focus +/// in a desktop application that uses a DesktopWindowXamlSource object to host XAML-based UI. +/// The XamlSourceFocusNavigationRequest.Reason property returns one of these values. +/// +public enum XamlSourceFocusNavigationReason { /// - /// Defines values that represent the reasons that the Windows.UI.Xaml.UIElement got focus - /// in a desktop application that uses a DesktopWindowXamlSource object to host XAML-based UI. - /// The XamlSourceFocusNavigationRequest.Reason property returns one of these values. - /// - public enum XamlSourceFocusNavigationReason - { - /// - /// The focus was set programmatically. - /// - Programmatic = 0, - - /// - /// The focus was restored after a task switch, such as pressing Alt + Tab. - /// - Restore = 1, - - /// - /// The focus was set in response to the user navigating to the next element - /// by using a bidirectional navigation experience (for example, by pressing Tab). - /// - First = 3, - - /// - /// The focus was set in response to the user navigating to the previous element - /// by using a bidirectional navigation experience (for example, by pressing Shift-Tab). - /// - Last = 4, - - /// - /// The focus was set in response to the user navigating left by using - /// a 4-direction navigation experience (for example, by using keyboard arrow keys). - /// - Left = 7, - - /// - /// The focus was set in response to the user navigating up by using - /// a 4-direction navigation experience (for example, by using keyboard arrow keys). - /// - Up = 8, - - /// - /// The focus was set in response to the user navigating right by using - /// a 4-direction navigation experience (for example, by using keyboard arrow keys). - /// - Right = 9, - - /// - /// The focus was set in response to the user navigating down by using - /// a 4-direction navigation experience (for example, by using keyboard arrow keys). - /// - Down = 10, - } + /// The focus was set programmatically. + /// + Programmatic = 0, + + /// + /// The focus was restored after a task switch, such as pressing Alt + Tab. + /// + Restore = 1, + + /// + /// The focus was set in response to the user navigating to the next element + /// by using a bidirectional navigation experience (for example, by pressing Tab). + /// + First = 3, + + /// + /// The focus was set in response to the user navigating to the previous element + /// by using a bidirectional navigation experience (for example, by pressing Shift-Tab). + /// + Last = 4, + + /// + /// The focus was set in response to the user navigating left by using + /// a 4-direction navigation experience (for example, by using keyboard arrow keys). + /// + Left = 7, + + /// + /// The focus was set in response to the user navigating up by using + /// a 4-direction navigation experience (for example, by using keyboard arrow keys). + /// + Up = 8, + + /// + /// The focus was set in response to the user navigating right by using + /// a 4-direction navigation experience (for example, by using keyboard arrow keys). + /// + Right = 9, + + /// + /// The focus was set in response to the user navigating down by using + /// a 4-direction navigation experience (for example, by using keyboard arrow keys). + /// + Down = 10, } diff --git a/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationRequest.cs b/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationRequest.cs index 0d30d118ec7e..12fc9f0ae2ce 100644 --- a/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationRequest.cs +++ b/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationRequest.cs @@ -1,70 +1,72 @@ using System; using Windows.Foundation; -namespace Windows.UI.Xaml.Hosting +namespace Windows.UI.Xaml.Hosting; + +/// +/// Provides information about a request to give focus to a DesktopWindowXamlSource object. +/// +public partial class XamlSourceFocusNavigationRequest { - public partial class XamlSourceFocusNavigationRequest + /// + /// Initializes a new instance of the XamlSourceFocusNavigationRequest + /// class with the reason for the navigation request. + /// + /// A value that indicates the reason for the navigation request. + public XamlSourceFocusNavigationRequest(XamlSourceFocusNavigationReason reason) { - /// - /// Initializes a new instance of the XamlSourceFocusNavigationRequest - /// class with the reason for the navigation request. - /// - /// A value that indicates the reason for the navigation request. - public XamlSourceFocusNavigationRequest(XamlSourceFocusNavigationReason reason) - { - Reason = reason; - } + Reason = reason; + } - /// - /// Initializes a new instance of the XamlSourceFocusNavigationRequest class - /// with the reason for the navigation request and the bounding rectangle - /// that will receive navigation focus. - /// - /// A value that indicates the reason for the navigation request. - /// The bounding rectangle of the element in the desktop application that is losing focus. - public XamlSourceFocusNavigationRequest(XamlSourceFocusNavigationReason reason, Rect hintRect) - { - Reason = reason; - HintRect = hintRect; - } + /// + /// Initializes a new instance of the XamlSourceFocusNavigationRequest class + /// with the reason for the navigation request and the bounding rectangle + /// that will receive navigation focus. + /// + /// A value that indicates the reason for the navigation request. + /// The bounding rectangle of the element in the desktop application that is losing focus. + public XamlSourceFocusNavigationRequest(XamlSourceFocusNavigationReason reason, Rect hintRect) + { + Reason = reason; + HintRect = hintRect; + } - /// - /// Initializes a new instance of the XamlSourceFocusNavigationRequest class - /// with the reason for the navigation request, the bounding rectangle that - /// will receive navigation focus, and the unique correlation ID for the request. - /// - /// A value that indicates the reason for the navigation request. - /// The bounding rectangle of the element in the desktop application that is losing focus. - /// The unique identifier for the navigation request. You can use this parameter - /// for logging purposes, or if you have an existing correlation ID from an in-progress focus movement - /// already in progress and you want to connect that focus movement with the current navigation request. - public XamlSourceFocusNavigationRequest(XamlSourceFocusNavigationReason reason, Rect hintRect, Guid correlationId) - { - Reason = reason; - HintRect = hintRect; - CorrelationId = correlationId; - } + /// + /// Initializes a new instance of the XamlSourceFocusNavigationRequest class + /// with the reason for the navigation request, the bounding rectangle that + /// will receive navigation focus, and the unique correlation ID for the request. + /// + /// A value that indicates the reason for the navigation request. + /// The bounding rectangle of the element in the desktop application that is losing focus. + /// The unique identifier for the navigation request. You can use this parameter + /// for logging purposes, or if you have an existing correlation ID from an in-progress focus movement + /// already in progress and you want to connect that focus movement with the current navigation request. + public XamlSourceFocusNavigationRequest(XamlSourceFocusNavigationReason reason, Rect hintRect, Guid correlationId) + { + Reason = reason; + HintRect = hintRect; + CorrelationId = correlationId; + } - /// - /// Gets the unique identifier for the navigation request. You can use this value for logging purposes, - /// or if you have an existing correlation ID from an in-progress focus movement already in progress - /// and you want to connect that focus movement with a new navigation request. - /// - public XamlSourceFocusNavigationReason Reason { get; } + /// + /// Gets the unique identifier for the navigation request. You can use this value for logging purposes, + /// or if you have an existing correlation ID from an in-progress focus movement already in progress + /// and you want to connect that focus movement with a new navigation request. + /// + public XamlSourceFocusNavigationReason Reason { get; } - /// - /// Gets the bounding rectangle of the element in the desktop application that is losing focus - /// (that is, the element that had focus before the DesktopWindowXamlSource received focus). - /// - public Rect HintRect { get; } + /// + /// Gets the bounding rectangle of the element in the desktop application that is losing focus + /// (that is, the element that had focus before the DesktopWindowXamlSource received focus). + /// + public Rect HintRect { get; } - /// - /// Gets the unique identifier for the navigation request. - /// You can use this value for logging purposes, or if you - /// have an existing correlation ID from an in-progress focus movement - /// already in progress and you want to connect that focus movement - /// with a new navigation request. - /// - public Guid CorrelationId { get; } - } + /// + /// Gets the unique identifier for the navigation request. + /// You can use this value for logging purposes, or if you + /// have an existing correlation ID from an in-progress focus movement + /// already in progress and you want to connect that focus movement + /// with a new navigation request. + /// + public Guid CorrelationId { get; } } diff --git a/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationResult.cs b/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationResult.cs index 52d999e37ee1..43885cedf088 100644 --- a/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationResult.cs +++ b/src/Uno.UI/UI/Xaml/Hosting/XamlSourceFocusNavigationResult.cs @@ -1,25 +1,24 @@ -namespace Windows.UI.Xaml.Hosting +namespace Windows.UI.Xaml.Hosting; + +/// +/// Provides data for a request to navigate focus to +/// a DesktopWindowXamlSource object by using the NavigateFocus method. +/// +public partial class XamlSourceFocusNavigationResult { /// - /// Provides data for a request to navigate focus to - /// a DesktopWindowXamlSource object by using the NavigateFocus method. + /// Initializes a new instance of the XamlSourceFocusNavigationResult class. /// - public partial class XamlSourceFocusNavigationResult + /// True if the focus successfully moved + /// to the DesktopWindowXamlSource object; otherwise, false. + public XamlSourceFocusNavigationResult(bool focusMoved) { - /// - /// Initializes a new instance of the XamlSourceFocusNavigationResult class. - /// - /// True if the focus successfully moved - /// to the DesktopWindowXamlSource object; otherwise, false. - public XamlSourceFocusNavigationResult(bool focusMoved) - { - WasFocusMoved = focusMoved; - } - - /// - /// Gets a value that indicates whether the focus successfully - /// moved to the DesktopWindowXamlSource object. - /// - public bool WasFocusMoved { get; } + WasFocusMoved = focusMoved; } + + /// + /// Gets a value that indicates whether the focus successfully + /// moved to the DesktopWindowXamlSource object. + /// + public bool WasFocusMoved { get; } }