public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            //Xamarin.Calabash.Start();
#if ENABLE_TEST_CLOUD
            // requires Xamarin Test Cloud Agent
            Xamarin.Calabash.Start();
#endif

            var normalTextAttributes = new UITextAttributes();

            normalTextAttributes.Font      = UIFont.FromName("Roboto-Bold", 16.0f); // -- Unselected
            normalTextAttributes.TextColor = Color.FromHex("#174163").ToUIColor();
            UINavigationBar.Appearance.SetTitleTextAttributes(normalTextAttributes);

            UINavigationBar.Appearance.BarTintColor = Color.FromHex("#eff9ff").ToUIColor();
            UINavigationBar.Appearance.TintColor    = Color.FromHex("#174163").ToUIColor();

            UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarPosition.Any, UIBarMetrics.Default);
            UINavigationBar.Appearance.ShadowImage = new UIImage();

            global::Xamarin.Forms.Forms.Init();

            MessagingCenter.Subscribe <StartLongRunningTaskMessage>(this, "StartLongRunningTaskMessage", async message => {
                upload_task = new LongRunningTask(new UploadLongRunningTask());
                await upload_task.Start();
            });

            MessagingCenter.Subscribe <StopLongRunningTaskMessage>(this, "StopLongRunningTaskMessage", message => {
                upload_task.Stop();
            });

            //DependencyService.Register<IProgressHUD, IOSProgressHUD>();

            App.ScreenSize = new Size(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);

            var fr = new CultureInfo("fr-FR");
            Thread.CurrentThread.CurrentCulture = fr;
            PopolLib.iOS.Renderers.FastListView.FastListViewRenderer.Init();

            LoadApplication(new App());

            // -- Liste des Fonts dans l'application
            //var fontList = new StringBuilder();
            //var familyNames = UIFont.FamilyNames;
            //foreach (var familyName in familyNames)
            //{
            //    fontList.Append(String.Format("Family: {0}\n", familyName));
            //    Console.WriteLine("Family: {0}\n", familyName);
            //    var fontNames = UIFont.FontNamesForFamilyName(familyName);
            //    foreach (var fontName in fontNames)
            //    {
            //        Console.WriteLine("\tFont: {0}\n", fontName);
            //        fontList.Append(String.Format("\tFont: {0}\n", fontName));
            //    }
            //};

            //Console.WriteLine(fontList.ToString());
            return(base.FinishedLaunching(uiApplication, launchOptions));
        }
