Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }