Allow Rainbow mode to change lightbar brush

This commit is contained in:
Travis Nickles 2019-12-22 16:30:13 -06:00
parent d1361a7460
commit aa7bf76d36
4 changed files with 47 additions and 1 deletions

View File

@ -100,7 +100,7 @@
</Style.Triggers>
</Style>
</Button.Style>
<Rectangle x:Name="lightbarRect" Fill="{Binding MainColorString,FallbackValue=Green}" Width="{Binding Path=Width, ElementName=ds4LightbarColorBtn}"
<Rectangle x:Name="lightbarRect" Fill="{Binding LightbarBrush,FallbackValue=Green}" Width="{Binding Path=Width, ElementName=ds4LightbarColorBtn}"
Height="{Binding Path=Height, ElementName=ds4LightbarColorBtn}">
<Rectangle.OpacityMask>
<ImageBrush ImageSource="/DS4Windows;component/Resources/DS4 lightbar.png" />

View File

@ -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)

View File

@ -410,6 +410,8 @@
<Content Include="BezierCurveEditor\index.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Resources\rainbowCCrop.png" />
<Resource Include="Resources\rainbowC.png" />
<Resource Include="Resources\DS4 lightbar.png" />
<Resource Include="Resources\keydown.png" />
<Resource Include="Resources\keyup.png" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB