/src/ColorsForm.cs
C# | 1986 lines | 1579 code | 246 blank | 161 comment | 127 complexity | 5d339fe38fe66f6437f439a9a23d2443 MD5 | raw file
- /////////////////////////////////////////////////////////////////////////////////
- // Paint.NET //
- // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. //
- // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. //
- // See src/Resources/Files/License.txt for full licensing and attribution //
- // details. //
- // . //
- /////////////////////////////////////////////////////////////////////////////////
-
- using PaintDotNet.Base;
- using PaintDotNet.SystemLayer;
- using System;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Windows.Forms;
-
- namespace PaintDotNet
- {
- // TODO: rewrite this ... the code is out of control here as it has grown organically,
- // and it's impossible to maintain. post-3.0
- internal class ColorsForm
- : FloatingToolForm
- {
- // We want some buttons that don't have a gradient background or fancy border
- private sealed class OurToolStripRenderer
- : ToolStripProfessionalRenderer
- {
- protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
- {
- if (e.ToolStrip is ToolStripDropDown)
- {
- base.OnRenderToolStripBackground(e);
- }
- else
- {
- using (var backBrush = new SolidBrush(e.BackColor))
- {
- e.Graphics.FillRectangle(backBrush, e.AffectedBounds);
- }
- }
- }
-
- protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
- {
- // Do not render a border.
- }
- }
-
- private Label _redLabel;
- private Label _blueLabel;
- private Label _greenLabel;
- private Label _hueLabel;
-
- private NumericUpDown _redUpDown;
- private NumericUpDown _greenUpDown;
- private NumericUpDown _blueUpDown;
- private NumericUpDown _hueUpDown;
- private NumericUpDown _valueUpDown;
- private NumericUpDown _saturationUpDown;
-
- private Container _components;
- private Label _saturationLabel;
- private Label _valueLabel;
- private ComboBox _whichUserColorBox;
- private ColorGradientControl _valueGradientControl;
- private NumericUpDown _alphaUpDown;
- private ColorGradientControl _alphaGradientControl;
- private ColorWheel _colorWheel;
-
- private int _ignoreChangedEvents;
- private ColorBgra _lastPrimaryColor;
- private Button _moreLessButton;
- private ColorBgra _lastSecondaryColor;
-
- private int _suspendSetWhichUserColor;
- private readonly string _lessText;
- private readonly string _moreText;
- private readonly Size _moreSize;
- private readonly Size _lessSize;
- private Control _lessModeButtonSentinel;
- private Control _moreModeButtonSentinel;
- private Control _lessModeHeaderSentinel;
- private Control _moreModeHeaderSentinel;
- private bool _inMoreState = true;
- private Label _hexLabel;
- private TextBox _hexBox;
- private uint _ignore;
- private HeaderLabel _rgbHeader;
- private HeaderLabel _hsvHeader;
- private HeaderLabel _swatchHeader;
- private SwatchControl _swatchControl;
- private ColorDisplayWidget _colorDisplayWidget;
- private ToolStripEx _toolStrip;
- private ToolStripButton _colorAddButton;
- private HeaderLabel _alphaHeader;
-
- private readonly Image _colorAddOverlay;
- private ToolStripSplitButton _colorPalettesButton;
- private Bitmap _colorAddIcon;
- private ColorGradientControl _hueGradientControl;
- private ColorGradientControl _saturationGradientControl;
- private ColorGradientControl _redGradientControl;
- private ColorGradientControl _greenGradientControl;
- private ColorGradientControl _blueGradientControl;
-
- private PaletteCollection _paletteCollection;
-
- public PaletteCollection PaletteCollection
- {
- get
- {
- return _paletteCollection;
- }
-
- set
- {
- _paletteCollection = value;
- }
- }
-
- private bool IgnoreChangedEvents
- {
- get
- {
- return _ignoreChangedEvents != 0;
- }
- }
-
- private class WhichUserColorWrapper
- {
- private readonly WhichUserColor _whichUserColor;
-
- public WhichUserColor WhichUserColor
- {
- get
- {
- return _whichUserColor;
- }
- }
-
- public override int GetHashCode()
- {
- return _whichUserColor.GetHashCode();
- }
-
- public override bool Equals(object obj)
- {
- var rhs = obj as WhichUserColorWrapper;
-
- if (rhs == null)
- {
- return false;
- }
-
- return rhs._whichUserColor == _whichUserColor;
- }
-
- public override string ToString()
- {
- return PdnResources.GetString("WhichUserColor." + _whichUserColor);
- }
-
- public WhichUserColorWrapper(WhichUserColor whichUserColor)
- {
- _whichUserColor = whichUserColor;
- }
- }
-
- public void SuspendSetWhichUserColor()
- {
- ++_suspendSetWhichUserColor;
- }
-
- public void ResumeSetWhichUserColor()
- {
- --_suspendSetWhichUserColor;
- }
-
- public WhichUserColor WhichUserColor
- {
- get
- {
- return ((WhichUserColorWrapper)_whichUserColorBox.SelectedItem).WhichUserColor;
- }
-
- set
- {
- if (_suspendSetWhichUserColor <= 0)
- {
- _whichUserColorBox.SelectedItem = new WhichUserColorWrapper(value);
- }
- }
- }
-
- public void ToggleWhichUserColor()
- {
- switch (WhichUserColor)
- {
- case WhichUserColor.Primary:
- WhichUserColor = WhichUserColor.Secondary;
- break;
-
- case WhichUserColor.Secondary:
- WhichUserColor = WhichUserColor.Primary;
- break;
-
- default:
- throw new InvalidEnumArgumentException();
- }
- }
-
- public void SetColorControlsRedraw(bool enabled)
- {
- var controls =
- new Control[]
- {
- _colorWheel,
- _whichUserColorBox,
- _hueGradientControl,
- _saturationGradientControl,
- _valueGradientControl,
- _redGradientControl,
- _greenGradientControl,
- _blueGradientControl,
- _alphaGradientControl,
- _hueUpDown,
- _saturationUpDown,
- _valueUpDown,
- _redUpDown,
- _greenUpDown,
- _blueUpDown,
- _alphaUpDown,
- _toolStrip
- };
-
- foreach (Control control in controls)
- {
- if (enabled)
- {
- UI.ResumeControlPainting(control);
- control.Invalidate(true);
- }
- else
- {
- UI.SuspendControlPainting(control);
- }
- }
- }
-
- public event ColorEventHandler UserPrimaryColorChanged;
- protected virtual void OnUserPrimaryColorChanged(ColorBgra newColor)
- {
- if (UserPrimaryColorChanged != null && _ignore == 0)
- {
- _userPrimaryColor = newColor;
- UserPrimaryColorChanged(this, new ColorEventArgs(newColor));
- _lastPrimaryColor = newColor;
- _colorDisplayWidget.UserPrimaryColor = newColor;
- }
-
- RenderColorAddIcon(newColor);
- }
-
- private ColorBgra _userPrimaryColor;
- public ColorBgra UserPrimaryColor
- {
- get
- {
- return _userPrimaryColor;
- }
-
- set
- {
- if (IgnoreChangedEvents)
- {
- return;
- }
-
- if (_userPrimaryColor == value) return;
- _userPrimaryColor = value;
- OnUserPrimaryColorChanged(value);
-
- if (WhichUserColor != WhichUserColor.Primary)
- {
- WhichUserColor = WhichUserColor.Primary;
- }
-
- _ignore++;
-
- // only do the update on the last one, so partial RGB info isn't parsed.
- Utility.SetNumericUpDownValue(_alphaUpDown, value.A);
- Utility.SetNumericUpDownValue(_redUpDown, value.R);
- Utility.SetNumericUpDownValue(_greenUpDown, value.G);
- SetColorGradientValuesRgb(value.R, value.G, value.B);
- SetColorGradientMinMaxColorsRgb(value.R, value.G, value.B);
- SetColorGradientMinMaxColorsAlpha(value.A);
-
- _ignore--;
- Utility.SetNumericUpDownValue(_blueUpDown, value.B);
- Update();
-
- string hexText = GetHexNumericUpDownValue(value.R, value.G, value.B);
- _hexBox.Text = hexText;
-
- SyncHsvFromRgb(value);
- _colorDisplayWidget.UserPrimaryColor = _userPrimaryColor;
- }
- }
-
- private static string GetHexNumericUpDownValue(int red, int green, int blue)
- {
- int newHexNumber = (red << 16) | (green << 8) | blue;
- string newHexText = Convert.ToString(newHexNumber, 16);
-
- while (newHexText.Length < 6)
- {
- newHexText = "0" + newHexText;
- }
-
- return newHexText.ToUpper();
- }
-
- public event ColorEventHandler UserSecondaryColorChanged;
- protected virtual void OnUserSecondaryColorChanged(ColorBgra newColor)
- {
- if (UserSecondaryColorChanged != null && _ignore == 0)
- {
- _userSecondaryColor = newColor;
- UserSecondaryColorChanged(this, new ColorEventArgs(newColor));
- _lastSecondaryColor = newColor;
- _colorDisplayWidget.UserSecondaryColor = newColor;
- }
-
- RenderColorAddIcon(newColor);
- }
-
- private ColorBgra _userSecondaryColor;
- public ColorBgra UserSecondaryColor
- {
- get
- {
- return _userSecondaryColor;
- }
-
- set
- {
- if (IgnoreChangedEvents)
- {
- return;
- }
-
- if (_userSecondaryColor == value) return;
- _userSecondaryColor = value;
- OnUserSecondaryColorChanged(value);
-
- if (WhichUserColor != WhichUserColor.Secondary)
- {
- WhichUserColor = WhichUserColor.Secondary;
- }
-
- _ignore++;
-
- //only do the update on the last one, so partial RGB info isn't parsed.
- Utility.SetNumericUpDownValue(_alphaUpDown, value.A);
- Utility.SetNumericUpDownValue(_redUpDown, value.R);
- Utility.SetNumericUpDownValue(_greenUpDown, value.G);
-
- SetColorGradientValuesRgb(value.R, value.G, value.B);
- SetColorGradientMinMaxColorsRgb(value.R, value.G, value.B);
- SetColorGradientMinMaxColorsAlpha(value.A);
-
- _ignore--;
- Utility.SetNumericUpDownValue(_blueUpDown, value.B);
- Update();
-
- string hexText = GetHexNumericUpDownValue(value.R, value.G, value.B);
- _hexBox.Text = hexText;
-
- SyncHsvFromRgb(value);
- _colorDisplayWidget.UserSecondaryColor = _userSecondaryColor;
- }
- }
-
- /// <summary>
- /// Convenience function for ColorsForm internals. Checks the value of the
- /// WhichUserColor property and raises either the UserPrimaryColorChanged or
- /// the UserSecondaryColorChanged events.
- /// </summary>
- /// <param name="newColor">The new color to notify clients about.</param>
- private void OnUserColorChanged(ColorBgra newColor)
- {
- switch (WhichUserColor)
- {
- case WhichUserColor.Primary:
- OnUserPrimaryColorChanged(newColor);
- break;
-
- case WhichUserColor.Secondary:
- OnUserSecondaryColorChanged(newColor);
- break;
-
- default:
- throw new InvalidEnumArgumentException("WhichUserColor property");
- }
- }
-
- /// <summary>
- /// Whenever a color is changed via RGB methods, call this and the HSV
- /// counterparts will be sync'd up.
- /// </summary>
- /// <param name="newColor">The RGB color that should be converted to HSV.</param>
- private void SyncHsvFromRgb(ColorBgra newColor)
- {
- if (_ignore != 0) return;
- _ignore++;
- HsvColor hsvColor = HsvColor.FromColor(newColor.ToColor());
-
- Utility.SetNumericUpDownValue(_hueUpDown, hsvColor.Hue);
- Utility.SetNumericUpDownValue(_saturationUpDown, hsvColor.Saturation);
- Utility.SetNumericUpDownValue(_valueUpDown, hsvColor.Value);
-
- SetColorGradientValuesHsv(hsvColor.Hue, hsvColor.Saturation, hsvColor.Value);
- SetColorGradientMinMaxColorsHsv(hsvColor.Hue, hsvColor.Saturation, hsvColor.Value);
-
- _colorWheel.HsvColor = hsvColor;
- _ignore--;
- }
-
- private void SetColorGradientValuesRgb(int r, int g, int b)
- {
- PushIgnoreChangedEvents();
-
- if (_redGradientControl.Value != r)
- {
- _redGradientControl.Value = r;
- }
-
- if (_greenGradientControl.Value != g)
- {
- _greenGradientControl.Value = g;
- }
-
- if (_blueGradientControl.Value != b)
- {
- _blueGradientControl.Value = b;
- }
-
- PopIgnoreChangedEvents();
- }
-
- private void SetColorGradientValuesHsv(int h, int s, int v)
- {
- PushIgnoreChangedEvents();
-
- if (((_hueGradientControl.Value * 360) / 255) != h)
- {
- _hueGradientControl.Value = (255 * h) / 360;
- }
-
- if (((_saturationGradientControl.Value * 100) / 255) != s)
- {
- _saturationGradientControl.Value = (255 * s) / 100;
- }
-
- if (((_valueGradientControl.Value * 100) / 255) != v)
- {
- _valueGradientControl.Value = (255 * v) / 100;
- }
-
- PopIgnoreChangedEvents();
- }
-
- /// <summary>
- /// Whenever a color is changed via HSV methods, call this and the RGB
- /// counterparts will be sync'd up.
- /// </summary>
- /// <param name="newColor">The HSV color that should be converted to RGB.</param>
- private void SyncRgbFromHsv(HsvColor newColor)
- {
- if (_ignore != 0) return;
- _ignore++;
- RgbColor rgbColor = newColor.ToRgb();
-
- Utility.SetNumericUpDownValue(_redUpDown, rgbColor.Red);
- Utility.SetNumericUpDownValue(_greenUpDown, rgbColor.Green);
- Utility.SetNumericUpDownValue(_blueUpDown, rgbColor.Blue);
-
- string hexText = GetHexNumericUpDownValue(rgbColor.Red, rgbColor.Green, rgbColor.Blue);
- _hexBox.Text = hexText;
-
- SetColorGradientValuesRgb(rgbColor.Red, rgbColor.Green, rgbColor.Blue);
- SetColorGradientMinMaxColorsRgb(rgbColor.Red, rgbColor.Green, rgbColor.Blue);
- SetColorGradientMinMaxColorsAlpha((int)_alphaUpDown.Value);
-
- _ignore--;
- }
-
- private void RenderColorAddIcon(ColorBgra newColor)
- {
- if (_colorAddIcon == null)
- {
- _colorAddIcon = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
- }
-
- using (Graphics g = Graphics.FromImage(_colorAddIcon))
- {
- var rect = new Rectangle(0, 0, _colorAddIcon.Width - 2, _colorAddIcon.Height - 2);
- Utility.DrawColorRectangle(g, rect, newColor.ToColor(), true);
- g.DrawImage(_colorAddOverlay, 0, 0);
- }
-
- _colorAddButton.Image = _colorAddIcon;
- _colorAddButton.Invalidate();
- }
-
- public ColorsForm()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
-
- _whichUserColorBox.Items.Add(new WhichUserColorWrapper(WhichUserColor.Primary));
- _whichUserColorBox.Items.Add(new WhichUserColorWrapper(WhichUserColor.Secondary));
- _whichUserColorBox.SelectedIndex = 0;
-
- _moreSize = ClientSize;
- _lessSize = new Size(_swatchHeader.Width + UI.ScaleWidth(16), _moreSize.Height);
-
- Text = PdnResources.GetString("ColorsForm.Text");
- _redLabel.Text = PdnResources.GetString("ColorsForm.RedLabel.Text");
- _blueLabel.Text = PdnResources.GetString("ColorsForm.BlueLabel.Text");
- _greenLabel.Text = PdnResources.GetString("ColorsForm.GreenLabel.Text");
- _saturationLabel.Text = PdnResources.GetString("ColorsForm.SaturationLabel.Text");
- _valueLabel.Text = PdnResources.GetString("ColorsForm.ValueLabel.Text");
- _hueLabel.Text = PdnResources.GetString("ColorsForm.HueLabel.Text");
- _rgbHeader.Text = PdnResources.GetString("ColorsForm.RgbHeader.Text");
- _hexLabel.Text = PdnResources.GetString("ColorsForm.HexLabel.Text");
- _hsvHeader.Text = PdnResources.GetString("ColorsForm.HsvHeader.Text");
- _alphaHeader.Text = PdnResources.GetString("ColorsForm.AlphaHeader.Text");
-
- _lessText = "<< " + PdnResources.GetString("ColorsForm.MoreLessButton.Text.Less");
- _moreText = PdnResources.GetString("ColorsForm.MoreLessButton.Text.More") + " >>";
- _moreLessButton.Text = _lessText;
-
- _toolStrip.Renderer = new OurToolStripRenderer();
-
- _colorAddOverlay = PdnResources.GetImageResource("Icons.ColorAddOverlay.png").Reference;
- _colorPalettesButton.Image = PdnResources.GetImageResource("Icons.ColorPalettes.png").Reference;
-
- RenderColorAddIcon(UserPrimaryColor);
-
- _colorAddButton.ToolTipText = PdnResources.GetString("ColorsForm.ColorAddButton.ToolTipText");
- _colorPalettesButton.ToolTipText = PdnResources.GetString("ColorsForm.ColorPalettesButton.ToolTipText");
-
- // Load the current palette
- string currentPaletteString;
-
- try
- {
- currentPaletteString = Settings.CurrentUser.GetString(SettingNames.CurrentPalette, null);
- }
-
- catch (Exception)
- {
- currentPaletteString = null;
- }
-
- if (currentPaletteString == null)
- {
- string defaultPaletteString = PaletteCollection.GetPaletteSaveString(PaletteCollection.DefaultPalette);
- currentPaletteString = defaultPaletteString;
- }
-
- ColorBgra[] currentPalette = PaletteCollection.ParsePaletteString(currentPaletteString);
-
- _swatchControl.Colors = currentPalette;
- }
-
- public override sealed string Text
- {
- get { return base.Text; }
- set { base.Text = value; }
- }
-
- protected override void OnLoad(EventArgs e)
- {
- _inMoreState = true;
- _moreLessButton.PerformClick();
- base.OnLoad(e);
- }
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (_components != null)
- {
- _components.Dispose();
- _components = null;
- }
- }
-
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this._valueGradientControl = new PaintDotNet.ColorGradientControl();
- this._colorWheel = new PaintDotNet.ColorWheel();
- this._redUpDown = new System.Windows.Forms.NumericUpDown();
- this._greenUpDown = new System.Windows.Forms.NumericUpDown();
- this._blueUpDown = new System.Windows.Forms.NumericUpDown();
- this._redLabel = new System.Windows.Forms.Label();
- this._blueLabel = new System.Windows.Forms.Label();
- this._greenLabel = new System.Windows.Forms.Label();
- this._saturationLabel = new System.Windows.Forms.Label();
- this._valueLabel = new System.Windows.Forms.Label();
- this._hueLabel = new System.Windows.Forms.Label();
- this._valueUpDown = new System.Windows.Forms.NumericUpDown();
- this._saturationUpDown = new System.Windows.Forms.NumericUpDown();
- this._hueUpDown = new System.Windows.Forms.NumericUpDown();
- this._hexBox = new System.Windows.Forms.TextBox();
- this._hexLabel = new System.Windows.Forms.Label();
- this._whichUserColorBox = new System.Windows.Forms.ComboBox();
- this._alphaUpDown = new System.Windows.Forms.NumericUpDown();
- this._moreLessButton = new System.Windows.Forms.Button();
- this._lessModeButtonSentinel = new System.Windows.Forms.Control();
- this._moreModeButtonSentinel = new System.Windows.Forms.Control();
- this._lessModeHeaderSentinel = new System.Windows.Forms.Control();
- this._moreModeHeaderSentinel = new System.Windows.Forms.Control();
- this._rgbHeader = new PaintDotNet.HeaderLabel();
- this._hsvHeader = new PaintDotNet.HeaderLabel();
- this._alphaHeader = new PaintDotNet.HeaderLabel();
- this._swatchHeader = new PaintDotNet.HeaderLabel();
- this._swatchControl = new PaintDotNet.SwatchControl();
- this._colorDisplayWidget = new PaintDotNet.ColorDisplayWidget();
- this._toolStrip = new PaintDotNet.SystemLayer.ToolStripEx();
- this._colorAddButton = new System.Windows.Forms.ToolStripButton();
- this._colorPalettesButton = new System.Windows.Forms.ToolStripSplitButton();
- this._hueGradientControl = new PaintDotNet.ColorGradientControl();
- this._saturationGradientControl = new PaintDotNet.ColorGradientControl();
- this._alphaGradientControl = new PaintDotNet.ColorGradientControl();
- this._redGradientControl = new PaintDotNet.ColorGradientControl();
- this._greenGradientControl = new PaintDotNet.ColorGradientControl();
- this._blueGradientControl = new PaintDotNet.ColorGradientControl();
- ((System.ComponentModel.ISupportInitialize)(this._redUpDown)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this._greenUpDown)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this._blueUpDown)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this._valueUpDown)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this._saturationUpDown)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this._hueUpDown)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this._alphaUpDown)).BeginInit();
- this._toolStrip.SuspendLayout();
- this.SuspendLayout();
- //
- // valueGradientControl
- //
- this._valueGradientControl.Count = 1;
- this._valueGradientControl.CustomGradient = null;
- this._valueGradientControl.DrawFarNub = true;
- this._valueGradientControl.DrawNearNub = false;
- this._valueGradientControl.Location = new System.Drawing.Point(243, 185);
- this._valueGradientControl.MaxColor = System.Drawing.Color.White;
- this._valueGradientControl.MinColor = System.Drawing.Color.Black;
- this._valueGradientControl.Name = "_valueGradientControl";
- this._valueGradientControl.Orientation = System.Windows.Forms.Orientation.Horizontal;
- this._valueGradientControl.Size = new System.Drawing.Size(73, 19);
- this._valueGradientControl.TabIndex = 2;
- this._valueGradientControl.TabStop = false;
- this._valueGradientControl.Value = 0;
- this._valueGradientControl.ValueChanged += new PaintDotNet.IndexEventHandler(this.HsvGradientControlValueChanged);
- //
- // colorWheel
- //
- this._colorWheel.Location = new System.Drawing.Point(65, 35);
- this._colorWheel.Name = "_colorWheel";
- this._colorWheel.Size = new System.Drawing.Size(129, 130);
- this._colorWheel.TabIndex = 3;
- this._colorWheel.TabStop = false;
- this._colorWheel.ColorChanged += new System.EventHandler(this.ColorWheelColorChanged);
- //
- // redUpDown
- //
- this._redUpDown.Location = new System.Drawing.Point(320, 24);
- this._redUpDown.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this._redUpDown.Name = "_redUpDown";
- this._redUpDown.Size = new System.Drawing.Size(56, 20);
- this._redUpDown.TabIndex = 2;
- this._redUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- this._redUpDown.Enter += new System.EventHandler(this.UpDownEnter);
- this._redUpDown.ValueChanged += new System.EventHandler(this.UpDownValueChanged);
- this._redUpDown.Leave += new System.EventHandler(this.UpDownLeave);
- this._redUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDownKeyUp);
- //
- // greenUpDown
- //
- this._greenUpDown.Location = new System.Drawing.Point(320, 48);
- this._greenUpDown.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this._greenUpDown.Name = "_greenUpDown";
- this._greenUpDown.Size = new System.Drawing.Size(56, 20);
- this._greenUpDown.TabIndex = 3;
- this._greenUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- this._greenUpDown.Enter += new System.EventHandler(this.UpDownEnter);
- this._greenUpDown.ValueChanged += new System.EventHandler(this.UpDownValueChanged);
- this._greenUpDown.Leave += new System.EventHandler(this.UpDownLeave);
- this._greenUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDownKeyUp);
- //
- // blueUpDown
- //
- this._blueUpDown.Location = new System.Drawing.Point(320, 72);
- this._blueUpDown.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this._blueUpDown.Name = "_blueUpDown";
- this._blueUpDown.Size = new System.Drawing.Size(56, 20);
- this._blueUpDown.TabIndex = 4;
- this._blueUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- this._blueUpDown.Enter += new System.EventHandler(this.UpDownEnter);
- this._blueUpDown.ValueChanged += new System.EventHandler(this.UpDownValueChanged);
- this._blueUpDown.Leave += new System.EventHandler(this.UpDownLeave);
- this._blueUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDownKeyUp);
- //
- // redLabel
- //
- this._redLabel.AutoSize = true;
- this._redLabel.Location = new System.Drawing.Point(222, 28);
- this._redLabel.Name = "_redLabel";
- this._redLabel.Size = new System.Drawing.Size(15, 13);
- this._redLabel.TabIndex = 7;
- this._redLabel.Text = "R";
- this._redLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // blueLabel
- //
- this._blueLabel.AutoSize = true;
- this._blueLabel.Location = new System.Drawing.Point(222, 76);
- this._blueLabel.Name = "_blueLabel";
- this._blueLabel.Size = new System.Drawing.Size(14, 13);
- this._blueLabel.TabIndex = 8;
- this._blueLabel.Text = "B";
- this._blueLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // greenLabel
- //
- this._greenLabel.AutoSize = true;
- this._greenLabel.Location = new System.Drawing.Point(222, 52);
- this._greenLabel.Name = "_greenLabel";
- this._greenLabel.Size = new System.Drawing.Size(15, 13);
- this._greenLabel.TabIndex = 9;
- this._greenLabel.Text = "G";
- this._greenLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // saturationLabel
- //
- this._saturationLabel.AutoSize = true;
- this._saturationLabel.Location = new System.Drawing.Point(222, 164);
- this._saturationLabel.Name = "_saturationLabel";
- this._saturationLabel.Size = new System.Drawing.Size(17, 13);
- this._saturationLabel.TabIndex = 16;
- this._saturationLabel.Text = "S:";
- this._saturationLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // valueLabel
- //
- this._valueLabel.AutoSize = true;
- this._valueLabel.Location = new System.Drawing.Point(222, 188);
- this._valueLabel.Name = "_valueLabel";
- this._valueLabel.Size = new System.Drawing.Size(17, 13);
- this._valueLabel.TabIndex = 15;
- this._valueLabel.Text = "V:";
- this._valueLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // hueLabel
- //
- this._hueLabel.AutoSize = true;
- this._hueLabel.Location = new System.Drawing.Point(222, 140);
- this._hueLabel.Name = "_hueLabel";
- this._hueLabel.Size = new System.Drawing.Size(18, 13);
- this._hueLabel.TabIndex = 14;
- this._hueLabel.Text = "H:";
- this._hueLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // valueUpDown
- //
- this._valueUpDown.Location = new System.Drawing.Point(320, 184);
- this._valueUpDown.Name = "_valueUpDown";
- this._valueUpDown.Size = new System.Drawing.Size(56, 20);
- this._valueUpDown.TabIndex = 8;
- this._valueUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- this._valueUpDown.Enter += new System.EventHandler(this.UpDownEnter);
- this._valueUpDown.ValueChanged += new System.EventHandler(this.UpDownValueChanged);
- this._valueUpDown.Leave += new System.EventHandler(this.UpDownLeave);
- this._valueUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDownKeyUp);
- //
- // saturationUpDown
- //
- this._saturationUpDown.Location = new System.Drawing.Point(320, 160);
- this._saturationUpDown.Name = "_saturationUpDown";
- this._saturationUpDown.Size = new System.Drawing.Size(56, 20);
- this._saturationUpDown.TabIndex = 7;
- this._saturationUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- this._saturationUpDown.Enter += new System.EventHandler(this.UpDownEnter);
- this._saturationUpDown.ValueChanged += new System.EventHandler(this.UpDownValueChanged);
- this._saturationUpDown.Leave += new System.EventHandler(this.UpDownLeave);
- this._saturationUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDownKeyUp);
- //
- // hueUpDown
- //
- this._hueUpDown.Location = new System.Drawing.Point(320, 136);
- this._hueUpDown.Maximum = new decimal(new int[] {
- 360,
- 0,
- 0,
- 0});
- this._hueUpDown.Name = "_hueUpDown";
- this._hueUpDown.Size = new System.Drawing.Size(56, 20);
- this._hueUpDown.TabIndex = 6;
- this._hueUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- this._hueUpDown.Enter += new System.EventHandler(this.UpDownEnter);
- this._hueUpDown.ValueChanged += new System.EventHandler(this.UpDownValueChanged);
- this._hueUpDown.Leave += new System.EventHandler(this.UpDownLeave);
- this._hueUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDownKeyUp);
- //
- // hexBox
- //
- this._hexBox.Location = new System.Drawing.Point(320, 96);
- this._hexBox.Name = "_hexBox";
- this._hexBox.Size = new System.Drawing.Size(56, 20);
- this._hexBox.TabIndex = 5;
- this._hexBox.Text = "000000";
- this._hexBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- this._hexBox.Enter += new System.EventHandler(this.HexUpDownEnter);
- this._hexBox.Leave += new System.EventHandler(this.HexUpDownLeave);
- this._hexBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.HexUpDownKeyUp);
- this._hexBox.TextChanged += new System.EventHandler(this.UpDownValueChanged);
- //
- // hexLabel
- //
- this._hexLabel.AutoSize = true;
- this._hexLabel.Location = new System.Drawing.Point(222, 99);
- this._hexLabel.Name = "_hexLabel";
- this._hexLabel.Size = new System.Drawing.Size(26, 13);
- this._hexLabel.TabIndex = 13;
- this._hexLabel.Text = "Hex";
- this._hexLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // whichUserColorBox
- //
- this._whichUserColorBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this._whichUserColorBox.Location = new System.Drawing.Point(8, 8);
- this._whichUserColorBox.Name = "_whichUserColorBox";
- this._whichUserColorBox.Size = new System.Drawing.Size(112, 21);
- this._whichUserColorBox.TabIndex = 0;
- this._whichUserColorBox.SelectedIndexChanged += new System.EventHandler(this.WhichUserColorBoxSelectedIndexChanged);
- //
- // alphaUpDown
- //
- this._alphaUpDown.Location = new System.Drawing.Point(320, 228);
- this._alphaUpDown.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this._alphaUpDown.Name = "_alphaUpDown";
- this._alphaUpDown.Size = new System.Drawing.Size(56, 20);
- this._alphaUpDown.TabIndex = 10;
- this._alphaUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- this._alphaUpDown.Enter += new System.EventHandler(this.UpDownEnter);
- this._alphaUpDown.ValueChanged += new System.EventHandler(this.UpDownValueChanged);
- this._alphaUpDown.Leave += new System.EventHandler(this.UpDownLeave);
- this._alphaUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDownKeyUp);
- //
- // moreLessButton
- //
- this._moreLessButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this._moreLessButton.Location = new System.Drawing.Point(126, 7);
- this._moreLessButton.Name = "_moreLessButton";
- this._moreLessButton.Size = new System.Drawing.Size(75, 23);
- this._moreLessButton.TabIndex = 1;
- this._moreLessButton.Click += new System.EventHandler(this.MoreLessButtonClick);
- //
- // lessModeButtonSentinel
- //
- this._lessModeButtonSentinel.Location = new System.Drawing.Point(128, 7);
- this._lessModeButtonSentinel.Name = "_lessModeButtonSentinel";
- this._lessModeButtonSentinel.Size = new System.Drawing.Size(0, 0);
- this._lessModeButtonSentinel.TabIndex = 22;
- this._lessModeButtonSentinel.Text = "we put the lessMore control here when in \"Less\" mode";
- this._lessModeButtonSentinel.Visible = false;
- //
- // moreModeButtonSentinel
- //
- this._moreModeButtonSentinel.Location = new System.Drawing.Point(165, 7);
- this._moreModeButtonSentinel.Name = "_moreModeButtonSentinel";
- this._moreModeButtonSentinel.Size = new System.Drawing.Size(0, 0);
- this._moreModeButtonSentinel.TabIndex = 23;
- this._moreModeButtonSentinel.Visible = false;
- //
- // lessModeHeaderSentinel
- //
- this._lessModeHeaderSentinel.Location = new System.Drawing.Point(8, 40);
- this._lessModeHeaderSentinel.Name = "_lessModeHeaderSentinel";
- this._lessModeHeaderSentinel.Size = new System.Drawing.Size(195, 185);
- this._lessModeHeaderSentinel.TabIndex = 24;
- this._lessModeHeaderSentinel.Visible = false;
- //
- // moreModeHeaderSentinel
- //
- this._moreModeHeaderSentinel.Location = new System.Drawing.Point(8, 40);
- this._moreModeHeaderSentinel.Name = "_moreModeHeaderSentinel";
- this._moreModeHeaderSentinel.Size = new System.Drawing.Size(232, 216);
- this._moreModeHeaderSentinel.TabIndex = 25;
- this._moreModeHeaderSentinel.TabStop = false;
- this._moreModeHeaderSentinel.Visible = false;
- //
- // rgbHeader
- //
- this._rgbHeader.Location = new System.Drawing.Point(222, 8);
- this._rgbHeader.Name = "_rgbHeader";
- this._rgbHeader.RightMargin = 0;
- this._rgbHeader.Size = new System.Drawing.Size(154, 14);
- this._rgbHeader.TabIndex = 27;
- this._rgbHeader.TabStop = false;
- //
- // hsvHeader
- //
- this._hsvHeader.Location = new System.Drawing.Point(222, 120);
- this._hsvHeader.Name = "_hsvHeader";
- this._hsvHeader.RightMargin = 0;
- this._hsvHeader.Size = new System.Drawing.Size(154, 14);
- this._hsvHeader.TabIndex = 28;
- this._hsvHeader.TabStop = false;
- //
- // alphaHeader
- //
- this._alphaHeader.Location = new System.Drawing.Point(222, 212);
- this._alphaHeader.Name = "_alphaHeader";
- this._alphaHeader.RightMargin = 0;
- this._alphaHeader.Size = new System.Drawing.Size(154, 14);
- this._alphaHeader.TabIndex = 29;
- this._alphaHeader.TabStop = false;
- //
- // swatchHeader
- //
- this._swatchHeader.Location = new System.Drawing.Point(8, 177);
- this._swatchHeader.Name = "_swatchHeader";
- this._swatchHeader.RightMargin = 0;
- this._swatchHeader.Size = new System.Drawing.Size(193, 14);
- this._swatchHeader.TabIndex = 30;
- this._swatchHeader.TabStop = false;
- //
- // swatchControl
- //
- this._swatchControl.BlinkHighlight = false;
- this._swatchControl.Colors = new PaintDotNet.ColorBgra[0];
- this._swatchControl.Location = new System.Drawing.Point(8, 189);
- this._swatchControl.Name = "_swatchControl";
- this._swatchControl.Size = new System.Drawing.Size(192, 74);
- this._swatchControl.TabIndex = 31;
- this._swatchControl.Text = "swatchControl1";
- this._swatchControl.ColorsChanged += this.SwatchControlColorsChanged;
- this._swatchControl.ColorClicked += this.SwatchControlColorClicked;
- //
- // colorDisplayWidget
- //
- this._colorDisplayWidget.Location = new System.Drawing.Point(4, 32);
- this._colorDisplayWidget.Name = "_colorDisplayWidget";
- this._colorDisplayWidget.Size = new System.Drawing.Size(52, 52);
- this._colorDisplayWidget.TabIndex = 32;
- this._colorDisplayWidget.BlackAndWhiteButtonClicked += ColorDisplayWidgetBlackAndWhiteButtonClicked;
- this._colorDisplayWidget.SwapColorsClicked += ColorDisplayWidgetSwapColorsClicked;
- this._colorDisplayWidget.UserPrimaryColorClick += ColorDisplayPrimaryColorClicked;
- this._colorDisplayWidget.UserSecondaryColorClick += ColorDisplaySecondaryColorClicked;
- //
- // toolStrip
- //
- this._toolStrip.ClickThrough = true;
- this._toolStrip.Dock = System.Windows.Forms.DockStyle.None;
- this._toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
- this._toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this._colorAddButton,
- this._colorPalettesButton});
- this._toolStrip.Location = new System.Drawing.Point(5, 157);
- this._toolStrip.ManagedFocus = true;
- this._toolStrip.Name = "_toolStrip";
- this._toolStrip.Size = new System.Drawing.Size(65, 25);
- this._toolStrip.TabIndex = 33;
- this._toolStrip.Text = "toolStrip";
- //
- // colorAddButton
- //
- this._colorAddButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
- this._colorAddButton.ImageTransparentColor = System.Drawing.Color.Magenta;
- this._colorAddButton.Name = "colorAddButton";
- this._colorAddButton.Size = new System.Drawing.Size(23, 22);
- this._colorAddButton.Text = "colorAddButton";
- this._colorAddButton.Click += new System.EventHandler(this.ColorAddButtonClick);
- //
- // colorPalettesButton
- //
- this._colorPalettesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
- this._colorPalettesButton.Name = "colorPalettesButton";
- this._colorPalettesButton.Size = new System.Drawing.Size(16, 22);
- this._colorPalettesButton.Click += new System.EventHandler(this.ColorPalettesButtonClick);
- this._colorPalettesButton.DropDownOpening += new System.EventHandler(this.ColorPalettesButtonDropDownOpening);
- //
- // hueGradientControl
- //
- this._hueGradientControl.Count = 1;
- this._hueGradientControl.CustomGradient = null;
- this._hueGradientControl.DrawFarNub = true;
- this._hueGradientControl.DrawNearNub = false;
- this._hueGradientControl.Location = new System.Drawing.Point(243, 137);
- this._hueGradientControl.MaxColor = System.Drawing.Color.White;
- this._hueGradientControl.MinColor = System.Drawing.Color.Black;
- this._hueGradientControl.Name = "_hueGradientControl";
- this._hueGradientControl.Orientation = System.Windows.Forms.Orientation.Horizontal;
- this._hueGradientControl.Size = new System.Drawing.Size(73, 19);
- this._hueGradientControl.TabIndex = 34;
- this._hueGradientControl.TabStop = false;
- this._hueGradientControl.Value = 0;
- this._hueGradientControl.ValueChanged += new PaintDotNet.IndexEventHandler(this.HsvGradientControlValueChanged);
- //
- // saturationGradientControl
- //
- this._saturationGradientControl.Count = 1;
- this._saturationGradientControl.CustomGradient = null;
- this._saturationGradientControl.DrawFarNub = true;
- this._saturationGradientControl.DrawNearNub = false;
- this._saturationGradientControl.Location = new System.Drawing.Point(243, 161);
- this._saturationGradientControl.MaxColor = System.Drawing.Color.White;
- this._saturationGradientControl.MinColor = System.Drawing.Color.Black;
- this._saturationGradientControl.Name = "_saturationGradientControl";
- this._saturationGradientControl.Orientation = System.Windows.Forms.Orientation.Horizontal;
- this._saturationGradientControl.Size = new System.Drawing.Size(73, 19);
- this._saturationGradientControl.TabIndex = 35;
- this._saturationGradientControl.TabStop = false;
- this._saturationGradientControl.Value = 0;
- this._saturationGradientControl.ValueChanged += new PaintDotNet.IndexEventHandler(this.HsvGradientControlValueChanged);
- //
- // alphaGradientControl
- //
- this._alphaGradientControl.Count = 1;
- this._alphaGradientControl.CustomGradient = null;
- this._alphaGradientControl.DrawFarNub = true;
- this._alphaGradientControl.DrawNearNub = false;
- this._alphaGradientControl.Location = new System.Drawing.Point(243, 229);
- this._alphaGradientControl.MaxColor = System.Drawing.Color.White;
- this._alphaGradientControl.MinColor = System.Drawing.Color.Black;
- this._alphaGradientControl.Name = "_alphaGradientControl";
- this._alphaGradientControl.Orientation = System.Windows.Forms.Orientation.Horizontal;
- this._alphaGradientControl.Size = new System.Drawing.Size(73, 19);
- this._alphaGradientControl.TabIndex = 36;
- this._alphaGradientControl.TabStop = false;
- this._alphaGradientControl.Value = 0;
- this._alphaGradientControl.ValueChanged += new PaintDotNet.IndexEventHandler(this.UpDownValueChanged);
- //
- // redGradientControl
- //
- this._redGradientControl.Count = 1;
- this._redGradientControl.CustomGradient = null;
- this._redGradientControl.DrawFarNub = true;
- this._redGradientControl.DrawNearNub = false;
- this._redGradientControl.Location = new System.Drawing.Point(243, 25);
- this._redGradientControl.MaxColor = System.Drawing.Color.White;
- this._redGradientControl.MinColor = System.Drawing.Color.Black;
- this._redGradientControl.Name = "_redGradientControl";
- this._redGradientControl.Orientation = System.Windows.Forms.Orientation.Horizontal;
- this._redGradientControl.Size = new System.Drawing.Size(73, 19);
- this._redGradientControl.TabIndex = 37;
- this._redGradientControl.TabStop = false;
- this._redGradientControl.Value = 0;
- this._redGradientControl.ValueChanged += new PaintDotNet.IndexEventHandler(this.RgbGradientControlValueChanged);
- //
- // greenGradientControl
- //
- this._greenGradientControl.Count = 1;
- this._greenGradientControl.CustomGradient = null;
- this._greenGradientControl.DrawFarNub = true;
- this._greenGradientControl.DrawNearNub = false;
- this._greenGradientControl.Location = new System.Drawing.Point(243, 49);
- this._greenGradientControl.MaxColor = System.Drawing.Color.White;
- this._greenGradientControl.MinColor = System.Drawing.Color.Black;
- this._greenGradientControl.Name = "_greenGradientControl";
- this._greenGradientControl.Orientation = System.Windows.Forms.Orientation.Horizontal;
- this._greenGradientControl.Size = new System.Drawing.Size(73, 19);
- this._greenGradientControl.TabIndex = 38;
- this._greenGradientControl.TabStop = false;
- this._greenGradientControl.Value = 0;
- this._greenGradientControl.ValueChanged += new PaintDotNet.IndexEventHandler(this.RgbGradientControlValueChanged);
- //
- // blueGradientControl
- //
- this._blueGradientControl.Count = 1;
- this._blueGradientControl.CustomGradient = null;
- this._blueGradientControl.DrawFarNub = true;
- this._blueGradientControl.DrawNearNub = false;
- this._blueGradientControl.Location = new System.Drawing.Point(243, 73);
- this._blueGradientControl.MaxColor = System.Drawing.Color.White;
- this._blueGradientControl.MinColor = System.Drawing.Color.Black;
- this._blueGradientControl.Name = "_blueGradientControl";
- this._blueGradientControl.Orientation = System.Windows.Forms.Orientation.Horizontal;
- this._blueGradientControl.Size = new System.Drawing.Size(73, 19);
- this._blueGradientControl.TabIndex = 39;
- this._blueGradientControl.TabStop = false;
- this._blueGradientControl.Value = 0;
- this._blueGradientControl.ValueChanged += new PaintDotNet.IndexEventHandler(this.RgbGradientControlValueChanged);
- //
- // ColorsForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
- this.ClientSize = new System.Drawing.Size(386, 266);
- this.Controls.Add(this._valueLabel);
- this.Controls.Add(this._saturationLabel);
- this.Controls.Add(this._hueLabel);
- this.Controls.Add(this._greenLabel);
- this.Controls.Add(this._blueLabel);
- this.Controls.Add(this._redLabel);
- this.Controls.Add(this._hexLabel);
- this.Controls.Add(this._blueGradientControl);
- this.Controls.Add(this._greenGradientControl);
- this.Controls.Add(this._redGradientControl);
- this.Controls.Add(this._alphaGradientControl);
- this.Controls.Add(this._saturationGradientControl);
- this.Controls.Add(this._hueGradientControl);
- this.Controls.Add(this._toolStrip);
- this.Controls.Add(this._colorWheel);
- this.Controls.Add(this._colorDisplayWidget);
- this.Controls.Add(this._swatchControl);
- this.Controls.Add(this._swatchHeader);
- this.Controls.Add(this._alphaHeader);
- this.Controls.Add(this._hsvHeader);
- this.Controls.Add(this._rgbHeader);
- this.Controls.Add(this._valueGradientControl);
- this.Controls.Add(this._moreModeButtonSentinel);
- this.Controls.Add(this._lessModeButtonSentinel);
- this.Controls.Add(this._moreLessButton);
- this.Controls.Add(this._whichUserColorBox);
- this.Controls.Add(this._lessModeHeaderSentinel);
- this.Controls.Add(this._moreModeHeaderSentinel);
- this.Controls.Add(this._blueUpDown);
- this.Controls.Add(this._greenUpDown);
- this.Controls.Add(this._redUpDown);
- this.Controls.Add(this._hexBox);
- this.Controls.Add(this._hueUpDown);
- this.Controls.Add(this._saturationUpDown);
- this.Controls.Add(this._valueUpDown);
- this.Controls.Add(this._alphaUpDown);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
- this.Name = "ColorsForm";
- this.Controls.SetChildIndex(this._alphaUpDown, 0);
- this.Controls.SetChildIndex(this._valueUpDown, 0);
- this.Controls.SetChildIndex(this._saturationUpDown, 0);
- this.Controls.SetChildIndex(this._hueUpDown, 0);
- this.Controls.SetChildIndex(this._hexBox, 0);
- this.Controls.SetChildIndex(this._redUpDown, 0);
- this.Controls.SetChildIndex(this._greenUpDown, 0);
- this.Controls.SetChildIndex(this._blueUpDown, 0);
- this.Controls.SetChildIndex(this._moreModeHeaderSentinel, 0);
- this.Controls.SetChildIndex(this._lessModeHeaderSentinel, 0);
- this.Controls.SetChildIndex(this._whichUserColorBox, 0);
- this.Controls.SetChildIndex(this._moreLessButton, 0);
- this.Controls.SetChildIndex(this._lessModeButtonSentinel, 0);
- this.Controls.SetChildIndex(this._moreModeButtonSentinel, 0);
- this.Controls.SetChildIndex(this._valueGradientControl, 0);
- this.Controls.SetChildIndex(this._rgbHeader, 0);
- this.Controls.SetChildIndex(this._hsvHeader, 0);
- this.Controls.SetChildIndex(this._alphaHeader, 0);
- this.Controls.SetChildIndex(this._swatchHeader, 0);
- this.Controls.SetChildIndex(this._swatchControl, 0);
- this.Controls.SetChildIndex(this._colorDisplayWidget, 0);
- this.Controls.SetChildIndex(this._colorWheel, 0);
- this.Controls.SetChildIndex(this._toolStrip, 0);
- this.Controls.SetChildIndex(this._hueGradientControl, 0);
- this.Controls.SetChildIndex(this._saturationGradientControl, 0);
- this.Controls.SetChildIndex(this._alphaGradientControl, 0);
- this.Controls.SetChildIndex(this._redGradientControl, 0);
- this.Controls.SetChildIndex(this._greenGradientControl, 0);
- this.Controls.SetChildIndex(this._blueGradientControl, 0);
- this.Controls.SetChildIndex(this._hexLabel, 0);
- this.Controls.SetChildIndex(this._redLabel, 0);
- this.Controls.SetChildIndex(this._blueLabel, 0);
- this.Controls.SetChildIndex(this._greenLabel, 0);
- this.Controls.SetChildIndex(this._hueLabel, 0);
- this.Controls.SetChildIndex(this._saturationLabel, 0);
- this.Controls.SetChildIndex(this._valueLabel, 0);
- ((System.ComponentModel.ISupportInitialize)(this._redUpDown)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this._greenUpDown)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this._blueUpDown)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this._valueUpDown)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this._saturationUpDown)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this._hueUpDown)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this._alphaUpDown)).EndInit();
- this._toolStrip.ResumeLayout(false);
- this._toolStrip.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
- #endregion
-
- public void SetUserColors(ColorBgra primary, ColorBgra secondary)
- {
- SetColorControlsRedraw(false);
- WhichUserColor which = WhichUserColor;
- UserPrimaryColor = primary;
- UserSecondaryColor = secondary;
- WhichUserColor = which;
- SetColorControlsRedraw(true);
- }
-
- public void SwapUserColors()
- {
- ColorBgra primary = UserPrimaryColor;
- ColorBgra secondary = UserSecondaryColor;
- SetUserColors(secondary, primary);
- }
-
- public void SetUserColorsToBlackAndWhite()
- {
- SetUserColors(ColorBgra.Black, ColorBgra.White);
- }
-
- private void ColorDisplayWidgetSwapColorsClicked(object sender, EventArgs e)
- {
- SwapUserColors();
- OnRelinquishFocus();
- }
-
- private void ColorDisplayWidgetBlackAndWhiteButtonClicked(object sender, EventArgs e)
- {
- SetUserColorsToBlackAndWhite();
- OnRelinquishFocus();
- }
-
- private void ColorDisplayPrimaryColorClicked(object sender, EventArgs e)
- {
- WhichUserColor = WhichUserColor.Primary;
- OnRelinquishFocus();
- }
-
- private void ColorDisplaySecondaryColorClicked(object sender, EventArgs e)
- {
- WhichUserColor = WhichUserColor.Secondary;
- OnRelinquishFocus();
- }
-
- private void WhichUserColorBoxSelectedIndexChanged(object sender, EventArgs e)
- {
- ColorBgra color;
-
- switch (WhichUserColor)
- {
- case WhichUserColor.Primary:
- color = _userPrimaryColor;
- break;
-
- case WhichUserColor.Secondary:
- color = _userSecondaryColor;
- break;
-
- default:
- throw new InvalidEnumArgumentException("WhichUserColor property");
- }
-
- PushIgnoreChangedEvents();
- Utility.SetNumericUpDownValue(_redUpDown, color.R);
- Utility.SetNumericUpDownValue(_greenUpDown, color.G);
- Utility.SetNumericUpDownValue(_blueUpDown, color.B);
-
- string hexText = GetHexNumericUpDownValue(color.R, color.G, color.B);
- _hexBox.Text = hexText;
-
- Utility.SetNumericUpDownValue(_alphaUpDown, color.A);
- PopIgnoreChangedEvents();
-
- SetColorGradientMinMaxColorsRgb(color.R, color.G, color.B);
- SetColorGradientValuesRgb(color.R, color.G, color.B);
- SetColorGradientMinMaxColorsAlpha(color.A);
-
- SyncHsvFromRgb(color);
-
- OnRelinquishFocus();
- }
-
- private void ColorWheelColorChanged(object sender, EventArgs e)
- {
- if (IgnoreChangedEvents)
- {
- return;
- }
-
- PushIgnoreChangedEvents();
-
- HsvColor hsvColor = _colorWheel.HsvColor;
- RgbColor rgbColor = hsvColor.ToRgb();
- ColorBgra color = ColorBgra.FromBgra((byte)rgbColor.Blue, (byte)rgbColor.Green, (byte)rgbColor.Red, (byte)_alphaUpDown.Value);
-
- Utility.SetNumericUpDownValue(_hueUpDown, hsvColor.Hue);
- Utility.SetNumericUpDownValue(_saturationUpDown, hsvColor.Saturation);
- Utility.SetNumericUpDownValue(_valueUpDown, hsvColor.Value);
-
- Utility.SetNumericUpDownValue(_redUpDown, color.R);
- Utility.SetNumericUpDownValue(_greenUpDown, color.G);
- Utility.SetNumericUpDownValue(_blueUpDown, color.B);
-
- string hexText = GetHexNumericUpDownValue(color.R, color.G, color.B);
- _hexBox.Text = hexText;
-
- Utility.SetNumericUpDownValue(_alphaUpDown, color.A);
-
- SetColorGradientValuesHsv(hsvColor.Hue, hsvColor.Saturation, hsvColor.Value);
- SetColorGradientMinMaxColorsHsv(hsvColor.Hue, hsvColor.Saturation, hsvColor.Value);
-
- SetColorGradientValuesRgb(color.R, color.G, color.B);
- SetColorGradientMinMaxColorsRgb(color.R, color.G, color.B);
- SetColorGradientMinMaxColorsAlpha(color.A);
-
- switch (WhichUserColor)
- {
- case WhichUserColor.Primary:
- //UserPrimaryColor = color;
- _userPrimaryColor = color;
- OnUserPrimaryColorChanged(color);
- OnRelinquishFocus();
- break;
-
- case WhichUserColor.Secondary:
- //UserSecondaryColor = color;
- _userSecondaryColor = color;
- OnUserSecondaryColorChanged(color);
- OnRelinquishFocus();
- break;
-
- default:
- throw new InvalidEnumArgumentException("WhichUserColor property");
- }
-
- PopIgnoreChangedEvents();
-
- Update();
- }
-
- private void SetColorGradientMinMaxColorsHsv(int h, int s, int v)
- {
- var hueColors = new Color[361];
-
- for (int newH = 0; newH <= 360; ++newH)
- {
- var hsv = new HsvColor(newH, 100, 100);
- hueColors[newH] = hsv.ToColor();
- }
-
- _hueGradientControl.CustomGradient = hueColors;
-
- var satColors = new Color[101];
-
- for (int newS = 0; newS <= 100; ++newS)
- {
- var hsv = new HsvColor(h, newS, v);
- satColors[newS] = hsv.ToColor();
- }
-
- _saturationGradientControl.CustomGradient = satColors;
-
- _valueGradientControl.MaxColor = new HsvColor(h, s, 100).ToColor();
- _valueGradientControl.MinColor = new HsvColor(h, s, 0).ToColor();
- }
-
- private void SetColorGradientMinMaxColorsRgb(int r, int g, int b)
- {
- _redGradientControl.MaxColor = Color.FromArgb(255, g, b);
- _redGradientControl.MinColor = Color.FromArgb(0, g, b);
- _greenGradientControl.MaxColor = Color.FromArgb(r, 255, b);
- _greenGradientControl.MinColor = Color.FromArgb(r, 0, b);
- _blueGradientControl.MaxColor = Color.FromArgb(r, g, 255);
- _blueGradientControl.MinColor = Color.FromArgb(r, g, 0);
- }
-
- private void SetColorGradientMinMaxColorsAlpha(int a)
- {
- var colors = new Color[256];
-
- for (int newA = 0; newA <= 255; ++newA)
- {
- colors[newA] = Color.FromArgb(newA, _redGradientControl.Value,
- _greenGradientControl.Value, _blueGradientControl.Value);
- }
-
- _alphaGradientControl.CustomGradient = colors;
- }
-
- private void RgbGradientControlValueChanged(object sender, IndexEventArgs ce)
- {
- if (IgnoreChangedEvents)
- {
- return;
- }
-
- int red;
- if (sender == _redGradientControl)
- {
- red = _redGradientControl.Value;
- }
- else
- {
- red = (int)_redUpDown.Value;
- }
-
- int green;
- if (sender == _greenGradientControl)
- {
- green = _greenGradientControl.Value;
- }
- else
- {
- green = (int)_greenUpDown.Value;
- }
-
- int blue;
- if (sender == _blueGradientControl)
- {
- blue = _blueGradientControl.Value;
- }
- else
- {
- blue = (int)_blueUpDown.Value;
- }
-
- int alpha;
- if (sender == _alphaGradientControl)
- {
- alpha = _alphaGradientControl.Value;
- }
- else
- {
- alpha = (int)_alphaUpDown.Value;
- }
-
- Color rgbColor = Color.FromArgb(alpha, red, green, blue);
- HsvColor hsvColor = HsvColor.FromColor(rgbColor);
-
- PushIgnoreChangedEvents();
- Utility.SetNumericUpDownValue(_hueUpDown, hsvColor.Hue);
- Utility.SetNumericUpDownValue(_saturationUpDown, hsvColor.Saturation);
- Utility.SetNumericUpDownValue(_valueUpDown, hsvColor.Value);
-
- Utility.SetNumericUpDownValue(_redUpDown, rgbColor.R);
- Utility.SetNumericUpDownValue(_greenUpDown, rgbColor.G);
- Utility.SetNumericUpDownValue(_blueUpDown, rgbColor.B);
- PopIgnoreChangedEvents();
- Utility.SetNumericUpDownValue(_alphaUpDown, rgbColor.A);
-
- string hexText = GetHexNumericUpDownValue(rgbColor.R, rgbColor.G, rgbColor.B);
- _hexBox.Text = hexText;
-
- ColorBgra color = ColorBgra.FromColor(rgbColor);
-
- switch (WhichUserColor)
- {
- case WhichUserColor.Primary:
- UserPrimaryColor = color;
- OnRelinquishFocus();
- break;
-
- case WhichUserColor.Secondary:
- UserSecondaryColor = color;
- OnRelinquishFocus();
- break;
-
- default:
- throw new InvalidEnumArgumentException("WhichUserColor property");
- }
-
- Update();
- }
-
- private void HsvGradientControlValueChanged(object sender, IndexEventArgs e)
- {
- if (IgnoreChangedEvents)
- {
- return;
- }
-
- int hue;
- if (sender == _hueGradientControl)
- {
- hue = (_hueGradientControl.Value * 360) / 255;
- }
- else
- {
- hue = (int)_hueUpDown.Value;
- }
-
- int saturation;
- if (sender == _saturationGradientControl)
- {
- saturation = (_saturationGradientControl.Value * 100) / 255;
- }
- else
- {
- saturation = (int)_saturationUpDown.Value;
- }
-
- int value;
- if (sender == _valueGradientControl)
- {
- value = (_valueGradientControl.Value * 100) / 255;
- }
- else
- {
- value = (int)_valueUpDown.Value;
- }
-
- var hsvColor = new HsvColor(hue, saturation, value);
- _colorWheel.HsvColor = hsvColor;
- RgbColor rgbColor = hsvColor.ToRgb();
- ColorBgra color = ColorBgra.FromBgra((byte)rgbColor.Blue, (byte)rgbColor.Green, (byte)rgbColor.Red, (byte)_alphaUpDown.Value);
-
- Utility.SetNumericUpDownValue(_hueUpDown, hsvColor.Hue);
- Utility.SetNumericUpDownValue(_saturationUpDown, hsvColor.Saturation);
- Utility.SetNumericUpDownValue(_valueUpDown, hsvColor.Value);
-
- Utility.SetNumericUpDownValue(_redUpDown, rgbColor.Red);
- Utility.SetNumericUpDownValue(_greenUpDown, rgbColor.Green);
- Utility.SetNumericUpDownValue(_blueUpDown, rgbColor.Blue);
-
- string hexText = GetHexNumericUpDownValue(rgbColor.Red, rgbColor.Green, rgbColor.Blue);
- _hexBox.Text = hexText;
-
- switch (WhichUserColor)
- {
- case WhichUserColor.Primary:
- UserPrimaryColor = color;
- OnRelinquishFocus();
- break;
-
- case WhichUserColor.Secondary:
- UserSecondaryColor = color;
- OnRelinquishFocus();
- break;
-
- default:
- throw new InvalidEnumArgumentException("WhichUserColor property");
- }
-
- Update();
- }
-
- private void UpDownEnter(object sender, EventArgs e)
- {
- var nud = (NumericUpDown)sender;
- nud.Select(0, nud.Text.Length);
- }
-
- private void UpDownLeave(object sender, EventArgs e)
- {
- UpDownValueChanged(sender, e);
- }
-
- private void HexUpDownEnter(object sender, EventArgs e)
- {
- var tb = (TextBox)sender;
- tb.Select(0, tb.Text.Length);
- }
-
- private void HexUpDownLeave(object sender, EventArgs e)
- {
- _hexBox.Text = _hexBox.Text.ToUpper();
- UpDownValueChanged(sender, e);
- }
-
- private void HexUpDownKeyUp(object sender, KeyEventArgs e)
- {
- var tb = (TextBox)sender;
-
- if (CheckHexBox(tb.Text))
- {
- UpDownValueChanged(sender, e);
- }
- }
-
- private static bool CheckHexBox(String checkHex)
- {
- int num;
-
- try
- {
- num = int.Parse(checkHex, System.Globalization.NumberStyles.HexNumber);
- }
-
- catch (FormatException)
- {
- return false;
- }
-
- catch (OverflowException)
- {
- return false;
- }
-
- return (num <= 16777215) && (num >= 0);
- }
-
- private void UpDownKeyUp(object sender, KeyEventArgs e)
- {
- var nud = (NumericUpDown)sender;
-
- if (Utility.CheckNumericUpDown(nud))
- {
- UpDownValueChanged(sender, e);
- }
- }
-
- private void UpDownValueChanged(object sender, EventArgs e)
- {
- if (sender == _alphaUpDown || sender == _alphaGradientControl)
- {
- if (sender == _alphaGradientControl)
- {
- if (_alphaUpDown.Value != _alphaGradientControl.Value)
- {
- _alphaUpDown.Value = _alphaGradientControl.Value;
- }
- }
- else
- {
- if (_alphaGradientControl.Value != (int)_alphaUpDown.Value)
- {
- _alphaGradientControl.Value = (int)_alphaUpDown.Value;
- }
- }
-
- PushIgnoreChangedEvents();
-
- switch (WhichUserColor)
- {
- case WhichUserColor.Primary:
- ColorBgra newPrimaryColor = ColorBgra.FromBgra(_lastPrimaryColor.B, _lastPrimaryColor.G, _lastPrimaryColor.R, (byte)_alphaGradientControl.Value);
- _userPrimaryColor = newPrimaryColor;
- OnUserPrimaryColorChanged(newPrimaryColor);
- break;
-
- case WhichUserColor.Secondary:
- ColorBgra newSecondaryColor = ColorBgra.FromBgra(_lastSecondaryColor.B, _lastSecondaryColor.G, _lastSecondaryColor.R, (byte)_alphaGradientControl.Value);
- _userSecondaryColor = newSecondaryColor;
- OnUserSecondaryColorChanged(newSecondaryColor);
- break;
-
- default:
- throw new InvalidEnumArgumentException("WhichUserColor property");
- }
-
- PopIgnoreChangedEvents();
- Update();
- }
- else if (IgnoreChangedEvents)
- {
- return;
- }
- else
- {
- PushIgnoreChangedEvents();
-
- if (sender == _redUpDown || sender == _greenUpDown || sender == _blueUpDown)
- {
- string hexText = GetHexNumericUpDownValue((int)_redUpDown.Value, (int)_greenUpDown.Value, (int)_blueUpDown.Value);
- _hexBox.Text = hexText;
-
- ColorBgra rgbColor = ColorBgra.FromBgra((byte)_blueUpDown.Value, (byte)_greenUpDown.Value, (byte)_redUpDown.Value, (byte)_alphaUpDown.Value);
-
- SetColorGradientMinMaxColorsRgb(rgbColor.R, rgbColor.G, rgbColor.B);
- SetColorGradientMinMaxColorsAlpha(rgbColor.A);
- SetColorGradientValuesRgb(rgbColor.R, rgbColor.G, rgbColor.B);
- SetColorGradientMinMaxColorsAlpha(rgbColor.A);
-
- SyncHsvFromRgb(rgbColor);
- OnUserColorChanged(rgbColor);
- }
- else if (sender == _hexBox)
- {
- int hexInt = 0;
-
- if (_hexBox.Text.Length > 0)
- {
- try
- {
- hexInt = int.Parse(_hexBox.Text,System.Globalization.NumberStyles.HexNumber);
- }
-
- // Needs to be changed so it reads what the RGB values were last
- catch (FormatException)
- {
- hexInt = 0;
- _hexBox.Text = "";
- }
-
- catch (OverflowException)
- {
- hexInt = 16777215;
- _hexBox.Text = "FFFFFF";
- }
-
- if (!((hexInt <= 16777215) && (hexInt >= 0)))
- {
- hexInt = 16777215;
- _hexBox.Text = "FFFFFF";
- }
- }
-
- int newRed = ((hexInt & 0xff0000) >> 16);
- int newGreen = ((hexInt & 0x00ff00) >> 8);
- int newBlue = (hexInt & 0x0000ff);
-
- Utility.SetNumericUpDownValue(_redUpDown, newRed);
- Utility.SetNumericUpDownValue(_greenUpDown, newGreen);
- Utility.SetNumericUpDownValue(_blueUpDown, newBlue);
-
- SetColorGradientMinMaxColorsRgb(newRed, newGreen, newBlue);
- SetColorGradientValuesRgb(newRed, newGreen, newBlue);
- SetColorGradientMinMaxColorsAlpha((int)_alphaUpDown.Value);
-
- ColorBgra rgbColor = ColorBgra.FromBgra((byte)newBlue, (byte)newGreen, (byte)newRed, (byte)_alphaUpDown.Value);
- SyncHsvFromRgb(rgbColor);
- OnUserColorChanged(rgbColor);
- }
- else if (sender == _hueUpDown || sender == _saturationUpDown || sender == _valueUpDown)
- {
- HsvColor oldHsvColor = _colorWheel.HsvColor;
- var newHsvColor = new HsvColor((int)_hueUpDown.Value, (int)_saturationUpDown.Value, (int)_valueUpDown.Value);
-
- if (oldHsvColor != newHsvColor)
- {
- _colorWheel.HsvColor = newHsvColor;
-
- SetColorGradientValuesHsv(newHsvColor.Hue, newHsvColor.Saturation, newHsvColor.Value);
- SetColorGradientMinMaxColorsHsv(newHsvColor.Hue, newHsvColor.Saturation, newHsvColor.Value);
-
- SyncRgbFromHsv(newHsvColor);
- RgbColor rgbColor = newHsvColor.ToRgb();
- OnUserColorChanged(ColorBgra.FromBgra((byte)rgbColor.Blue, (byte)rgbColor.Green, (byte)rgbColor.Red, (byte)_alphaUpDown.Value));
- }
- }
-
- PopIgnoreChangedEvents();
- }
- }
-
- private void PushIgnoreChangedEvents()
- {
- ++_ignoreChangedEvents;
- }
-
- private void PopIgnoreChangedEvents()
- {
- --_ignoreChangedEvents;
- }
-
- private void MoreLessButtonClick(object sender, EventArgs e)
- {
- OnRelinquishFocus();
-
- SuspendLayout();
-
- if (_inMoreState)
- {
- _inMoreState = false;
- Size newSize = _lessSize;
- _moreLessButton.Text = _moreText;
-
- int heightDelta = (_moreModeHeaderSentinel.Height - _lessModeHeaderSentinel.Height);
-
- newSize.Height -= heightDelta;
- newSize.Height -= UI.ScaleHeight(18);
-
- ClientSize = newSize;
- }
- else
- {
- _inMoreState = true;
- _moreLessButton.Text = _lessText;
-
- ClientSize = _moreSize;
- }
-
- _swatchControl.Height = ClientSize.Height - UI.ScaleHeight(4) - _swatchControl.Top;
-
- ResumeLayout(false);
- }
-
- private void ColorAddButtonClick(object sender, EventArgs e)
- {
- if (_colorAddButton.Checked)
- {
- _colorAddButton.Checked = false;
- _swatchControl.BlinkHighlight = false;
- }
- else
- {
- _colorAddButton.Checked = true;
- _swatchControl.BlinkHighlight = true;
- }
- }
-
- private ColorBgra GetColorFromUpDowns()
- {
- var r = (int)_redUpDown.Value;
- var g = (int)_greenUpDown.Value;
- var b = (int)_blueUpDown.Value;
- var a = (int)_alphaUpDown.Value;
-
- return ColorBgra.FromBgra((byte)b, (byte)g, (byte)r, (byte)a);
- }
-
- private void SwatchControlColorClicked(object sender, EventArgs<Pair<int, MouseButtons>> e)
- {
- var colors = new List<ColorBgra>(_swatchControl.Colors);
-
- if (_colorAddButton.Checked)
- {
- colors[e.Data.First] = GetColorFromUpDowns();
- _swatchControl.Colors = colors.ToArray();
- _colorAddButton.Checked = false;
- _swatchControl.BlinkHighlight = false;
- }
- else
- {
- ColorBgra color = colors[e.Data.First];
-
- if (e.Data.Second == MouseButtons.Right)
- {
- SetUserColors(UserPrimaryColor, color);
- }
- else
- {
- switch (WhichUserColor)
- {
- case WhichUserColor.Primary:
- UserPrimaryColor = color;
- break;
-
- case WhichUserColor.Secondary:
- UserSecondaryColor = color;
- break;
-
- default:
- throw new InvalidEnumArgumentException();
- }
- }
- }
-
- OnRelinquishFocus();
- }
-
- private void ColorPalettesButtonClick(object sender, EventArgs e)
- {
- _colorPalettesButton.ShowDropDown();
- }
-
- private void ColorPalettesButtonDropDownOpening(object sender, EventArgs e)
- {
- _colorPalettesButton.DropDownItems.Clear();
-
- if (_paletteCollection != null)
- {
- using (new WaitCursorChanger(this))
- {
- _paletteCollection.Load();
- }
-
- string[] paletteNames = _paletteCollection.PaletteNames;
-
- foreach (string paletteName in paletteNames)
- {
- _colorPalettesButton.DropDownItems.Add(
- paletteName,
- PdnResources.GetImageResource("Icons.SwatchIcon.png").Reference,
- OnPaletteClickedHandler);
- }
-
- if (paletteNames.Length > 0)
- {
- _colorPalettesButton.DropDownItems.Add(new ToolStripSeparator());
- }
- }
-
- _colorPalettesButton.DropDownItems.Add(
- PdnResources.GetString("ColorsForm.ColorPalettesButton.SaveCurrentPaletteAs.Text"),
- PdnResources.GetImageResource("Icons.SavePaletteIcon.png").Reference,
- OnSavePaletteAsHandler);
-
- _colorPalettesButton.DropDownItems.Add(
- PdnResources.GetString("ColorsForm.ColorPalettesButton.OpenPalettesFolder.Text"),
- PdnResources.GetImageResource("Icons.ColorPalettes.png").Reference,
- OnOpenPalettesFolderClickedHandler);
-
- _colorPalettesButton.DropDownItems.Add(new ToolStripSeparator());
-
- _colorPalettesButton.DropDownItems.Add(
- PdnResources.GetString("ColorsForm.ColorPalettesButton.ResetToDefaultPalette.Text"),
- null,
- OnResetPaletteHandler);
- }
-
- private void OnSavePaletteAsHandler(object sender, EventArgs e)
- {
- using (var spd = new SavePaletteDialog())
- {
- spd.PaletteNames = _paletteCollection.PaletteNames;
- spd.ShowDialog(this);
-
- if (spd.DialogResult != DialogResult.OK) return;
- _paletteCollection.AddOrUpdate(spd.PaletteName, _swatchControl.Colors);
-
- using (new WaitCursorChanger(this))
- {
- _paletteCollection.Save();
- }
- }
- }
-
- private void OnResetPaletteHandler(object sender, EventArgs e)
- {
- _swatchControl.Colors = PaletteCollection.DefaultPalette;
- }
-
- private void OnPaletteClickedHandler(object sender, EventArgs e)
- {
- var tsi = sender as ToolStripItem;
-
- if (tsi == null) return;
- ColorBgra[] palette = _paletteCollection.Get(tsi.Text);
-
- if (palette != null)
- {
- _swatchControl.Colors = palette;
- }
- }
-
- private void SwatchControlColorsChanged(object sender, EventArgs e)
- {
- string paletteString = PaletteCollection.GetPaletteSaveString(_swatchControl.Colors);
- Settings.CurrentUser.SetString(SettingNames.CurrentPalette, paletteString);
- }
-
- private void OnOpenPalettesFolderClickedHandler(object sender, EventArgs e)
- {
- PaletteCollection.EnsurePalettesPathExists();
-
- try
- {
- using (new WaitCursorChanger(this))
- {
- Shell.BrowseFolder(this, PaletteCollection.PalettesPath);
- }
- }
-
- catch (Exception ex)
- {
- Tracing.Ping("Exception when launching PalettesPath (" + PaletteCollection.PalettesPath + "):" + ex.ToString());
- }
- }
- }
- }