/// <summary> /// Changes the color of a numbered fan's power status led on main panel. /// </summary> /// <param name="fan">Fan to change LED of.</param> /// <param name="ledColor">Color to change LED to.</param> private void UpdateFanLED(Fan fan, LEDColors ledColor) { PictureBox ledPictureBox = null; Debug.Assert(fan != null); //Lookup the LED WinForm picture box to redraw. switch (fan.Number) { case 1: ledPictureBox = pictureBoxFan1LED; break; case 2: ledPictureBox = pictureBoxFan2LED; break; case 3: ledPictureBox = pictureBoxFan3LED; break; default: throw new ArgumentOutOfRangeException("Fan fan", string.Format("Invalid Fan Number. Found: {0}", fan.Number)); } //Redraw the the LED image for the fan. Debug.Assert(ledPictureBox != null); LEDHelper.ChangeColor(ledPictureBox, ledColor); }
/// <summary> /// Changes the color of an LED PictureBox. /// </summary> /// <param name="ledPictureBox">WinFom LED PictureBox to change.</param> /// <param name="ledColor">Color to set LED to.</param> internal static void ChangeColor(PictureBox ledPictureBox, LEDColors ledColor) { string resourceUrl = string.Empty; //Parameter Validations. if (ledPictureBox == null) throw new ArgumentNullException("PictureBox ledPictureBox"); //Switch on the color and update the image. switch(ledColor) { case LEDColors.Green: resourceUrl = @"..\..\Resources\GreenLED_25x25.png"; break; case LEDColors.Yellow: resourceUrl = @"..\..\Resources\YellowLED_25x25.png"; break; case LEDColors.Red: resourceUrl = @"..\..\Resources\RedLED_25x25.png"; break; default: throw new ArgumentOutOfRangeException("LEDColors ledColor", string.Format("Unsupported Color. Color: {0}", ledColor.ToString())); } //Attempt to load it. Debug.Assert(string.IsNullOrEmpty(resourceUrl) == false); ledPictureBox.Load(resourceUrl); }
/// <summary> /// Changes the color of an LED PictureBox. /// </summary> /// <param name="ledPictureBox">WinFom LED PictureBox to change.</param> /// <param name="ledColor">Color to set LED to.</param> internal static void ChangeColor(PictureBox ledPictureBox, LEDColors ledColor) { string resourceUrl = string.Empty; //Parameter Validations. if (ledPictureBox == null) { throw new ArgumentNullException("PictureBox ledPictureBox"); } //Switch on the color and update the image. switch (ledColor) { case LEDColors.Green: resourceUrl = @"..\..\Resources\GreenLED_25x25.png"; break; case LEDColors.Yellow: resourceUrl = @"..\..\Resources\YellowLED_25x25.png"; break; case LEDColors.Red: resourceUrl = @"..\..\Resources\RedLED_25x25.png"; break; default: throw new ArgumentOutOfRangeException("LEDColors ledColor", string.Format("Unsupported Color. Color: {0}", ledColor.ToString())); } //Attempt to load it. Debug.Assert(string.IsNullOrEmpty(resourceUrl) == false); ledPictureBox.Load(resourceUrl); }
/// <summary> /// array of LEDs with numeric color values /// </summary> /// <param name="clearDirty">reset dirty flag</param> internal int[] GetColors(bool clearDirty = false) { if (clearDirty) { IsDirty = false; } return(LEDColors.Select(x => x.RGBValue).ToArray()); }
/// <summary> /// Changes the color of the primary status LED in the lower-right corner. /// </summary> /// <param name="ledColor">Color to change LED to.</param> private void UpdateStatusLED(LEDColors ledColor) { if (this.InvokeRequired == true) { Invoke(new Action(() => { LEDHelper.ChangeColor(pictureBoxStatusLED, ledColor); })); } else { LEDHelper.ChangeColor(pictureBoxStatusLED, ledColor); } }
/// <summary> /// Changes the color of the primary status LED in the lower-right corner. /// </summary> /// <param name="ledColor">Color to change LED to.</param> private void UpdateStatusLED(LEDColors ledColor) { if (this.InvokeRequired == true) Invoke(new Action(() => { LEDHelper.ChangeColor(pictureBoxStatusLED, ledColor); })); else LEDHelper.ChangeColor(pictureBoxStatusLED, ledColor); }
/// <summary> /// Changes the color of a numbered fan's power status led on main panel. /// </summary> /// <param name="fan">Fan to change LED of.</param> /// <param name="ledColor">Color to change LED to.</param> private void UpdateFanLED(Fan fan, LEDColors ledColor) { PictureBox ledPictureBox = null; Debug.Assert(fan != null); //Lookup the LED WinForm picture box to redraw. switch(fan.Number) { case 1: ledPictureBox = pictureBoxFan1LED; break; case 2: ledPictureBox = pictureBoxFan2LED; break; case 3: ledPictureBox = pictureBoxFan3LED; break; default: throw new ArgumentOutOfRangeException("Fan fan", string.Format("Invalid Fan Number. Found: {0}", fan.Number)); } //Redraw the the LED image for the fan. Debug.Assert(ledPictureBox != null); LEDHelper.ChangeColor(ledPictureBox, ledColor); }
/// <summary> /// Turn off all the LEDs in the strip /// </summary> public void Reset() { LEDColors.ForEach(led => led.Color = Color.Empty); IsDirty = true; }
/// <summary> /// Set all the LEDs in the strip to same color /// </summary> /// <param name="color">color to set all the LEDs</param> public void SetAll(Color color) { LEDColors.ForEach(led => led.Color = color); IsDirty = true; }
internal int[] GetColors() { return(LEDColors.Select(x => x.RGBValue).ToArray()); }
public void Reset() { LEDColors.ForEach(led => led.Color = Color.Empty); }
public void SetAll(Color color) { LEDColors.ForEach(led => led.Color = color); }