예제 #1
0
        /// <summary>
        /// The Run application.
        /// </summary>
        /// <param name="args">The arguments from commandline.</param>
        public void Run(string[] args)
        {
            TizenSynchronizationContext.Initialize();

            args[0] = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath;
            if (string.IsNullOrEmpty(args[0]))
            {
                args[0] = this.GetType().Assembly.FullName.Replace(" ", "");
            }

            if (windowRectangle != null)
            {
                application = Application.NewApplication(args, stylesheet, windowMode, windowRectangle);
            }
            else
            {
                application = Application.NewApplication(args, stylesheet, windowMode);
            }

            application.BatteryLow      += OnBatteryLow;
            application.LanguageChanged += OnLanguageChanged;
            application.MemoryLow       += OnMemoryLow;
            application.RegionChanged   += OnRegionChanged;

            application.Initialized += OnInitialized;
            application.Resumed     += OnResumed;
            application.Terminating += OnTerminated;
            application.Paused      += OnPaused;
            application.AppControl  += OnAppControl;

            application.MainLoop();
            application.Dispose();
        }
예제 #2
0
        public void Run(string[] args)
        {
            TizenSynchronizationContext.Initialize();

            Interop.Widget.ErrorCode err = Interop.Widget.ErrorCode.None;
            err = Interop.Widget.AddEventHandler(out _lowMemoryEventHandle, Interop.Widget.AppEventType.LowMemory, _lowMemoryCallback, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to add event handler for LowMemory event. Err = " + err);
            }
            err = Interop.Widget.AddEventHandler(out _lowBatteryEventHandle, Interop.Widget.AppEventType.LowBattery, _lowBatteryCallback, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to add event handler for LowBattery event. Err = " + err);
            }

            err = Interop.Widget.AddEventHandler(out _localeChangedEventHandle, Interop.Widget.AppEventType.LanguageChanged, _localeChangedCallback, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to add event handler for LocaleChanged event. Err = " + err);
            }

            err = Interop.Widget.AddEventHandler(out _regionChangedEventHandle, Interop.Widget.AppEventType.RegionFormatChanged, _regionChangedCallback, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err);
            }

            err = Interop.Widget.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to run the application. Err = " + err);
            }
        }
예제 #3
0
        /// <summary>
        /// The Run application.
        /// </summary>
        /// <param name="args">The arguments from commandline.</param>
        public void Run(string[] args)
        {
            TizenSynchronizationContext.Initialize();

            args[0] = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath;
            if (args.Length == 1)
            {
                _application = Application.NewApplication();
            }
            else if (args.Length > 1)
            {
                _application = Application.NewApplication(args, _stylesheet, (Application.WindowMode)_windowMode);
            }

            _application.BatteryLow      += OnBatteryLow;
            _application.LanguageChanged += OnLanguageChanged;
            _application.MemoryLow       += OnMemoryLow;
            _application.RegionChanged   += OnRegionChanged;

            _application.Initialized += OnInitialized;
            _application.Resumed     += OnResumed;
            _application.Terminating += OnTerminated;
            _application.Paused      += OnPaused;
            _application.AppControl  += OnAppControl;

            _application.MainLoop();
        }
예제 #4
0
        /// <summary>
        /// The Run application.
        /// </summary>
        /// <param name="args">The arguments from commandline.</param>
        public void Run(string[] args)
        {
            TizenSynchronizationContext.Initialize();
            NDalicPINVOKE.SWIGStringHelper.RegistCallback();

            args[0] = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath;
            if ("" == args[0])
            {
                args[0] = this.GetType().Assembly.FullName;
            }

            if (args.Length == 1)
            {
                _application = Application.NewApplication();
            }
            else if (args.Length > 1)
            {
                _application = Application.NewApplication(args, _stylesheet, (Application.WindowMode)_windowMode);
            }

            _application.BatteryLow      += OnBatteryLow;
            _application.LanguageChanged += OnLanguageChanged;
            _application.MemoryLow       += OnMemoryLow;
            _application.RegionChanged   += OnRegionChanged;

            _application.Initialized += OnInitialized;
            _application.Resumed     += OnResumed;
            _application.Terminating += OnTerminated;
            _application.Paused      += OnPaused;
            _application.AppControl  += OnAppControl;

            _application.MainLoop();
            _application.Dispose();
        }
예제 #5
0
 protected UISynchronizer()
 {
     if (TizenSynchronizationContext.Current == null)
     {
         TizenSynchronizationContext.Initialize();
     }
     uiContext = TizenSynchronizationContext.Current;
 }
예제 #6
0
 static internal void SetParent(Page parent)
 {
     MessageBox.parent = parent;
     // TizenSynchronizationContext
     if (TizenSynchronizationContext.Current == null)
     {
         TizenSynchronizationContext.Initialize();
     }
     uiContext = TizenSynchronizationContext.Current;
 }
예제 #7
0
        public PlatformTicker()
        {
            if (SynchronizationContext.Current == null)
            {
                TizenSynchronizationContext.Initialize();
            }

            _context = SynchronizationContext.Current;
            _timer   = new Timer((object?o) => HandleElapsed(o), this, Timeout.Infinite, Timeout.Infinite);
        }
예제 #8
0
        /// <summary>
        /// The Run application.
        /// </summary>
        /// <param name="args">The arguments from commandline.</param>
        public void Run(string[] args)
        {
            Tizen.Tracer.Begin("[NUI] NUICorebackend Run()");

            Tizen.Tracer.Begin("[NUI] NUICorebackend Run(): TizenSynchronizationContext.Initialize() called");
            TizenSynchronizationContext.Initialize();
            Tizen.Tracer.End();

            Tizen.Tracer.Begin("[NUI] NUICorebackend Run(): args of main set, window type set");
            if (Tizen.Applications.Application.Current?.ApplicationInfo != null)
            {
                args[0] = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath;
            }
            if (string.IsNullOrEmpty(args[0]))
            {
                args[0] = this.GetType().Assembly.FullName.Replace(" ", "");
            }

            if (defaultWindowType != WindowType.Normal)
            {
                application = Application.NewApplication(stylesheet, windowMode, defaultWindowType);
            }
            else
            {
                if (windowRectangle != null)
                {
                    application = Application.NewApplication(args, stylesheet, windowMode, windowRectangle);
                }
                else
                {
                    application = Application.NewApplication(args, stylesheet, windowMode);
                }
            }
            Tizen.Tracer.End();

            Tizen.Tracer.Begin("[NUI] NUICorebackend Run(): add application related events");
            application.BatteryLow      += OnBatteryLow;
            application.LanguageChanged += OnLanguageChanged;
            application.MemoryLow       += OnMemoryLow;
            application.RegionChanged   += OnRegionChanged;

            application.Initialized += OnInitialized;
            application.Resumed     += OnResumed;
            application.Terminating += OnTerminated;
            application.Paused      += OnPaused;
            application.AppControl  += OnAppControl;
            Tizen.Tracer.End();

            Tizen.Tracer.End();

            application.MainLoop();
            application.Dispose();
        }
예제 #9
0
        /// <summary>
        /// Run Application.
        /// </summary>
        /// <param name="args">Arguments from commandline.</param>
        public void Run(string[] args)
        {
            TizenSynchronizationContext.Initialize();

            args[0]      = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath;
            _application = ComponentApplication.NewComponentApplication(args, _stylesheet);

            _application.Initialized  += OnInitialized;
            _application.CreateNative += OnCreateNative;
            _application.Terminating  += OnTerminated;

            _application.MainLoop();
        }
예제 #10
0
        /// <summary>
        /// Run Application.
        /// </summary>
        /// <param name="args">Arguments from commandline.</param>
        public void Run(string[] args)
        {
            args[0]      = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath;
            _application = WidgetApplication.NewWidgetApplication(args, _stylesheet);

            TizenSynchronizationContext.Initialize();
            _application.BatteryLow      += OnBatteryLow;
            _application.LanguageChanged += OnLanguageChanged;
            _application.MemoryLow       += OnMemoryLow;
            _application.RegionChanged   += OnRegionChanged;;

            _application.Init      += OnInit;
            _application.Terminate += OnTerminate;

            _application.MainLoop();
        }
예제 #11
0
        /// <summary>
        /// The Run application.
        /// </summary>
        /// <param name="args">The arguments from commandline.</param>
        public void Run(string[] args)
        {
            TizenSynchronizationContext.Initialize();

            args[0] = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath;
            if (string.IsNullOrEmpty(args[0]))
            {
                args[0] = this.GetType().Assembly.FullName;
            }

            if (args.Length == 1)
            {
                if (_windowSize != null)
                {
                    _application = Application.NewApplication(_stylesheet, (Application.WindowMode)_windowMode, new Rectangle(_windowPosition.X, _windowPosition.Y, _windowSize.Width, _windowSize.Height));
                }
                else
                {
                    _application = Application.NewApplication(_stylesheet, (Application.WindowMode)_windowMode);
                }
            }
            else if (args.Length > 1)
            {
                if (_windowSize != null)
                {
                    _application = Application.NewApplication(args, _stylesheet, (Application.WindowMode)_windowMode, new Rectangle(_windowPosition.X, _windowPosition.Y, _windowSize.Width, _windowSize.Height));
                }
                else
                {
                    _application = Application.NewApplication(args, _stylesheet, (Application.WindowMode)_windowMode);
                }
            }

            _application.BatteryLow      += OnBatteryLow;
            _application.LanguageChanged += OnLanguageChanged;
            _application.MemoryLow       += OnMemoryLow;
            _application.RegionChanged   += OnRegionChanged;

            _application.Initialized += OnInitialized;
            _application.Resumed     += OnResumed;
            _application.Terminating += OnTerminated;
            _application.Paused      += OnPaused;
            _application.AppControl  += OnAppControl;

            _application.MainLoop();
            _application.Dispose();
        }
예제 #12
0
        internal static void Start(IAppAdapter adapter)
        {
            Log.Debug("Start Service : initialize");
            if (IsInitialized)
            {
                return;
            }

            if (SynchronizationContext.Current == null)
            {
                TizenSynchronizationContext.Initialize();
            }
            s_context = SynchronizationContext.Current;

            Server.Instance.Start(adapter);

            IsInitialized = true;
        }
예제 #13
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;
        }
예제 #14
0
 /// <summary>
 /// Runs the mainloop of the backend.
 /// </summary>
 /// <param name="args"></param>
 /// <since_tizen> 3 </since_tizen>
 public virtual void Run(string[] args)
 {
     TizenSynchronizationContext.Initialize();
 }
예제 #15
0
        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.
            // TODO: AppDomain is comming back in NETStandard2.0. This logic should be changed at that time.
            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)
                });
            }

            // TODO: We should consider various tizen profiles such as TV, Wearable and so on.
            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
            {
                Device.SetIdiom(TargetIdiom.Unsupported);
            }
            Color.SetAccent(GetAccentColor(profile));
            ExpressionSearch.Default = new TizenExpressionSearch();
            IsInitialized            = true;
        }
예제 #16
0
        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;
        }