private void UpdateControls(Color color) { // What in the F**K TextBoxNumeric redBox = FindChildByName("RedBox", false) as TextBoxNumeric; if (redBox != null) { redBox.SetText(color.R.ToString(), false); } TextBoxNumeric greenBox = FindChildByName("GreenBox", false) as TextBoxNumeric; if (greenBox != null) { greenBox.SetText(color.G.ToString(), false); } TextBoxNumeric blueBox = FindChildByName("BlueBox", false) as TextBoxNumeric; if (blueBox != null) { blueBox.SetText(color.B.ToString(), false); } m_After.Color = color; if (ColorChanged != null) { ColorChanged.Invoke(this); } }
private void OnColorChange() { if(ColorChanged != null) { ColorChanged.Invoke(); } }
private void updateControls(Color color) { // [???] TODO: Make this code safer. // [halfofastaple] This code SHOULD (in theory) never crash/not work as intended, but referencing children by their name is unsafe. // Instead, a direct reference to their objects should be maintained. Worst case scenario, we grab the wrong "RedBox". TextBoxNumeric redBox = FindChildByName("RedBox", false) as TextBoxNumeric; if (redBox != null) { redBox.SetText(color.R.ToString(), false); } TextBoxNumeric greenBox = FindChildByName("GreenBox", false) as TextBoxNumeric; if (greenBox != null) { greenBox.SetText(color.G.ToString(), false); } TextBoxNumeric blueBox = FindChildByName("BlueBox", false) as TextBoxNumeric; if (blueBox != null) { blueBox.SetText(color.B.ToString(), false); } after.Color = color; if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Handler invoked on mouse moved event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="dx">X change.</param> /// <param name="dy">Y change.</param> protected override void OnMouseMoved(int x, int y, int dx, int dy) { if (m_Depressed) { m_CursorPos = CanvasPosToLocal(new Vector2i(x, y)); //Do we have clamp? if (m_CursorPos.X < 0) { m_CursorPos.X = 0; } if (m_CursorPos.X > Width) { m_CursorPos.X = Width; } if (m_CursorPos.Y < 0) { m_CursorPos.Y = 0; } if (m_CursorPos.Y > Height) { m_CursorPos.Y = Height; } if (ColorChanged != null) { ColorChanged.Invoke(this); } } }
/// <summary> /// Handler invoked on mouse moved event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="dx">X change.</param> /// <param name="dy">Y change.</param> protected override void onMouseMoved(int x, int y, int dx, int dy) { if (depressed) { cursorPos = CanvasPosToLocal(new Point(x, y)); //Do we have clamp? if (cursorPos.X < 0) { cursorPos.X = 0; } if (cursorPos.X > Width) { cursorPos.X = Width; } if (cursorPos.Y < 0) { cursorPos.Y = 0; } if (cursorPos.Y > Height) { cursorPos.Y = Height; } if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } } }
private void UpdateColorByHsvValues() { var color = Color.HSVToRGB(_hValue, _sValue, _vValue); if (_colorPreview != null) { _colorPreview.color = color; } if (_colorCodeFierd != null) { _colorCodeFierd.text = ColorToHex(color); } if (_sSliderBackground != null) { _sSliderBackground.material.SetFloat(_vShaderId, _vValue); } if (_vSliderBackground != null) { _vSliderBackground.material.SetFloat(_sShaderId, _sValue); } CurrentColor = color; if (ColorChanged != null) { ColorChanged.Invoke(color); } }
private void ColorBoxChanged(ControlBase control, EventArgs args) { UpdateControls(SelectedColor); //Invalidate(); if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
private void ColorSliderChanged(ControlBase control, EventArgs args) { m_LerpBox.SetColor(m_ColorSlider.SelectedColor, true, false); UpdateControls(SelectedColor); //Invalidate(); if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
public void SetColor(Color color, bool doEvents = true) { HSV hsv = color.ToHSV(); m_SelectedDist = (int)(hsv.H / 360 * ActualHeight); if (doEvents && ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
private void SetColor(Color color) { HSV hsv = color.ToHSV(); m_SelectedDist = (int)(hsv.h / 360 * Height); if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
private void UpdateControls() { //This is a little weird, but whatever for now UpdateColorControls("Red", Color.FromArgb(255, SelectedColor.R, 0, 0), SelectedColor.R); UpdateColorControls("Green", Color.FromArgb(255, 0, SelectedColor.G, 0), SelectedColor.G); UpdateColorControls("Blue", Color.FromArgb(255, 0, 0, SelectedColor.B), SelectedColor.B); UpdateColorControls("Alpha", Color.FromArgb(SelectedColor.A, 255, 255, 255), SelectedColor.A); ColorDisplay disp = FindChildByName("Result", true) as ColorDisplay; disp.Color = SelectedColor; if (ColorChanged != null) { ColorChanged.Invoke(this); } }
private void NumericTyped(ControlBase control, EventArgs args) { NumericUpDown box = control as NumericUpDown; if (box == null) { return; } int value = (int)box.Value; if (value < 0) { value = 0; } if (value > 255) { value = 255; } Color newColor = SelectedColor; if (box == m_Red) { newColor = new Color(SelectedColor.A, value, SelectedColor.G, SelectedColor.B); } else if (box == m_Green) { newColor = new Color(SelectedColor.A, SelectedColor.R, value, SelectedColor.B); } else if (box == m_Blue) { newColor = new Color(SelectedColor.A, SelectedColor.R, SelectedColor.G, value); } //else if (box.Name.Contains("Alpha")) // newColor = Color.FromArgb(textValue, SelectedColor.R, SelectedColor.G, SelectedColor.B); m_ColorSlider.SetColor(newColor, false); m_LerpBox.SetColor(newColor, false, false); m_After.Color = newColor; if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Sets the selected color. /// </summary> /// <param name="color">Color to set.</param> /// <param name="onlyHue">Determines whether only the hue should be set.</param> /// <param name="reset">Determines whether the "before" color should be set as well.</param> public void SetColor(Color color, bool onlyHue = false, bool reset = false) { UpdateControls(color); if (reset) { m_Before.Color = color; } m_ColorSlider.SetColor(color, false); m_LerpBox.SetColor(color, onlyHue, false); m_After.Color = color; if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Sets the selected color. /// </summary> /// <param name="value">Value to set.</param> /// <param name="onlyHue">Deetrmines whether to only set H value (not SV).</param> public void SetColor(Color value, bool onlyHue = true, bool doEvents = true) { HSV hsv = value.ToHSV(); m_Hue = hsv.H; if (!onlyHue) { m_CursorPos.X = (int)(hsv.S * ActualWidth); m_CursorPos.Y = (int)((1 - hsv.V) * ActualHeight); } InvalidateTexture(); if (doEvents && ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Sets the selected color. /// </summary> /// <param name="value">Value to set.</param> /// <param name="onlyHue">Deetrmines whether to only set H value (not SV).</param> public void SetColor(Color value, bool onlyHue = true) { HSV hsv = value.ToHSV(); hue = hsv.h; if (!onlyHue) { cursorPos.X = (int)(hsv.s * Width); cursorPos.Y = (int)((1 - hsv.v) * Height); } Invalidate(); if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Sets the selected color. /// </summary> /// <param name="value">Value to set.</param> /// <param name="onlyHue">Deetrmines whether to only set H value (not SV).</param> public void SetColor(Color value, bool onlyHue = true) { var hsv = value.ToHsv(); mHue = hsv.H; if (!onlyHue) { mCursorPos.X = (int)(hsv.s * Width); mCursorPos.Y = (int)((1 - hsv.V) * Height); } Invalidate(); if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }
Button MakeBtn(int i) { Color c = lightColors[i]; var btn = new Button(); btn.BackgroundColor = c; btn.HeightRequest = BTN_SIZE; btn.WidthRequest = BTN_SIZE; btn.CornerRadius = BTN_SIZE / 2; btn.BorderWidth = 2; btn.BorderColor = btn.BackgroundColor; btn.Margin = new Thickness(BTN_SIZE / 4, 0, 0, 0); btn.Clicked += (object sender, EventArgs e) => { Color x = borderColors[i]; byte[] rgb = new byte[] { (byte)(x.R * 255), (byte)(x.G * 255), (byte)(x.B * 255) }; ColorChanged.Invoke(btn, rgb); }; return(btn); }
private void ColorPickerControl_MouseMove(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { int x = 0; int y = 0; if (e.X < 0) { x = 0; } else if (e.X > Height) { x = Height; } else { x = e.X; } if (e.Y < 0) { y = 0; } else if (e.Y > Height) { y = Height; } else { y = e.Y; } //Saturation = x / (float)Height; //Luminisity = (Height-y) / (float)Height; Saturation = x / (float)Height; Value = (Height - y) / (float)Height; Invalidate(); if (ColorChanged != null) { ColorChanged.Invoke(GetSelectedColor()); } } }
/// <summary> /// Interpolates between <see cref="Info.StartColor"/> and <see cref="Info.TargetColor"/> with the specified /// percentage value and invokes the <see cref="Info.ColorChanged"/> callback. /// </summary> /// <param name="percentage">Percentage.</param> public void TweenValue(float percentage) { Color result = Color.Lerp(this.StartColor, this.TargetColor, percentage); switch (this.TweenMode) { case Mode.Alpha: result.r = this.StartColor.r; result.g = this.StartColor.g; result.b = this.StartColor.b; break; case Mode.RGB: result.a = this.StartColor.a; break; } if (ColorChanged != null) { ColorChanged.Invoke(this, result); } }
/// <summary> /// Handler invoked on mouse moved event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="dx">X change.</param> /// <param name="dy">Y change.</param> protected override void OnMouseMoved(int x, int y, int dx, int dy) { if (m_Depressed) { var cursorPos = CanvasPosToLocal(new Vector2i(x, y)); if (cursorPos.Y < 0) { cursorPos.Y = 0; } if (cursorPos.Y > Height) { cursorPos.Y = Height; } m_SelectedDist = cursorPos.Y; if (ColorChanged != null) { ColorChanged.Invoke(this); } } }
/// <summary> /// Handler invoked on mouse moved event. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="dx">X change.</param> /// <param name="dy">Y change.</param> protected override void OnMouseMoved(int x, int y, int dx, int dy) { if (m_Depressed) { Point cursorPos = CanvasPosToLocal(new Point(x, y)); if (cursorPos.Y < 0) { cursorPos.Y = 0; } if (cursorPos.Y > ActualHeight) { cursorPos.Y = ActualHeight; } m_SelectedDist = cursorPos.Y; if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } } }
private void ClickHandler(Object sender, EventArgs e) { SuspendLayout(); MakeLookAsSelected((Panel)sender); selectedcolor = ((Panel)sender).BackColor; selectedpen = new Pen(selectedcolor); foreach (Panel p in ColorPanels) { if (p != sender) { MakeLookAsUnselected(p); } } ResumeLayout(); if (ColorChanged != null) { ColorChanged.Invoke(this, null); } }
private void OnColorChanged() { ColorChanged?.Invoke(this, new EventArgs()); }
public void SendColorChanged() { ColorChanged?.Invoke(this, EventArgs.Empty); }
private void Picture_Click(object sender, EventArgs e) { PictureBox picture = sender as PictureBox; ColorChanged.Invoke(picture.BackColor); }
/// <summary> /// Fires the ColorChanged event. /// </summary> protected virtual void OnColorChanged() { ColorChanged?.Invoke(this, EventArgs.Empty); }
private void Eyedropper_ColorChanged(Eyedropper sender, ColorChangedEventArgs args) { Color = args.NewColor; ColorChanged?.Invoke(this, args); }
/// <summary> /// Called before the <see cref="ColorChanged"/> event occurs. /// </summary> /// <param name="e">The <see cref="ColorChangedEventArgs"/> defining old/new colors.</param> protected virtual void OnColorChanged(ColorChangedEventArgs e) { ColorChanged?.Invoke(this, e); }
private void ColorPicker_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs <Color?> e) { ColorChanged?.Invoke(this, e.NewValue.GetValueOrDefault()); }
private void OnColorChanged(ColorType colorType = ColorType.None) { ColorChanged?.Invoke(this, new ColorEventArgs(SelectedColor, colorType)); }