Update custom led color from main Controllers tab

Related to issue #153.
This commit is contained in:
Travis Nickles 2017-11-22 19:23:23 -06:00
parent 1e8925ebfe
commit c073e721fc
2 changed files with 24 additions and 7 deletions

View File

@ -1297,11 +1297,11 @@ namespace DS4Windows
public bool[] useCustomLeds = new bool[5] { false, false, false, false, false }; public bool[] useCustomLeds = new bool[5] { false, false, false, false, false };
public DS4Color[] m_CustomLeds = new DS4Color[5] public DS4Color[] m_CustomLeds = new DS4Color[5]
{ {
new DS4Color(Color.Black), new DS4Color(Color.Blue),
new DS4Color(Color.Black), new DS4Color(Color.Blue),
new DS4Color(Color.Black), new DS4Color(Color.Blue),
new DS4Color(Color.Black), new DS4Color(Color.Blue),
new DS4Color(Color.Black) new DS4Color(Color.Blue)
}; };
public int[] chargingType = new int[5] { 0, 0, 0, 0, 0 }; public int[] chargingType = new int[5] { 0, 0, 0, 0, 0 };
@ -2850,7 +2850,7 @@ namespace DS4Windows
bool.TryParse(ss[0], out useCustomLeds[i]); bool.TryParse(ss[0], out useCustomLeds[i]);
DS4Color.TryParse(ss[1], ref m_CustomLeds[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_ChargingLeds[device] = new DS4Color(Color.Black);
m_FlashLeds[device] = new DS4Color(Color.Black); m_FlashLeds[device] = new DS4Color(Color.Black);
useCustomLeds[device] = false; useCustomLeds[device] = false;
m_CustomLeds[device] = new DS4Color(Color.Black); m_CustomLeds[device] = new DS4Color(Color.Blue);
chargingType[device] = 0; chargingType[device] = 0;
launchProgram[device] = string.Empty; launchProgram[device] = string.Empty;

View File

@ -2292,6 +2292,10 @@ namespace DS4Windows
private void useCustomColorToolStripMenuItem_Click(object sender, EventArgs e) private void useCustomColorToolStripMenuItem_Click(object sender, EventArgs e)
{ {
advColorDialog.Color = CustomColor[currentCustomLed].ToColor; advColorDialog.Color = CustomColor[currentCustomLed].ToColor;
AdvancedColorDialog.ColorUpdateHandler tempDel =
new AdvancedColorDialog.ColorUpdateHandler(advColor_CustomColorUpdate);
advColorDialog.OnUpdateColor += tempDel;
if (advColorDialog.ShowDialog() == DialogResult.OK) if (advColorDialog.ShowDialog() == DialogResult.OK)
{ {
lights[currentCustomLed].BackColor = new DS4Color(advColorDialog.Color).ToColorA; lights[currentCustomLed].BackColor = new DS4Color(advColorDialog.Color).ToColorA;
@ -2300,10 +2304,23 @@ namespace DS4Windows
Global.Save(); Global.Save();
} }
advColorDialog.OnUpdateColor -= tempDel;
DS4LightBar.forcedFlash[currentCustomLed] = 0; DS4LightBar.forcedFlash[currentCustomLed] = 0;
DS4LightBar.forcelight[currentCustomLed] = false; 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) private void cBUseWhiteIcon_CheckedChanged(object sender, EventArgs e)
{ {
UseWhiteIcon = cBUseWhiteIcon.Checked; UseWhiteIcon = cBUseWhiteIcon.Checked;