private void UpdateColorButtons(ClassicScriptColorScheme scheme) { colorButton_Sections.BackColor = ColorTranslator.FromHtml(scheme.Sections.HtmlColor); colorButton_Sections.Tag = scheme.Sections; colorButton_Values.BackColor = ColorTranslator.FromHtml(scheme.Values.HtmlColor); colorButton_Values.Tag = scheme.Values; colorButton_References.BackColor = ColorTranslator.FromHtml(scheme.References.HtmlColor); colorButton_References.Tag = scheme.References; colorButton_StandardCommands.BackColor = ColorTranslator.FromHtml(scheme.StandardCommands.HtmlColor); colorButton_StandardCommands.Tag = scheme.StandardCommands; colorButton_NewCommands.BackColor = ColorTranslator.FromHtml(scheme.NewCommands.HtmlColor); colorButton_NewCommands.Tag = scheme.NewCommands; colorButton_Comments.BackColor = ColorTranslator.FromHtml(scheme.Comments.HtmlColor); colorButton_Comments.Tag = scheme.Comments; UpdateColorButtonStyleText(colorButton_Sections); UpdateColorButtonStyleText(colorButton_Values); UpdateColorButtonStyleText(colorButton_References); UpdateColorButtonStyleText(colorButton_StandardCommands); UpdateColorButtonStyleText(colorButton_NewCommands); UpdateColorButtonStyleText(colorButton_Comments); colorButton_Background.BackColor = ColorTranslator.FromHtml(scheme.Background); colorButton_Foreground.BackColor = ColorTranslator.FromHtml(scheme.Foreground); }
private void button_SaveScheme_Click(object sender, EventArgs e) { using (FormSaveSchemeAs form = new FormSaveSchemeAs(ColorSchemeType.ClassicScript)) if (form.ShowDialog(this) == DialogResult.OK) { ClassicScriptColorScheme currentScheme = new ClassicScriptColorScheme { Sections = (HighlightingObject)colorButton_Sections.Tag, Values = (HighlightingObject)colorButton_Values.Tag, References = (HighlightingObject)colorButton_References.Tag, StandardCommands = (HighlightingObject)colorButton_StandardCommands.Tag, NewCommands = (HighlightingObject)colorButton_NewCommands.Tag, Comments = (HighlightingObject)colorButton_Comments.Tag, Background = ColorTranslator.ToHtml(colorButton_Background.BackColor), Foreground = ColorTranslator.ToHtml(colorButton_Foreground.BackColor) }; XmlHandling.SaveXmlFile(form.SchemeFilePath, currentScheme); comboBox_ColorSchemes.Items.Add(Path.GetFileNameWithoutExtension(form.SchemeFilePath)); comboBox_ColorSchemes.SelectedItem = Path.GetFileNameWithoutExtension(form.SchemeFilePath); comboBox_ColorSchemes.Items.Remove("~UNTITLED"); } }
private void comboBox_ColorSchemes_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_ColorSchemes.Items.Count == 1) { button_DeleteScheme.Enabled = false; // Disallow deleting the last available scheme } ToggleSaveSchemeButton(); string fullSchemePath = Path.Combine(DefaultPaths.GetClassicScriptColorConfigsPath(), comboBox_ColorSchemes.SelectedItem.ToString() + ".cssch"); ClassicScriptColorScheme selectedScheme = XmlHandling.ReadXmlFile <ClassicScriptColorScheme>(fullSchemePath); UpdateColorButtons(selectedScheme); UpdatePreviewColors(selectedScheme); }
private void UpdatePreview() { ClassicScriptColorScheme currentScheme = new ClassicScriptColorScheme { Sections = (HighlightingObject)colorButton_Sections.Tag, Values = (HighlightingObject)colorButton_Values.Tag, References = (HighlightingObject)colorButton_References.Tag, StandardCommands = (HighlightingObject)colorButton_StandardCommands.Tag, NewCommands = (HighlightingObject)colorButton_NewCommands.Tag, Comments = (HighlightingObject)colorButton_Comments.Tag, Background = ColorTranslator.ToHtml(colorButton_Background.BackColor), Foreground = ColorTranslator.ToHtml(colorButton_Foreground.BackColor) }; bool itemFound = false; foreach (string item in comboBox_ColorSchemes.Items) { if (item == "~UNTITLED") { continue; } ClassicScriptColorScheme itemScheme = XmlHandling.ReadXmlFile <ClassicScriptColorScheme>(Path.Combine(DefaultPaths.GetClassicScriptColorConfigsPath(), item + ".cssch")); if (currentScheme == itemScheme) { comboBox_ColorSchemes.SelectedItem = item; itemFound = true; break; } } if (!itemFound) { if (!comboBox_ColorSchemes.Items.Contains("~UNTITLED")) { comboBox_ColorSchemes.Items.Add("~UNTITLED"); } XmlHandling.SaveXmlFile(Path.Combine(DefaultPaths.GetClassicScriptColorConfigsPath(), "~UNTITLED.cssch"), currentScheme); comboBox_ColorSchemes.SelectedItem = "~UNTITLED"; } UpdatePreviewColors(currentScheme); }
private void UpdatePreviewColors(ClassicScriptColorScheme scheme) { editorPreview.Background = new System.Windows.Media.SolidColorBrush ( (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString ( scheme.Background ) ); editorPreview.Foreground = new System.Windows.Media.SolidColorBrush ( (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString ( scheme.Foreground ) ); editorPreview.SyntaxHighlighting = new ClassicScriptSyntaxHighlighting(scheme); }
public ClassicScriptSyntaxHighlighting(ClassicScriptColorScheme scheme) { _scheme = scheme; }