Beispiel #1
0
        public void LoadSettings()
        {
            PreferencesG.LoadFromProperties();
            this.Top                = Properties.Settings.Default.Top;
            this.Left               = Properties.Settings.Default.Left;
            this.Height             = Properties.Settings.Default.Height;
            this.Width              = Properties.Settings.Default.Width;
            showLineThing.IsChecked = Properties.Settings.Default.allowCaretLineOutline;
            switch (Properties.Settings.Default.Theme)
            {
            case 1: SetTheme(ThemeTypes.Light); break;

            case 2: SetTheme(ThemeTypes.Dark); break;

            case 3: SetTheme(ThemeTypes.ColourfulLight); break;

            case 4: SetTheme(ThemeTypes.ColourfulDark); break;
            }
        }
Beispiel #2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (ViewModel.CheckHasMadeChanges())
            {
                MessageBoxResult mbr = MessageBox.Show(
                    "You have unsaved work. Do you want to save it/them?",
                    "Unsaved Work",
                    MessageBoxButton.YesNoCancel,
                    MessageBoxImage.Information);

                if (mbr == MessageBoxResult.Yes)
                {
                    ViewModel.SaveAllNotepadItems();
                }
                if (mbr == MessageBoxResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            if (!IsDuplicatedWindow)
            {
                try
                {
                    PreferencesG.SaveToProperties();
                    if (WindowState == WindowState.Maximized)
                    {
                        // Use the RestoreBounds as the current values will be 0, 0 and the size of the screen
                        Properties.Settings.Default.Top    = RestoreBounds.Top;
                        Properties.Settings.Default.Left   = RestoreBounds.Left;
                        Properties.Settings.Default.Height = RestoreBounds.Height;
                        Properties.Settings.Default.Width  = RestoreBounds.Width;
                    }
                    else
                    {
                        Properties.Settings.Default.Top    = this.Top;
                        Properties.Settings.Default.Left   = this.Left;
                        Properties.Settings.Default.Height = this.Height;
                        Properties.Settings.Default.Width  = this.Width;
                    }
                    switch (ThemesController.CurrentTheme)
                    {
                    case ThemeTypes.Light: Properties.Settings.Default.Theme = 1; break;

                    case ThemeTypes.Dark: Properties.Settings.Default.Theme = 2; break;

                    case ThemeTypes.ColourfulLight: Properties.Settings.Default.Theme = 3; break;

                    case ThemeTypes.ColourfulDark: Properties.Settings.Default.Theme = 4; break;
                    }
                    if (!this.ViewModel.CheckNotepadNull())
                    {
                        if (ViewModel.Notepad.DocumentFormat != null)
                        {
                            Properties.Settings.Default.DefaultFont     = this.ViewModel.Notepad.DocumentFormat.Family.ToString();
                            Properties.Settings.Default.DefaultFontSize = this.ViewModel.Notepad.DocumentFormat.Size;
                        }
                    }
                    Properties.Settings.Default.allowCaretLineOutline = showLineThing.IsChecked ?? true;
                    Properties.Settings.Default.Save();
                }
                catch { }
                ViewModel?.ShutdownInformationHook();
            }
        }