Allow setting lightbar mode in GUI

Now Witcher 3 lightbar functionality is usable
This commit is contained in:
Travis Nickles 2020-02-22 19:58:34 -06:00
parent 653b7424ee
commit 967c919086
2 changed files with 136 additions and 70 deletions

View File

@ -601,83 +601,93 @@
<TabItem Header="Lightbar">
<StackPanel>
<StackPanel Orientation="Horizontal">
<GroupBox x:Name="colorGB" Header="{lex:Loc Color}" Padding="4">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="R" />
<Slider Value="{Binding MainColorR}" Minimum="0" Maximum="255" ToolTip="{Binding MainColorR}" MinWidth="100" Background="{Binding MainColorRString, FallbackValue=Red}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="G" />
<Slider Value="{Binding MainColorG}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding MainColorG}" Background="{Binding MainColorGString, FallbackValue=Lime}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="B" />
<Slider Value="{Binding MainColorB}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding MainColorB}" Background="{Binding MainColorBString, FallbackValue=Blue}"/>
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox x:Name="emptyColorGB" Header="Empty" Padding="4">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="R" />
<Slider Value="{Binding LowColorR}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding LowColorR}" Background="{Binding LowColorRString, FallbackValue=Red}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="G" />
<Slider Value="{Binding LowColorG}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding LowColorG}" Background="{Binding LowColorGString, FallbackValue=Lime}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="B" />
<Slider Value="{Binding LowColorB}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding LowColorB}" Background="{Binding LowColorBString, FallbackValue=Blue}"/>
</StackPanel>
<Button x:Name="lowColorBtn" Width="10" Height="10" Background="{Binding LowColor}" HorizontalAlignment="Right" Margin="0,6,0,0" Click="LowColorBtn_Click" />
</StackPanel>
</GroupBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<ComboBox x:Name="flashTypeCombo" SelectedIndex="{Binding FlashTypeIndex,FallbackValue=0}">
<ComboBoxItem Content="Flash at"/>
<ComboBoxItem Content="Pulse at"/>
</ComboBox>
<xctk:IntegerUpDown d:IsHidden="True" Value="{Binding FlashAt,FallbackValue=0}" MinWidth="50"
Minimum="-1" Maximum="100" Increment="10" />
<Label Content="%" />
<Button x:Name="flashColorBtn" Width="20" Height="20" Background="{Binding FlashColor,FallbackValue=Blue}"
ToolTip="{lex:Loc Resources:FlashAtTip}" Click="FlashColorBtn_Click" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="While Charging:"/>
<ComboBox Margin="8,0,0,0" SelectedIndex="{Binding ChargingType,FallbackValue=0}">
<Label Content="Mode:" />
<ComboBox x:Name="lightbarModeCombo" Width="160" SelectedIndex="{Binding LightbarModeIndex, FallbackValue=0}"
VerticalContentAlignment="Center" Margin="10,0,0,0">
<ComboBoxItem Content="Normal" />
<ComboBoxItem Content="Pulse" />
<ComboBoxItem Content="Rainbow" />
<ComboBoxItem Content="Color" />
<ComboBoxItem Content="Passthru" />
</ComboBox>
<Button x:Name="chargingColorBtn" Width="20" Height="20" Background="{Binding ChargingColor,FallbackValue=Blue}"
Visibility="{Binding ChargingColorVisible}" Click="ChargingColorBtn_Click" Margin="20,0,0,0" />
</StackPanel>
<StackPanel Visibility="{Binding DS4WinLightVisible,Mode=OneWay}">
<StackPanel Orientation="Horizontal">
<GroupBox x:Name="colorGB" Header="{lex:Loc Color}" Padding="4">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="R" />
<Slider Value="{Binding MainColorR}" Minimum="0" Maximum="255" ToolTip="{Binding MainColorR}" MinWidth="100" Background="{Binding MainColorRString, FallbackValue=Red}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="G" />
<Slider Value="{Binding MainColorG}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding MainColorG}" Background="{Binding MainColorGString, FallbackValue=Lime}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="B" />
<Slider Value="{Binding MainColorB}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding MainColorB}" Background="{Binding MainColorBString, FallbackValue=Blue}"/>
</StackPanel>
</StackPanel>
</GroupBox>
<CheckBox x:Name="colorByBatteryPerCk" Content="Color by Battery %" IsChecked="{Binding ColorBatteryPercent}"
<GroupBox x:Name="emptyColorGB" Header="Empty" Padding="4">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="R" />
<Slider Value="{Binding LowColorR}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding LowColorR}" Background="{Binding LowColorRString, FallbackValue=Red}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="G" />
<Slider Value="{Binding LowColorG}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding LowColorG}" Background="{Binding LowColorGString, FallbackValue=Lime}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="B" />
<Slider Value="{Binding LowColorB}" MinWidth="100" Minimum="0" Maximum="255" ToolTip="{Binding LowColorB}" Background="{Binding LowColorBString, FallbackValue=Blue}"/>
</StackPanel>
<Button x:Name="lowColorBtn" Width="10" Height="10" Background="{Binding LowColor}" HorizontalAlignment="Right" Margin="0,6,0,0" Click="LowColorBtn_Click" />
</StackPanel>
</GroupBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<ComboBox x:Name="flashTypeCombo" SelectedIndex="{Binding FlashTypeIndex,FallbackValue=0}">
<ComboBoxItem Content="Flash at"/>
<ComboBoxItem Content="Pulse at"/>
</ComboBox>
<xctk:IntegerUpDown d:IsHidden="True" Value="{Binding FlashAt,FallbackValue=0}" MinWidth="50"
Minimum="-1" Maximum="100" Increment="10" />
<Label Content="%" />
<Button x:Name="flashColorBtn" Width="20" Height="20" Background="{Binding FlashColor,FallbackValue=Blue}"
ToolTip="{lex:Loc Resources:FlashAtTip}" Click="FlashColorBtn_Click" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="While Charging:"/>
<ComboBox Margin="8,0,0,0" SelectedIndex="{Binding ChargingType,FallbackValue=0}">
<ComboBoxItem Content="Normal" />
<ComboBoxItem Content="Pulse" />
<ComboBoxItem Content="Rainbow" />
<ComboBoxItem Content="Color" />
</ComboBox>
<Button x:Name="chargingColorBtn" Width="20" Height="20" Background="{Binding ChargingColor,FallbackValue=Blue}"
Visibility="{Binding ChargingColorVisible}" Click="ChargingColorBtn_Click" Margin="20,0,0,0" />
</StackPanel>
<CheckBox x:Name="colorByBatteryPerCk" Content="Color by Battery %" IsChecked="{Binding ColorBatteryPercent}"
ToolTip="{lex:Loc Resources:LightByBatteryTip}" Click="ColorByBatteryPerCk_Click" Margin="0,10,0,0" />
<StackPanel Orientation="Horizontal" Height="60" Margin="0,10,0,0">
<Button x:Name="rainbowBtn" Height="20" Width="20"
<StackPanel Orientation="Horizontal" Height="60" Margin="0,10,0,0">
<Button x:Name="rainbowBtn" Height="20" Width="20"
ToolTip="{lex:Loc Resources:AlwaysRainbow}" Click="RainbowBtn_Click">
<Button.Content>
<Image Source="/DS4Windows;component/Resources/rainbow.png" />
</Button.Content>
</Button>
<xctk:IntegerUpDown MinWidth="30" Height="30" Minimum="0" Maximum="60" Increment="1" Margin="8,0,0,0"
<Button.Content>
<Image Source="/DS4Windows;component/Resources/rainbow.png" />
</Button.Content>
</Button>
<xctk:IntegerUpDown MinWidth="30" Height="30" Minimum="0" Maximum="60" Increment="1" Margin="8,0,0,0"
Value="{Binding Rainbow,FallbackValue=5}" IsEnabled="{Binding RainbowExists}" />
<Label Content="secs/cycle" Padding="0" Margin="8,0,0,0" VerticalContentAlignment="Center" />
<StackPanel Margin="8,0,0,0">
<Label Content="Max Sat." />
<Slider Value="{Binding MaxSatRainbow,FallbackValue=100}" Minimum="0" Maximum="100" Width="100" IsEnabled="{Binding RainbowExists}" />
<Label Content="secs/cycle" Padding="0" Margin="8,0,0,0" VerticalContentAlignment="Center" />
<StackPanel Margin="8,0,0,0">
<Label Content="Max Sat." />
<Slider Value="{Binding MaxSatRainbow,FallbackValue=100}" Minimum="0" Maximum="100" Width="100" IsEnabled="{Binding RainbowExists}" />
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>

