public ColorPickerPopup() : base(Settings.Config.ColorPickerSettings.WindowWidth, Settings.Config.ColorPickerSettings.WindowHeight) { Center(); otherColorPopup = new OtherColorsPopup(); otherColorPopup.Closed += (sender2, e2) => { if (otherColorPopup.DialogResult) { _barR.SelectedColor = otherColorPopup.SelectedColor.RedOnly(); _barG.SelectedColor = otherColorPopup.SelectedColor.GreenOnly(); _barB.SelectedColor = otherColorPopup.SelectedColor.BlueOnly(); _alphaInput.Text = otherColorPopup.SelectedColor.A.ToString(); } }; _picker = new Controls.ColorPicker(textSurface.Width - RideSideX - 1, textSurface.Height - 11, Color.YellowGreen) { Position = new Point(1, 1) }; _picker.SelectedColorChanged += _picker_SelectedColorChanged; Add(_picker); #region TextBoxes _redInput = new InputBox(5); _redInput.IsNumeric = true; _redInput.MaxLength = 3; _redInput.Position = new Point(textSurface.Width - 7, textSurface.Height - 14); _redInput.TextChanged += (sender, e) => { _barR.SelectedColor = new Color(int.Parse(_redInput.Text), 0, 0); }; Add(_redInput); _greenInput = new InputBox(5); _greenInput.IsNumeric = true; _greenInput.MaxLength = 3; _greenInput.Position = new Point(textSurface.Width - 7, textSurface.Height - 13); _greenInput.TextChanged += (sender, e) => { _barG.SelectedColor = new Color(0, int.Parse(_greenInput.Text), 0); }; Add(_greenInput); _blueInput = new InputBox(5); _blueInput.IsNumeric = true; _blueInput.MaxLength = 3; _blueInput.Position = new Point(textSurface.Width - 7, textSurface.Height - 12); _blueInput.TextChanged += (sender, e) => { _barB.SelectedColor = new Color(0, 0, int.Parse(_blueInput.Text)); }; Add(_blueInput); _alphaInput = new InputBox(5); _alphaInput.IsNumeric = true; _alphaInput.MaxLength = 3; _alphaInput.Position = new Point(textSurface.Width - 7, textSurface.Height - 11); _alphaInput.Text = "255"; Add(_alphaInput); #endregion #region Bars _barH = new HueBar(base.TextSurface.RenderArea.Width - 2); _barH.Position = new Point(1, textSurface.Height - 9); _barH.ColorChanged += _barH_ColorChanged; Add(_barH); _barR = new ColorBar(base.TextSurface.RenderArea.Width - 2); _barR.StartingColor = Color.Black; _barR.EndingColor = Color.Red; _barR.Position = new Point(1, textSurface.Height - 7); _barR.ColorChanged += bar_ColorChanged; Add(_barR); _barG = new ColorBar(base.TextSurface.RenderArea.Width - 2); _barG.StartingColor = Color.Black; _barG.EndingColor = new Color(0, 255, 0); _barG.Position = new Point(1, textSurface.Height - 5); _barG.ColorChanged += bar_ColorChanged; Add(_barG); _barB = new ColorBar(base.TextSurface.RenderArea.Width - 2); _barB.StartingColor = Color.Black; _barB.EndingColor = Color.Blue; _barB.Position = new Point(1, textSurface.Height - 3); _barB.ColorChanged += bar_ColorChanged; Add(_barB); _selectedColor = _picker.SelectedColor; _barH.SelectedColor = _selectedColor; #endregion #region Buttons _okButton = new Button(RideSideX - 4, 1); _okButton.Text = "OK"; _okButton.Position = new Point(textSurface.Width - RideSideX + 2, textSurface.Height - 18); _okButton.ButtonClicked += (sender, r) => { this.DialogResult = true; _selectedColor.A = byte.Parse(_alphaInput.Text); AddPreviousColor(SelectedColor); Hide(); }; Add(_okButton); _cancelButton = new Button(RideSideX - 4, 1); _cancelButton.Text = "Cancel"; _cancelButton.Position = new Point(textSurface.Width - RideSideX + 2, textSurface.Height - 16); _cancelButton.ButtonClicked += (sender, r) => { this.DialogResult = false; Hide(); }; Add(_cancelButton); _otherColorsButton = new Button(RideSideX - 4, 1); _otherColorsButton.Text = "Other Colors"; _otherColorsButton.Position = new Point(textSurface.Width - RideSideX + 2, textSurface.Height - 20); _otherColorsButton.ButtonClicked += (sender, e) => { otherColorPopup.Show(true); }; Add(_otherColorsButton); #endregion _previousColors = new ListBox<ListBoxItemColor>(RideSideX - 4, textSurface.Height - 20 - 9 + 1); _previousColors.Position = new Point(textSurface.Width - RideSideX + 2, 8); _previousColors.SelectedItemChanged += (sender, e) => { if (_previousColors.SelectedItem != null) SelectedColor = (Color)_previousColors.SelectedItem; }; Add(_previousColors); this.CloseOnESC = true; this.Title = "Select Color"; }
public ColorPickerPopup() : base(Settings.Config.ColorPickerSettings.WindowWidth, Settings.Config.ColorPickerSettings.WindowHeight) { Center(); otherColorPopup = new OtherColorsPopup(); otherColorPopup.Closed += (sender2, e2) => { if (otherColorPopup.DialogResult) { _barR.SelectedColor = otherColorPopup.SelectedColor.RedOnly(); _barG.SelectedColor = otherColorPopup.SelectedColor.GreenOnly(); _barB.SelectedColor = otherColorPopup.SelectedColor.BlueOnly(); _alphaInput.Text = otherColorPopup.SelectedColor.A.ToString(); } }; _picker = new Controls.ColorPicker(TextSurface.Width - RideSideX - 1, TextSurface.Height - 11, Color.YellowGreen) { Position = new Point(1, 1) }; _picker.SelectedColorChanged += _picker_SelectedColorChanged; Add(_picker); #region TextBoxes _redInput = new InputBox(5); _redInput.IsNumeric = true; _redInput.MaxLength = 3; _redInput.Position = new Point(TextSurface.Width - 7, TextSurface.Height - 14); _redInput.TextChanged += (sender, e) => { _barR.SelectedColor = new Color(int.Parse(_redInput.Text), 0, 0); }; Add(_redInput); _greenInput = new InputBox(5); _greenInput.IsNumeric = true; _greenInput.MaxLength = 3; _greenInput.Position = new Point(TextSurface.Width - 7, TextSurface.Height - 13); _greenInput.TextChanged += (sender, e) => { _barG.SelectedColor = new Color(0, int.Parse(_greenInput.Text), 0); }; Add(_greenInput); _blueInput = new InputBox(5); _blueInput.IsNumeric = true; _blueInput.MaxLength = 3; _blueInput.Position = new Point(TextSurface.Width - 7, TextSurface.Height - 12); _blueInput.TextChanged += (sender, e) => { _barB.SelectedColor = new Color(0, 0, int.Parse(_blueInput.Text)); }; Add(_blueInput); _alphaInput = new InputBox(5); _alphaInput.IsNumeric = true; _alphaInput.MaxLength = 3; _alphaInput.Position = new Point(TextSurface.Width - 7, TextSurface.Height - 11); _alphaInput.Text = "255"; Add(_alphaInput); #endregion #region Bars _barH = new HueBar(base.TextSurface.RenderArea.Width - 2); _barH.Position = new Point(1, TextSurface.Height - 9); _barH.ColorChanged += _barH_ColorChanged; Add(_barH); _barR = new ColorBar(base.TextSurface.RenderArea.Width - 2); _barR.StartingColor = Color.Black; _barR.EndingColor = Color.Red; _barR.Position = new Point(1, TextSurface.Height - 7); _barR.ColorChanged += bar_ColorChanged; Add(_barR); _barG = new ColorBar(base.TextSurface.RenderArea.Width - 2); _barG.StartingColor = Color.Black; _barG.EndingColor = new Color(0, 255, 0); _barG.Position = new Point(1, TextSurface.Height - 5); _barG.ColorChanged += bar_ColorChanged; Add(_barG); _barB = new ColorBar(base.TextSurface.RenderArea.Width - 2); _barB.StartingColor = Color.Black; _barB.EndingColor = Color.Blue; _barB.Position = new Point(1, TextSurface.Height - 3); _barB.ColorChanged += bar_ColorChanged; Add(_barB); _selectedColor = _picker.SelectedColor; _barH.SelectedColor = _selectedColor; #endregion #region Buttons _okButton = new Button(RideSideX - 4); _okButton.Text = "OK"; _okButton.Position = new Point(TextSurface.Width - RideSideX + 2, TextSurface.Height - 18); _okButton.Click += (sender, r) => { this.DialogResult = true; _selectedColor.A = byte.Parse(_alphaInput.Text); AddPreviousColor(SelectedColor); Hide(); }; Add(_okButton); _cancelButton = new Button(RideSideX - 4); _cancelButton.Text = "Cancel"; _cancelButton.Position = new Point(TextSurface.Width - RideSideX + 2, TextSurface.Height - 16); _cancelButton.Click += (sender, r) => { this.DialogResult = false; Hide(); }; Add(_cancelButton); _otherColorsButton = new Button(RideSideX - 4); _otherColorsButton.Text = "Other Colors"; _otherColorsButton.Position = new Point(TextSurface.Width - RideSideX + 2, TextSurface.Height - 20); _otherColorsButton.Click += (sender, e) => { otherColorPopup.Show(true); }; Add(_otherColorsButton); #endregion _previousColors = new ListBox <ListBoxItemColor>(RideSideX - 4, TextSurface.Height - 20 - 9 + 1); _previousColors.Position = new Point(TextSurface.Width - RideSideX + 2, 8); _previousColors.SelectedItemChanged += (sender, e) => { if (_previousColors.SelectedItem != null) { SelectedColor = (Color)_previousColors.SelectedItem; } }; Add(_previousColors); this.CloseOnESC = true; this.Title = "Select Color"; }