From c073e721fc335bd467d2fb41b7ebcc7cd1a84dec Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 22 Nov 2017 19:23:23 -0600 Subject: [PATCH] Update custom led color from main Controllers tab Related to issue #153. --- DS4Windows/DS4Control/ScpUtil.cs | 14 +++++++------- DS4Windows/DS4Forms/DS4Form.cs | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index b16d409..084ecd1 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -1297,11 +1297,11 @@ namespace DS4Windows public bool[] useCustomLeds = new bool[5] { false, false, false, false, false }; public DS4Color[] m_CustomLeds = new DS4Color[5] { - new DS4Color(Color.Black), - new DS4Color(Color.Black), - new DS4Color(Color.Black), - new DS4Color(Color.Black), - new DS4Color(Color.Black) + new DS4Color(Color.Blue), + new DS4Color(Color.Blue), + new DS4Color(Color.Blue), + new DS4Color(Color.Blue), + new DS4Color(Color.Blue) }; public int[] chargingType = new int[5] { 0, 0, 0, 0, 0 }; @@ -2850,7 +2850,7 @@ namespace DS4Windows bool.TryParse(ss[0], out useCustomLeds[i]); DS4Color.TryParse(ss[1], ref m_CustomLeds[i]); } - catch { useCustomLeds[i] = false; m_CustomLeds[i] = new DS4Color(Color.Black); missingSetting = true; } + catch { useCustomLeds[i] = false; m_CustomLeds[i] = new DS4Color(Color.Blue); missingSetting = true; } } } } @@ -3524,7 +3524,7 @@ namespace DS4Windows m_ChargingLeds[device] = new DS4Color(Color.Black); m_FlashLeds[device] = new DS4Color(Color.Black); useCustomLeds[device] = false; - m_CustomLeds[device] = new DS4Color(Color.Black); + m_CustomLeds[device] = new DS4Color(Color.Blue); chargingType[device] = 0; launchProgram[device] = string.Empty; diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 1021bef..52c9c94 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -2292,6 +2292,10 @@ namespace DS4Windows private void useCustomColorToolStripMenuItem_Click(object sender, EventArgs e) { advColorDialog.Color = CustomColor[currentCustomLed].ToColor; + AdvancedColorDialog.ColorUpdateHandler tempDel = + new AdvancedColorDialog.ColorUpdateHandler(advColor_CustomColorUpdate); + + advColorDialog.OnUpdateColor += tempDel; if (advColorDialog.ShowDialog() == DialogResult.OK) { lights[currentCustomLed].BackColor = new DS4Color(advColorDialog.Color).ToColorA; @@ -2300,10 +2304,23 @@ namespace DS4Windows Global.Save(); } + advColorDialog.OnUpdateColor -= tempDel; DS4LightBar.forcedFlash[currentCustomLed] = 0; DS4LightBar.forcelight[currentCustomLed] = false; } + private void advColor_CustomColorUpdate(object sender, EventArgs e) + { + if (sender is Color && currentCustomLed < 4) + { + Color color = (Color)sender; + DS4Color dcolor = new DS4Color { red = color.R, green = color.G, blue = color.B }; + DS4LightBar.forcedColor[currentCustomLed] = dcolor; + DS4LightBar.forcedFlash[currentCustomLed] = 0; + DS4LightBar.forcelight[currentCustomLed] = true; + } + } + private void cBUseWhiteIcon_CheckedChanged(object sender, EventArgs e) { UseWhiteIcon = cBUseWhiteIcon.Checked;