mirror of
https://github.com/DarthAffe/KeyboardAudioVisualizer.git
synced 2025-12-12 23:28:30 +00:00
Added LevelVisualization, fixed some bugs and tweaked some values in the audio processing, added more gui stuff
This commit is contained in:
parent
57d49ff5b5
commit
492cd52689
3
.gitignore
vendored
3
.gitignore
vendored
@ -286,3 +286,6 @@ __pycache__/
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
/NuGet.Config
|
||||
/NuGet.Config
|
||||
/KeyboardAudioVisualizer/NuGet.Config
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
MenuActivation="RightClick">
|
||||
<tb:TaskbarIcon.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Open configuration" Command="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=OpenConfigurationCommand}" />
|
||||
<MenuItem Header="Open Configuration" Command="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=OpenConfigurationCommand}" />
|
||||
<MenuItem Header="Exit" Command="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=ExitCommand}" />
|
||||
</ContextMenu>
|
||||
</tb:TaskbarIcon.ContextMenu>
|
||||
|
||||
@ -51,7 +51,9 @@ namespace KeyboardAudioVisualizer
|
||||
{
|
||||
File.WriteAllText("error.log", $"[{DateTime.Now:G}] Exception!\r\n\r\nMessage:\r\n{ex.GetFullMessage()}\r\n\r\nStackTrace:\r\n{ex.StackTrace}\r\n\r\n");
|
||||
MessageBox.Show("An error occured while starting the Keyboard Audio-Visualizer.\r\nPlease double check if SDK-support for your devices is enabled.\r\nMore information can be found in the error.log file in the application directory.", "Can't start Keyboard Audio-Visualizer.");
|
||||
Shutdown();
|
||||
|
||||
try { ApplicationManager.Instance.ExitCommand.Execute(null); }
|
||||
catch { Environment.Exit(0); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,14 +54,61 @@ namespace KeyboardAudioVisualizer
|
||||
//surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
|
||||
|
||||
ILedGroup background = new ListLedGroup(surface.Leds);
|
||||
background.Brush = new SolidColorBrush(new Color(0, 0, 0));
|
||||
background.Brush = new SolidColorBrush(new Color(96, 0, 0, 0)); //TODO DarthAffe 06.08.2017: A-Channel gives some kind of blur - settings!
|
||||
|
||||
//TODO DarthAffe 03.08.2017: Changeable, Settings etc.
|
||||
foreach (IRGBDevice device in surface.Devices)
|
||||
{
|
||||
if (device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard)
|
||||
new ListLedGroup(device).Brush = new FrequencyBarsBrush(AudioProcessor.Instance.PrimaryVisualizationProvider, new RainbowGradient(300, -14));
|
||||
}
|
||||
switch (device.DeviceInfo.DeviceType)
|
||||
{
|
||||
case RGBDeviceType.Keyboard:
|
||||
//TODO DarthAffe 05.08.2017: Lighbar-support has to be better in RGB.NET
|
||||
if (device.DeviceInfo.Model.Equals("K95 RGB Platinum"))
|
||||
{
|
||||
ILedGroup lightbarLeft = new ListLedGroup(new CorsairLedId(device, CorsairLedIds.Lightbar1), new CorsairLedId(device, CorsairLedIds.Lightbar2),
|
||||
new CorsairLedId(device, CorsairLedIds.Lightbar3), new CorsairLedId(device, CorsairLedIds.Lightbar4),
|
||||
new CorsairLedId(device, CorsairLedIds.Lightbar5), new CorsairLedId(device, CorsairLedIds.Lightbar6),
|
||||
new CorsairLedId(device, CorsairLedIds.Lightbar7), new CorsairLedId(device, CorsairLedIds.Lightbar8),
|
||||
new CorsairLedId(device, CorsairLedIds.Lightbar9));
|
||||
ILedGroup lightbarCenter = new ListLedGroup(new CorsairLedId(device, CorsairLedIds.Lightbar1));
|
||||
ILedGroup lightbarRight = new ListLedGroup(new CorsairLedId(device, CorsairLedIds.Lightbar11), new CorsairLedId(device, CorsairLedIds.Lightbar12),
|
||||
new CorsairLedId(device, CorsairLedIds.Lightbar13), new CorsairLedId(device, CorsairLedIds.Lightbar14),
|
||||
new CorsairLedId(device, CorsairLedIds.Lightbar15), new CorsairLedId(device, CorsairLedIds.Lightbar16),
|
||||
new CorsairLedId(device, CorsairLedIds.Lightbar17), new CorsairLedId(device, CorsairLedIds.Lightbar18),
|
||||
new CorsairLedId(device, CorsairLedIds.Lightbar19));
|
||||
ListLedGroup primary = new ListLedGroup(device);
|
||||
primary.RemoveLeds(lightbarLeft.GetLeds());
|
||||
primary.RemoveLeds(lightbarCenter.GetLeds());
|
||||
primary.RemoveLeds(lightbarRight.GetLeds());
|
||||
|
||||
IGradient keyboardLevelGradient = new LinearGradient(new GradientStop(0, new Color(0, 0, 255)), new GradientStop(1, new Color(255, 0, 0)));
|
||||
lightbarLeft.Brush = new LevelBarBrush(AudioProcessor.Instance.SecondaryVisualizationProvider, keyboardLevelGradient, LevelBarDirection.Left, 0);
|
||||
lightbarRight.Brush = new LevelBarBrush(AudioProcessor.Instance.SecondaryVisualizationProvider, keyboardLevelGradient, LevelBarDirection.Right, 1);
|
||||
lightbarCenter.Brush = new SolidColorBrush(new Color(255, 255, 255)); //TODO DarthAffe 06.08.2017: Insert beat-detetion here!
|
||||
|
||||
primary.Brush = new FrequencyBarsBrush(AudioProcessor.Instance.PrimaryVisualizationProvider, new RainbowGradient(300, -14));
|
||||
}
|
||||
else
|
||||
new ListLedGroup(device).Brush = new FrequencyBarsBrush(AudioProcessor.Instance.PrimaryVisualizationProvider, new RainbowGradient(300, -14));
|
||||
|
||||
//{
|
||||
// ILedGroup left = new RectangleLedGroup(new Rectangle(device.Location.X, device.Location.Y, device.Size.Width / 2.0, device.Size.Height));
|
||||
// ILedGroup right = new RectangleLedGroup(new Rectangle(device.Location.X + (device.Size.Width / 2.0), device.Location.Y, device.Size.Width / 2.0, device.Size.Height));
|
||||
|
||||
// IGradient levelGradient = new LinearGradient(new GradientStop(0, new Color(0, 0, 255)), new GradientStop(1, new Color(255, 0, 0)));
|
||||
// left.Brush = new LevelBarBrush(AudioProcessor.Instance.SecondaryVisualizationProvider, levelGradient, LevelBarDirection.Left, 0);
|
||||
// right.Brush = new LevelBarBrush(AudioProcessor.Instance.SecondaryVisualizationProvider, levelGradient, LevelBarDirection.Right, 1);
|
||||
//}
|
||||
break;
|
||||
|
||||
case RGBDeviceType.Mousemat:
|
||||
ILedGroup left = new RectangleLedGroup(new Rectangle(device.Location.X, device.Location.Y, device.Size.Width / 2.0, device.Size.Height));
|
||||
ILedGroup right = new RectangleLedGroup(new Rectangle(device.Location.X + (device.Size.Width / 2.0), device.Location.Y, device.Size.Width / 2.0, device.Size.Height));
|
||||
|
||||
IGradient mousematLevelGradient = new LinearGradient(new GradientStop(0, new Color(0, 0, 255)), new GradientStop(1, new Color(255, 0, 0)));
|
||||
left.Brush = new LevelBarBrush(AudioProcessor.Instance.SecondaryVisualizationProvider, mousematLevelGradient, LevelBarDirection.Top, 0);
|
||||
right.Brush = new LevelBarBrush(AudioProcessor.Instance.SecondaryVisualizationProvider, mousematLevelGradient, LevelBarDirection.Top, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
surface.Updating += args => AudioProcessor.Instance.Update();
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
namespace KeyboardAudioVisualizer.AudioCapture
|
||||
using System;
|
||||
|
||||
namespace KeyboardAudioVisualizer.AudioCapture
|
||||
{
|
||||
public class AudioBuffer
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using KeyboardAudioVisualizer.AudioCapture;
|
||||
using KeyboardAudioVisualizer.AudioProcessing.Equalizer;
|
||||
using KeyboardAudioVisualizer.AudioProcessing.Spectrum;
|
||||
using KeyboardAudioVisualizer.AudioProcessing.VisualizationPRovider;
|
||||
using KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider;
|
||||
|
||||
namespace KeyboardAudioVisualizer.AudioProcessing
|
||||
{
|
||||
@ -22,6 +22,7 @@ namespace KeyboardAudioVisualizer.AudioProcessing
|
||||
private IAudioInput _audioInput;
|
||||
private ISpectrumProvider _spectrumProvider;
|
||||
public IVisualizationProvider PrimaryVisualizationProvider { get; private set; }
|
||||
public IVisualizationProvider SecondaryVisualizationProvider { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -37,6 +38,7 @@ namespace KeyboardAudioVisualizer.AudioProcessing
|
||||
{
|
||||
_spectrumProvider.Update();
|
||||
PrimaryVisualizationProvider.Update();
|
||||
SecondaryVisualizationProvider.Update();
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
@ -59,9 +61,12 @@ namespace KeyboardAudioVisualizer.AudioProcessing
|
||||
_spectrumProvider.Initialize();
|
||||
|
||||
//TODO DarthAffe 03.08.2017: Initialize correctly; Settings
|
||||
MultiBandEqualizer equalizer = new MultiBandEqualizer { [0] = -5, [1] = -1, [2] = 0, [3] = 2, [4] = 2 };
|
||||
PrimaryVisualizationProvider = new FrequencyBarsVisualizationProvider(new FrequencyBarsVisualizationProviderConfiguration { Scale = 38 }, _spectrumProvider) { Equalizer = equalizer };
|
||||
MultiBandEqualizer equalizer = new MultiBandEqualizer { [0] = -3, [1] = -1, [2] = -1, [3] = 1, [4] = 3 };
|
||||
PrimaryVisualizationProvider = new FrequencyBarsVisualizationProvider(new FrequencyBarsVisualizationProviderConfiguration { Scale = 34 }, _spectrumProvider) { Equalizer = equalizer };
|
||||
PrimaryVisualizationProvider.Initialize();
|
||||
|
||||
SecondaryVisualizationProvider = new LevelVisualizationProvider(new LevelVisualizationProviderConfiguration(), _audioBuffer);
|
||||
SecondaryVisualizationProvider.Initialize();
|
||||
}
|
||||
|
||||
private int CalculateSampleSize(int sampleRate, int maximumUpdateRate)
|
||||
|
||||
@ -5,7 +5,7 @@ using KeyboardAudioVisualizer.AudioProcessing.Spectrum;
|
||||
using KeyboardAudioVisualizer.Configuration;
|
||||
using KeyboardAudioVisualizer.Helper;
|
||||
|
||||
namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationPRovider
|
||||
namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
|
||||
{
|
||||
#region Configuration
|
||||
|
||||
@ -76,6 +76,7 @@ namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationPRovider
|
||||
private double _scalingValue;
|
||||
|
||||
public IEqualizer Equalizer { get; set; }
|
||||
public IConfiguration Configuration => _configuration;
|
||||
public float[] VisualizationData { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationPRovider
|
||||
using KeyboardAudioVisualizer.Configuration;
|
||||
|
||||
namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
|
||||
{
|
||||
public interface IVisualizationProvider : IAudioProcessor
|
||||
{
|
||||
IConfiguration Configuration { get; }
|
||||
float[] VisualizationData { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using KeyboardAudioVisualizer.AudioCapture;
|
||||
using KeyboardAudioVisualizer.Configuration;
|
||||
using KeyboardAudioVisualizer.Helper;
|
||||
|
||||
namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
|
||||
{
|
||||
#region Configuration
|
||||
|
||||
public enum ConversionMode
|
||||
{
|
||||
Linear, Logarithmic, Exponential
|
||||
}
|
||||
|
||||
public class LevelVisualizationProviderConfiguration : AbstractConfiguration
|
||||
{
|
||||
private double _smoothing = 8;
|
||||
public double Smoothing
|
||||
{
|
||||
get => _smoothing;
|
||||
set => SetProperty(ref _smoothing, value);
|
||||
}
|
||||
|
||||
private double _scale = 4;
|
||||
public double Scale
|
||||
{
|
||||
get => _scale;
|
||||
set => SetProperty(ref _scale, value);
|
||||
}
|
||||
|
||||
private ConversionMode _conversionMode = ConversionMode.Exponential;
|
||||
public ConversionMode ConversionMode
|
||||
{
|
||||
get => _conversionMode;
|
||||
set => SetProperty(ref _conversionMode, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public class LevelVisualizationProvider : IVisualizationProvider
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const int DB_THRESHOLD = 90;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly LevelVisualizationProviderConfiguration _configuration;
|
||||
private readonly AudioBuffer _audioBuffer;
|
||||
|
||||
private float[] _sampleDataLeft;
|
||||
private float[] _sampleDataRight;
|
||||
private float[] _sampleDataMix;
|
||||
private double _smoothingFactor;
|
||||
|
||||
public IConfiguration Configuration => _configuration;
|
||||
public float[] VisualizationData { get; } = new float[3];
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public LevelVisualizationProvider(LevelVisualizationProviderConfiguration configuration, AudioBuffer audioBuffer)
|
||||
{
|
||||
this._configuration = configuration;
|
||||
this._audioBuffer = audioBuffer;
|
||||
|
||||
configuration.PropertyChanged += (sender, args) => RecalculateConfigValues(args.PropertyName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_sampleDataLeft = new float[_audioBuffer.Size];
|
||||
_sampleDataRight = new float[_audioBuffer.Size];
|
||||
_sampleDataMix = new float[_audioBuffer.Size];
|
||||
|
||||
RecalculateConfigValues(null);
|
||||
}
|
||||
|
||||
private void RecalculateConfigValues(string changedPropertyName)
|
||||
{
|
||||
if ((changedPropertyName == null) || (changedPropertyName == nameof(LevelVisualizationProviderConfiguration.Smoothing)))
|
||||
_smoothingFactor = MathHelper.Clamp(0.000015 * Math.Pow(2, _configuration.Smoothing), 0, 0.99);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
_audioBuffer.CopyLeftInto(ref _sampleDataLeft, 0);
|
||||
_audioBuffer.CopyRightInto(ref _sampleDataRight, 0);
|
||||
_audioBuffer.CopyMixInto(ref _sampleDataMix, 0);
|
||||
|
||||
float levelLeft = Convert(GetRms(ref _sampleDataLeft));
|
||||
float levelRight = Convert(GetRms(ref _sampleDataRight));
|
||||
float levelMix = Convert(GetRms(ref _sampleDataMix));
|
||||
|
||||
UpdateData(0, levelLeft);
|
||||
UpdateData(1, levelRight);
|
||||
UpdateData(2, levelMix);
|
||||
}
|
||||
|
||||
private float GetRms(ref float[] data) => (float)Math.Sqrt(data.Average(x => x * x));
|
||||
|
||||
private float Convert(float level)
|
||||
{
|
||||
switch (_configuration.ConversionMode)
|
||||
{
|
||||
case ConversionMode.Exponential:
|
||||
return level * level;
|
||||
|
||||
case ConversionMode.Logarithmic:
|
||||
return (float)Math.Max(0, (DB_THRESHOLD + (Math.Log10(level) * 20)) / DB_THRESHOLD);
|
||||
|
||||
default: return level;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateData(int index, float level)
|
||||
{
|
||||
VisualizationData[index] = (float)((VisualizationData[index] * _smoothingFactor) + (level * _configuration.Scale * (1.0 - _smoothingFactor)));
|
||||
if (double.IsNaN(VisualizationData[index])) VisualizationData[index] = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using KeyboardAudioVisualizer.AudioProcessing.VisualizationPRovider;
|
||||
using KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider;
|
||||
using RGB.NET.Brushes;
|
||||
using RGB.NET.Brushes.Gradients;
|
||||
using RGB.NET.Core;
|
||||
|
||||
70
KeyboardAudioVisualizer/Brushes/LevelBarBrush.cs
Normal file
70
KeyboardAudioVisualizer/Brushes/LevelBarBrush.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider;
|
||||
using RGB.NET.Brushes;
|
||||
using RGB.NET.Brushes.Gradients;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace KeyboardAudioVisualizer.Brushes
|
||||
{
|
||||
public class LevelBarBrush : LinearGradientBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly IVisualizationProvider _visualizationProvider;
|
||||
public LevelBarDirection Direction { get; set; }
|
||||
public int DataIndex { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public LevelBarBrush(IVisualizationProvider visualizationProvider, IGradient gradient, LevelBarDirection direction, int dataIndex)
|
||||
: base(gradient)
|
||||
{
|
||||
this._visualizationProvider = visualizationProvider;
|
||||
this.Direction = direction;
|
||||
this.DataIndex = dataIndex;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget)
|
||||
{
|
||||
double offset = CalculateOffset(rectangle, renderTarget);
|
||||
return offset < _visualizationProvider.VisualizationData[DataIndex] ? Gradient.GetColor(offset) : Color.Transparent;
|
||||
}
|
||||
|
||||
private double CalculateOffset(Rectangle rectangle, BrushRenderTarget renderTarget)
|
||||
{
|
||||
switch (Direction)
|
||||
{
|
||||
case LevelBarDirection.Left:
|
||||
return (rectangle.Size.Width - renderTarget.Rectangle.Center.X) / rectangle.Size.Width;
|
||||
|
||||
case LevelBarDirection.Right:
|
||||
return renderTarget.Rectangle.Center.X / rectangle.Size.Width;
|
||||
|
||||
case LevelBarDirection.Top:
|
||||
return (rectangle.Size.Height - renderTarget.Rectangle.Center.Y) / rectangle.Size.Height;
|
||||
|
||||
case LevelBarDirection.Bottom:
|
||||
return renderTarget.Rectangle.Center.Y / rectangle.Size.Height;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Data
|
||||
|
||||
public enum LevelBarDirection
|
||||
{
|
||||
Left, Right, Top, Bottom
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace KeyboardAudioVisualizer.Configuration
|
||||
{
|
||||
public class AbstractConfiguration : INotifyPropertyChanged
|
||||
public class AbstractConfiguration : IConfiguration, INotifyPropertyChanged
|
||||
{
|
||||
#region Events
|
||||
|
||||
|
||||
5
KeyboardAudioVisualizer/Configuration/IConfiguration.cs
Normal file
5
KeyboardAudioVisualizer/Configuration/IConfiguration.cs
Normal file
@ -0,0 +1,5 @@
|
||||
namespace KeyboardAudioVisualizer.Configuration
|
||||
{
|
||||
// DarthAffe 05.08.2017: Marker interface
|
||||
public interface IConfiguration { }
|
||||
}
|
||||
202
KeyboardAudioVisualizer/Controls/Formular.cs
Normal file
202
KeyboardAudioVisualizer/Controls/Formular.cs
Normal file
@ -0,0 +1,202 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace KeyboardAudioVisualizer.Controls
|
||||
{
|
||||
public class Formular : Panel
|
||||
{
|
||||
#region DependencyProperties
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
public static readonly DependencyProperty RowHeightProperty = DependencyProperty.Register("RowHeight", typeof(double), typeof(Formular),
|
||||
new FrameworkPropertyMetadata(24.0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double RowHeight
|
||||
{
|
||||
get => (double)GetValue(RowHeightProperty);
|
||||
set
|
||||
{
|
||||
if (value < 0) throw new ArgumentOutOfRangeException(nameof(RowHeight), "Row height can't be negative");
|
||||
SetValue(RowHeightProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty LabelWidthProperty = DependencyProperty.Register("LabelWidth", typeof(double), typeof(Formular),
|
||||
new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double LabelWidth
|
||||
{
|
||||
get => (double)GetValue(LabelWidthProperty);
|
||||
set
|
||||
{
|
||||
if (value < 0) throw new ArgumentOutOfRangeException(nameof(RowHeight), "Label width can't be negative");
|
||||
SetValue(LabelWidthProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ElementSpacingProperty = DependencyProperty.Register("ElementSpacing", typeof(double), typeof(Formular),
|
||||
new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double ElementSpacing
|
||||
{
|
||||
get => (double)GetValue(ElementSpacingProperty);
|
||||
set => SetValue(ElementSpacingProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty RowSpacingProperty = DependencyProperty.Register("RowSpacing", typeof(double), typeof(Formular),
|
||||
new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double RowSpacing
|
||||
{
|
||||
get => (double)GetValue(RowSpacingProperty);
|
||||
set => SetValue(RowSpacingProperty, value);
|
||||
}
|
||||
|
||||
// ReSharper restore InconsistentNaming
|
||||
#endregion
|
||||
|
||||
#region AttachedProperties
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
public static readonly DependencyProperty IsLabelProperty = DependencyProperty.RegisterAttached("IsLabel", typeof(bool), typeof(Formular),
|
||||
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public static void SetIsLabel(UIElement element, bool value) => element.SetValue(IsLabelProperty, value);
|
||||
public static bool GetIsLabel(UIElement element) => (bool)element.GetValue(IsLabelProperty);
|
||||
|
||||
public static readonly DependencyProperty LineBreaksProperty = DependencyProperty.RegisterAttached("LineBreaks", typeof(int), typeof(Formular),
|
||||
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public static void SetLineBreaks(UIElement element, int value) => element.SetValue(LineBreaksProperty, value);
|
||||
public static int GetLineBreaks(UIElement element) => (int)element.GetValue(LineBreaksProperty);
|
||||
|
||||
public static readonly DependencyProperty RowSpanProperty = DependencyProperty.RegisterAttached("RowSpan", typeof(int), typeof(Formular),
|
||||
new FrameworkPropertyMetadata(1, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public static void SetRowSpan(DependencyObject element, int value) => element.SetValue(RowSpanProperty, value);
|
||||
public static int GetRowSpan(DependencyObject element) => (int)element.GetValue(RowSpanProperty);
|
||||
|
||||
// ReSharper restore InconsistentNaming
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
if (InternalChildren.Count == 0) return new Size(0, 0);
|
||||
|
||||
FormularLayout layout = new FormularLayout(RowHeight, LabelWidth, ElementSpacing, RowSpacing);
|
||||
|
||||
foreach (UIElement child in InternalChildren)
|
||||
{
|
||||
child.Measure(availableSize);
|
||||
layout.AddElement(child);
|
||||
}
|
||||
|
||||
return new Size(layout.Width, layout.Height);
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
if (InternalChildren.Count == 0) return new Size(0, 0);
|
||||
|
||||
FormularLayout layout = new FormularLayout(RowHeight, LabelWidth, ElementSpacing, RowSpacing);
|
||||
|
||||
foreach (UIElement child in InternalChildren)
|
||||
child.Arrange(layout.AddElement(child));
|
||||
|
||||
return new Size(layout.Width, layout.Height);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data
|
||||
|
||||
private class FormularLayout
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly double _rowHeight;
|
||||
private readonly double _labelWidth;
|
||||
private readonly double _elementSpacing;
|
||||
private readonly double _rowSpacing;
|
||||
|
||||
private double _currentRowWidth;
|
||||
|
||||
private int _newRows = 0;
|
||||
private int _rows = -1;
|
||||
private double _currentMaxWidth;
|
||||
public double Width => Math.Max((Math.Max(_currentMaxWidth, _currentRowWidth) - _elementSpacing), 0);
|
||||
public double Height => ((_rows + 1) * _rowHeight) + (_rows * _rowSpacing);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public FormularLayout(double rowHeight, double labelWidth, double elementSpacing, double rowSpacing)
|
||||
{
|
||||
this._rowHeight = rowHeight;
|
||||
this._labelWidth = labelWidth;
|
||||
this._elementSpacing = elementSpacing;
|
||||
this._rowSpacing = rowSpacing;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public Rect AddElement(UIElement element)
|
||||
{
|
||||
bool isLabel = GetIsLabel(element);
|
||||
int lineBreaks = GetLineBreaks(element);
|
||||
int rowSpan = GetRowSpan(element);
|
||||
|
||||
double elementWidth = isLabel ? _labelWidth : element.DesiredSize.Width;
|
||||
double height = _rowHeight;
|
||||
|
||||
if (_newRows > 0)
|
||||
{
|
||||
AddLineBreaks(_newRows);
|
||||
_newRows = 0;
|
||||
}
|
||||
|
||||
if (lineBreaks > 0) AddLineBreaks(lineBreaks);
|
||||
else if (isLabel) AddLineBreaks(1);
|
||||
else if (_rows < 0) _rows = 0;
|
||||
|
||||
if (!isLabel && (_currentRowWidth < _labelWidth))
|
||||
_currentRowWidth = _labelWidth + _elementSpacing;
|
||||
|
||||
if (rowSpan > 1)
|
||||
{
|
||||
height = (rowSpan * _rowHeight) + ((rowSpan - 1) * _rowSpacing);
|
||||
_newRows = Math.Max(_newRows, rowSpan - 1);
|
||||
}
|
||||
|
||||
if (element is FrameworkElement fe)
|
||||
fe.MaxHeight = height;
|
||||
|
||||
Rect rect = new Rect(new Point(_currentRowWidth, (_rows * _rowHeight) + (_rows * _rowSpacing)), new Size(elementWidth, height));
|
||||
|
||||
_currentRowWidth += elementWidth + _elementSpacing;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
private void AddLineBreaks(int count)
|
||||
{
|
||||
if (count <= 0) return;
|
||||
|
||||
_currentMaxWidth = Math.Max(_currentMaxWidth, _currentRowWidth);
|
||||
|
||||
_currentRowWidth = 0;
|
||||
_rows += count;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,7 @@ namespace KeyboardAudioVisualizer.Helper
|
||||
{
|
||||
#region Methods
|
||||
|
||||
public static double Clamp(double value, double min, double max) => Math.Max(min, Math.Min(max / 2.0, value));
|
||||
public static double Clamp(double value, double min, double max) => Math.Max(min, Math.Min(max, value));
|
||||
public static float Clamp(float value, float min, float max) => (float)Clamp((double)value, min, max);
|
||||
|
||||
#endregion
|
||||
|
||||
@ -48,15 +48,24 @@
|
||||
<Reference Include="MathNet.Numerics, Version=3.20.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MathNet.Numerics.3.20.0\lib\net40\MathNet.Numerics.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Brushes, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="RGB.NET.Brushes">
|
||||
<HintPath>..\packages\RGB.NET.Brushes.1.0.0\lib\net45\RGB.NET.Brushes.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="RGB.NET.Core">
|
||||
<HintPath>..\packages\RGB.NET.Core.1.0.0\lib\net45\RGB.NET.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.CoolerMaster">
|
||||
<HintPath>..\packages\RGB.NET.Devices.CoolerMaster.1.0.0\lib\net45\RGB.NET.Devices.CoolerMaster.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.Corsair, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.Corsair.1.0.0\lib\net45\RGB.NET.Devices.Corsair.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Devices.Logitech, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Devices.Logitech.1.0.0\lib\net45\RGB.NET.Devices.Logitech.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Groups, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RGB.NET.Groups.1.0.0\lib\net45\RGB.NET.Groups.dll</HintPath>
|
||||
</Reference>
|
||||
@ -64,6 +73,9 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -99,10 +111,14 @@
|
||||
<Compile Include="AudioProcessing\IAudioProcessor.cs" />
|
||||
<Compile Include="AudioProcessing\Spectrum\ISpectrumProvider.cs" />
|
||||
<Compile Include="AudioProcessing\Spectrum\FourierSpectrumProvider.cs" />
|
||||
<Compile Include="AudioProcessing\VisualizationPRovider\FrequencyBarsVisualizationProvider.cs" />
|
||||
<Compile Include="AudioProcessing\VisualizationPRovider\IVisualizationProvider.cs" />
|
||||
<Compile Include="AudioProcessing\VisualizationProvider\FrequencyBarsVisualizationProvider.cs" />
|
||||
<Compile Include="AudioProcessing\VisualizationProvider\IVisualizationProvider.cs" />
|
||||
<Compile Include="AudioProcessing\VisualizationProvider\LevelVisualizationProvider.cs" />
|
||||
<Compile Include="Brushes\FrequencyBarsBrush.cs" />
|
||||
<Compile Include="Brushes\LevelBarBrush.cs" />
|
||||
<Compile Include="Configuration\AbstractConfiguration.cs" />
|
||||
<Compile Include="Configuration\IConfiguration.cs" />
|
||||
<Compile Include="Controls\Formular.cs" />
|
||||
<Compile Include="Controls\ImageButton.cs" />
|
||||
<Compile Include="Helper\ActionCommand.cs" />
|
||||
<Compile Include="Helper\ExceptionExtension.cs" />
|
||||
@ -135,7 +151,10 @@
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="NuGet.Config" />
|
||||
<None Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@ -174,6 +193,14 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\GroupBox.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\Formular.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\ToolTip.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@ -182,12 +209,19 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UI\Configuration\FrequencyBarsConfiguration.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\background.png" />
|
||||
<Resource Include="Resources\close.png" />
|
||||
<Resource Include="Resources\minimize.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="UI\Visualization\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\RGB.NET.Devices.Corsair.1.0.0\build\net45\RGB.NET.Devices.Corsair.targets" Condition="Exists('..\packages\RGB.NET.Devices.Corsair.1.0.0\build\net45\RGB.NET.Devices.Corsair.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
@ -195,5 +229,9 @@
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\RGB.NET.Devices.Corsair.1.0.0\build\net45\RGB.NET.Devices.Corsair.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\RGB.NET.Devices.Corsair.1.0.0\build\net45\RGB.NET.Devices.Corsair.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\RGB.NET.Devices.CoolerMaster.1.0.0\build\net45\RGB.NET.Devices.CoolerMaster.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\RGB.NET.Devices.CoolerMaster.1.0.0\build\net45\RGB.NET.Devices.CoolerMaster.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\RGB.NET.Devices.Logitech.1.0.0\build\net45\RGB.NET.Devices.Logitech.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\RGB.NET.Devices.Logitech.1.0.0\build\net45\RGB.NET.Devices.Logitech.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\RGB.NET.Devices.CoolerMaster.1.0.0\build\net45\RGB.NET.Devices.CoolerMaster.targets" Condition="Exists('..\packages\RGB.NET.Devices.CoolerMaster.1.0.0\build\net45\RGB.NET.Devices.CoolerMaster.targets')" />
|
||||
<Import Project="..\packages\RGB.NET.Devices.Logitech.1.0.0\build\net45\RGB.NET.Devices.Logitech.targets" Condition="Exists('..\packages\RGB.NET.Devices.Logitech.1.0.0\build\net45\RGB.NET.Devices.Logitech.targets')" />
|
||||
</Project>
|
||||
@ -1,18 +1,22 @@
|
||||
<styles:CachedResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:window="clr-namespace:KeyboardAudioVisualizer.Controls"
|
||||
xmlns:ui="clr-namespace:KeyboardAudioVisualizer.UI"
|
||||
xmlns:styles="clr-namespace:KeyboardAudioVisualizer.Styles">
|
||||
xmlns:styles="clr-namespace:KeyboardAudioVisualizer.Styles"
|
||||
xmlns:controls="clr-namespace:KeyboardAudioVisualizer.Controls">
|
||||
|
||||
<styles:CachedResourceDictionary.MergedDictionaries>
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/BlurredDecorationWindow.xaml" />
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/ImageButton.xaml" />
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/Formular.xaml" />
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/GroupBox.xaml" />
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/ToolTip.xaml" />
|
||||
</styles:CachedResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="{x:Type window:BlurredDecorationWindow}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" />
|
||||
<Style TargetType="{x:Type controls:BlurredDecorationWindow}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" />
|
||||
<Style TargetType="{x:Type ui:ConfigurationWindow}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" />
|
||||
<Style TargetType="{x:Type window:ImageButton}" BasedOn="{StaticResource StyleImageButton}" />
|
||||
<Style TargetType="{x:Type controls:ImageButton}" BasedOn="{StaticResource StyleImageButton}" />
|
||||
<Style TargetType="{x:Type controls:Formular}" BasedOn="{StaticResource StyleFormular}" />
|
||||
<Style TargetType="GroupBox" BasedOn="{StaticResource StyleGroupBoxBox}" />
|
||||
<Style TargetType="ToolTip" BasedOn="{StaticResource StyleToolTip}" />
|
||||
|
||||
</styles:CachedResourceDictionary>
|
||||
|
||||
98
KeyboardAudioVisualizer/Styles/Formular.xaml
Normal file
98
KeyboardAudioVisualizer/Styles/Formular.xaml
Normal file
@ -0,0 +1,98 @@
|
||||
<styles:CachedResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:styles="clr-namespace:KeyboardAudioVisualizer.Styles"
|
||||
xmlns:controls="clr-namespace:KeyboardAudioVisualizer.Controls">
|
||||
|
||||
<styles:CachedResourceDictionary.MergedDictionaries>
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/FrameworkElement.xaml" />
|
||||
</styles:CachedResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="StyleFormular"
|
||||
BasedOn="{StaticResource StyleFrameworkElement}"
|
||||
TargetType="{x:Type controls:Formular}">
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
<Setter Property="LabelWidth" Value="160" />
|
||||
<Setter Property="ElementSpacing" Value="8" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StyleLabelFormular"
|
||||
TargetType="Label">
|
||||
<Setter Property="Foreground" Value="{StaticResource BrushForeground}" />
|
||||
<Setter Property="FontSize" Value="{StaticResource FontSizeDefault}" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="FontFamily" Value="pack://application:,,,/Resources/#Cinzel" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
|
||||
<!-- DarthAffe 04.08.2017: Quite a botch, but it works ... -->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Label">
|
||||
<TextBlock HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
FontFamily="{TemplateBinding FontFamily}"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
FontStyle="{TemplateBinding FontStyle}"
|
||||
FontWeight="{TemplateBinding FontWeight}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Text="{TemplateBinding Content}" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StyleTextBlockFormular"
|
||||
TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{StaticResource BrushForeground}" />
|
||||
<Setter Property="FontSize" Value="{StaticResource FontSizeDefault}" />
|
||||
<Setter Property="FontFamily" Value="pack://application:,,,/Resources/#Cinzel" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="TextAlignment" Value="Left" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StyleListBoxItemFormular"
|
||||
TargetType="ListBoxItem">
|
||||
<Setter Property="MinWidth" Value="0" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="Padding" Value="0,2" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border x:Name="Border"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StyleListBoxFormular"
|
||||
TargetType="ListBox">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
<Setter Property="MinWidth" Value="0" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource StyleListBoxItemFormular}" />
|
||||
</Style>
|
||||
|
||||
</styles:CachedResourceDictionary>
|
||||
|
||||
34
KeyboardAudioVisualizer/Styles/GroupBox.xaml
Normal file
34
KeyboardAudioVisualizer/Styles/GroupBox.xaml
Normal file
@ -0,0 +1,34 @@
|
||||
<styles:CachedResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:styles="clr-namespace:KeyboardAudioVisualizer.Styles">
|
||||
|
||||
<styles:CachedResourceDictionary.MergedDictionaries>
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/FrameworkElement.xaml" />
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/Theme.xaml" />
|
||||
</styles:CachedResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="StyleGroupBoxBox"
|
||||
BasedOn="{StaticResource StyleFrameworkElement}"
|
||||
TargetType="GroupBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource BrushForeground}" />
|
||||
<Setter Property="FontSize" Value="{StaticResource FontSizeDefault}" />
|
||||
<Setter Property="FontFamily" Value="pack://application:,,,/Resources/#Cinzel" />
|
||||
<Setter Property="Background" Value="{StaticResource BrushBoxBackground}" />
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BrushBoxBorder}" />
|
||||
<Setter Property="BorderThickness" Value="2" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupBox">
|
||||
<Border BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Background="{TemplateBinding Background}">
|
||||
<ContentPresenter Margin="6,4" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</styles:CachedResourceDictionary>
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
<transitions:FadeTransition x:Key="TransitionFade" Duration="0:0:0.200" />
|
||||
|
||||
<Style x:Key="StyleTabControlNavigation"
|
||||
TargetType="{x:Type TabControl}">
|
||||
TargetType="TabControl">
|
||||
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
@ -23,7 +23,7 @@
|
||||
<!-- DarthAffe 04.08.2017: The TabControl is a shitty one to style - if unused parts are removed it throws exceptions ... -->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TabControl}">
|
||||
<ControlTemplate TargetType="TabControl">
|
||||
<Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="ColumnDefinition0" />
|
||||
@ -43,6 +43,7 @@
|
||||
<Border x:Name="ContentPanel"
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Margin="4"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
@ -97,7 +98,7 @@
|
||||
|
||||
<Style x:Key="StyleTabItemNavigation"
|
||||
BasedOn="{StaticResource StyleFrameworkElement}"
|
||||
TargetType="{x:Type TabItem}">
|
||||
TargetType="TabItem">
|
||||
|
||||
<Setter Property="Height" Value="72" />
|
||||
<Setter Property="FontSize" Value="{StaticResource FontSizeNavigation}" />
|
||||
@ -105,7 +106,7 @@
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TabItem}">
|
||||
<ControlTemplate TargetType="TabItem">
|
||||
<Border Margin="8,0"
|
||||
Padding="4"
|
||||
IsHitTestVisible="True"
|
||||
@ -171,7 +172,7 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource StyleTabItemNavigation}" TargetType="{x:Type TabItem}" />
|
||||
<Style BasedOn="{StaticResource StyleTabItemNavigation}" TargetType="TabItem" />
|
||||
|
||||
</styles:CachedResourceDictionary>
|
||||
|
||||
|
||||
@ -3,26 +3,32 @@
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:presentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">
|
||||
<!-- ### Colors ### -->
|
||||
<Color x:Key="ColorTelegrey">#FFD0D0D0</Color>
|
||||
<Color x:Key="ColorGainsboro">#FFDCDCDC</Color>
|
||||
<Color x:Key="ColorJetBlack">#111111</Color>
|
||||
<Color x:Key="ColorJetBlackTransparent">#A0111111</Color>
|
||||
<Color x:Key="ColorJetBlackTransparent">#B8111111</Color>
|
||||
<Color x:Key="ColorJetBlackSuperTransparent">#60111111</Color>
|
||||
<Color x:Key="ColorBlackTransparent">#50000000</Color>
|
||||
<Color x:Key="ColorBananaYellow">#FFE135</Color>
|
||||
|
||||
<!-- ### Brushes ### -->
|
||||
<SolidColorBrush x:Key="BrushBackground" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlack}" />
|
||||
<SolidColorBrush x:Key="BrushForeground" presentationOptions:Freeze="True" Color="{StaticResource ColorGainsboro}" />
|
||||
|
||||
<!-- Window -->
|
||||
<SolidColorBrush x:Key="BrushWindowBorder" presentationOptions:Freeze="True" Color="{StaticResource ColorBlackTransparent}" />
|
||||
<SolidColorBrush x:Key="BrushWindowBackground" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlack}" />
|
||||
|
||||
<!-- Box -->
|
||||
<SolidColorBrush x:Key="BrushBoxBorder" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlackTransparent}" />
|
||||
<SolidColorBrush x:Key="BrushBoxBackground" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlackSuperTransparent}" />
|
||||
|
||||
<!-- ToolTip -->
|
||||
<SolidColorBrush x:Key="BrushTooltipForeground" presentationOptions:Freeze="True" Color="{StaticResource ColorTelegrey}" />
|
||||
<SolidColorBrush x:Key="BrushTooltipForeground" presentationOptions:Freeze="True" Color="{StaticResource ColorGainsboro}" />
|
||||
<SolidColorBrush x:Key="BrushTooltipBorder" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlack}" />
|
||||
<SolidColorBrush x:Key="BrushTooltipBackground" presentationOptions:Freeze="True" Color="{StaticResource ColorJetBlackTransparent}" />
|
||||
|
||||
<!-- Navigation -->
|
||||
<SolidColorBrush x:Key="BrushNavigationItem" presentationOptions:Freeze="True" Color="{StaticResource ColorTelegrey}" />
|
||||
<SolidColorBrush x:Key="BrushNavigationItem" presentationOptions:Freeze="True" Color="{StaticResource ColorGainsboro}" />
|
||||
<SolidColorBrush x:Key="BrushNavigationItemBlur" presentationOptions:Freeze="True" Color="{StaticResource ColorBananaYellow}" />
|
||||
|
||||
|
||||
@ -31,7 +37,7 @@
|
||||
|
||||
|
||||
<!-- ### Fonts ### -->
|
||||
<sys:Double x:Key="FontSizeDefault">13</sys:Double>
|
||||
<sys:Double x:Key="FontSizeDefault">14</sys:Double>
|
||||
<sys:Double x:Key="FontSizeTooltip">14</sys:Double>
|
||||
<sys:Double x:Key="FontSizeNavigation">28</sys:Double>
|
||||
</ResourceDictionary>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<styles:CachedResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:styles="clr-namespace:KeyboardAudioVisualizer.Styles">
|
||||
|
||||
|
||||
<styles:CachedResourceDictionary.MergedDictionaries>
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/FrameworkElement.xaml" />
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/Theme.xaml" />
|
||||
@ -9,28 +9,23 @@
|
||||
|
||||
<Style x:Key="StyleToolTip"
|
||||
BasedOn="{StaticResource StyleFrameworkElement}"
|
||||
TargetType="ToolTip">
|
||||
<Style.Setters>
|
||||
<Setter Property="Foreground" Value="{StaticResource BrushTooltipForeground}" />
|
||||
<Setter Property="FontSize" Value="{StaticResource FontSizeTooltip}" />
|
||||
<Setter Property="FontFamily" Value="pack://application:,,,/Resources/#Cinzel" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToolTip">
|
||||
<Border BorderThickness="1"
|
||||
BorderBrush="{StaticResource BrushTooltipBorder}"
|
||||
Background="{StaticResource BrushTooltipBackground}">
|
||||
<ContentPresenter Margin="6,4" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style.Setters>
|
||||
TargetType="{x:Type ToolTip}">
|
||||
<Setter Property="Foreground" Value="{StaticResource BrushTooltipForeground}" />
|
||||
<Setter Property="FontSize" Value="{StaticResource FontSizeTooltip}" />
|
||||
<Setter Property="FontFamily" Value="pack://application:,,,/Resources/#Cinzel" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToolTip}">
|
||||
<Border BorderThickness="1"
|
||||
BorderBrush="{StaticResource BrushTooltipBorder}"
|
||||
Background="{StaticResource BrushTooltipBackground}">
|
||||
<ContentPresenter Margin="6,4" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</styles:CachedResourceDictionary>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
<styles:CachedResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:styles="clr-namespace:KeyboardAudioVisualizer.Styles"
|
||||
xmlns:visualizationPRovider="clr-namespace:KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider"
|
||||
xmlns:controls="clr-namespace:KeyboardAudioVisualizer.Controls">
|
||||
|
||||
<styles:CachedResourceDictionary.MergedDictionaries>
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/FrameworkElement.xaml" />
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/Theme.xaml" />
|
||||
</styles:CachedResourceDictionary.MergedDictionaries>
|
||||
|
||||
<DataTemplate DataType="{x:Type visualizationPRovider:FrequencyBarsVisualizationProviderConfiguration}">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" />
|
||||
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" />
|
||||
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" />
|
||||
</Grid.Resources>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="8" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="8" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:Formular Grid.Column="0">
|
||||
</controls:Formular>
|
||||
|
||||
<controls:Formular Grid.Column="1">
|
||||
</controls:Formular>
|
||||
|
||||
<controls:Formular Grid.Column="2">
|
||||
</controls:Formular>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</styles:CachedResourceDictionary>
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using KeyboardAudioVisualizer.Helper;
|
||||
|
||||
namespace KeyboardAudioVisualizer.UI
|
||||
@ -7,6 +9,8 @@ namespace KeyboardAudioVisualizer.UI
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public Version Version => Assembly.GetEntryAssembly().GetName().Version;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
xmlns:ui="clr-namespace:KeyboardAudioVisualizer.UI"
|
||||
xmlns:controls="clr-namespace:KeyboardAudioVisualizer.Controls"
|
||||
xmlns:styles="clr-namespace:KeyboardAudioVisualizer.Styles"
|
||||
xmlns:core="clr-namespace:RGB.NET.Core;assembly=RGB.NET.Core"
|
||||
xmlns:audioProcessing="clr-namespace:KeyboardAudioVisualizer.AudioProcessing"
|
||||
mc:Ignorable="d"
|
||||
Title="Keyboard Audio-Visualizer # Configuration"
|
||||
Icon="pack://application:,,,/KeyboardAudioVisualizer;component/Resources/Icon.ico"
|
||||
@ -13,7 +15,12 @@
|
||||
Width="1280" Height="720">
|
||||
|
||||
<controls:BlurredDecorationWindow.Resources>
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/Navigation.xaml" />
|
||||
<styles:CachedResourceDictionary>
|
||||
<styles:CachedResourceDictionary.MergedDictionaries>
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/Navigation.xaml" />
|
||||
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/UI/Configuration/FrequencyBarsConfiguration.xaml" />
|
||||
</styles:CachedResourceDictionary.MergedDictionaries>
|
||||
</styles:CachedResourceDictionary>
|
||||
</controls:BlurredDecorationWindow.Resources>
|
||||
|
||||
<controls:BlurredDecorationWindow.DataContext>
|
||||
@ -22,11 +29,59 @@
|
||||
|
||||
<TabControl Style="{StaticResource StyleTabControlNavigation}">
|
||||
<TabItem Header="Primary">
|
||||
<Border Background="Black"></Border>
|
||||
<DockPanel>
|
||||
<GroupBox DockPanel.Dock="Top">
|
||||
<ContentControl Content="{Binding Source={x:Static audioProcessing:AudioProcessor.Instance}, Path=PrimaryVisualizationProvider.Configuration}" />
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Margin="0,8,0,0">
|
||||
<ContentControl Content="{Binding Source={x:Static audioProcessing:AudioProcessor.Instance}, Path=PrimaryVisualizationProvider}" />
|
||||
</GroupBox>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Secondary">
|
||||
<Border Background="White"></Border>
|
||||
<DockPanel>
|
||||
<GroupBox DockPanel.Dock="Top">
|
||||
<ContentControl Content="{Binding Source={x:Static audioProcessing:AudioProcessor.Instance}, Path=SecondaryVisualizationProvider.Configuration}" />
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Margin="0,8,0,0">
|
||||
<ContentControl Content="{Binding Source={x:Static audioProcessing:AudioProcessor.Instance}, Path=SecondaryVisualizationProvider}" />
|
||||
</GroupBox>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Settings">
|
||||
<GroupBox VerticalAlignment="Top">
|
||||
<controls:Formular>
|
||||
<controls:Formular.Resources>
|
||||
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" />
|
||||
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" />
|
||||
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" />
|
||||
</controls:Formular.Resources>
|
||||
|
||||
<Label controls:Formular.IsLabel="True" Content="Version:" />
|
||||
<TextBlock Text="{Binding Version}" />
|
||||
|
||||
<Label controls:Formular.LineBreaks="1" controls:Formular.IsLabel="True" Content="Connected Devices:" />
|
||||
<ListBox Width="400" ItemsSource="{Binding Source={x:Static core:RGBSurface.Instance}, Path=Devices}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Style="{StaticResource StyleTextBlockFormular}">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding StringFormat="> {0} {1} ({2})">
|
||||
<Binding Path="DeviceInfo.Manufacturer" />
|
||||
<Binding Path="DeviceInfo.Model" />
|
||||
<Binding Path="DeviceInfo.DeviceType" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</controls:Formular>
|
||||
</GroupBox>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
|
||||
@ -5,6 +5,9 @@
|
||||
<package id="MathNet.Numerics" version="3.20.0" targetFramework="net461" />
|
||||
<package id="RGB.NET.Brushes" version="1.0.0" targetFramework="net461" />
|
||||
<package id="RGB.NET.Core" version="1.0.0" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.CoolerMaster" version="1.0.0" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Corsair" version="1.0.0" targetFramework="net461" />
|
||||
<package id="RGB.NET.Devices.Logitech" version="1.0.0" targetFramework="net461" />
|
||||
<package id="RGB.NET.Groups" version="1.0.0" targetFramework="net461" />
|
||||
<package id="System.ValueTuple" version="4.3.1" targetFramework="net461" />
|
||||
</packages>
|
||||
Loading…
x
Reference in New Issue
Block a user