Exemplo n.º 1
0
 public static void Init(InitializationOptions options)
 {
     Profile.FrameBegin();
     SetupInit(
         options.Activity,
         options.ResourceAssembly,
         options
         );
     Profile.FrameEnd();
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
 public static void Init(InitializationOptions options)
 {
     s_useDeviceIndependentPixel = options?.UseDeviceIndependentPixel ?? false;
     SetupInit(options.Context, options);
 }
Exemplo n.º 4
0
 public static void Init(InitializationOptions options)
 {
     SetupInit(options.Context, options);
 }