- 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.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
@@ -227,8 +226,6 @@ namespace DesktopMagic
lastFft = fft;
try
{
Stopwatch sw = new Stopwatch();
sw.Start();
Bitmap bm = new Bitmap(880, 300);
int offset = 0;
+13 -17
View File
@@ -78,31 +78,27 @@
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
<Grid>
<Grid Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Display Font: " Grid.Column="0" VerticalAlignment="Center"></TextBlock>
<ComboBox x:Name="fontComboBox" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
</Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<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">
<TextBlock Text="Display Font: " Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
<ComboBox x:Name="fontComboBox" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
<TextBlock Text="Corner Radius: " Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
<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">
<materialDesign:TextFieldAssist.CharacterCounterStyle>
<Style TargetType="TextBlock" />
</materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox>
</Grid>
</StackPanel>
<StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Left">
<StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
<DockPanel Margin="0,0,0,5">
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
<Rectangle x:Name="primaryColorRechtangle" Fill="White" />
+1 -2
View File
@@ -11,14 +11,13 @@ namespace DesktopMagic.Plugins
public PluginData(PluginWindow window)
{
this.window = window;
Theme = MainWindow.Theme;
}
public string Font => Theme.Font;
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);
@@ -75,7 +75,7 @@ namespace DesktopMagic
//Set the window style to noactivate.
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);
}
@@ -202,10 +202,10 @@ namespace DesktopMagic
{
if (prop.GetValue(instance) is Element element)
{
object[] attrs = prop.GetCustomAttributes(true);
foreach (object attr in attrs)
object[] attributes = prop.GetCustomAttributes(true);
foreach (object attribute in attributes)
{
if (attr is ElementAttribute elementAttribute)
if (attribute is ElementAttribute elementAttribute)
{
settingElements.Add(new SettingElement(element, elementAttribute.Name, elementAttribute.OrderIndex));
break;
@@ -294,7 +294,7 @@ namespace DesktopMagic
BitmapSource bitmapSource = BitmapSource.Create(
bitmapData.Width, bitmapData.Height,
bitmap.HorizontalResolution, bitmap.VerticalResolution,
System.Windows.Media.PixelFormats.Bgra32, null,
PixelFormats.Bgra32, null,
bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);
bitmap.UnlockBits(bitmapData);