private void CreateColorControl(ControlBase parent, string name) { GroupBox colorGroup = new GroupBox(parent); colorGroup.Text = name; colorGroup.Name = name + "groupbox"; DockLayout layout = new DockLayout(colorGroup); ColorDisplay disp = new ColorDisplay(layout); disp.Height = Util.Ignore; disp.Dock = Dock.Left; disp.Name = name; TextBoxNumeric numeric = new TextBoxNumeric(layout); numeric.Dock = Dock.Right; numeric.FitToText = "000"; numeric.Name = name + "Box"; numeric.SelectAllOnFocus = true; numeric.TextChanged += NumericTyped; HorizontalSlider slider = new HorizontalSlider(layout); slider.Dock = Dock.Fill; slider.VerticalAlignment = VerticalAlignment.Center; slider.SetRange(0, 255); slider.Name = name + "Slider"; slider.ValueChanged += SlidersMoved; }
private void UpdateColorControls(string name, Color col, int sliderVal) { ColorDisplay disp = FindChildByName(name, true) as ColorDisplay; disp.Color = col; HorizontalSlider slider = FindChildByName(name + "Slider", true) as HorizontalSlider; slider.Value = sliderVal; TextBoxNumeric box = FindChildByName(name + "Box", true) as TextBoxNumeric; box.Value = sliderVal; }
private void NumericTyped(ControlBase control, EventArgs args) { TextBoxNumeric box = control as TextBoxNumeric; if (null == box) { return; } if (box.Text == string.Empty) { return; } int textValue = (int)box.Value; if (textValue < 0) { textValue = 0; } if (textValue > 255) { textValue = 255; } if (box.Name.Contains("Red")) { R = textValue; } if (box.Name.Contains("Green")) { G = textValue; } if (box.Name.Contains("Blue")) { B = textValue; } if (box.Name.Contains("Alpha")) { A = textValue; } UpdateControls(); }