Added setting to change the background-brush

This commit is contained in:
Darth Affe 2018-10-06 11:53:58 +02:00
parent 7eac420a8e
commit dde304b007
4 changed files with 69 additions and 51 deletions

View File

@ -8,6 +8,8 @@ using KeyboardAudioVisualizer.Configuration;
using KeyboardAudioVisualizer.Helper;
using KeyboardAudioVisualizer.Legacy;
using Newtonsoft.Json;
using RGB.NET.Brushes.Gradients;
using RGB.NET.Core;
using Settings = KeyboardAudioVisualizer.Configuration.Settings;
namespace KeyboardAudioVisualizer
@ -53,7 +55,11 @@ namespace KeyboardAudioVisualizer
if (settings == null)
{
settings = new Settings { Version = Settings.CURRENT_VERSION };
settings = new Settings
{
Version = Settings.CURRENT_VERSION,
Background = new LinearGradient(new GradientStop(0.1, new Color(64, 0, 0, 0)))
};
_taskbarIcon.ShowBalloonTip("Keyboard Audio-Visualizer is starting in the tray!", "Click on the icon to open the configuration.", BalloonIcon.Info);
}
else if (settings.Version != Settings.CURRENT_VERSION)

View File

@ -75,7 +75,7 @@ namespace KeyboardAudioVisualizer
surface.AlignDevices();
ILedGroup background = new ListLedGroup(surface.Leds);
background.Brush = new SolidColorBrush(new Color(64, 0, 0, 0)); //TODO DarthAffe 06.08.2017: A-Channel gives some kind of blur - settings!
background.Brush = new LinearGradientBrush(Settings.Background);
LinearGradient primaryGradient = Settings[VisualizationIndex.Primary].Gradient;
LinearGradient secondaryGradient = Settings[VisualizationIndex.Secondary].Gradient;

View File

@ -22,7 +22,9 @@ namespace KeyboardAudioVisualizer.Configuration
public double UpdateRate { get; set; } = 40.0;
public bool EnableAudioPrescale { get; set; } = false;
public LinearGradient Background { get; set; }
public Dictionary<VisualizationIndex, VisualizationSettings> Visualizations { get; set; } = new Dictionary<VisualizationIndex, VisualizationSettings>();
public VisualizationSettings this[VisualizationIndex visualizationIndex]

View File

@ -163,60 +163,70 @@
<TabItem Header="Settings">
<AdornerDecorator>
<GroupBox VerticalAlignment="Top">
<StackPanel Orientation="Vertical">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
</Grid.Resources>
<DockPanel LastChildFill="False">
<DockPanel.Resources>
<Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
</DockPanel.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<GroupBox DockPanel.Dock="Top">
<controls:Form>
<Label controls:Form.IsLabel="True" Content="Version" />
<TextBlock Text="{Binding Version}" />
<controls:Form Grid.Column="0">
<Label controls:Form.IsLabel="True" Content="Version:" />
<TextBlock Text="{Binding Version}" />
<Label controls:Form.IsLabel="True" Content="Update-Rate" />
<Slider Minimum="1" Maximum="60" controls:Form.Fill="True" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight"
Value="{Binding UpdateRate}"
attached:SliderValue.Unit="FPS"
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." />
<Label controls:Form.IsLabel="True" Content="Update-Rate" />
<Slider Minimum="1" Maximum="60" controls:Form.Fill="True" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight"
Value="{Binding UpdateRate}"
attached:SliderValue.Unit="FPS"
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." />
<Label controls:Form.IsLabel="True" Content="Fix Volume" />
<CheckBox VerticalAlignment="Center"
IsChecked="{Binding EnableAudioPrescale}"
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." />
<Label controls:Form.IsLabel="True" Content="Fix Volume" />
<CheckBox VerticalAlignment="Center"
IsChecked="{Binding EnableAudioPrescale}"
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." />
</controls:Form>
</GroupBox>
<Label controls:Form.LineBreaks="1" controls:Form.IsLabel="True" Content="Devices:" />
</controls:Form>
</Grid>
<GroupBox Margin="0,8,0,0" DockPanel.Dock="Top">
<StackPanel Orientation="Vertical">
<Border HorizontalAlignment="Left" Width="111">
<Label HorizontalAlignment="Right"
Content="Background" />
</Border>
<!-- TODO DarthAffe 05.08.2017: Fix the formular to support that use-case -->
<ItemsControl VerticalAlignment="Top" HorizontalAlignment="Left" Margin="120,-22,0,0" ItemsSource="{Binding Source={x:Static core:RGBSurface.Instance}, Path=Devices}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Style="{StaticResource StyleTextBlockForm}">
<TextBlock.Text>
<MultiBinding StringFormat="> {0} {1} ({2})">
<Binding Path="DeviceInfo.Manufacturer" />
<Binding Path="DeviceInfo.Model" />
<Binding Path="DeviceInfo.DeviceType" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</GroupBox>
<controls:GradientEditor Margin="120,-18,0,0"
Gradient="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=Settings.Background}"
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;" />
</StackPanel>
</GroupBox>
<GroupBox Margin="0,8,0,0" DockPanel.Dock="Top">
<StackPanel Orientation="Vertical">
<Border HorizontalAlignment="Left" Width="111">
<Label HorizontalAlignment="Right"
Content="Devices" />
</Border>
<ItemsControl VerticalAlignment="Top" HorizontalAlignment="Left" Margin="120,-18,0,0" ItemsSource="{Binding Source={x:Static core:RGBSurface.Instance}, Path=Devices}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Style="{StaticResource StyleTextBlockForm}">
<TextBlock.Text>
<MultiBinding StringFormat="> {0} {1} ({2})">
<Binding Path="DeviceInfo.Manufacturer" />
<Binding Path="DeviceInfo.Model" />
<Binding Path="DeviceInfo.DeviceType" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</GroupBox>
</DockPanel>
</AdornerDecorator>
</TabItem>
</TabControl>