From aeb31af2f9c5506ed09bc0bc7c38257f3eb05422 Mon Sep 17 00:00:00 2001
From: Stone-Red-Code <56473591+Stone-Red-Code@users.noreply.github.com>
Date: Thu, 28 Oct 2021 17:53:01 +0200
Subject: [PATCH] - Minor code impovemnets
---
.../MusicVisualizerWindow.xaml.cs | 3 --
src/DesktopMagic/MainWindow.xaml | 44 +++++++++----------
src/DesktopMagic/Plugins/PluginData.cs | 3 +-
src/DesktopMagic/Plugins/PluginWindow.xaml.cs | 10 ++---
4 files changed, 26 insertions(+), 34 deletions(-)
diff --git a/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml.cs b/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml.cs
index 82e1754..37fea35 100644
--- a/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml.cs
+++ b/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml.cs
@@ -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;
diff --git a/src/DesktopMagic/MainWindow.xaml b/src/DesktopMagic/MainWindow.xaml
index 11eeeed..9c998bc 100644
--- a/src/DesktopMagic/MainWindow.xaml
+++ b/src/DesktopMagic/MainWindow.xaml
@@ -78,31 +78,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/DesktopMagic/Plugins/PluginData.cs b/src/DesktopMagic/Plugins/PluginData.cs
index c2ade16..57ab715 100644
--- a/src/DesktopMagic/Plugins/PluginData.cs
+++ b/src/DesktopMagic/Plugins/PluginData.cs
@@ -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);
diff --git a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
index 52a7423..cde49bd 100644
--- a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
+++ b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
@@ -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);