View File

@ -23,6 +23,58 @@ namespace DS4WinWPF.DS4Forms.ViewModels
private ImageBrush lightbarImgBrush = new ImageBrush();
private SolidColorBrush lightbarColBrush = new SolidColorBrush();
public int LightbarModeIndex
{
get
{
int index = 0;
switch(Global.LightbarSettingsInfo[device].Mode)
{
case LightbarMode.DS4Win:
index = 0; break;
case LightbarMode.Passthru:
index = 1; break;
default: break;
}
return index;
}
set
{
LightbarMode temp = LightbarMode.DS4Win;
switch(value)
{
case 0:
temp = LightbarMode.DS4Win; break;
case 1:
temp = LightbarMode.Passthru; break;
default: break;
}
Global.LightbarSettingsInfo[device].Mode = temp;
LightbarModeIndexChanged?.Invoke(this, EventArgs.Empty);
}
}
public event EventHandler LightbarModeIndexChanged;
public Visibility DS4WinLightVisible
{
get
{
Visibility temp = Visibility.Visible;
switch(Global.LightbarSettingsInfo[device].Mode)
{
case LightbarMode.DS4Win:
temp = Visibility.Visible; break;
case LightbarMode.Passthru:
temp = Visibility.Collapsed; break;
}
return temp;
}
}
public event EventHandler DS4WinLightVisibleChanged;
public System.Windows.Media.Brush LightbarBrush
{
get
@ -602,7 +654,6 @@ namespace DS4WinWPF.DS4Forms.ViewModels
}
}
public OutContType ContType
{
get => Global.OutContType[device];
@ -1495,6 +1546,11 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{
OutputMouseSpeed = CalculateOutputMouseSpeed(ButtonMouseSensitivity);
};
LightbarModeIndexChanged += (sender, args) =>
{
DS4WinLightVisibleChanged?.Invoke(this, EventArgs.Empty);
};
}
private void ProfileSettingsViewModel_MainColorChanged(object sender, EventArgs e)