Example #1
0
        // For some reason reiniting is flaky :(
        public IEnumerator <object> InitGateways()
        {
            DestroyEndpoints();
            Endpoints.Clear();

            EndpointSettings[] endpoints = null;
            using (var q = Database.BuildQuery("SELECT * FROM jabber.endpoints"))
                yield return(q.ExecuteArray <EndpointSettings>().Bind(() => endpoints));

            foreach (var settings in endpoints)
            {
                Endpoints[settings.Name] = null;
            }

            if (endpoints.Length == 0)
            {
                yield break;
            }

            using (var lw = new LoadingWindow()) {
                lw.SetStatus("Connecting", null);
                lw.Text = "Jabber Gateway";
                lw.Show();

                float?current  = null;
                float stepSize = (1.0f / endpoints.Length);
                var   sleep    = new Sleep(0.25f);

                foreach (var settings in endpoints)
                {
                    lw.SetStatus(String.Format("Connecting endpoint {0}", settings.Name), current);
                    Console.Write("Initializing endpoint '{0}'... ", settings.Name);
                    var f = Endpoint.Connect(
                        this, settings,
                        (s) => lw.SetProgress(current + (s * stepSize))
                        );
                    yield return(f);

                    if (f.Error != null)
                    {
                        Console.WriteLine("failed: {0}", f.Error);
                        Scheduler.OnTaskError(f.Error);
                    }
                    else
                    {
                        Console.WriteLine("initialized.");
                    }

                    current = current.GetValueOrDefault(0.0f) + stepSize;
                    lw.SetProgress(current);

                    yield return(sleep);
                }

                lw.SetStatus("Ready", 1.0f);
                lw.Close();
            }
        }
Example #2
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            this.Dispatcher.UnhandledException += DispatcherOnUnhandledException;
            var loadingWindow = new LoadingWindow();

            loadingWindow.Show(null, MiscStrings.CheckingConfiguration, MiscStrings.Initialising);
            var initResult = await BootStrap.CheckConfigurationAndInit();

            _container = initResult.container;
            if (!initResult.ConfigResult.Success)
            {
                MessageBox.Show(string.Join(Environment.NewLine, initResult.ConfigResult.Errors),
                                MiscStrings.LoadErrorCaption);
                Shutdown();
                return;
            }
            loadingWindow.SetStatus(MiscStrings.CheckingForNewVersion);
            var release = await _container.GetInstance <IVersionChecker>().GetLatestVersion();

            if (release.NewVersion)
            {
                MessageBox.Show(release.Release.ChangeLog, "New version " + release.Release.TagName + " is available!");
            }
            loadingWindow.Hide();
            _container.Configure(c => c.For <ILoadingWindow>().Use(loadingWindow).Singleton());
            var windowProvider = _container.GetInstance <IWindowProvider>();

            windowProvider.CreateWindow <IDeployment>().Show();
        }
Example #3
0
        /// <summary>
        ///     Keeps the loading window updated while the game is loading.
        /// </summary>
        protected void LoadingWindowThread()
        {
            // Create a loading window.
            LoadingWindow loadingWindow = new LoadingWindow();

            loadingWindow.Text = "Loading " + _gameTitle;
            loadingWindow.SetStatus("Loading " + _gameTitle + "...");
            loadingWindow.Show();

            while (_loading == true)
            {
                Application.DoEvents();
                Thread.Sleep(50);
            }

            loadingWindow.Close();
        }
Example #4
0
        /// <summary>
        ///     Keeps the loading window updated while the game is loading.
        /// </summary>
        protected void LoadingWindowThread()
        {
            // Create a loading window.
            LoadingWindow loadingWindow = new LoadingWindow();
            loadingWindow.Text = "Loading " + _gameTitle;
            loadingWindow.SetStatus("Loading "+_gameTitle+"...");
            loadingWindow.Show();

            while (_loading == true)
            {
                Application.DoEvents();
                Thread.Sleep(50);
            }

            loadingWindow.Close();
        }