コード例 #1
0
        private void editColorsButton_Click(object sender, EventArgs e)
        {
            ColorPickerPopup window = new ColorPickerPopup();

            window.Center();
            window.SelectedColor = ((ValueTuple <Color, string>)_colorsListBox.SelectedItem).Item1;
            window.Closed       += (s, e) =>
            {
                if (window.DialogResult)
                {
                    var selectedColor = window.SelectedColor;
                    var selectedItem  = (ValueTuple <Color, string>)_colorsListBox.SelectedItem;
                    var newItem       = (selectedColor, selectedItem.Item2);

                    if (!Container.EditingColors.TryToColorName(selectedItem.Item1, out var colorEnumValue))
                    {
                        throw new Exception("How did this happen? Color not in editing colors collection");
                    }

                    _colorsListBox.Items.Insert(_colorsListBox.SelectedIndex, newItem);
                    _colorsListBox.Items.Remove(selectedItem);
                    _colorsListBox.SelectedItem = newItem;

                    Container.EditingColors.SetColorByName(colorEnumValue, selectedColor);

                    DrawThemeParts();
                }
            };
            window.Show(true);
        }
コード例 #2
0
        private void themePartSettingColorSet_Click(object sender, EventArgs e)
        {
            AdjustableColor setting = _themeParts[_themePartSelectedIndex];

            if (setting.IsCustomColor)
            {
                ColorPickerPopup window = new ColorPickerPopup();
                window.Center();
                window.SelectedColor = _themeParts[_themePartSelectedIndex].BaseColor;
                window.Closed       += (s, e) =>
                {
                    if (window.DialogResult)
                    {
                        _themeParts[_themePartSelectedIndex].SetColor(window.SelectedColor, Container.EditingColors, Colors.Brightness.Normal);
                        DrawThemeParts();
                    }
                };
                window.Show(true);
            }
            else
            {
                SelectPaletteColor window = new SelectPaletteColor(setting.UIColor);
                window.Center();
                window.Closed += (s, e) =>
                {
                    if (window.DialogResult)
                    {
                        _themeParts[_themePartSelectedIndex].SetUIColor(window.SelectedColor, Container.EditingColors, Colors.Brightness.Normal);
                        DrawThemeParts();
                    }
                };
                window.Show(true);
            }
        }