From aa7bf76d36a4b1bbf07b3ad403eb0bf4688aa7c5 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sun, 22 Dec 2019 16:30:13 -0600 Subject: [PATCH] Allow Rainbow mode to change lightbar brush --- DS4Windows/DS4Forms/ProfileEditor.xaml | 2 +- .../ViewModels/ProfileSettingsViewModel.cs | 44 ++++++++++++++++++ DS4Windows/DS4WinWPF.csproj | 2 + DS4Windows/Resources/rainbowCCrop.png | Bin 0 -> 2634 bytes 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 DS4Windows/Resources/rainbowCCrop.png diff --git a/DS4Windows/DS4Forms/ProfileEditor.xaml b/DS4Windows/DS4Forms/ProfileEditor.xaml index 45ee8ad..b4d2f48 100644 --- a/DS4Windows/DS4Forms/ProfileEditor.xaml +++ b/DS4Windows/DS4Forms/ProfileEditor.xaml @@ -100,7 +100,7 @@ - diff --git a/DS4Windows/DS4Forms/ViewModels/ProfileSettingsViewModel.cs b/DS4Windows/DS4Forms/ViewModels/ProfileSettingsViewModel.cs index 9587918..5e2e153 100644 --- a/DS4Windows/DS4Forms/ViewModels/ProfileSettingsViewModel.cs +++ b/DS4Windows/DS4Forms/ViewModels/ProfileSettingsViewModel.cs @@ -20,6 +20,36 @@ namespace DS4WinWPF.DS4Forms.ViewModels private int funcDevNum; public int FuncDevNum { get => funcDevNum; } + private ImageBrush lightbarImgBrush = new ImageBrush(); + private SolidColorBrush lightbarColBrush = new SolidColorBrush(); + + public System.Windows.Media.Brush LightbarBrush + { + get + { + System.Windows.Media.Brush tempBrush; + ref DS4Color color = ref Global.MainColor[device]; + if (!RainbowExists) + { + lightbarColBrush.Color = new System.Windows.Media.Color() + { + A = 255, + R = color.red, + G = color.green, + B = color.blue + }; + tempBrush = lightbarColBrush as System.Windows.Media.Brush; + } + else + { + tempBrush = lightbarImgBrush as System.Windows.Media.Brush; + } + + return tempBrush; + } + } + public event EventHandler LightbarBrushChanged; + public System.Windows.Media.Color MainColor { get @@ -1372,21 +1402,34 @@ namespace DS4WinWPF.DS4Forms.ViewModels Global.outDevTypeTemp[device] = OutContType.X360; tempBtPollRate = Global.BTPollRate[device]; + ImageSourceConverter sourceConverter = new ImageSourceConverter(); + ImageSource temp = sourceConverter. + ConvertFromString("pack://application:,,,/DS4Windows;component/Resources/rainbowCCrop.png") as ImageSource; + lightbarImgBrush.ImageSource = temp.Clone(); + MainColorChanged += ProfileSettingsViewModel_MainColorChanged; MainColorRChanged += (sender, args) => { MainColorRStringChanged?.Invoke(this, EventArgs.Empty); MainColorStringChanged?.Invoke(this, EventArgs.Empty); + LightbarBrushChanged?.Invoke(this, EventArgs.Empty); }; MainColorGChanged += (sender, args) => { MainColorGStringChanged?.Invoke(this, EventArgs.Empty); MainColorStringChanged?.Invoke(this, EventArgs.Empty); + LightbarBrushChanged?.Invoke(this, EventArgs.Empty); }; MainColorBChanged += (sender, args) => { MainColorBStringChanged?.Invoke(this, EventArgs.Empty); MainColorStringChanged?.Invoke(this, EventArgs.Empty); + LightbarBrushChanged?.Invoke(this, EventArgs.Empty); + }; + + RainbowChanged += (sender, args) => + { + LightbarBrushChanged?.Invoke(this, EventArgs.Empty); }; } @@ -1396,6 +1439,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels MainColorRChanged?.Invoke(this, EventArgs.Empty); MainColorGChanged?.Invoke(this, EventArgs.Empty); MainColorBChanged?.Invoke(this, EventArgs.Empty); + LightbarBrushChanged?.Invoke(this, EventArgs.Empty); } public void UpdateFlashColor(System.Windows.Media.Color color) diff --git a/DS4Windows/DS4WinWPF.csproj b/DS4Windows/DS4WinWPF.csproj index 0501d8e..6843a66 100644 --- a/DS4Windows/DS4WinWPF.csproj +++ b/DS4Windows/DS4WinWPF.csproj @@ -410,6 +410,8 @@ PreserveNewest + + diff --git a/DS4Windows/Resources/rainbowCCrop.png b/DS4Windows/Resources/rainbowCCrop.png new file mode 100644 index 0000000000000000000000000000000000000000..38e581e31fd582b18fe2918010b1ed4da9c28175 GIT binary patch literal 2634 z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