Esempio n. 1
0
        public static void Exit()
        {
            LogManager.Shutdown();
            Application.Current.Dispatcher.Invoke(new Action(() => {
                Application.Current.MainWindow = null;
                if (LobbyClient != null)
                {
                    LobbyClient.Stop();
                }

                try
                {
                    if (WindowManager.DebugWindow != null)
                    {
                        if (WindowManager.DebugWindow.IsLoaded)
                        {
                            WindowManager.DebugWindow.Close();
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                }
                if (WindowManager.PlayWindow != null)
                {
                    if (WindowManager.PlayWindow.IsLoaded)
                    {
                        WindowManager.PlayWindow.Close();
                    }
                }
                //Apparently this can be null sometimes?
                if (Application.Current != null)
                {
                    Application.Current.Shutdown(0);
                }
            }));
        }
Esempio n. 2
0
        public static void Exit()
        {
            UpdateManager.Instance.Stop();
            LogManager.Shutdown();
            Application.Current.Dispatcher.Invoke(new Action(() => {
                Application.Current.MainWindow = null;
                if (LobbyClient != null)
                {
                    LobbyClient.Stop();
                }

                try
                {
                    if (WindowManager.DebugWindow != null)
                    {
                        if (WindowManager.DebugWindow.IsLoaded)
                        {
                            WindowManager.DebugWindow.Close();
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                }
                try
                {
                    foreach (var w in WindowManager.ChatWindows.ToArray())
                    {
                        try
                        {
                            if (w.IsLoaded)
                            {
                                w.CloseDown();
                            }
                            w.Dispose();
                        }
                        catch (Exception e)
                        {
                            Log.Warn("Close chat window error", e);
                        }
                    }
                    WindowManager.ChatWindows = new ConcurrentBag <ChatWindow>();
                }
                catch (Exception e)
                {
                    Log.Warn("Close chat window enumerate error", e);
                }
                if (WindowManager.PlayWindow != null)
                {
                    if (WindowManager.PlayWindow.IsLoaded)
                    {
                        WindowManager.PlayWindow.Close();
                    }
                }
                //Apparently this can be null sometimes?
                if (Application.Current != null)
                {
                    Application.Current.Shutdown(0);
                }
            }));
        }
Esempio n. 3
0
        public static void Exit()
        {
            Application.Current.MainWindow = null;
            if (LobbyClient != null)
            {
                LobbyClient.Stop();
            }

            SaveLocation();
            try
            {
                if (DebugWindow != null)
                {
                    if (DebugWindow.IsLoaded)
                    {
                        DebugWindow.Close();
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
            }
            if (LauncherWindow != null)
            {
                if (LauncherWindow.IsLoaded)
                {
                    LauncherWindow.Close();
                }
            }
            if (MainWindow != null)
            {
                if (MainWindow.IsLoaded)
                {
                    MainWindow.Close();
                }
            }
            if (PlayWindow != null)
            {
                if (PlayWindow.IsLoaded)
                {
                    PlayWindow.Close();
                }
            }
            try
            {
                foreach (ChatWindow cw in ChatWindows.Where(cw => cw.IsLoaded))
                {
                    cw.CloseChatWindow();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
            //Apparently this can be null sometimes?
            if (Application.Current != null)
            {
                Application.Current.Shutdown(0);
            }
        }