- Minor code impovemnets

This commit is contained in:
Stone-Red-Code
2021-10-28 17:53:01 +02:00
parent 8f650ac35a
commit aeb31af2f9
4 changed files with 26 additions and 34 deletions
@@ -4,7 +4,6 @@ using NAudio.Wave;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Globalization; using System.Globalization;
@@ -227,8 +226,6 @@ namespace DesktopMagic
lastFft = fft; lastFft = fft;
try try
{ {
Stopwatch sw = new Stopwatch();
sw.Start();
Bitmap bm = new Bitmap(880, 300); Bitmap bm = new Bitmap(880, 300);
int offset = 0; int offset = 0;
+13 -17
View File
@@ -78,31 +78,27 @@
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch"> <Grid Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="2*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="Display Font: " Grid.Column="0" VerticalAlignment="Center"></TextBlock> <Grid.RowDefinitions>
<ComboBox x:Name="fontComboBox" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" /> <RowDefinition Height="Auto"/>
</Grid> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid> <TextBlock Text="Display Font: " Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
<Grid.ColumnDefinitions> <ComboBox x:Name="fontComboBox" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/> <TextBlock Text="Corner Radius: " Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
</Grid.ColumnDefinitions> <TextBox x:Name="cornerRadiusTextBox" Grid.Column="1" Grid.Row="1" Text="10" TextChanged="CornerRadiusTextBox_TextChanged" materialDesign:HintAssist.HelperText="In px" materialDesign:HintAssist.Hint="Enter a number">
<TextBlock Text="Corner Radius: " Grid.Column="0" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="cornerRadiusTextBox" Grid.Column="1" Text="10" TextChanged="CornerRadiusTextBox_TextChanged" materialDesign:HintAssist.HelperText="In px" materialDesign:HintAssist.Hint="Enter a number">
<materialDesign:TextFieldAssist.CharacterCounterStyle> <materialDesign:TextFieldAssist.CharacterCounterStyle>
<Style TargetType="TextBlock" /> <Style TargetType="TextBlock" />
</materialDesign:TextFieldAssist.CharacterCounterStyle> </materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox> </TextBox>
</Grid> </Grid>
</StackPanel> <StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
<StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Left">
<DockPanel Margin="0,0,0,5"> <DockPanel Margin="0,0,0,5">
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0"> <Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
<Rectangle x:Name="primaryColorRechtangle" Fill="White" /> <Rectangle x:Name="primaryColorRechtangle" Fill="White" />
+1 -2
View File
@@ -11,14 +11,13 @@ namespace DesktopMagic.Plugins
public PluginData(PluginWindow window) public PluginData(PluginWindow window)
{ {
this.window = window; this.window = window;
Theme = MainWindow.Theme;
} }
public string Font => Theme.Font; public string Font => Theme.Font;
public Color Color => Theme.PrimaryColor; public Color Color => Theme.PrimaryColor;
public ITheme Theme { get; } public ITheme Theme { get; } = MainWindow.Theme;
public Size WindowSize => new Size((int)window.ActualWidth, (int)window.ActualHeight); public Size WindowSize => new Size((int)window.ActualWidth, (int)window.ActualHeight);
@@ -75,7 +75,7 @@ namespace DesktopMagic
//Set the window style to noactivate. //Set the window style to noactivate.
WindowInteropHelper helper = new(this); WindowInteropHelper helper = new(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE, _ = WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }
@@ -202,10 +202,10 @@ namespace DesktopMagic
{ {
if (prop.GetValue(instance) is Element element) if (prop.GetValue(instance) is Element element)
{ {
object[] attrs = prop.GetCustomAttributes(true); object[] attributes = prop.GetCustomAttributes(true);
foreach (object attr in attrs) foreach (object attribute in attributes)
{ {
if (attr is ElementAttribute elementAttribute) if (attribute is ElementAttribute elementAttribute)
{ {
settingElements.Add(new SettingElement(element, elementAttribute.Name, elementAttribute.OrderIndex)); settingElements.Add(new SettingElement(element, elementAttribute.Name, elementAttribute.OrderIndex));
break; break;
@@ -294,7 +294,7 @@ namespace DesktopMagic
BitmapSource bitmapSource = BitmapSource.Create( BitmapSource bitmapSource = BitmapSource.Create(
bitmapData.Width, bitmapData.Height, bitmapData.Width, bitmapData.Height,
bitmap.HorizontalResolution, bitmap.VerticalResolution, bitmap.HorizontalResolution, bitmap.VerticalResolution,
System.Windows.Media.PixelFormats.Bgra32, null, PixelFormats.Bgra32, null,
bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride); bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);
bitmap.UnlockBits(bitmapData); bitmap.UnlockBits(bitmapData);