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 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); }