Esempio n. 1
0
        private void CreateColorButton_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new ColorEditor("New Color", Colors.White)
            {
                Owner = this
            };

            if ((bool)dlg.ShowDialog())
            {
                if (!string.IsNullOrEmpty(dlg.ColorName))
                {
                    if (ConfigManager.ColorReader.Contents.ColorDictionary.ContainsKey(dlg.ColorName))
                    {
                        bool confirm = MessageBox.Show($"The color {dlg.ColorName} is already defined. Do you want to replace it?",
                                                       $"Replace {dlg.ColorName}",
                                                       MessageBoxButton.YesNo) == MessageBoxResult.Yes;
                        if (confirm)
                        {
                            ConfigManager.ColorReader.Contents.ColorDictionary[dlg.ColorName] = dlg.Color;
                        }
                    }
                    else
                    {
                        ConfigManager.ColorReader.Contents.ColorDictionary.Add(dlg.ColorName, dlg.Color);
                    }
                    SelectedColorName = dlg.ColorName;
                    SelectedColor     = dlg.Color;
                }
            }
            Reset();
        }
Esempio n. 2
0
 private void EditColorButton_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(SelectedColorName))
     {
         var dlg = new ColorEditor(SelectedColorName, SelectedColor)
         {
             Owner = this
         };
         if ((bool)dlg.ShowDialog() && !string.IsNullOrEmpty(dlg.ColorName))
         {
             if (ConfigManager.ColorReader.Contents.ColorDictionary.ContainsKey(dlg.ColorName))
             {
                 MessageBox.Show($"{dlg.ColorName} already exists in your color palette.");
             }
             else
             {
                 ConfigManager.ColorReader.Contents.ColorDictionary.Remove(SelectedColorName);
                 ConfigManager.ColorReader.Contents.ColorDictionary.Add(dlg.ColorName, dlg.Color);
                 SelectedColorName = dlg.ColorName;
                 SelectedColor     = dlg.Color;
             }
         }
     }
     Reset();
 }