Exemple #2
0
        public virtual void Start()
        {
            if (IsRunning)
            {
                return;
            }
            lock (_stateLock)
            {
                if (IsRunning)
                {
                    return;
                }
                Log.Log(LogCatagory.Info, "Starting {0}. . .", ModuleName);

                LongRunningTask = new LongRunningTask(AttendIncomingQueue);
                LongRunningTask.Start();

                OnStart();

                Log.Log(LogCatagory.Info, "{0} started.", ModuleName);
                IsRunning = true;
            }
        }
        private void DoWork()
        {
            try
            {
                Resources.InitUpdaterDirectories();

                if (_frameworkUpdate != null)
                {
                    string frameworkFile = Path.Combine(Resources.DownloadsDir, "framework.zip");
                    try
                    {
                        lock (_lock)
                        {
                            Logger.Current.Write(LogInfoLevel.Info, "Downloading framework update...");
                            _currentDownloader = new FileDownloader(_frameworkUpdate, frameworkFile, _frameworkUpdateHash, null);
                            _currentTask       = _currentDownloader;
                            View.Invoke(() =>
                            {
                                View.Details     = "Downloading MGDF framework update...";
                                View.AllowCancel = true;
                            });
                        }
                        var result = _currentDownloader.Start();

                        lock (_lock)
                        {
                            _currentDownloader = null;
                            View.Invoke(() => View.AllowCancel = false);
                        }

                        if (result == LongRunningTaskResult.Cancelled)
                        {
                            _workerThread = null;
                            View.Invoke(CloseView);
                            return;
                        }
                        else if (result == LongRunningTaskResult.Error)
                        {
                            //show an error message, though we may still be able to download a game update, so don't bail out yet.
                            ShowError("Download failed", "Failed to download MGDF framework update");
                        }
                        else
                        {
                            lock (_lock)
                            {
                                Logger.Current.Write(LogInfoLevel.Info, "Installing framework update...");
                                //success, now try to install the downloaded update
                                View.Invoke(() => View.Details = "Installing MGDF framework update...");
                                _currentTask = new FrameworkUpdater(frameworkFile);
                            }
                            result = _currentTask.Start();

                            if (result == LongRunningTaskResult.Error)
                            {
                                //show an error message, though we may still be able to download a game update, so don't bail out yet.
                                ShowError("Install failed", "Failed to install MGDF framework update");
                            }
                            else
                            {
                                View.Invoke(() => View.Details = "Installing framework dependencies...");
                                DependencyInstaller.Install();
                            }
                        }
                    }
                    finally
                    {
                        var file = FileSystem.Current.GetFile(frameworkFile);
                        if (file.Exists)
                        {
                            file.DeleteWithTimeout();
                        }
                    }
                }

                if (_gameUpdate != null)
                {
                    string gameUpdateFile = Path.Combine(Resources.DownloadsDir, "update.zip");
                    try
                    {
                        lock (_lock)
                        {
                            Logger.Current.Write(LogInfoLevel.Info, "Downloading game update...");
                            _currentDownloader = new GameDownloader(Game.Current, _gameUpdate, gameUpdateFile, _gameUpdateHash, GetUpdateCredentials);
                            _currentTask       = _currentDownloader;
                            View.Invoke(() =>
                            {
                                View.Details     = "Downloading " + Game.Current.Name + " update...";
                                View.AllowCancel = true;
                            });
                        }
                        var result = _currentDownloader.Start();

                        lock (_lock)
                        {
                            _currentDownloader = null;
                            View.Invoke(() => View.AllowCancel = false);
                        }

                        if (result == LongRunningTaskResult.Cancelled)
                        {
                            _workerThread = null;
                            View.Invoke(CloseView);
                            return;
                        }
                        else if (result == LongRunningTaskResult.Error)
                        {
                            ShowError("Download failed", "Failed to download " + Game.Current.Name + " update");
                            _workerThread = null;
                            View.Invoke(CloseView);
                            return;
                        }
                        else
                        {
                            using (var gameInstall = new GameInstall(gameUpdateFile))
                            {
                                lock (_lock)
                                {
                                    Logger.Current.Write(LogInfoLevel.Info, "Installing " + Game.Current.Name + " update...");
                                    //success, now try to apply the downloaded update
                                    View.Invoke(() => View.Details = "Installing " + Game.Current.Name + " update...");
                                    _currentTask = new GameUpdater(gameInstall);
                                }
                                result = _currentTask.Start();

                                if (result == LongRunningTaskResult.Error)
                                {
                                    ShowError("Install failed", "Failed to install " + Game.Current.Name + " update");
                                }
                            }

                            //now if we're auto installing on update, update the registry/desktop icons etc..
                            if (Config.Current.AutoRegisterOnUpdate)
                            {
                                lock (_lock)
                                {
                                    Logger.Current.Write(LogInfoLevel.Info, "Registering game update...");
                                    _currentTask = new GameRegistrar(true, Game.Current);
                                }
                                result = _currentTask.Start();
                                if (result == LongRunningTaskResult.Error)
                                {
                                    ShowError("Registration failed", "Failed to register " + Game.Current.Name + " update");
                                }
                            }
                        }
                    }
                    finally
                    {
                        var file = FileSystem.Current.GetFile(gameUpdateFile);
                        if (file.Exists)
                        {
                            file.DeleteWithTimeout();
                        }
                    }
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                View.Invoke(() => Program.ShowUnhandledError(ex));
            }

            _workerThread = null;
            View.Invoke(CloseView);
        }