private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //First save general Editor Appearance Settings
                Properties.Settings.Default.EditorFontFace   = (FontFamily)this.cboFont.SelectedItem;
                Properties.Settings.Default.EditorFontSize   = this.fontSizeSlider.Value;
                Properties.Settings.Default.EditorForeground = this.GetColour(Properties.Settings.Default.EditorForeground, this.cboEditorForeground);
                Properties.Settings.Default.EditorBackground = this.GetColour(Properties.Settings.Default.EditorBackground, this.cboEditorBackground);
                Properties.Settings.Default.Save();

                //Then save Syntax Highlighting Settings
                Properties.Settings.Default.SyntaxColourXmlAttrName     = this.GetColour(Properties.Settings.Default.SyntaxColourXmlAttrName, this.cboColourXmlAttrName);
                Properties.Settings.Default.SyntaxColourXmlAttrValue    = this.GetColour(Properties.Settings.Default.SyntaxColourXmlAttrValue, this.cboColourXmlAttrValue);
                Properties.Settings.Default.SyntaxColourXmlBrokenEntity = this.GetColour(Properties.Settings.Default.SyntaxColourXmlBrokenEntity, this.cboColourXmlBrokenEntities);
                Properties.Settings.Default.SyntaxColourXmlCData        = this.GetColour(Properties.Settings.Default.SyntaxColourXmlCData, this.cboColourXmlCData);
                Properties.Settings.Default.SyntaxColourXmlComments     = this.GetColour(Properties.Settings.Default.SyntaxColourXmlComments, this.cboColourXmlComments);
                Properties.Settings.Default.SyntaxColourXmlDocType      = this.GetColour(Properties.Settings.Default.SyntaxColourXmlDocType, this.cboColourXmlDocType);
                Properties.Settings.Default.SyntaxColourXmlEntity       = this.GetColour(Properties.Settings.Default.SyntaxColourXmlEntity, this.cboColourXmlEntities);
                Properties.Settings.Default.SyntaxColourXmlTag          = this.GetColour(Properties.Settings.Default.SyntaxColourXmlTag, this.cboColourXmlTags);

                Properties.Settings.Default.SyntaxColourBNode       = this.GetColour(Properties.Settings.Default.SyntaxColourBNode, this.cboColourBNode);
                Properties.Settings.Default.SyntaxColourComment     = this.GetColour(Properties.Settings.Default.SyntaxColourComment, this.cboColourComments);
                Properties.Settings.Default.SyntaxColourEscapedChar = this.GetColour(Properties.Settings.Default.SyntaxColourEscapedChar, this.cboColourEscapedChars);
                Properties.Settings.Default.SyntaxColourKeyword     = this.GetColour(Properties.Settings.Default.SyntaxColourKeyword, this.cboColourKeywords);
                Properties.Settings.Default.SyntaxColourLangSpec    = this.GetColour(Properties.Settings.Default.SyntaxColourLangSpec, this.cboColourLangSpec);
                Properties.Settings.Default.SyntaxColourNumbers     = this.GetColour(Properties.Settings.Default.SyntaxColourNumbers, this.cboColourNumbers);
                Properties.Settings.Default.SyntaxColourPunctuation = this.GetColour(Properties.Settings.Default.SyntaxColourPunctuation, this.cboColourPunctuation);
                Properties.Settings.Default.SyntaxColourQName       = this.GetColour(Properties.Settings.Default.SyntaxColourQName, this.cboColourQNames);
                Properties.Settings.Default.SyntaxColourString      = this.GetColour(Properties.Settings.Default.SyntaxColourString, this.cboColourStrings);
                Properties.Settings.Default.SyntaxColourURI         = this.GetColour(Properties.Settings.Default.SyntaxColourURI, this.cboColourURIs);
                Properties.Settings.Default.SyntaxColourVariables   = this.GetColour(Properties.Settings.Default.SyntaxColourVariables, this.cboColourVariable);

                //Then save the Error Highlighting Settings
                Properties.Settings.Default.ErrorHighlightBackground = this.GetColour(Properties.Settings.Default.ErrorHighlightBackground, this.cboColourErrorBackground);
                Properties.Settings.Default.ErrorHighlightDecoration = this.GetDecoration(this.cboErrorDecoration);
                Properties.Settings.Default.ErrorHighlightFontFamily = (FontFamily)this.cboErrorFont.SelectedItem;
                Properties.Settings.Default.ErrorHighlightForeground = this.GetColour(Properties.Settings.Default.ErrorHighlightForeground, this.cboColourErrorFont);

                //Finally save the updated settings
                Properties.Settings.Default.Save();

                //Force the Syntax Manager to update colours appropriately
                AppearanceSettings.UpdateHighlightingColours();

                this.DialogResult = true;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred trying to save your settings: " + ex.Message, "Save Settings Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
        private void mnuCustomiseAppearance_Click(object sender, RoutedEventArgs e)
        {
            AppearanceSettings settings = new AppearanceSettings(this._editor.DocumentManager.VisualOptions);
            settings.Owner = this;
            if (settings.ShowDialog() == true)
            {
                if (Properties.Settings.Default.EditorFontFace != null)
                {
                    this._editor.DocumentManager.VisualOptions.FontFace = Properties.Settings.Default.EditorFontFace;
                }
                this._editor.DocumentManager.VisualOptions.FontSize = Math.Round(Properties.Settings.Default.EditorFontSize, 0);
                this._editor.DocumentManager.VisualOptions.Foreground = Properties.Settings.Default.EditorForeground;
                this._editor.DocumentManager.VisualOptions.Background = Properties.Settings.Default.EditorBackground;

                this._editor.DocumentManager.VisualOptions.ErrorBackground = Properties.Settings.Default.ErrorHighlightBackground;
                this._editor.DocumentManager.VisualOptions.ErrorDecoration = Properties.Settings.Default.ErrorHighlightDecoration;
                if (Properties.Settings.Default.ErrorHighlightFontFamily != null)
                {
                    this._editor.DocumentManager.VisualOptions.ErrorFontFace = Properties.Settings.Default.ErrorHighlightFontFamily;
                }
                this._editor.DocumentManager.VisualOptions.ErrorForeground = Properties.Settings.Default.ErrorHighlightForeground;
            }
        }