private void faderTrack_ValueChanged(object sender, EventArgs e) { if (!colourUpdating) { PaintDotNet.HsvColor newHsv = new PaintDotNet.HsvColor(); newHsv.Value = faderTrack.Value; newHsv.Hue = colorWheel1.HsvColor.Hue; newHsv.Saturation = colorWheel1.HsvColor.Saturation; updateSetColour(newHsv.ToRgb().Red, newHsv.ToRgb().Green, newHsv.ToRgb().Blue, faderTrack.Value); } }
// Updates all controls with the supplied colour public void updateSetColour(int red, int green, int blue, int faderVal) { if (!BroadcastUpdatingFlag) { PaintDotNet.HsvColor newHsv = new PaintDotNet.HsvColor(); PaintDotNet.RgbColor newRgb = new PaintDotNet.RgbColor(); // Set a global flag to inidcate to all controls we are updating there values so they // dont fire try and update other controls in turn colourUpdating = true; lblColourSelectorRgb.Text = red.ToString() + "," + green.ToString() + "," + blue.ToString(); RedTrack.Value = red; GreenTrack.Value = green; BlueTrack.Value = blue; faderTrack.Value = faderVal; newRgb.Red = red; newRgb.Green = green; newRgb.Blue = blue; newHsv = newRgb.ToHsv(); newHsv.Value = faderTrack.Value; lblColourSelectorHsv.Text = newHsv.Hue.ToString() + "," + newHsv.Saturation.ToString() + "," + newHsv.Value.ToString(); colorWheel1.HsvColor = newHsv; if (optAddjustTop.Checked) { try { lblTopRGB.Text = red.ToString() + "," + green.ToString() + "," + blue.ToString(); panelTopRGB.BackColor = Color.FromArgb(red, green, blue); } catch (Exception) { } } else if (optAddjustBottom.Checked) { try { lblBottomRGB.Text = red.ToString() + "," + green.ToString() + "," + blue.ToString(); panelBottomRGB.BackColor = Color.FromArgb(red, green, blue); } catch (Exception) { } } // Send the message if auto send is ticked if (chkAutoSend.Checked) { butSend_Click(null, null); } colourUpdating = false; } }