Example #1
0
        private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (ServerCheckThread != null)
            {
                ServerCheckThread.Abort(); //a join would not work, so we have to be..forcefully...
            }
            List <string> lastOpenFiles = new List <string>();

            EditorElement[] editors     = GetAllEditorElements();
            bool?           SaveUnsaved = null;

            if (editors != null)
            {
                for (int i = 0; i < editors.Length; ++i)
                {
                    if (File.Exists(editors[i].FullFilePath))
                    {
                        lastOpenFiles.Add(editors[i].FullFilePath);
                        if (editors[i].NeedsSave)
                        {
                            if (SaveUnsaved == null)
                            {
                                var result = MessageBox.Show(this, "Save all unsaved files?", "Saving", MessageBoxButton.YesNo, MessageBoxImage.Question);
                                if (result == MessageBoxResult.Yes)
                                {
                                    SaveUnsaved = true;
                                }
                                else
                                {
                                    SaveUnsaved = false;
                                }
                            }
                            if (SaveUnsaved.Value)
                            {
                                editors[i].Close(true, true);
                            }
                            else
                            {
                                editors[i].Close(false, false);
                            }
                        }
                        else
                        {
                            editors[i].Close(false, false);
                        }
                    }
                }
            }
            Program.OptionsObject.LastOpenFiles = lastOpenFiles.ToArray();
#if !DEBUG
            if (Program.UpdateStatus.IsAvailable)
            {
                UpdateWindow updateWin = new UpdateWindow(Program.UpdateStatus)
                {
                    Owner = this
                };
                updateWin.ShowDialog();
            }
#endif
        }
        private void MetroWindow_Closing(object sender, CancelEventArgs e)
        {
            ServerCheckThread?.Abort(); //a join would not work, so we have to be..forcefully...
            var  lastOpenFiles = new List <string>();
            var  editors       = GetAllEditorElements();
            bool?SaveUnsaved   = null;

            if (editors != null)
            {
                foreach (var editor in editors)
                {
                    if (File.Exists(editor.FullFilePath))
                    {
                        lastOpenFiles.Add(editor.FullFilePath);
                        if (editor.NeedsSave)
                        {
                            if (SaveUnsaved == null)
                            {
                                var result = MessageBox.Show(this, Program.Translations.GetLanguage("SavingUFiles"),
                                                             Program.Translations.GetLanguage("Saving"), MessageBoxButton.YesNo,
                                                             MessageBoxImage.Question);
                                SaveUnsaved = result == MessageBoxResult.Yes;
                            }

                            if (SaveUnsaved.Value)
                            {
                                editor.Close(true);
                            }
                            else
                            {
                                editor.Close(false, false);
                            }
                        }
                        else
                        {
                            editor.Close(false, false);
                        }
                    }
                }
            }

            Program.OptionsObject.LastOpenFiles = lastOpenFiles.ToArray();

            Program.discordClient.Dispose();
#if !DEBUG
            if (Program.UpdateStatus.IsAvailable)
            {
                var updateWin = new UpdateWindow(Program.UpdateStatus)
                {
                    Owner = this
                };
                updateWin.ShowDialog();
            }
#endif
        }
Example #3
0
        private void MetroWindow_Closing(object sender, CancelEventArgs e)
        {
            backgroundParserThread?.Abort();
            parseDistributorTimer?.Stop();
            ServerCheckThread?.Abort(); //a join would not work, so we have to be..forcefully...

            List <string> lastOpenFiles = new List <string>();

            EditorElement[] editors     = GetAllEditorElements();
            bool?           saveUnsaved = null;

            if (editors != null)
            {
                foreach (var editor in editors)
                {
                    if (File.Exists(editor.FullFilePath))
                    {
                        lastOpenFiles.Add(editor.FullFilePath);
                        if (editor.NeedsSave)
                        {
                            if (saveUnsaved == null)
                            {
                                var result = MessageBox.Show(this, Properties.Resources.SavingUFiles, Properties.Resources.Saving, MessageBoxButton.YesNo, MessageBoxImage.Question);
                                saveUnsaved = (result == MessageBoxResult.Yes);
                            }

                            editor.Close(saveUnsaved.Value, saveUnsaved.Value);
                        }
                        else
                        {
                            editor.Close(false, false);
                        }
                    }
                }
            }
            Program.Options.LastOpenFiles = lastOpenFiles.ToArray();
        }