- Fix resize courser showing when windows are not in edit mode.

- Add more logging
- Implement some IntelliSense suggestions
This commit is contained in:
Stone-Red-Code
2021-10-26 23:16:38 +02:00
parent d75aef7460
commit b69bba68bb
11 changed files with 130 additions and 118 deletions
@@ -113,18 +113,18 @@ namespace DesktopMagic
{ {
listBox.Items.Clear(); listBox.Items.Clear();
CalendarItems calendarItem = new CalendarItems(); CalendarItems calendarItem = new CalendarItems();
calendarItem.eventname = "Termine: "; calendarItem.Eventname = "Termine: ";
calendarItem.font = MainWindow.Theme.Font; calendarItem.Font = MainWindow.Theme.Font;
calendarItem.color = MainWindow.Theme.PrimaryColor.ToString(); calendarItem.Color = MainWindow.Theme.PrimaryColor.ToString();
listBox.Items.Add(calendarItem); listBox.Items.Add(calendarItem);
for (int i = 0; i < upcomingEventNames.Count; i++) for (int i = 0; i < upcomingEventNames.Count; i++)
{ {
calendarItem = new CalendarItems(); calendarItem = new CalendarItems();
calendarItem.eventname = upcomingEventNames[i]; calendarItem.Eventname = upcomingEventNames[i];
calendarItem.dateTime = DateTime.Now.ToString("dd-MM-yyyy"); calendarItem.DateTime = DateTime.Now.ToString("dd-MM-yyyy");
calendarItem.font = MainWindow.Theme.Font; calendarItem.Font = MainWindow.Theme.Font;
calendarItem.color = MainWindow.Theme.PrimaryBrush.ToString(); calendarItem.Color = MainWindow.Theme.PrimaryBrush.ToString();
if (DateTime.Now < DateTime.Today.AddMonths(12) || upcomingEventTimes[i] == "-") if (DateTime.Now < DateTime.Today.AddMonths(12) || upcomingEventTimes[i] == "-")
{ {
@@ -40,7 +40,7 @@ namespace DesktopMagic
cpuCounter.InstanceName = "_Total"; cpuCounter.InstanceName = "_Total";
Timer t = new Timer(); Timer t = new Timer();
t.Interval = 500; t.Interval = 100;
t.Elapsed += UpdateTimer_Elapsed; t.Elapsed += UpdateTimer_Elapsed;
t.Start(); t.Start();
@@ -75,12 +75,16 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10;
WindowPos.SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
ResizeMode = ResizeMode.CanResize;
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
tileBar.CaptionHeight = 0;
WindowPos.SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
ResizeMode = ResizeMode.NoResize;
} }
textBlock.Background = MainWindow.Theme.BackgroundBrush; textBlock.Background = MainWindow.Theme.BackgroundBrush;
@@ -58,12 +58,16 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10;
WindowPos.SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
ResizeMode = ResizeMode.CanResize;
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
tileBar.CaptionHeight = 0;
WindowPos.SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
ResizeMode = ResizeMode.NoResize;
} }
textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font); textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
textBlock.Foreground = MainWindow.Theme.PrimaryBrush; textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Timers; using System.Timers;
@@ -61,13 +62,13 @@ namespace DesktopMagic
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName); key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
Top = double.Parse(key.GetValue("MusicVisualizerWindowTop", 100).ToString()); Top = double.Parse(key.GetValue("MusicVisualizerWindowTop", 100).ToString(), CultureInfo.InvariantCulture);
Left = double.Parse(key.GetValue("MusicVisualizerWindowLeft", 100).ToString()); Left = double.Parse(key.GetValue("MusicVisualizerWindowLeft", 100).ToString(), CultureInfo.InvariantCulture);
Height = double.Parse(key.GetValue("MusicVisualizerWindowHeight", 200).ToString()); Height = double.Parse(key.GetValue("MusicVisualizerWindowHeight", 200).ToString(), CultureInfo.InvariantCulture);
Width = double.Parse(key.GetValue("MusicVisualizerWindowWidth", 500).ToString()); Width = double.Parse(key.GetValue("MusicVisualizerWindowWidth", 500).ToString(), CultureInfo.InvariantCulture);
IsEnabled = false; IsEnabled = false;
} }
@@ -78,7 +79,7 @@ namespace DesktopMagic
//Set the window style to noactivate. //Set the window style to noactivate.
WindowInteropHelper helper = new WindowInteropHelper(this); WindowInteropHelper helper = new WindowInteropHelper(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);
} }
@@ -89,21 +90,18 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10;
WindowPos.SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
ResizeMode = ResizeMode.CanResize;
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
tileBar.CaptionHeight = 0;
WindowPos.SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
ResizeMode = ResizeMode.NoResize;
} }
if (!IsLoaded) calculate = IsLoaded;
{
calculate = false;
}
else
{
calculate = true;
}
backgroundGrid.Background = MainWindow.Theme.BackgroundBrush; backgroundGrid.Background = MainWindow.Theme.BackgroundBrush;
}); });
} }
@@ -134,7 +132,7 @@ namespace DesktopMagic
} }
List<double> fft = new List<double>(); List<double> fft = new List<double>();
for (int i = 0; i < e.Result.Length / 2 - 70; i++) for (int i = 0; i < (e.Result.Length / 2) - 70; i++)
{ {
int v = i; int v = i;
if (v < 20) if (v < 20)
@@ -142,7 +140,7 @@ namespace DesktopMagic
v = 20; v = 20;
} }
int multiplier = 100 - MainWindow.AmplifierLevel * 2; int multiplier = 100 - (MainWindow.AmplifierLevel * 2);
multiplier = multiplier == 0 ? 1 : multiplier; multiplier = multiplier == 0 ? 1 : multiplier;
fft.Add(Math.Abs(e.Result[i].Y * v / multiplier)); fft.Add(Math.Abs(e.Result[i].Y * v / multiplier));
} }
@@ -173,7 +171,7 @@ namespace DesktopMagic
{ {
double temp = 0; double temp = 0;
int j; int j;
for (j = i * count; j < count + i * count; j++) for (j = i * count; j < count + (i * count); j++)
{ {
temp += fft[j]; temp += fft[j];
} }
@@ -229,7 +227,7 @@ namespace DesktopMagic
{ {
Stopwatch sw = new Stopwatch(); Stopwatch sw = new Stopwatch();
sw.Start(); sw.Start();
Bitmap bm = new Bitmap(885, 300); Bitmap bm = new Bitmap(880, 300);
int offset = 0; int offset = 0;
if (!MainWindow.MirrorMode && MainWindow.SpectrumMode != 1) if (!MainWindow.MirrorMode && MainWindow.SpectrumMode != 1)
@@ -263,8 +261,8 @@ namespace DesktopMagic
if (!fftIndexReverse) if (!fftIndexReverse)
{ {
points[pointIndex + 1] = new PointF(bm.Width - 4 * pointIndex, bm.Height / 2 + value); points[pointIndex + 1] = new PointF(bm.Width - (4 * pointIndex), (bm.Height / 2) + value);
points[points.Length / 2 + pointIndex + 1] = new PointF(bm.Width - 4 * pointIndex, bm.Height / 2 - value); points[(points.Length / 2) + pointIndex + 1] = new PointF(bm.Width - (4 * pointIndex), (bm.Height / 2) - value);
} }
break; break;
@@ -297,15 +295,9 @@ namespace DesktopMagic
SetPoints(points, bm.Width, bm.Height, offset); SetPoints(points, bm.Width, bm.Height, offset);
Brush brush; Brush brush = MainWindow.MusicVisualzerColor.HasValue
if (MainWindow.MusicVisualzerColor.HasValue) ? new SolidBrush(MainWindow.MusicVisualzerColor.Value)
{ : new SolidBrush(MainWindow.Theme.PrimaryColor);
brush = new SolidBrush(MainWindow.MusicVisualzerColor.Value);
}
else
{
brush = new SolidBrush(MainWindow.Theme.PrimaryColor);
}
if (MainWindow.LineMode) if (MainWindow.LineMode)
{ {
@@ -325,10 +317,10 @@ namespace DesktopMagic
} }
} }
Dispatcher.BeginInvoke((Action)delegate _ = Dispatcher.BeginInvoke((Action)delegate
{ {
image.Source = BitmapToImageSource(bm); image.Source = BitmapToImageSource(bm);
}); });
} }
catch { } catch { }
} }
@@ -342,7 +334,7 @@ namespace DesktopMagic
points[^1] = new PointF(0, height / 2); points[^1] = new PointF(0, height / 2);
points[points.Length / 2] = new PointF(width, height / 2); points[points.Length / 2] = new PointF(width, height / 2);
points[points.Length / 2 - 1] = new PointF(0, height / 2); points[(points.Length / 2) - 1] = new PointF(0, height / 2);
break; break;
case 2: case 2:
@@ -31,7 +31,7 @@ namespace DesktopMagic
w.Hide(); w.Hide();
Timer t = new Timer(); Timer t = new Timer();
t.Interval = 500; t.Interval = 100;
t.Elapsed += UpdateTimer_Elapsed; t.Elapsed += UpdateTimer_Elapsed;
t.Start(); t.Start();
@@ -60,12 +60,16 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10;
WindowPos.SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
ResizeMode = ResizeMode.CanResize;
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
tileBar.CaptionHeight = 0;
WindowPos.SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
ResizeMode = ResizeMode.NoResize;
} }
textBlock.Background = MainWindow.Theme.BackgroundBrush; textBlock.Background = MainWindow.Theme.BackgroundBrush;
+2 -1
View File
@@ -5,4 +5,5 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Windows only application")] [assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Windows only application")]
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")]
@@ -83,9 +83,9 @@ namespace DesktopMagic
internal class CalendarItems internal class CalendarItems
{ {
public string eventname { get; set; } public string Eventname { get; set; }
public string dateTime { get; set; } public string DateTime { get; set; }
public string font { get; set; } public string Font { get; set; }
public string color { get; set; } public string Color { get; set; }
} }
} }
+20 -15
View File
@@ -541,7 +541,7 @@ namespace DesktopMagic
public static extern int GetSystemMetrics(int abc); public static extern int GetSystemMetrics(int abc);
[DllImport("user32.dll", EntryPoint = "GetWindowDC")] [DllImport("user32.dll", EntryPoint = "GetWindowDC")]
public static extern IntPtr GetWindowDC(Int32 ptr); public static extern IntPtr GetWindowDC(int ptr);
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern bool IsWindowVisible(IntPtr hWnd); public static extern bool IsWindowVisible(IntPtr hWnd);
@@ -559,7 +559,7 @@ namespace DesktopMagic
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp); public static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
[DllImport("user32.dll", CharSet = CharSet.Auto)] [DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, IntPtr lParam); public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(IntPtr windowHandle, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags flags, uint timeout, out IntPtr result); public static extern IntPtr SendMessageTimeout(IntPtr windowHandle, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags flags, uint timeout, out IntPtr result);
@@ -590,7 +590,7 @@ namespace DesktopMagic
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags); public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags);
[DllImport("user32.dll", CharSet = CharSet.Auto)] [DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern Int32 SystemParametersInfo(UInt32 action, UInt32 uParam, string vParam, UInt32 winIni); public static extern int SystemParametersInfo(uint action, uint uParam, string vParam, uint winIni);
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct BbStruct //Blur Behind Structure public struct BbStruct //Blur Behind Structure
@@ -642,37 +642,37 @@ namespace DesktopMagic
public int X public int X
{ {
get { return Left; } get => Left;
set { Right -= (Left - value); Left = value; } set { Right -= (Left - value); Left = value; }
} }
public int Y public int Y
{ {
get { return Top; } get => Top;
set { Bottom -= (Top - value); Top = value; } set { Bottom -= (Top - value); Top = value; }
} }
public int Height public int Height
{ {
get { return Bottom - Top; } get => Bottom - Top;
set { Bottom = value + Top; } set => Bottom = value + Top;
} }
public int Width public int Width
{ {
get { return Right - Left; } get => Right - Left;
set { Right = value + Left; } set => Right = value + Left;
} }
public System.Drawing.Point Location public System.Drawing.Point Location
{ {
get { return new System.Drawing.Point(Left, Top); } get => new System.Drawing.Point(Left, Top);
set { X = value.X; Y = value.Y; } set { X = value.X; Y = value.Y; }
} }
public System.Drawing.Size Size public System.Drawing.Size Size
{ {
get { return new System.Drawing.Size(Width, Height); } get => new System.Drawing.Size(Width, Height);
set { Width = value.Width; Height = value.Height; } set { Width = value.Width; Height = value.Height; }
} }
@@ -703,10 +703,15 @@ namespace DesktopMagic
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj is RECT) if (obj is RECT rECT)
return Equals((RECT)obj); {
else if (obj is System.Drawing.Rectangle) return Equals(rECT);
return Equals(new RECT((System.Drawing.Rectangle)obj)); }
else if (obj is System.Drawing.Rectangle rectangle)
{
return Equals(new RECT(rectangle));
}
return false; return false;
} }
+10 -11
View File
@@ -29,8 +29,8 @@ namespace DesktopMagic
int cy, int cy,
uint uFlags); uint uFlags);
private const UInt32 SWP_NOSIZE1 = 0x0001; private const uint SWP_NOSIZE1 = 0x0001;
private const UInt32 SWP_NOMOVE1 = 0x0002; private const uint SWP_NOMOVE1 = 0x0002;
private static readonly IntPtr HWND_BOTTOM = new IntPtr(1); private static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
@@ -42,7 +42,7 @@ namespace DesktopMagic
public static void SendWpfWindowBack(Window window) public static void SendWpfWindowBack(Window window)
{ {
var hWnd = new WindowInteropHelper(window).Handle; IntPtr hWnd = new WindowInteropHelper(window).Handle;
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE1 | SWP_NOMOVE1); SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE1 | SWP_NOMOVE1);
} }
@@ -62,12 +62,12 @@ namespace DesktopMagic
private static void IsLocked_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void IsLocked_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var window = (Window)d; Window window = (Window)d;
var isHooked = d.GetValue(IsHookedProperty) != null; bool isHooked = d.GetValue(IsHookedProperty) != null;
if (!isHooked) if (!isHooked)
{ {
var hook = new WindowLockHook(window); WindowLockHook hook = new WindowLockHook(window);
d.SetValue(IsHookedProperty, hook); d.SetValue(IsHookedProperty, hook);
} }
} }
@@ -82,10 +82,9 @@ namespace DesktopMagic
public WindowLockHook(Window window) public WindowLockHook(Window window)
{ {
this.Window = window; Window = window;
var source = PresentationSource.FromVisual(window) as HwndSource; if (PresentationSource.FromVisual(window) is not HwndSource source)
if (source == null)
{ {
// If there is no hWnd, we need to wait until there is // If there is no hWnd, we need to wait until there is
window.SourceInitialized += Window_SourceInitialized; window.SourceInitialized += Window_SourceInitialized;
@@ -98,7 +97,7 @@ namespace DesktopMagic
private void Window_SourceInitialized(object sender, EventArgs e) private void Window_SourceInitialized(object sender, EventArgs e)
{ {
var source = (HwndSource)PresentationSource.FromVisual(Window); HwndSource source = (HwndSource)PresentationSource.FromVisual(Window);
source.AddHook(WndProc); source.AddHook(WndProc);
} }
@@ -106,7 +105,7 @@ namespace DesktopMagic
{ {
if (msg == WM_WINDOWPOSCHANGING && GetIsLocked(Window)) if (msg == WM_WINDOWPOSCHANGING && GetIsLocked(Window))
{ {
var wp = Marshal.PtrToStructure<WINDOWPOS>(lParam); WINDOWPOS wp = Marshal.PtrToStructure<WINDOWPOS>(lParam);
wp.flags |= SWP_NOMOVE | SWP_NOSIZE; wp.flags |= SWP_NOMOVE | SWP_NOSIZE;
Marshal.StructureToPtr(wp, lParam, false); Marshal.StructureToPtr(wp, lParam, false);
} }
+47 -44
View File
@@ -4,9 +4,12 @@ using DesktopMagic.Plugins;
using Microsoft.Win32; using Microsoft.Win32;
using Stone_Red_Utilities.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@@ -81,7 +84,7 @@ namespace DesktopMagic
} }
} }
#region load #region Load
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
@@ -105,8 +108,6 @@ namespace DesktopMagic
} }
App.Logger.Log("Created layouts.save file", "Main"); App.Logger.Log("Created layouts.save file", "Main");
_ = optionsComboBox.Items.Add(new Tuple<string, int>((string)FindResource("musicVisualizer"), 0));
//Write To Log File and Load Elements //Write To Log File and Load Elements
App.Logger.Log("Loading Plugin names", "Main"); App.Logger.Log("Loading Plugin names", "Main");
@@ -121,7 +122,8 @@ namespace DesktopMagic
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.ToString()); App.Logger.Log(ex.Message, "Main", LogSeverity.Error);
_ = MessageBox.Show(ex.ToString());
} }
} }
@@ -137,7 +139,10 @@ namespace DesktopMagic
_ = Directory.CreateDirectory(PluginsPath + "\\" + PluginName); _ = Directory.CreateDirectory(PluginsPath + "\\" + PluginName);
File.Move(fileName, $"{PluginsPath}\\{PluginName}\\{PluginName}.dll"); File.Move(fileName, $"{PluginsPath}\\{PluginName}\\{PluginName}.dll");
} }
catch { } catch (Exception ex)
{
App.Logger.Log(ex.Message, "Main", LogSeverity.Error);
}
} }
foreach (string directory in Directory.GetDirectories(PluginsPath)) foreach (string directory in Directory.GetDirectories(PluginsPath))
@@ -182,7 +187,7 @@ namespace DesktopMagic
} }
} }
#endregion load #endregion Load
#region Windows #region Windows
@@ -334,7 +339,7 @@ namespace DesktopMagic
#endregion Windows #endregion Windows
#region options #region Options
private void AmplifierLevelSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) private void AmplifierLevelSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{ {
@@ -658,7 +663,7 @@ namespace DesktopMagic
window?.Exit(); window?.Exit();
} }
#endregion options #endregion Options
private void TextBlock_Loaded(object sender, RoutedEventArgs e) private void TextBlock_Loaded(object sender, RoutedEventArgs e)
{ {
@@ -684,10 +689,6 @@ namespace DesktopMagic
} }
} }
private void ColorHexTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
}
private void ChangePrimaryColorButton_Click(object sender, RoutedEventArgs e) private void ChangePrimaryColorButton_Click(object sender, RoutedEventArgs e)
{ {
ColorDialog colorDialog = new ColorDialog("Set Primary Color", Theme.PrimaryColor); ColorDialog colorDialog = new ColorDialog("Set Primary Color", Theme.PrimaryColor);
@@ -705,7 +706,6 @@ namespace DesktopMagic
private void ChangeSecondaryColorButton_Click(object sender, RoutedEventArgs e) private void ChangeSecondaryColorButton_Click(object sender, RoutedEventArgs e)
{ {
ColorDialog colorDialog = new ColorDialog("Set Secondary Color", Theme.SecondaryColor); ColorDialog colorDialog = new ColorDialog("Set Secondary Color", Theme.SecondaryColor);
if (colorDialog.ShowDialog() == true) if (colorDialog.ShowDialog() == true)
{ {
Theme.SecondaryBrush = colorDialog.ResultBrush; Theme.SecondaryBrush = colorDialog.ResultBrush;
@@ -837,14 +837,14 @@ namespace DesktopMagic
string name = line[(line.LastIndexOf(";", StringComparison.InvariantCulture) + 1)..]; string name = line[(line.LastIndexOf(";", StringComparison.InvariantCulture) + 1)..];
_ = layoutsComboBox.Items.Add(name); _ = layoutsComboBox.Items.Add(name);
} }
layoutsComboBox.SelectedIndex = int.Parse(key.GetValue("SelectedLayout", "0").ToString()); layoutsComboBox.SelectedIndex = int.Parse(key.GetValue("SelectedLayout", "0").ToString(), CultureInfo.InvariantCulture);
} }
private void LoadLayout(bool minimize = true) private void LoadLayout(bool minimize = true)
{ {
Theme.Font = key.GetValue("Font", "Segoe UI").ToString(); Theme.Font = key.GetValue("Font", "Segoe UI").ToString();
spectrumModeComboBox.SelectedIndex = int.Parse(key.GetValue("SpectrumMode", "0").ToString()); spectrumModeComboBox.SelectedIndex = int.Parse(key.GetValue("SpectrumMode", "0").ToString(), CultureInfo.InvariantCulture);
amplifierLevelSlider.Value = int.Parse(key.GetValue("AmplifierLevel", "0").ToString()); amplifierLevelSlider.Value = int.Parse(key.GetValue("AmplifierLevel", "0").ToString(), CultureInfo.InvariantCulture);
mirrorModeCheckBox.IsChecked = bool.Parse(key.GetValue("MirrorMode", "false").ToString()); mirrorModeCheckBox.IsChecked = bool.Parse(key.GetValue("MirrorMode", "false").ToString());
lineModeCheckBox.IsChecked = bool.Parse(key.GetValue("LineMode", "false").ToString()); lineModeCheckBox.IsChecked = bool.Parse(key.GetValue("LineMode", "false").ToString());
musicVisualizerColorTextBox.Text = key.GetValue("MusicVisualizerColor", "").ToString(); musicVisualizerColorTextBox.Text = key.GetValue("MusicVisualizerColor", "").ToString();
@@ -890,6 +890,9 @@ namespace DesktopMagic
blockWindowsClosing = true; blockWindowsClosing = true;
Windows.Clear(); Windows.Clear();
WindowNames.Clear(); WindowNames.Clear();
optionsComboBox.Items.Clear();
_ = optionsComboBox.Items.Add(new Tuple<string, int>((string)FindResource("musicVisualizer"), 0));
IEnumerable<CheckBox> list = stackPanel.Children.OfType<CheckBox>(); IEnumerable<CheckBox> list = stackPanel.Children.OfType<CheckBox>();
bool showWindow = true; bool showWindow = true;
@@ -914,7 +917,7 @@ namespace DesktopMagic
catch (Exception ex) catch (Exception ex)
{ {
App.Logger.Log(ex.ToString(), "Main"); App.Logger.Log(ex.ToString(), "Main");
MessageBox.Show(ex.ToString()); _ = MessageBox.Show(ex.ToString());
} }
} }
} }
@@ -941,16 +944,16 @@ namespace DesktopMagic
private void UpdatePluginsButton_Click(object sender, RoutedEventArgs e) private void UpdatePluginsButton_Click(object sender, RoutedEventArgs e)
{ {
LoadPlugins(); LoadPlugins();
Task.Run(() => _ = Task.Run(() =>
{ {
foreach (Window window in Windows.ToArray()) foreach (Window window in Windows.ToArray())
{ {
if (window.GetType() == typeof(PluginWindow)) if (window.GetType() == typeof(PluginWindow))
{ {
((PluginWindow)window).UpdatePluginWindow(); ((PluginWindow)window).UpdatePluginWindow();
} }
} }
}); });
} }
private void OpenPluginsFolderButton_Click(object sender, RoutedEventArgs e) private void OpenPluginsFolderButton_Click(object sender, RoutedEventArgs e)
@@ -973,27 +976,11 @@ namespace DesktopMagic
Visibility = Visibility.Visible; Visibility = Visibility.Visible;
SystemCommands.RestoreWindow(this); SystemCommands.RestoreWindow(this);
Topmost = true; Topmost = true;
Activate(); _ = Activate();
Topmost = false; Topmost = false;
} }
} }
private void SetLanguageDictionary()
{
ResourceDictionary dict = new ResourceDictionary();
string currentCulture = Thread.CurrentThread.CurrentUICulture.ToString();
if (currentCulture.Contains("de"))
{
dict.Source = new Uri("..\\Resources\\StringResources.de.xaml", UriKind.Relative);
}
else
{
dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative);
}
Resources.MergedDictionaries.Add(dict);
}
private void GithubButton_Click(object sender, RoutedEventArgs e) private void GithubButton_Click(object sender, RoutedEventArgs e)
{ {
string uri = "https://github.com/Stone-Red-Code/DesktopMagic"; string uri = "https://github.com/Stone-Red-Code/DesktopMagic";
@@ -1011,5 +998,21 @@ namespace DesktopMagic
psi.FileName = uri; psi.FileName = uri;
_ = Process.Start(psi); _ = Process.Start(psi);
} }
private void SetLanguageDictionary()
{
ResourceDictionary dict = new ResourceDictionary();
string currentCulture = Thread.CurrentThread.CurrentUICulture.ToString();
if (currentCulture.Contains("de"))
{
dict.Source = new Uri("..\\Resources\\StringResources.de.xaml", UriKind.Relative);
}
else
{
dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative);
}
Resources.MergedDictionaries.Add(dict);
}
} }
} }
@@ -283,7 +283,7 @@ namespace DesktopMagic
} }
} }
private BitmapSource BitmapToImageSource(Bitmap bitmap) private static BitmapSource BitmapToImageSource(Bitmap bitmap)
{ {
BitmapData bitmapData = bitmap.LockBits( BitmapData bitmapData = bitmap.LockBits(
new Rectangle(0, 0, bitmap.Width, bitmap.Height), new Rectangle(0, 0, bitmap.Width, bitmap.Height),