Skip to content
This repository was archived by the owner on Aug 6, 2021. It is now read-only.

Commit dde304b

Browse files
committed
Added setting to change the background-brush
1 parent 7eac420 commit dde304b

File tree

4 files changed

+75
-57
lines changed

4 files changed

+75
-57
lines changed

KeyboardAudioVisualizer/App.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using KeyboardAudioVisualizer.Helper;
99
using KeyboardAudioVisualizer.Legacy;
1010
using Newtonsoft.Json;
11+
using RGB.NET.Brushes.Gradients;
12+
using RGB.NET.Core;
1113
using Settings = KeyboardAudioVisualizer.Configuration.Settings;
1214

1315
namespace KeyboardAudioVisualizer
@@ -53,7 +55,11 @@ protected override void OnStartup(StartupEventArgs e)
5355

5456
if (settings == null)
5557
{
56-
settings = new Settings { Version = Settings.CURRENT_VERSION };
58+
settings = new Settings
59+
{
60+
Version = Settings.CURRENT_VERSION,
61+
Background = new LinearGradient(new GradientStop(0.1, new Color(64, 0, 0, 0)))
62+
};
5763
_taskbarIcon.ShowBalloonTip("Keyboard Audio-Visualizer is starting in the tray!", "Click on the icon to open the configuration.", BalloonIcon.Info);
5864
}
5965
else if (settings.Version != Settings.CURRENT_VERSION)

KeyboardAudioVisualizer/ApplicationManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void InitializeDevices()
7575
surface.AlignDevices();
7676

7777
ILedGroup background = new ListLedGroup(surface.Leds);
78-
background.Brush = new SolidColorBrush(new Color(64, 0, 0, 0)); //TODO DarthAffe 06.08.2017: A-Channel gives some kind of blur - settings!
78+
background.Brush = new LinearGradientBrush(Settings.Background);
7979

8080
LinearGradient primaryGradient = Settings[VisualizationIndex.Primary].Gradient;
8181
LinearGradient secondaryGradient = Settings[VisualizationIndex.Secondary].Gradient;

KeyboardAudioVisualizer/Configuration/Settings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public class Settings
2222
public double UpdateRate { get; set; } = 40.0;
2323

2424
public bool EnableAudioPrescale { get; set; } = false;
25-
25+
26+
public LinearGradient Background { get; set; }
27+
2628
public Dictionary<VisualizationIndex, VisualizationSettings> Visualizations { get; set; } = new Dictionary<VisualizationIndex, VisualizationSettings>();
2729

2830
public VisualizationSettings this[VisualizationIndex visualizationIndex]

KeyboardAudioVisualizer/UI/ConfigurationWindow.xaml

Lines changed: 64 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -163,60 +163,70 @@
163163

