123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025 |
- using Resources;
- using SmartCoalApplication.Base;
- using SmartCoalApplication.Core;
- using SmartCoalApplication.SystemLayer;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace SmartCoalApplication.PluginAssemblys
- {
- internal class ColorsForm : FloatingToolForm
- {
- private sealed class OurToolStripRenderer
- : ToolStripProfessionalRenderer
- {
- protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
- {
- if (e.ToolStrip is ToolStripDropDown)
- {
- base.OnRenderToolStripBackground(e);
- }
- else
- {
- using (SolidBrush 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 System.ComponentModel.Container components = null;
- private Label saturationLabel;
- private Label valueLabel;
- private ComboBox whichUserColorBox;
- private ColorGradientControl valueGradientControl;
- private NumericUpDown alphaUpDown;
- private ColorGradientControl alphaGradientControl;
- private ColorWheel colorWheel;
- private int ignoreChangedEvents = 0;
- private ColorBgra lastPrimaryColor;
- private Button moreLessButton;
- private ColorBgra lastSecondaryColor;
- private int suspendSetWhichUserColor;
- private string lessText;
- private string moreText;
- private Size moreSize;
- private Size lessSize;
- private Control lessModeButtonSentinel;
- private Control moreModeButtonSentinel;
- private Control lessModeHeaderSentinel;
- private Control moreModeHeaderSentinel;
- private bool inMoreState = true;
- private System.Windows.Forms.Label hexLabel;
- private System.Windows.Forms.TextBox hexBox;
- private uint ignore = 0;
- 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 Image colorAddOverlay;
- private ToolStripSplitButton colorPalettesButton;
- private Bitmap colorAddIcon;
- private ColorGradientControl hueGradientControl;
- private ColorGradientControl saturationGradientControl;
- private ColorGradientControl redGradientControl;
- private ColorGradientControl greenGradientControl;
- private ColorGradientControl blueGradientControl;
- private Button saveBtn;
- private PaletteCollection paletteCollection = null;
- public PaletteCollection PaletteCollection
- {
- get
- {
- return this.paletteCollection;
- }
- set
- {
- this.paletteCollection = value;
- }
- }
- private bool IgnoreChangedEvents
- {
- get
- {
- return this.ignoreChangedEvents != 0;
- }
- }
- private class WhichUserColorWrapper
- {
- private WhichUserColor whichUserColor;
- public WhichUserColor WhichUserColor
- {
- get
- {
- return this.whichUserColor;
- }
- }
- public override int GetHashCode()
- {
- return this.whichUserColor.GetHashCode();
- }
- public override bool Equals(object obj)
- {
- WhichUserColorWrapper rhs = obj as WhichUserColorWrapper;
- if (rhs == null)
- {
- return false;
- }
- if (rhs.whichUserColor == this.whichUserColor)
- {
- return true;
- }
- return false;
- }
- public override string ToString()
- {
- return "";// PdnResources.GetString("WhichUserColor." + this.whichUserColor.ToString());
- }
- public WhichUserColorWrapper(WhichUserColor whichUserColor)
- {
- this.whichUserColor = whichUserColor;
- }
- }
- public void SuspendSetWhichUserColor()
- {
- ++this.suspendSetWhichUserColor;
- }
- public void ResumeSetWhichUserColor()
- {
- --this.suspendSetWhichUserColor;
- }
- public WhichUserColor WhichUserColor
- {
- get
- {
- return ((WhichUserColorWrapper)whichUserColorBox.SelectedItem).WhichUserColor;
- }
- set
- {
- if (this.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)
- {
- Control[] controls =
- new Control[]
- {
- this.colorWheel,
- this.whichUserColorBox,
- this.hueGradientControl,
- this.saturationGradientControl,
- this.valueGradientControl,
- this.redGradientControl,
- this.greenGradientControl,
- this.blueGradientControl,
- this.alphaGradientControl,
- this.hueUpDown,
- this.saturationUpDown,
- this.valueUpDown,
- this.redUpDown,
- this.greenUpDown,
- this.blueUpDown,
- this.alphaUpDown,
- this.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)
- {
- this.userPrimaryColor = newColor;
- UserPrimaryColorChanged(this, new ColorEventArgs(newColor));
- this.lastPrimaryColor = newColor;
- this.colorDisplayWidget.UserPrimaryColor = newColor;
- }
- RenderColorAddIcon(newColor);
- }
- private ColorBgra userPrimaryColor;
- public ColorBgra UserPrimaryColor
- {
- get
- {
- return userPrimaryColor;
- }
- set
- {
- if (IgnoreChangedEvents)
- {
- return;
- }
- if (userPrimaryColor != value)
- {
- userPrimaryColor = value;
- OnUserPrimaryColorChanged(value);
- if (WhichUserColor != WhichUserColor.Primary)
- {
- this.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);
- this.colorDisplayWidget.UserPrimaryColor = this.userPrimaryColor;
- }
- }
- }
- private string GetHexNumericUpDownValue(int red, int green, int blue)
- {
- int newHexNumber = (red << 16) | (green << 8) | blue;
- string newHexText = System.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)
- {
- this.userSecondaryColor = newColor;
- UserSecondaryColorChanged(this, new ColorEventArgs(newColor));
- this.lastSecondaryColor = newColor;
- this.colorDisplayWidget.UserSecondaryColor = newColor;
- }
- RenderColorAddIcon(newColor);
- }
- private ColorBgra userSecondaryColor;
- public ColorBgra UserSecondaryColor
- {
- get
- {
- return userSecondaryColor;
- }
- set
- {
- if (IgnoreChangedEvents)
- {
- return;
- }
- if (userSecondaryColor != value)
- {
- userSecondaryColor = value;
- OnUserSecondaryColorChanged(value);
- if (WhichUserColor != WhichUserColor.Secondary)
- {
- this.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);
- this.colorDisplayWidget.UserSecondaryColor = this.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)
- {
- 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)
- {
- 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 (this.colorAddIcon == null)
- {
- this.colorAddIcon = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
- }
- using (Graphics g = Graphics.FromImage(this.colorAddIcon))
- {
- Rectangle rect = new Rectangle(0, 0, this.colorAddIcon.Width - 2, this.colorAddIcon.Height - 2);
- Utility.DrawColorRectangle(g, rect, newColor.ToColor(), true);
- g.DrawImage(this.colorAddOverlay, 0, 0);
- }
- this.colorAddButton.Image = this.colorAddIcon;
- this.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 = this.ClientSize;
- lessSize = new Size(this.swatchHeader.Width + SystemLayer.UI.ScaleWidth(16), moreSize.Height);
- this.colorAddOverlay = PdnResources.GetImageResource("Icons.ColorAddOverlay.png").Reference;
- this.colorPalettesButton.Image = PdnResources.GetImageResource("Icons.ColorPalettes.png").Reference;
- InitTextAndData();
- }
- private void InitTextAndData()
- {
- this.saveBtn.Text = PdnResources.GetString("Menu.ensure.text");
- this.Text = PdnResources.GetString("ColorsForm.Text");
- this.saturationLabel.Text = PdnResources.GetString("ColorsForm.SaturationLabel.Text");
- this.valueLabel.Text = PdnResources.GetString("ColorsForm.ValueLabel.Text");
- this.hueLabel.Text = PdnResources.GetString("ColorsForm.HueLabel.Text");
- this.rgbHeader.Text = PdnResources.GetString("ColorsForm.RgbHeader.Text");
- this.hexLabel.Text = PdnResources.GetString("ColorsForm.HexLabel.Text");
- this.hsvHeader.Text = PdnResources.GetString("ColorsForm.HsvHeader.Text");
- this.alphaHeader.Text = PdnResources.GetString("ColorsForm.AlphaHeader.Text");
- this.lessText = "<< " + PdnResources.GetString("ColorsForm.MoreLessButton.Text.Less");
- this.moreText = PdnResources.GetString("ColorsForm.MoreLessButton.Text.More") + " >>";
- this.moreLessButton.Text = lessText;
- this.toolStrip.Renderer = new OurToolStripRenderer();
- RenderColorAddIcon(this.UserPrimaryColor);
- this.colorAddButton.ToolTipText = PdnResources.GetString("ColorsForm.ColorAddButton.ToolTipText");
- this.colorPalettesButton.ToolTipText = PdnResources.GetString("ColorsForm.ColorPalettesButton.ToolTipText");
- // Load the current palette
- string currentPaletteString = null;
- /*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);
- this.swatchControl.Colors = currentPalette;
- }
- protected override void OnLoad(EventArgs e)
- {
- this.inMoreState = true;
- this.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 ColorGradientControl();
- this.colorWheel = new 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 HeaderLabel();
- this.hsvHeader = new HeaderLabel();
- this.alphaHeader = new HeaderLabel();
- this.swatchHeader = new HeaderLabel();
- this.swatchControl = new SwatchControl();
- this.colorDisplayWidget = new ColorDisplayWidget();
- this.toolStrip = new SystemLayer.ToolStripEx();
- this.colorAddButton = new System.Windows.Forms.ToolStripButton();
- this.colorPalettesButton = new System.Windows.Forms.ToolStripSplitButton();
- this.hueGradientControl = new ColorGradientControl();
- this.saturationGradientControl = new ColorGradientControl();
- this.alphaGradientControl = new ColorGradientControl();
- this.redGradientControl = new ColorGradientControl();
- this.greenGradientControl = new ColorGradientControl();
- this.blueGradientControl = new ColorGradientControl();
- this.saveBtn = new Button();
- ((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 IndexEventHandler(this.HsvGradientControl_ValueChanged);
- //
- // 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.ColorWheel_ColorChanged);
- //
- // 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.UpDown_Enter);
- this.redUpDown.ValueChanged += new System.EventHandler(this.UpDown_ValueChanged);
- this.redUpDown.Leave += new System.EventHandler(this.UpDown_Leave);
- this.redUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDown_KeyUp);
- //
- // 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.UpDown_Enter);
- this.greenUpDown.ValueChanged += new System.EventHandler(this.UpDown_ValueChanged);
- this.greenUpDown.Leave += new System.EventHandler(this.UpDown_Leave);
- this.greenUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDown_KeyUp);
- //
- // 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.UpDown_Enter);
- this.blueUpDown.ValueChanged += new System.EventHandler(this.UpDown_ValueChanged);
- this.blueUpDown.Leave += new System.EventHandler(this.UpDown_Leave);
- this.blueUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDown_KeyUp);
- //
- // 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.UpDown_Enter);
- this.valueUpDown.ValueChanged += new System.EventHandler(this.UpDown_ValueChanged);
- this.valueUpDown.Leave += new System.EventHandler(this.UpDown_Leave);
- this.valueUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDown_KeyUp);
- //
- // 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.UpDown_Enter);
- this.saturationUpDown.ValueChanged += new System.EventHandler(this.UpDown_ValueChanged);
- this.saturationUpDown.Leave += new System.EventHandler(this.UpDown_Leave);
- this.saturationUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDown_KeyUp);
- //
- // 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.UpDown_Enter);
- this.hueUpDown.ValueChanged += new System.EventHandler(this.UpDown_ValueChanged);
- this.hueUpDown.Leave += new System.EventHandler(this.UpDown_Leave);
- this.hueUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDown_KeyUp);
- //
- // 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.HexUpDown_Enter);
- this.hexBox.Leave += new System.EventHandler(this.HexUpDown_Leave);
- this.hexBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.HexUpDown_KeyUp);
- this.hexBox.TextChanged += new System.EventHandler(this.UpDown_ValueChanged);
- //
- // 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.WhichUserColorBox_SelectedIndexChanged);
- this.whichUserColorBox.Visible = false;
- //
- // 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.UpDown_Enter);
- this.alphaUpDown.ValueChanged += new System.EventHandler(this.UpDown_ValueChanged);
- this.alphaUpDown.Leave += new System.EventHandler(this.UpDown_Leave);
- this.alphaUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UpDown_KeyUp);
- //
- // 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.MoreLessButton_Click);
- //
- // 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 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.SwatchControl_ColorsChanged;
- this.swatchControl.ColorClicked += this.SwatchControl_ColorClicked;
- //
- // 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 += ColorDisplayWidget_BlackAndWhiteButtonClicked;
- this.colorDisplayWidget.SwapColorsClicked += ColorDisplayWidget_SwapColorsClicked;
- this.colorDisplayWidget.UserPrimaryColorClick += ColorDisplay_PrimaryColorClicked;
- this.colorDisplayWidget.UserSecondaryColorClick += ColorDisplay_SecondaryColorClicked;
- this.colorDisplayWidget.Visible = false;
- //
- // 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.ColorAddButton_Click);
- this.colorAddButton.Visible = true;
- //
- // 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.ColorPalettesButton_Click);
- this.colorPalettesButton.DropDownOpening += new System.EventHandler(this.ColorPalettesButton_DropDownOpening);
- this.colorPalettesButton.Visible = false;
- //
- // 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 IndexEventHandler(this.HsvGradientControl_ValueChanged);
- //
- // 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 IndexEventHandler(this.HsvGradientControl_ValueChanged);
- //
- // 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 IndexEventHandler(this.UpDown_ValueChanged);
- //
- // 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 IndexEventHandler(this.RgbGradientControl_ValueChanged);
- //
- // 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 IndexEventHandler(this.RgbGradientControl_ValueChanged);
- //
- // 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 IndexEventHandler(this.RgbGradientControl_ValueChanged);
- //
- // saveBtn
- //
- this.saveBtn.Location = new System.Drawing.Point(8, 8);
- this.saveBtn.Name = "whichUserColorBox";
- this.saveBtn.Size = new System.Drawing.Size(75, 21);
- //
- // 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.Controls.Add(this.saveBtn);
- 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 = this.UserPrimaryColor;
- ColorBgra secondary = this.UserSecondaryColor;
- SetUserColors(secondary, primary);
- }
- public void SetUserColorsToBlackAndWhite()
- {
- SetUserColors(ColorBgra.Black, ColorBgra.White);
- }
- private void ColorDisplayWidget_SwapColorsClicked(object sender, EventArgs e)
- {
- SwapUserColors();
- OnRelinquishFocus();
- }
- private void ColorDisplayWidget_BlackAndWhiteButtonClicked(object sender, EventArgs e)
- {
- SetUserColorsToBlackAndWhite();
- OnRelinquishFocus();
- }
- private void ColorDisplay_PrimaryColorClicked(object sender, System.EventArgs e)
- {
- WhichUserColor = WhichUserColor.Primary;
- OnRelinquishFocus();
- }
- private void ColorDisplay_SecondaryColorClicked(object sender, System.EventArgs e)
- {
- WhichUserColor = WhichUserColor.Secondary;
- OnRelinquishFocus();
- }
- private void WhichUserColorBox_SelectedIndexChanged(object sender, System.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 ColorWheel_ColorChanged(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;
- this.userPrimaryColor = color;
- OnUserPrimaryColorChanged(color);
- OnRelinquishFocus();
- break;
- case WhichUserColor.Secondary:
- //UserSecondaryColor = color;
- this.userSecondaryColor = color;
- OnUserSecondaryColorChanged(color);
- OnRelinquishFocus();
- break;
- default:
- throw new InvalidEnumArgumentException("WhichUserColor property");
- }
- PopIgnoreChangedEvents();
- Update();
- }
- private void SetColorGradientMinMaxColorsHsv(int h, int s, int v)
- {
- Color[] hueColors = new Color[361];
- for (int newH = 0; newH <= 360; ++newH)
- {
- HsvColor hsv = new HsvColor(newH, 100, 100);
- hueColors[newH] = hsv.ToColor();
- }
- this.hueGradientControl.CustomGradient = hueColors;
- Color[] satColors = new Color[101];
- for (int newS = 0; newS <= 100; ++newS)
- {
- HsvColor hsv = new HsvColor(h, newS, v);
- satColors[newS] = hsv.ToColor();
- }
- this.saturationGradientControl.CustomGradient = satColors;
- this.valueGradientControl.MaxColor = new HsvColor(h, s, 100).ToColor();
- this.valueGradientControl.MinColor = new HsvColor(h, s, 0).ToColor();
- }
- private void SetColorGradientMinMaxColorsRgb(int r, int g, int b)
- {
- this.redGradientControl.MaxColor = Color.FromArgb(255, g, b);
- this.redGradientControl.MinColor = Color.FromArgb(0, g, b);
- this.greenGradientControl.MaxColor = Color.FromArgb(r, 255, b);
- this.greenGradientControl.MinColor = Color.FromArgb(r, 0, b);
- this.blueGradientControl.MaxColor = Color.FromArgb(r, g, 255);
- this.blueGradientControl.MinColor = Color.FromArgb(r, g, 0);
- }
- private void SetColorGradientMinMaxColorsAlpha(int a)
- {
- Color[] colors = new Color[256];
- for (int newA = 0; newA <= 255; ++newA)
- {
- colors[newA] = Color.FromArgb(newA, this.redGradientControl.Value,
- this.greenGradientControl.Value, this.blueGradientControl.Value);
- }
- this.alphaGradientControl.CustomGradient = colors;
- }
- private void RgbGradientControl_ValueChanged(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 HsvGradientControl_ValueChanged(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;
- }
- HsvColor 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 UpDown_Enter(object sender, System.EventArgs e)
- {
- NumericUpDown nud = (NumericUpDown)sender;
- nud.Select(0, nud.Text.Length);
- }
- private void UpDown_Leave(object sender, System.EventArgs e)
- {
- UpDown_ValueChanged(sender, e);
- }
- private void HexUpDown_Enter(object sender, System.EventArgs e)
- {
- TextBox tb = (TextBox)sender;
- tb.Select(0, tb.Text.Length);
- }
- private void HexUpDown_Leave(object sender, System.EventArgs e)
- {
- hexBox.Text = hexBox.Text.ToUpper();
- UpDown_ValueChanged(sender, e);
- }
- private void HexUpDown_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
- {
- TextBox tb = (TextBox)sender;
- if (CheckHexBox(tb.Text))
- {
- UpDown_ValueChanged(sender, e);
- }
- }
- private bool CheckHexBox(String checkHex)
- {
- int num;
- try
- {
- num = int.Parse(checkHex, System.Globalization.NumberStyles.HexNumber);
- }
- catch (FormatException)
- {
- return false;
- }
- catch (OverflowException)
- {
- return false;
- }
- if ((num <= 16777215) && (num >= 0))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void UpDown_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
- {
- NumericUpDown nud = (NumericUpDown)sender;
- if (Utility.CheckNumericUpDown(nud))
- {
- UpDown_ValueChanged(sender, e);
- }
- }
- private void UpDown_ValueChanged(object sender, System.EventArgs e)
- {
- if (sender == alphaUpDown || sender == alphaGradientControl)
- {
- if (sender == alphaGradientControl)
- {
- if (alphaUpDown.Value != (decimal)alphaGradientControl.Value)
- {
- alphaUpDown.Value = (decimal)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);
- this.userPrimaryColor = newPrimaryColor;
- OnUserPrimaryColorChanged(newPrimaryColor);
- break;
- case WhichUserColor.Secondary:
- ColorBgra newSecondaryColor = ColorBgra.FromBgra(lastSecondaryColor.B, lastSecondaryColor.G, lastSecondaryColor.R, (byte)alphaGradientControl.Value);
- this.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;
- HsvColor 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()
- {
- ++this.ignoreChangedEvents;
- }
- private void PopIgnoreChangedEvents()
- {
- --this.ignoreChangedEvents;
- }
- private void MoreLessButton_Click(object sender, System.EventArgs e)
- {
- OnRelinquishFocus();
- this.SuspendLayout();
- if (this.moreLessButton.Text.Equals(this.moreText))
- this.inMoreState = false;
- if (this.inMoreState)
- {
- this.inMoreState = false;
- Size newSize = lessSize;
- this.moreLessButton.Text = this.moreText;
- int heightDelta = (moreModeHeaderSentinel.Height - lessModeHeaderSentinel.Height);
- newSize.Height -= heightDelta;
- newSize.Height -= SystemLayer.UI.ScaleHeight(18);
- this.ClientSize = newSize;
- }
- else
- {
- this.inMoreState = true;
- this.moreLessButton.Text = this.lessText;
- this.ClientSize = moreSize;
- }
- this.swatchControl.Height = this.ClientSize.Height - SystemLayer.UI.ScaleHeight(4) - this.swatchControl.Top;
- this.ResumeLayout(false);
- }
- private void ColorAddButton_Click(object sender, EventArgs e)
- {
- if (this.colorAddButton.Checked)
- {
- this.colorAddButton.Checked = false;
- this.swatchControl.BlinkHighlight = false;
- }
- else
- {
- this.colorAddButton.Checked = true;
- this.swatchControl.BlinkHighlight = true;
- }
- }
- private ColorBgra GetColorFromUpDowns()
- {
- int r = (int)this.redUpDown.Value;
- int g = (int)this.greenUpDown.Value;
- int b = (int)this.blueUpDown.Value;
- int a = (int)this.alphaUpDown.Value;
- return ColorBgra.FromBgra((byte)b, (byte)g, (byte)r, (byte)a);
- }
- private void SwatchControl_ColorClicked(object sender, EventArgs<Pair<int, MouseButtons>> e)
- {
- List<ColorBgra> colors = new List<ColorBgra>(this.swatchControl.Colors);
- if (this.colorAddButton.Checked)
- {
- colors[e.Data.First] = GetColorFromUpDowns();
- this.swatchControl.Colors = colors.ToArray();
- this.colorAddButton.Checked = false;
- this.swatchControl.BlinkHighlight = false;
- }
- else
- {
- ColorBgra color = colors[e.Data.First];
- if (e.Data.Second == MouseButtons.Right)
- {
- SetUserColors(UserPrimaryColor, color);
- }
- else
- {
- switch (this.WhichUserColor)
- {
- case WhichUserColor.Primary:
- this.UserPrimaryColor = color;
- break;
- case WhichUserColor.Secondary:
- this.UserSecondaryColor = color;
- break;
- default:
- throw new InvalidEnumArgumentException();
- }
- }
- }
- OnRelinquishFocus();
- }
- private void ColorPalettesButton_Click(object sender, EventArgs e)
- {
- this.colorPalettesButton.ShowDropDown();
- }
- private void ColorPalettesButton_DropDownOpening(object sender, EventArgs e)
- {
- this.colorPalettesButton.DropDownItems.Clear();
- if (this.paletteCollection != null)
- {
- using (new WaitCursorChanger(this))
- {
- this.paletteCollection.Load();
- }
- string[] paletteNames = this.paletteCollection.PaletteNames;
- foreach (string paletteName in paletteNames)
- {
- this.colorPalettesButton.DropDownItems.Add(
- paletteName,
- PdnResources.GetImageResource("Icons.SwatchIcon.png").Reference,
- OnPaletteClickedHandler);
- }
- if (paletteNames.Length > 0)
- {
- this.colorPalettesButton.DropDownItems.Add(new ToolStripSeparator());
- }
- }
- this.colorPalettesButton.DropDownItems.Add(
- PdnResources.GetString("ColorsForm.ColorPalettesButton.SaveCurrentPaletteAs.Text"),
- PdnResources.GetImageResource("Icons.SavePaletteIcon.png").Reference,
- OnSavePaletteAsHandler);
- this.colorPalettesButton.DropDownItems.Add(
- PdnResources.GetString("ColorsForm.ColorPalettesButton.OpenPalettesFolder.Text"),
- PdnResources.GetImageResource("Icons.ColorPalettes.png").Reference,
- OnOpenPalettesFolderClickedHandler);
- this.colorPalettesButton.DropDownItems.Add(new ToolStripSeparator());
- this.colorPalettesButton.DropDownItems.Add(
- PdnResources.GetString("ColorsForm.ColorPalettesButton.ResetToDefaultPalette.Text"),
- null,
- OnResetPaletteHandler);
- }
- private void OnSavePaletteAsHandler(object sender, EventArgs e)
- {
- /*using (SavePaletteDialog spd = new SavePaletteDialog())
- {
- spd.PaletteNames = this.paletteCollection.PaletteNames;
- spd.ShowDialog(this);
- if (spd.DialogResult == DialogResult.OK)
- {
- this.paletteCollection.AddOrUpdate(spd.PaletteName, this.swatchControl.Colors);
- using (new WaitCursorChanger(this))
- {
- this.paletteCollection.Save();
- }
- }
- }*/
- }
- private void OnResetPaletteHandler(object sender, EventArgs e)
- {
- this.swatchControl.Colors = PaletteCollection.DefaultPalette;
- }
- private void OnPaletteClickedHandler(object sender, EventArgs e)
- {
- ToolStripItem tsi = sender as ToolStripItem;
- if (tsi != null)
- {
- ColorBgra[] palette = this.paletteCollection.Get(tsi.Text);
- if (palette != null)
- {
- this.swatchControl.Colors = palette;
- }
- }
- }
- private void SwatchControl_ColorsChanged(object sender, EventArgs e)
- {
- string paletteString = PaletteCollection.GetPaletteSaveString(this.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());
- }
- }
- public ComboBox getWhichUserColorBox()
- {
- return this.whichUserColorBox;
- }
- public void setSaveBtn_Click(System.EventHandler saveBtn_Click)
- {
- this.saveBtn.Click += saveBtn_Click;
- }
- }
- }
|