From 6100f444a8d57832e61381f1c9ff619c4ed702b2 Mon Sep 17 00:00:00 2001
From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com>
Date: Sun, 23 Feb 2025 15:32:17 +0100
Subject: [PATCH] Center dialogs on parent window
---
src/DesktopMagic/Dialogs/ColorDialog.xaml | 9 ++++---
src/DesktopMagic/Dialogs/InputDialog.xaml | 11 +++++----
src/DesktopMagic/MainWindow.xaml.cs | 30 +++++++++++++++++++----
3 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/src/DesktopMagic/Dialogs/ColorDialog.xaml b/src/DesktopMagic/Dialogs/ColorDialog.xaml
index abd2ee2..18c4330 100644
--- a/src/DesktopMagic/Dialogs/ColorDialog.xaml
+++ b/src/DesktopMagic/Dialogs/ColorDialog.xaml
@@ -8,10 +8,11 @@
mc:Ignorable="d"
ResizeMode="NoResize"
Title="ColorDialog"
+ WindowStartupLocation="CenterOwner"
SizeToContent="WidthAndHeight">
-
+
@@ -41,9 +42,9 @@
-
-
+
+
-
+
\ No newline at end of file
diff --git a/src/DesktopMagic/Dialogs/InputDialog.xaml b/src/DesktopMagic/Dialogs/InputDialog.xaml
index f42c6f7..d873210 100644
--- a/src/DesktopMagic/Dialogs/InputDialog.xaml
+++ b/src/DesktopMagic/Dialogs/InputDialog.xaml
@@ -7,15 +7,16 @@
mc:Ignorable="d"
Title="InputDialog"
ResizeMode="NoResize"
+ WindowStartupLocation="CenterOwner"
SizeToContent="WidthAndHeight">
-
-
+
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/src/DesktopMagic/MainWindow.xaml.cs b/src/DesktopMagic/MainWindow.xaml.cs
index 5b58189..dfb5214 100644
--- a/src/DesktopMagic/MainWindow.xaml.cs
+++ b/src/DesktopMagic/MainWindow.xaml.cs
@@ -418,7 +418,11 @@ namespace DesktopMagic
private void ChangePrimaryColorButton_Click(object sender, RoutedEventArgs e)
{
- ColorDialog colorDialog = new ColorDialog("Set Primary Color", Settings.CurrentLayout.Theme.PrimaryColor);
+ ColorDialog colorDialog = new ColorDialog("Set Primary Color", Settings.CurrentLayout.Theme.PrimaryColor)
+ {
+ Owner = this
+ };
+
if (colorDialog.ShowDialog() == true)
{
Settings.CurrentLayout.Theme.PrimaryColor = colorDialog.ResultColor;
@@ -428,7 +432,11 @@ namespace DesktopMagic
private void ChangeSecondaryColorButton_Click(object sender, RoutedEventArgs e)
{
- ColorDialog colorDialog = new ColorDialog("Set Secondary Color", Settings.CurrentLayout.Theme.SecondaryColor);
+ ColorDialog colorDialog = new ColorDialog("Set Secondary Color", Settings.CurrentLayout.Theme.SecondaryColor)
+ {
+ Owner = this
+ };
+
if (colorDialog.ShowDialog() == true)
{
Settings.CurrentLayout.Theme.SecondaryColor = colorDialog.ResultColor;
@@ -438,7 +446,11 @@ namespace DesktopMagic
private void ChangeBackgroundColorButton_Click(object sender, RoutedEventArgs e)
{
- ColorDialog colorDialog = new ColorDialog("Set Background Color", Settings.CurrentLayout.Theme.BackgroundColor);
+ ColorDialog colorDialog = new ColorDialog("Set Background Color", Settings.CurrentLayout.Theme.BackgroundColor)
+ {
+ Owner = this
+ };
+
if (colorDialog.ShowDialog() == true)
{
Settings.CurrentLayout.Theme.BackgroundColor = colorDialog.ResultColor;
@@ -495,7 +507,11 @@ namespace DesktopMagic
private void NewLayoutButton_Click(object sender, RoutedEventArgs e)
{
- InputDialog inputDialog = new((string)FindResource("enterLayoutName"));
+ InputDialog inputDialog = new((string)FindResource("enterLayoutName"))
+ {
+ Owner = this
+ };
+
if (inputDialog.ShowDialog() == true)
{
if (Settings.Layouts.Any(l => l.Name.Trim() == inputDialog.ResponseText.Trim()))
@@ -659,7 +675,11 @@ namespace DesktopMagic
private void PluginManagerButton_Click(object sender, RoutedEventArgs e)
{
- PluginManager pluginManager = new PluginManager();
+ PluginManager pluginManager = new PluginManager
+ {
+ Owner = this
+ };
+
pluginManager.ShowDialog();
LoadPlugins();
LoadLayout(Visibility != Visibility.Visible);