static void SetupInit( IMauiContext mauiContext, UI.Xaml.Window mainWindow, IEnumerable <Assembly> rendererAssemblies = null, InitializationOptions?maybeOptions = null) { MauiContext = mauiContext; Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); var accent = (WSolidColorBrush)Microsoft.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; KnownColor.SetAccent(accent.ToColor()); Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(mauiContext.GetFlowDirection()); //TODO WINUI3 //switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) //{ // case "Windows.Desktop": // if (Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == // Windows.UI.ViewManagement.UserInteractionMode.Touch) // Device.SetIdiom(TargetIdiom.Tablet); // else // Device.SetIdiom(TargetIdiom.Desktop); // break; // case "Windows.Mobile": // Device.SetIdiom(TargetIdiom.Phone); // break; // case "Windows.Xbox": // Device.SetIdiom(TargetIdiom.TV); // break; // default: // Device.SetIdiom(TargetIdiom.Unsupported); // break; //} ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); var platformServices = new WindowsPlatformServices(); Device.PlatformServices = platformServices; Device.PlatformInvalidator = platformServices; if (mainWindow != null) { MainWindow = mainWindow; //if (mainWindow is WindowsBasePage windowsPage) //{ // windowsPage.LoadApplication(windowsPage.CreateApplication()); // windowsPage.Activate(); //} } IsInitialized = true; }
#pragma warning disable CS8305 // Type is for evaluation purposes only and is subject to change or removal in future updates. public static void InitDispatcher(Microsoft.System.DispatcherQueue dispatcher) #pragma warning restore CS8305 // Type is for evaluation purposes only and is subject to change or removal in future updates. { var platformServices = new WindowsPlatformServices(dispatcher); Device.PlatformServices = platformServices; Device.PlatformInvalidator = platformServices; Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportFontAttribute) }); IsInitialized = true; Platform.UWP.Platform.SubscribeAlertsAndActionSheets(); }
static void SetupInit( IMauiContext mauiContext, UI.Xaml.Window mainWindow, IEnumerable <Assembly> rendererAssemblies = null, InitializationOptions?maybeOptions = null) { MauiContext = mauiContext; Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); var accent = (WSolidColorBrush)Microsoft.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; KnownColor.SetAccent(accent.ToColor()); Device.SetFlowDirection(mauiContext.GetFlowDirection()); ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); var platformServices = new WindowsPlatformServices(); Device.PlatformServices = platformServices; if (mainWindow != null) { MainWindow = mainWindow; //if (mainWindow is WindowsBasePage windowsPage) //{ // windowsPage.LoadApplication(windowsPage.CreateApplication()); // windowsPage.Activate(); //} } IsInitialized = true; }
public static void Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } var accent = (WSolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; Color.SetAccent(accent.ToFormsColor()); #if !UWP_16299 Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); #else Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #endif if (!Windows.UI.Xaml.Application.Current.Resources.ContainsKey("RootContainerStyle")) { Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); } try { Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(new Microsoft.UI.Xaml.Controls.XamlControlsResources()); } catch { Log.Warning("Resources", "Unable to load WinUI resources. Try adding Xamarin.Forms nuget to UWP project"); } Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); var platformServices = new WindowsPlatformServices(Window.Current.Dispatcher); Device.PlatformServices = platformServices; Device.PlatformInvalidator = platformServices; Device.SetFlags(s_flags); Device.Info = new WindowsDeviceInfo(); switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Desktop": if (Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == Windows.UI.ViewManagement.UserInteractionMode.Touch) { Device.SetIdiom(TargetIdiom.Tablet); } else { Device.SetIdiom(TargetIdiom.Desktop); } break; case "Windows.Mobile": Device.SetIdiom(TargetIdiom.Phone); break; case "Windows.Xbox": Device.SetIdiom(TargetIdiom.TV); break; default: Device.SetIdiom(TargetIdiom.Unsupported); break; } ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportFontAttribute) }); IsInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; Platform.UWP.Platform.SubscribeAlertsAndActionSheets(); }
static void SetupInit( IMauiContext mauiContext, UI.Xaml.LaunchActivatedEventArgs launchActivatedEventArgs, WindowsBasePage mainWindow, IEnumerable <Assembly> rendererAssemblies = null, InitializationOptions?maybeOptions = null) { MauiContext = mauiContext; Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); var accent = (WSolidColorBrush)Microsoft.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; KnownColor.SetAccent(accent.ToFormsColor()); if (!IsInitialized) { #if !UWP_16299 Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); #else Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #endif } if (!UI.Xaml.Application.Current.Resources.ContainsKey("RootContainerStyle")) { UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); } try { UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(new UI.Xaml.Controls.XamlControlsResources()); } catch { Log.Warning("Resources", "Unable to load WinUI resources. Try adding Microsoft.Maui.Controls.Compatibility nuget to UWP project"); } Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); Device.SetFlags(s_flags); //TODO WINUI3 //// use field and not property to avoid exception in getter //if (Device.info != null) //{ // Device.info.Dispose(); // Device.info = null; //} //Device.Info = new WindowsDeviceInfo(); //TODO WINUI3 //switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) //{ // case "Windows.Desktop": // if (Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == // Windows.UI.ViewManagement.UserInteractionMode.Touch) // Device.SetIdiom(TargetIdiom.Tablet); // else // Device.SetIdiom(TargetIdiom.Desktop); // break; // case "Windows.Mobile": // Device.SetIdiom(TargetIdiom.Phone); // break; // case "Windows.Xbox": // Device.SetIdiom(TargetIdiom.TV); // break; // default: // Device.SetIdiom(TargetIdiom.Unsupported); // break; //} ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); s_state = launchActivatedEventArgs.UWPLaunchActivatedEventArgs.PreviousExecutionState; var dispatcher = mainWindow?.DispatcherQueue ?? System.DispatcherQueue.GetForCurrentThread(); var platformServices = new WindowsPlatformServices(dispatcher); Device.PlatformServices = platformServices; Device.PlatformInvalidator = platformServices; if (maybeOptions?.Flags.HasFlag(InitializationFlags.SkipRenderers) != true) { RegisterCompatRenderers(); } if (mainWindow != null) { MainWindow = mainWindow; //TODO WINUI3 Platform.UWP.Platform.SubscribeAlertsAndActionSheets(); mainWindow.LoadApplication(mainWindow.CreateApplication()); mainWindow.Activate(); } IsInitialized = true; }
static void SetupInit( IMauiContext mauiContext, UI.Xaml.Window mainWindow, IEnumerable <Assembly> rendererAssemblies = null, InitializationOptions?maybeOptions = null) { MauiContext = mauiContext; Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); var accent = (WSolidColorBrush)Microsoft.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; KnownColor.SetAccent(accent.ToColor()); if (!IsInitialized) { Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); } Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(mauiContext.GetFlowDirection()); Device.SetFlags(s_flags); Device.Info = new WindowsDeviceInfo(); //TODO WINUI3 //// use field and not property to avoid exception in getter //if (Device.info != null) //{ // Device.info.Dispose(); // Device.info = null; //} //Device.Info = new WindowsDeviceInfo(); //TODO WINUI3 //switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) //{ // case "Windows.Desktop": // if (Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == // Windows.UI.ViewManagement.UserInteractionMode.Touch) // Device.SetIdiom(TargetIdiom.Tablet); // else // Device.SetIdiom(TargetIdiom.Desktop); // break; // case "Windows.Mobile": // Device.SetIdiom(TargetIdiom.Phone); // break; // case "Windows.Xbox": // Device.SetIdiom(TargetIdiom.TV); // break; // default: // Device.SetIdiom(TargetIdiom.Unsupported); // break; //} ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); var dispatcher = mainWindow?.DispatcherQueue ?? UI.Dispatching.DispatcherQueue.GetForCurrentThread(); var platformServices = new WindowsPlatformServices(dispatcher); Device.PlatformServices = platformServices; Device.PlatformInvalidator = platformServices; if (mainWindow != null) { MainWindow = mainWindow; //if (mainWindow is WindowsBasePage windowsPage) //{ // windowsPage.LoadApplication(windowsPage.CreateApplication()); // windowsPage.Activate(); //} } IsInitialized = true; }