/// <summary> /// Normalize the Key Color channels /// /// For Single Color LEDs, sets the Green and Blue channels to the same as the Red channel. /// /// Otherwise, for RGB LEDs, just returns the supplied Key Color /// </summary> /// <param name="keyColor">The Key Color to normalize</param> /// <returns>Normalized Key Color</returns> private Sharp_SDK.KEY_COLOR NormalizeColors(Sharp_SDK.KEY_COLOR keyColor) { int selectedIndex = cbDeviceSelect.SelectedIndex; Sharp_SDK.DEVICE_INDEX selectedDevice = (Sharp_SDK.DEVICE_INDEX)selectedIndex; return(NormalizeColors(keyColor, selectedDevice)); }
/// <summary> /// Update the Key Color text-boxes with the new values based on the selected Key Row and Column /// </summary> private void UpdateSelectedLEDColor() { int row = 0; // Default to 0 int column = 0; // Default to 0 if (initialized == true) { // Only update the Key Color text-boxes if the window has actually been initialized and loaded if (cbLEDRow != null && cbLEDColumn != null) { // Only update the LED row & column index when both the LED Row & Column Combo boxes has been loaded row = cbLEDRow.SelectedIndex; column = cbLEDColumn.SelectedIndex; } // Get the current Key Color from the currently selected Key row and column Sharp_SDK.KEY_COLOR keyColor = this.deviceSettings.ColorMatrix.KeyColor[row][column]; // Normalize the color in-case of Single Color LED device keyColor = NormalizeColors(keyColor); // Update the Key LED Color Picker value System.Windows.Media.Color currColor = (System.Windows.Media.Color)clrPickerLED.SelectedColor; currColor.R = keyColor.r; currColor.G = keyColor.g; currColor.B = keyColor.b; clrPickerLED.SelectedColor = currColor; } }
/// <summary> /// Normalize the Key Color channels /// /// For Single Color LEDs, sets the Green and Blue channels to the same as the Red channel. /// /// Otherwise, for RGB LEDs, just returns the supplied Key Color /// </summary> /// <param name="keyColor">The Key Color to normalize</param> /// <param name="selectedDevice">The device to check against (if is Single Color LEDs or RGB LEDs)</param> /// <returns>Normalized Key Color</returns> private Sharp_SDK.KEY_COLOR NormalizeColors(Sharp_SDK.KEY_COLOR keyColor, Sharp_SDK.DEVICE_INDEX selectedDevice) { if (IsSingleColorLed(selectedDevice)) { // Set the other channels to the same as the Red channel keyColor.g = keyColor.r; // Green channel keyColor.b = keyColor.r; // Blue channel } return(keyColor); }
// Set the color for a single key private void ButtonSetSingleKeyColor_Click(object sender, RoutedEventArgs e) { // Setting the current color for a single key (only available when LED Control is enabled) int keyRowIndex = cbLEDRow.SelectedIndex; int keyColumnIndex = cbLEDColumn.SelectedIndex; Sharp_SDK.KEY_COLOR keyColor = this.deviceSettings.ColorMatrix.KeyColor[keyRowIndex][keyColumnIndex]; keyColor = NormalizeColors(keyColor); Sharp_SDK.SDK.SetLedColor(keyRowIndex, keyColumnIndex, keyColor.r, keyColor.g, keyColor.b); }
/// <summary> /// Update the Key Color for all keys with the value a new value /// </summary> private void UpdateAllLEDColor() { Sharp_SDK.KEY_COLOR keyColorAll = this.deviceSettings.KeyColorAll; Sharp_SDK.KEY_COLOR keyColor = UpdateAllLEDColor(keyColorAll, keyColorAll.r, keyColorAll.g, keyColorAll.b); // Update the LED Color Picker value System.Windows.Media.Color currColor = (System.Windows.Media.Color)clrPickerLED_All.SelectedColor; currColor.R = keyColor.r; currColor.G = keyColor.g; currColor.B = keyColor.b; clrPickerLED_All.SelectedColor = currColor; }
/// <summary> /// Update the Key Color for all keys with the value a new value /// </summary> /// <param name="keyColor">The Key Color to update the values from</param> /// <param name="redColor">Color value for Red channel</param> /// <param name="greenColor">Color value for Green channel</param> /// <param name="blueColor">Color value for Blue channel</param> private Sharp_SDK.KEY_COLOR UpdateAllLEDColor(Sharp_SDK.KEY_COLOR keyColor, byte redColor, byte greenColor, byte blueColor) { // Update the Key Color with the new values keyColor.r = redColor; // Update the red channel keyColor.g = greenColor; // Update the green channel keyColor.b = blueColor; // Update the red channel // Normalize the colors in-case of a non-RGB LED device keyColor = NormalizeColors(keyColor); // Set the Key Color for all keys with the new Key Color this.deviceSettings.KeyColorAll = keyColor; return(keyColor); }
// Set all the keys to the same color private void ButtonSetFullKeyColor_Click(object sender, RoutedEventArgs e) { // Setting the same color for all the each keys (only available when LED Control is enabled) byte redColor = this.deviceSettings.KeyColorAll.r; byte greenColor = this.deviceSettings.KeyColorAll.g; byte blueColor = this.deviceSettings.KeyColorAll.b; Sharp_SDK.KEY_COLOR keyColor = new Sharp_SDK.KEY_COLOR(redColor, greenColor, blueColor); keyColor = NormalizeColors(keyColor); var success = Sharp_SDK.SDK.SetFullLedColor(keyColor.r, keyColor.g, keyColor.b); if (success == false) { MessageBox.Show("SetFullLedColor Failed!"); } }
private void SetKeyColorMatrix(Sharp_SDK.DEVICE_INDEX deviceIndex) { // Setting the current colors set for each keys (only available when LED Control is enabled) //Sharp_SDK.SDK.SetAllLedColor(colorMatrix); Sharp_SDK.COLOR_MATRIX colorMatrix = this.deviceSettings.ColorMatrix; Sharp_SDK.KEY_COLOR[][] keyColors = colorMatrix.KeyColor; for (int i = 0; i < keyColors.Length; i++) { for (int j = 0; j < keyColors[i].Length; j++) { Sharp_SDK.KEY_COLOR keyColor = colorMatrix.KeyColor[i][j]; keyColor = NormalizeColors(keyColor, deviceIndex); Sharp_SDK.SDK.SetLedColor(i, j, keyColor.r, keyColor.g, keyColor.b); } } }
private void ColorPickerLED_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs <System.Windows.Media.Color?> e) { if (this.IsInitialized == true) { System.Windows.Media.Color currColor = clrPickerLED.SelectedColor.Value; bool isSingleColor = IsSingleColorLed(this.deviceSettings.SelectedDevice); if (isSingleColor) { currColor.G = currColor.R; currColor.B = currColor.R; currColor.A = 128; clrPickerLED.SelectedColor = currColor; } Sharp_SDK.KEY_COLOR keyColor = SetCurrentKeyColor(currColor.R, currColor.G, currColor.B); } }
private Sharp_SDK.KEY_COLOR SetCurrentKeyColor(byte redColor, byte greenColor, byte blueColor) { // Get the currently selected key row and column int row = cbLEDRow.SelectedIndex; int column = cbLEDColumn.SelectedIndex; // Get the current Key color of the selected key Sharp_SDK.KEY_COLOR keyColor = this.deviceSettings.ColorMatrix.KeyColor[row][column]; // Update the Key Color with the new values keyColor.r = redColor; // Update the red channel keyColor.g = greenColor; // Update the green channel keyColor.b = blueColor; // Update the blue channel // Normalize the colors in-case of a non-RGB LED device keyColor = NormalizeColors(keyColor); // Set the Color of the key with the new Key Color this.deviceSettings.ColorMatrix.KeyColor[row][column] = keyColor; return(keyColor); }