Ejemplo n.º 1
0
        void MainWindow_SourceInitialized(object sender, EventArgs e)
        {
            var config = ClientSavedConfig.Load();

            m_isFullScreen = config.IsFullScreen;
            if (m_isFullScreen)
            {
                m_storedWindowState = System.Windows.WindowState.Normal;
                this.WindowStyle    = System.Windows.WindowStyle.None;
            }

            if (config.WindowPlacement != null)
            {
                Win32.Helpers.LoadWindowPlacement(this, config.WindowPlacement);
            }
        }
Ejemplo n.º 2
0
        async void MainWindow_Closing(object sender, CancelEventArgs e)
        {
            switch (m_closeStatus)
            {
            case CloseStatus.None:
                m_closeStatus = CloseStatus.ShuttingDown;

                e.Cancel = true;

                var config = ClientSavedConfig.Load();
                config.WindowPlacement = Win32.Helpers.SaveWindowPlacement(this);
                config.IsFullScreen    = m_isFullScreen;
                config.Save();

                var dlg = OpenLogOnDialog();

                try
                {
                    var prog = new Progress <string>(str => dlg.AppendText(str));
                    await GameData.Data.ConnectManager.DisconnectAsync(prog);

                    await GameData.Data.ConnectManager.StopServerAsync(prog);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.ToString(), "Error closing down");
                }

                dlg.Close();

                m_closeStatus = CloseStatus.Ready;
                await this.Dispatcher.InvokeAsync(Close);

                break;

            case CloseStatus.ShuttingDown:
                e.Cancel = true;
                break;

            case CloseStatus.Ready:
                break;
            }
        }