164164
<TabItem Header="Settings">
165165
<AdornerDecorator>
166-
<GroupBox VerticalAlignment="Top">
167-
<StackPanel Orientation="Vertical">
168-
<Grid>
169-
<Grid.Resources>
170-
<Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
171-
<Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
172-
<Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
173-
</Grid.Resources>
174-
175-
<Grid.ColumnDefinitions>
176-
<ColumnDefinition Width="*" />
177-
<ColumnDefinition Width="8" />
178-
<ColumnDefinition Width="*" />
179-
<ColumnDefinition Width="8" />
180-
<ColumnDefinition Width="*" />
181-
</Grid.ColumnDefinitions>
182-
183-
<controls:Form Grid.Column="0">
184-
<Label controls:Form.IsLabel="True" Content="Version:" />
185-
<TextBlock Text="{Binding Version}" />
186-
187-
<Label controls:Form.IsLabel="True" Content="Update-Rate" />
188-
<Slider Minimum="1" Maximum="60" controls:Form.Fill="True" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight"
189-
Value="{Binding UpdateRate}"
190-
attached:SliderValue.Unit="FPS"
191-
ToolTip="Defines how fast the data is updated.&#x0a;Low values can reduce CPU-usage but will cause stuttering.&#x0a;Values above 40 will only affect the internal calculations and wont make the keyboard update faster.&#x0a;It's not recommended to select a value > 40." />
192-
193-
<Label controls:Form.IsLabel="True" Content="Fix Volume" />
194-
<CheckBox VerticalAlignment="Center"
195-
IsChecked="{Binding EnableAudioPrescale}"
196-
ToolTip="Scales the audio signal inverse to the OS-master-volume.&#x0a;This might (depending on the system) lead to decrased performance&#x0a; -> only activate it if you need it." />
197-
198-
<Label controls:Form.LineBreaks="1" controls:Form.IsLabel="True" Content="Devices:" />
199-
</controls:Form>
200-
</Grid>
201-
202-
<!-- TODO DarthAffe 05.08.2017: Fix the formular to support that use-case -->
203-
<ItemsControl VerticalAlignment="Top" HorizontalAlignment="Left" Margin="120,-22,0,0" ItemsSource="{Binding Source={x:Static core:RGBSurface.Instance}, Path=Devices}">
204-
<ItemsControl.ItemTemplate>
205-
<DataTemplate>
206-
<TextBlock Style="{StaticResource StyleTextBlockForm}">
207-
<TextBlock.Text>
208-
<MultiBinding StringFormat="> {0} {1} ({2})">
209-
<Binding Path="DeviceInfo.Manufacturer" />
210-
<Binding Path="DeviceInfo.Model" />
211-
<Binding Path="DeviceInfo.DeviceType" />
212-
</MultiBinding>
213-
</TextBlock.Text>
214-
</TextBlock>
215-
</DataTemplate>
216-
</ItemsControl.ItemTemplate>
217-
</ItemsControl>
218-
</StackPanel>
219-
</GroupBox>
166+
<DockPanel LastChildFill="False">
167+
<DockPanel.Resources>
168+
<Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
169+
<Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
170+
<Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
171+
</DockPanel.Resources>
172+
173+
<GroupBox DockPanel.Dock="Top">
174+
<controls:Form>
175+
<Label controls:Form.IsLabel="True" Content="Version" />
176+
<TextBlock Text="{Binding Version}" />
177+
178+
<Label controls:Form.IsLabel="True" Content="Update-Rate" />
179+
<Slider Minimum="1" Maximum="60" controls:Form.Fill="True" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight"
180+
Value="{Binding UpdateRate}"
181+
attached:SliderValue.Unit="FPS"
182+
ToolTip="Defines how fast the data is updated.&#x0a;Low values can reduce CPU-usage but will cause stuttering.&#x0a;Values above 40 will only affect the internal calculations and wont make the keyboard update faster.&#x0a;It's not recommended to select a value > 40." />
183+
184+
<Label controls:Form.IsLabel="True" Content="Fix Volume" />
185+
<CheckBox VerticalAlignment="Center"
186+
IsChecked="{Binding EnableAudioPrescale}"
187+
ToolTip="Scales the audio signal inverse to the OS-master-volume.&#x0a;This might (depending on the system) lead to decrased performance&#x0a; -> only activate it if you need it." />
188+
189+
</controls:Form>
190+
</GroupBox>
191+
192+
<GroupBox Margin="0,8,0,0" DockPanel.Dock="Top">
193+
<StackPanel Orientation="Vertical">
194+
<Border HorizontalAlignment="Left" Width="111">
195+
<Label HorizontalAlignment="Right"
196+
Content="Background" />
197+
</Border>
198+
199+
<controls:GradientEditor Margin="120,-18,0,0"
200+
Gradient="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=Settings.Background}"
201+
ToolTip="Defines the gradient used as the background. Use transparency to create some kind of blur. Usage:&#x0a; Left click inside the preview to add a new stop.&#x0a; Left-click stop to change the color or move it.&#x0a; Right-click stop to remove it.&#x0a;" />
202+
</StackPanel>
203+
</GroupBox>
204+
205+
<GroupBox Margin="0,8,0,0" DockPanel.Dock="Top">
206+
<StackPanel Orientation="Vertical">
207+
<Border HorizontalAlignment="Left" Width="111">
208+
<Label HorizontalAlignment="Right"
209+
Content="Devices" />
210+
</Border>
211+
212+
<ItemsControl VerticalAlignment="Top" HorizontalAlignment="Left" Margin="120,-18,0,0" ItemsSource="{Binding Source={x:Static core:RGBSurface.Instance}, Path=Devices}">
213+
<ItemsControl.ItemTemplate>
214+
<DataTemplate>
215+
<TextBlock Style="{StaticResource StyleTextBlockForm}">
216+
<TextBlock.Text>
217+
<MultiBinding StringFormat="> {0} {1} ({2})">
218+
<Binding Path="DeviceInfo.Manufacturer" />
219+
<Binding Path="DeviceInfo.Model" />
220+
<Binding Path="DeviceInfo.DeviceType" />
221+
</MultiBinding>
222+
</TextBlock.Text>
223+
</TextBlock>
224+
</DataTemplate>
225+
</ItemsControl.ItemTemplate>
226+
</ItemsControl>
227+
</StackPanel>
228+
</GroupBox>
229+
</DockPanel>
220230
</AdornerDecorator>
221231
</TabItem>
222232
</TabControl>

0 commit comments

Comments
 (0)