public static void Init(IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); IsInitialized = true; Device.SetIdiom(TargetIdiom.Desktop); Device.PlatformServices = new GtkPlatformServices(); Device.Info = new GtkDeviceInfo(); Color.SetAccent(Color.FromHex("#3498DB")); ExpressionSearch.Default = new GtkExpressionSearch(); Registrar.RegisterAll(new[] { typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportRendererAttribute) }); }
public static void Init() { if (Forms.IsInitialized) { return; } Forms.IsInitialized = true; Color.Accent = Color.FromRgba(50, 79, 133, (int)byte.MaxValue); Log.Listeners.Add(new DelegateLogListener((c, m) => { Console.WriteLine("{0}: {1}", c, m); })); Device.OS = TargetPlatform.Other; Device.PlatformServices = (IPlatformServices) new Forms.MacPlatformServices(); Device.Info = (DeviceInfo) new Forms.MacDeviceInfo(); // TODO: CADisplayLinkTicker //Ticker.Default = (Ticker)new CADisplayLinkTicker (); Registrar.RegisterAll(new Type[3] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); Device.Idiom = TargetIdiom.Desktop; ExpressionSearch.Default = (IExpressionSearch) new Forms.MacExpressionSearch(); }
public static void Init() { if (IsInitialized) { return; } string assemblyName = Assembly.GetExecutingAssembly().GetName().Name; System.Windows.Application.Current.Resources.MergedDictionaries.Add(new System.Windows.ResourceDictionary { Source = new Uri(string.Format("/{0};component/WPFResources.xaml", assemblyName), UriKind.Relative) }); var accentColor = (SolidColorBrush)System.Windows.Application.Current.Resources["AccentColor"]; Color.SetAccent(Color.FromRgba(accentColor.Color.R, accentColor.Color.G, accentColor.Color.B, accentColor.Color.A)); Log.Listeners.Add(new DelegateLogListener((c, m) => Console.WriteLine("[{0}] {1}", m, c))); Device.SetTargetIdiom(TargetIdiom.Desktop); Device.PlatformServices = new WPFPlatformServices(); Device.Info = new WPFDeviceInfo(); ExpressionSearch.Default = new WPFExpressionSearch(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); Ticker.SetDefault(new WPFTicker()); Device.SetIdiom(TargetIdiom.Desktop); IsInitialized = true; }
public static void Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } var accent = (SolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; Color.SetAccent(accent.ToFormsColor()); Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); Device.PlatformServices = new WindowsPlatformServices(Window.Current.Dispatcher); 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) }); IsInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; Platform.UWP.Platform.SubscribeAlertsAndActionSheets(); }
public static void Init(IActivatedEventArgs launchActivatedEventArgs) #endif { if (IsInitialized) { return; } var accent = (SolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; Color.SetAccent(Color.FromRgba(accent.Color.R, accent.Color.G, accent.Color.B, accent.Color.A)); Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); Device.PlatformServices = new WindowsPlatformServices(Window.Current.Dispatcher); #if WINDOWS_UWP Device.SetFlags(s_flags); #endif Device.Info = new WindowsDeviceInfo(); #if WINDOWS_UWP switch (DetectPlatform()) { case Windows.Foundation.Metadata.Platform.Windows: Device.SetIdiom(TargetIdiom.Desktop); break; case Windows.Foundation.Metadata.Platform.WindowsPhone: Device.SetIdiom(TargetIdiom.Phone); break; default: Device.SetIdiom(TargetIdiom.Tablet); break; } #endif ExpressionSearch.Default = new WindowsExpressionSearch(); #if WINDOWS_UWP Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); #endif Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); IsInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; #if WINDOWS_UWP SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; Platform.UWP.Platform.SubscribeAlertsAndActionSheets(); #endif }
static void SetupInit(Context activity, Assembly resourceAssembly) { Context = activity; ResourceManager.Init(resourceAssembly); Color.Accent = GetAccentColor(); if (!IsInitialized) { Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } Device.OS = TargetPlatform.Android; Device.PlatformServices = new AndroidPlatformServices(); // use field and not property to avoid exception in getter if (Device.info != null) { ((AndroidDeviceInfo)Device.info).Dispose(); Device.info = null; } // probably could be done in a better way var deviceInfoProvider = activity as IDeviceInfoProvider; if (deviceInfoProvider != null) { Device.Info = new AndroidDeviceInfo(deviceInfoProvider); } var ticker = Ticker.Default as AndroidTicker; if (ticker != null) { ticker.Dispose(); } Ticker.Default = new AndroidTicker(); if (!IsInitialized) { Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); } int minWidthDp = Context.Resources.Configuration.SmallestScreenWidthDp; Device.Idiom = minWidthDp >= TabletCrossover ? TargetIdiom.Tablet : TargetIdiom.Phone; if (ExpressionSearch.Default == null) { ExpressionSearch.Default = new AndroidExpressionSearch(); } IsInitialized = true; }
public static void Init(PlatformBase platform, TargetIdiom idiom) { Platform = platform; platform.Init(idiom); Device.OS = TargetPlatform.Other; Device.Idiom = idiom; Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute) }); NamedSizes.Register(); Forms.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(); }
public static void Init(IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } Device.SetTargetIdiom(TargetIdiom.Desktop); Device.PlatformServices = new WebassemblyPlatformServices(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute) }); Device.SetIdiom(TargetIdiom.Desktop); IsInitialized = true; }
public static void Init() { if (IsInitialized) { return; } IsInitialized = true; Color.Accent = Color.FromRgba(50, 79, 133, 255); Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); Device.OS = TargetPlatform.iOS; Device.PlatformServices = new IOSPlatformServices(); Device.Info = new IOSDeviceInfo(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); Device.Idiom = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone; ExpressionSearch.Default = new iOSExpressionSearch(); }
public static void Init() { if (IsInitialized) { return; } IsInitialized = true; Log.Listeners.Add(new DelegateLogListener((c, m) => System.Diagnostics.Debug.WriteLine(m, c))); Device.SetIdiom(TargetIdiom.Desktop); Device.PlatformServices = new OouiPlatformServices(); Device.Info = new OouiDeviceInfo(); Color.SetAccent(Color.FromHex("#337ab7")); // Bootstrap Blue Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), }); }
public static void Init() { if (s_isInitialized) { return; } // Needed to prevent stripping of System.Windows.Interactivity // which is current only referenced in the XAML DataTemplates var eventTrigger = new System.Windows.Interactivity.EventTrigger(); string assemblyName = Assembly.GetExecutingAssembly().GetName().Name; System.Windows.Application.Current.Resources.MergedDictionaries.Add(new System.Windows.ResourceDictionary { Source = new Uri(string.Format("/{0};component/WPResources.xaml", assemblyName), UriKind.Relative) }); var accent = System.Windows.Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush; System.Windows.Media.Color color = accent.Color; Color.Accent = Color.FromRgba(color.R, color.G, color.B, color.A); Log.Listeners.Add(new DelegateLogListener((c, m) => Console.WriteLine("[{0}] {1}", m, c))); Device.OS = TargetPlatform.WinPhone; Device.PlatformServices = new WP8PlatformServices(); Device.Info = new WP8DeviceInfo(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); Ticker.Default = new WinPhoneTicker(); Device.Idiom = TargetIdiom.Phone; ExpressionSearch.Default = new WinPhoneExpressionSearch(); s_isInitialized = true; }
public static void Init(IActivatedEventArgs launchActivatedEventArgs) { if (s_isInitialized) { return; } var accent = (SolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; Color.Accent = Color.FromRgba(accent.Color.R, accent.Color.G, accent.Color.B, accent.Color.A); Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetPhoneResources()); Device.OS = TargetPlatform.Windows; Device.PlatformServices = new WindowsPhonePlatformServices(Window.Current.Dispatcher); Device.Info = new WindowsDeviceInfo(); Device.Idiom = TargetIdiom.Phone; Ticker.Default = new WindowsTicker(); ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); MessagingCenter.Subscribe <Page, bool> (Device.PlatformServices, Page.BusySetSignalName, OnPageBusy); HardwareButtons.BackPressed += OnBackPressed; s_isInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; }
public static void InitHeadless(IActivatedEventArgs launchActivatedEventArgs, IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); Device.PlatformServices = new WindowsPlatformServices(CoreWindow.GetForCurrentThread().Dispatcher); Device.SetFlags(s_flags); Device.Info = new WindowsDeviceInfo(); ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); IsInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; }
public static void Init(IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } string assemblyName = Assembly.GetExecutingAssembly().GetName().Name; Log.Listeners.Add(new DelegateLogListener((c, m) => Console.WriteLine("[{0}] {1}", m, c))); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); Device.SetTargetIdiom(TargetIdiom.Desktop); Device.PlatformServices = new AvaloniaPlatformServices(); Device.Info = new AvaloniaUIDeviceInfo(); ExpressionSearch.Default = new AvaloniaUIExpressionSearch(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); Ticker.SetDefault(new AvaloniaUITicker()); Device.SetIdiom(TargetIdiom.Desktop); 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()); #if UWP_16299 Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add( new Windows.UI.Xaml.ResourceDictionary { Source = new Uri("ms-appx:///Xamarin.Forms.Platform.UAP/Shell/ShellStyles.xbf") }); #endif } 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( Context activity, Assembly resourceAssembly, ActivationOptions?maybeOptions = null ) { Profile.FrameBegin(); if (!IsInitialized) { // Only need to get this once; it won't change ApplicationContext = activity.ApplicationContext; } #pragma warning disable 618 // Still have to set this up so obsolete code can function Context = activity; #pragma warning restore 618 if (!IsInitialized) { // Only need to do this once Profile.FramePartition("ResourceManager.Init"); ResourceManager.Init(resourceAssembly); } Profile.FramePartition("Color.SetAccent()"); // We want this to be updated when we have a new activity (e.g. on a configuration change) // This could change if the UI mode changes (e.g., if night mode is enabled) Color.SetAccent(GetAccentColor(activity)); _ColorButtonNormalSet = false; if (!IsInitialized) { // Only need to do this once Profile.FramePartition("Log.Listeners"); Internals.Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because AndroidPlatformServices needs a current activity to launch URIs from Profile.FramePartition("Device.PlatformServices"); Device.PlatformServices = new AndroidPlatformServices(activity); // use field and not property to avoid exception in getter if (Device.info != null) { ((AndroidDeviceInfo)Device.info).Dispose(); Device.info = null; } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because Device.Info watches for orientation changes and we need a current activity for that Profile.FramePartition("new AndroidDeviceInfo(activity)"); Device.Info = new AndroidDeviceInfo(activity); Device.SetFlags(s_flags); Profile.FramePartition("AndroidTicker"); var ticker = Ticker.Default as AndroidTicker; if (ticker != null) { ticker.Dispose(); } Ticker.SetDefault(new AndroidTicker()); Profile.FramePartition("RegisterAll"); if (!IsInitialized) { if (maybeOptions.HasValue) { var options = maybeOptions.Value; var handlers = options.Handlers; var flags = options.Flags; var effectScopes = options.EffectScopes; // renderers Registrar.RegisterRenderers(handlers); // effects if (effectScopes != null) { for (var i = 0; i < effectScopes.Length; i++) { var effectScope = effectScopes[0]; Registrar.RegisterEffects(effectScope.Name, effectScope.Effects); } } // css var noCss = (flags & ActivationFlags.NoCss) != 0; if (!noCss) { Registrar.RegisterStylesheets(); } } else { // Only need to do this once Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); } } Profile.FramePartition("Epilog"); // This could change as a result of a config change, so we need to check it every time int minWidthDp = activity.Resources.Configuration.SmallestScreenWidthDp; Device.SetIdiom(minWidthDp >= TabletCrossover ? TargetIdiom.Tablet : TargetIdiom.Phone); if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1) { Device.SetFlowDirection(activity.Resources.Configuration.LayoutDirection.ToFlowDirection()); } if (ExpressionSearch.Default == null) { ExpressionSearch.Default = new AndroidExpressionSearch(); } IsInitialized = true; Profile.FrameEnd(); }
static void SetupInit(CoreApplication application, InitializationOptions?maybeOptions = null) { Context = application; if (!IsInitialized) { Internals.Log.Listeners.Add(new XamarinLogListener()); if (System.Threading.SynchronizationContext.Current == null) { TizenSynchronizationContext.Initialize(); } Elementary.Initialize(); Elementary.ThemeOverlay(); } Device.PlatformServices = new TizenPlatformServices(); if (Device.info != null) { ((TizenDeviceInfo)Device.info).Dispose(); Device.info = null; } Device.Info = new Forms.TizenDeviceInfo(); Device.SetFlags(s_flags); if (!Forms.IsInitialized) { if (maybeOptions.HasValue) { var options = maybeOptions.Value; _useDeviceIndependentPixel = options.UseDeviceIndependentPixel; if (options.Assemblies != null) { TizenPlatformServices.AppDomain.CurrentDomain.AddAssemblies(options.Assemblies); } // renderers if (options.Handlers != null) { Registrar.RegisterRenderers(options.Handlers); } else { Registrar.RegisterAll(new Type[] { typeof(ExportRendererAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportCellAttribute), typeof(ExportHandlerAttribute) }); } // effects var effectScopes = options.EffectScopes; if (effectScopes != null) { for (var i = 0; i < effectScopes.Length; i++) { var effectScope = effectScopes[0]; Registrar.RegisterEffects(effectScope.Name, effectScope.Effects); } } // css var flags = options.Flags; var noCss = (flags & InitializationFlags.DisableCss) != 0; if (!noCss) { Registrar.RegisterStylesheets(); } } else { // In .NETCore, AppDomain feature is not supported. // The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually. // The assembly of the executing application and referenced assemblies of it are added into the list here. TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssemblyRecursively(application.GetType().GetTypeInfo().Assembly); Registrar.RegisterAll(new Type[] { typeof(ExportRendererAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportCellAttribute), typeof(ExportHandlerAttribute) }); } } string profile = ((TizenDeviceInfo)Device.Info).Profile; if (profile == "mobile") { Device.SetIdiom(TargetIdiom.Phone); } else if (profile == "tv") { Device.SetIdiom(TargetIdiom.TV); } else if (profile == "desktop") { Device.SetIdiom(TargetIdiom.Desktop); } else if (profile == "wearable") { Device.SetIdiom(TargetIdiom.Watch); } else { Device.SetIdiom(TargetIdiom.Unsupported); } Color.SetAccent(GetAccentColor(profile)); ExpressionSearch.Default = new TizenExpressionSearch(); IsInitialized = true; }
static void SetupInit(CoreApplication application) { Context = application; if (!IsInitialized) { Internals.Log.Listeners.Add(new XamarinLogListener()); if (System.Threading.SynchronizationContext.Current == null) { TizenSynchronizationContext.Initialize(); } Elementary.Initialize(); Elementary.ThemeOverlay(); } // In .NETCore, AppDomain feature is not supported. // The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually. // The assembly of the executing application and referenced assemblies of it are added into the list here. TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssemblyRecursively(application.GetType().GetTypeInfo().Assembly); Device.PlatformServices = new TizenPlatformServices(); if (Device.info != null) { ((TizenDeviceInfo)Device.info).Dispose(); Device.info = null; } Device.Info = new Forms.TizenDeviceInfo(); Device.SetFlags(s_flags); if (!Forms.IsInitialized) { Registrar.RegisterAll(new Type[] { typeof(ExportRendererAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportCellAttribute), typeof(ExportHandlerAttribute) }); } string profile = ((TizenDeviceInfo)Device.Info).Profile; if (profile == "mobile") { Device.SetIdiom(TargetIdiom.Phone); } else if (profile == "tv") { Device.SetIdiom(TargetIdiom.TV); } else if (profile == "desktop") { Device.SetIdiom(TargetIdiom.Desktop); } else if (profile == "wearable") { Device.SetIdiom(TargetIdiom.Watch); } else { Device.SetIdiom(TargetIdiom.Unsupported); } Color.SetAccent(GetAccentColor(profile)); ExpressionSearch.Default = new TizenExpressionSearch(); IsInitialized = true; }
static void SetupInit(Context activity, Assembly resourceAssembly) { if (!IsInitialized) { // Only need to get this once; it won't change ApplicationContext = activity.ApplicationContext; } #pragma warning disable 618 // Still have to set this up so obsolete code can function Context = activity; #pragma warning restore 618 if (!IsInitialized) { // Only need to do this once ResourceManager.Init(resourceAssembly); } // We want this to be updated when we have a new activity (e.g. on a configuration change) // This could change if the UI mode changes (e.g., if night mode is enabled) Color.SetAccent(GetAccentColor(activity)); _ColorButtonNormalSet = false; if (!IsInitialized) { // Only need to do this once Internals.Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because AndroidPlatformServices needs a current activity to launch URIs from Device.PlatformServices = new AndroidPlatformServices(activity); // use field and not property to avoid exception in getter if (Device.info != null) { ((AndroidDeviceInfo)Device.info).Dispose(); Device.info = null; } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because Device.Info watches for orientation changes and we need a current activity for that Device.Info = new AndroidDeviceInfo(activity); Device.SetFlags(s_flags); var ticker = Ticker.Default as AndroidTicker; if (ticker != null) { ticker.Dispose(); } Ticker.SetDefault(new AndroidTicker()); if (!IsInitialized) { // Only need to do this once Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); } // This could change as a result of a config change, so we need to check it every time int minWidthDp = activity.Resources.Configuration.SmallestScreenWidthDp; Device.SetIdiom(minWidthDp >= TabletCrossover ? TargetIdiom.Tablet : TargetIdiom.Phone); if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1) { Device.SetFlowDirection(activity.Resources.Configuration.LayoutDirection.ToFlowDirection()); } if (ExpressionSearch.Default == null) { ExpressionSearch.Default = new AndroidExpressionSearch(); } IsInitialized = true; }
static void SetupInit( Context activity, Assembly resourceAssembly, InitializationOptions?maybeOptions = null ) { Profile.FrameBegin(); Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); if (!IsInitialized) { // Only need to get this once; it won't change ApplicationContext = activity.ApplicationContext; } #pragma warning disable 618 // Still have to set this up so obsolete code can function Context = activity; #pragma warning restore 618 if (!IsInitialized) { // Only need to do this once Profile.FramePartition("ResourceManager.Init"); ResourceManager.Init(resourceAssembly); } Profile.FramePartition("Color.SetAccent()"); // We want this to be updated when we have a new activity (e.g. on a configuration change) // This could change if the UI mode changes (e.g., if night mode is enabled) Color.SetAccent(GetAccentColor(activity)); _ColorButtonNormalSet = false; if (!IsInitialized) { // Only need to do this once Profile.FramePartition("Log.Listeners"); Internals.Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because AndroidPlatformServices needs a current activity to launch URIs from Profile.FramePartition("Device.PlatformServices"); var androidServices = new AndroidPlatformServices(activity); Device.PlatformServices = androidServices; Device.PlatformInvalidator = androidServices; // use field and not property to avoid exception in getter if (Device.info != null) { ((AndroidDeviceInfo)Device.info).Dispose(); Device.info = null; } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because Device.Info watches for orientation changes and we need a current activity for that Profile.FramePartition("create AndroidDeviceInfo"); Device.Info = new AndroidDeviceInfo(activity); Profile.FramePartition("setFlags"); Device.SetFlags(s_flags); Profile.FramePartition("AndroidTicker"); Ticker.SetDefault(null); Profile.FramePartition("RegisterAll"); if (!IsInitialized) { if (maybeOptions.HasValue) { var options = maybeOptions.Value; var handlers = options.Handlers; var flags = options.Flags; var effectScopes = options.EffectScopes; //TODO: ExportCell? //TODO: ExportFont // renderers Registrar.RegisterRenderers(handlers); // effects if (effectScopes != null) { for (var i = 0; i < effectScopes.Length; i++) { var effectScope = effectScopes[0]; Registrar.RegisterEffects(effectScope.Name, effectScope.Effects); } } // css Registrar.RegisterStylesheets(flags); } else { // Only need to do this once Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportFontAttribute) }); } } Profile.FramePartition("Epilog"); var currentIdiom = TargetIdiom.Unsupported; // First try UIModeManager using (var uiModeManager = UiModeManager.FromContext(ApplicationContext)) { try { var uiMode = uiModeManager?.CurrentModeType ?? UiMode.TypeUndefined; currentIdiom = DetectIdiom(uiMode); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Unable to detect using UiModeManager: {ex.Message}"); } } // Then try Configuration if (TargetIdiom.Unsupported == currentIdiom) { var configuration = activity.Resources.Configuration; if (configuration != null) { var minWidth = configuration.SmallestScreenWidthDp; var isWide = minWidth >= TabletCrossover; currentIdiom = isWide ? TargetIdiom.Tablet : TargetIdiom.Phone; } else { // Start clutching at straws var metrics = activity.Resources?.DisplayMetrics; if (metrics != null) { var minSize = Math.Min(metrics.WidthPixels, metrics.HeightPixels); var isWide = minSize * metrics.Density >= TabletCrossover; currentIdiom = isWide ? TargetIdiom.Tablet : TargetIdiom.Phone; } } } Device.SetIdiom(currentIdiom); if (SdkInt >= BuildVersionCodes.JellyBeanMr1) { Device.SetFlowDirection(activity.Resources.Configuration.LayoutDirection.ToFlowDirection()); } if (ExpressionSearch.Default == null) { ExpressionSearch.Default = new AndroidExpressionSearch(); } IsInitialized = true; Profile.FrameEnd(); }
static void SetupInit(CoreApplication application, InitializationOptions options = null) { Context = application; if (!IsInitialized) { Internals.Log.Listeners.Add(new XamarinLogListener()); if (System.Threading.SynchronizationContext.Current == null) { TizenSynchronizationContext.Initialize(); } Elementary.Initialize(); Elementary.ThemeOverlay(); Utility.AppendGlobalFontPath(@"/usr/share/fonts"); } Device.PlatformServices = new TizenPlatformServices(); if (Device.info != null) { ((TizenDeviceInfo)Device.info).Dispose(); Device.info = null; } Device.Info = new Forms.TizenDeviceInfo(); Device.SetFlags(s_flags); string profile = ((TizenDeviceInfo)Device.Info).Profile; if (profile == "mobile") { Device.SetIdiom(TargetIdiom.Phone); } else if (profile == "tv") { Device.SetIdiom(TargetIdiom.TV); } else if (profile == "desktop") { Device.SetIdiom(TargetIdiom.Desktop); } else if (profile == "wearable") { Device.SetIdiom(TargetIdiom.Watch); } else { Device.SetIdiom(TargetIdiom.Unsupported); } if (!Forms.IsInitialized) { if (options != null) { s_platformType = options.PlatformType; s_useMessagingCenter = options.UseMessagingCenter; if (options.Assemblies != null && options.Assemblies.Length > 0) { TizenPlatformServices.AppDomain.CurrentDomain.AddAssemblies(options.Assemblies); } // renderers if (options.Handlers != null) { Registrar.RegisterRenderers(options.Handlers); } else { // Add Xamarin.Forms.Core assembly by default to apply the styles. TizenPlatformServices.AppDomain.CurrentDomain.AddAssembly(Assembly.GetAssembly(typeof(Xamarin.Forms.View))); // static registrar if (options.StaticRegistarStrategy != StaticRegistrarStrategy.None) { s_staticRegistrarStrategy = options.StaticRegistarStrategy; StaticRegistrar.RegisterHandlers(options.CustomHandlers); if (options.StaticRegistarStrategy == StaticRegistrarStrategy.All) { Registrar.RegisterAll(new Type[] { typeof(ExportRendererAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportCellAttribute), typeof(ExportHandlerAttribute), typeof(ExportFontAttribute) }); } } else { Registrar.RegisterAll(new Type[] { typeof(ExportRendererAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportCellAttribute), typeof(ExportHandlerAttribute), typeof(ExportFontAttribute) }); } } // effects var effectScopes = options.EffectScopes; if (effectScopes != null) { for (var i = 0; i < effectScopes.Length; i++) { var effectScope = effectScopes[0]; Registrar.RegisterEffects(effectScope.Name, effectScope.Effects); } } // css Registrar.RegisterStylesheets(options.Flags); } else { // In .NETCore, AppDomain feature is not supported. // The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually. // The assembly of the executing application and referenced assemblies of it are added into the list here. TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssemblyRecursively(application.GetType().GetTypeInfo().Assembly); Registrar.RegisterAll(new Type[] { typeof(ExportRendererAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportCellAttribute), typeof(ExportHandlerAttribute), typeof(ExportFontAttribute) }); } } Color.SetAccent(GetAccentColor(profile)); ExpressionSearch.Default = new TizenExpressionSearch(); if (application is WatchApplication) { s_platformType = PlatformType.Lightweight; } IsInitialized = true; }
static void SetupInit(Context activity, Assembly resourceAssembly) { Context = activity; ResourceManager.Init(resourceAssembly); // Detect if legacy device and use appropriate accent color // Hardcoded because could not get color from the theme drawable var sdkVersion = (int)Build.VERSION.SdkInt; if (sdkVersion <= 10) { // legacy theme button pressed color Color.Accent = Color.FromHex("#fffeaa0c"); } else { // Holo dark light blue Color.Accent = Color.FromHex("#ff33b5e5"); } if (!IsInitialized) { Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } Device.OS = TargetPlatform.Android; Device.PlatformServices = new AndroidPlatformServices(); // use field and not property to avoid exception in getter if (Device.info != null) { ((AndroidDeviceInfo)Device.info).Dispose(); Device.info = null; } // probably could be done in a better way var deviceInfoProvider = activity as IDeviceInfoProvider; if (deviceInfoProvider != null) { Device.Info = new AndroidDeviceInfo(deviceInfoProvider); } var ticker = Ticker.Default as AndroidTicker; if (ticker != null) { ticker.Dispose(); } Ticker.Default = new AndroidTicker(); if (!IsInitialized) { Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); } int minWidthDp = Context.Resources.Configuration.SmallestScreenWidthDp; Device.Idiom = minWidthDp >= TabletCrossover ? TargetIdiom.Tablet : TargetIdiom.Phone; if (ExpressionSearch.Default == null) { ExpressionSearch.Default = new AndroidExpressionSearch(); } IsInitialized = true; }