Center dialogs on parent window

This commit is contained in:
Stone_Red
2025-02-23 15:32:25 +01:00
parent ead20d1279
commit 6100f444a8
3 changed files with 36 additions and 14 deletions
+5 -4
View File
@@ -8,10 +8,11 @@
mc:Ignorable="d" mc:Ignorable="d"
ResizeMode="NoResize" ResizeMode="NoResize"
Title="ColorDialog" Title="ColorDialog"
WindowStartupLocation="CenterOwner"
SizeToContent="WidthAndHeight"> SizeToContent="WidthAndHeight">
<Grid> <Grid>
<StackPanel Margin="15"> <StackPanel Margin="15">
<Label x:Name="label" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top"/> <Label x:Name="label" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top" />
<DockPanel> <DockPanel>
<Label Content="A:" Width="20" /> <Label Content="A:" Width="20" />
@@ -41,9 +42,9 @@
</TextBox> </TextBox>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
<Button x:Name="okButton" Content="{DynamicResource ok }" HorizontalAlignment="Left" Margin="0,0,10,0" VerticalAlignment="Top" Width="100" Click="OkButton_Click" Cursor="Hand"/> <Button x:Name="okButton" Content="{DynamicResource ok }" HorizontalAlignment="Left" Margin="0,0,10,0" VerticalAlignment="Top" Width="100" Click="OkButton_Click" Cursor="Hand" />
<Button x:Name="cancelButton" Content="{DynamicResource cancel }" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Click="CancelButton_Click"/> <Button x:Name="cancelButton" Content="{DynamicResource cancel }" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Click="CancelButton_Click" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Window> </Window>
+6 -5
View File
@@ -7,15 +7,16 @@
mc:Ignorable="d" mc:Ignorable="d"
Title="InputDialog" Title="InputDialog"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
SizeToContent="WidthAndHeight"> SizeToContent="WidthAndHeight">
<Grid> <Grid>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Margin="15"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Margin="15">
<Label x:Name="label" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top"/> <Label x:Name="label" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="280" VerticalContentAlignment="Center"/> <TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="280" VerticalContentAlignment="Center" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
<Button x:Name="okButton" Content="{DynamicResource ok }" HorizontalAlignment="Left" Margin="0,0,10,0" VerticalAlignment="Top" Width="100" Click="OkButton_Click" Cursor="Hand"/> <Button x:Name="okButton" Content="{DynamicResource ok }" HorizontalAlignment="Left" Margin="0,0,10,0" VerticalAlignment="Top" Width="100" Click="OkButton_Click" Cursor="Hand" />
<Button x:Name="cancelButton" Content="{DynamicResource cancel }" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Click="CancelButton_Click"/> <Button x:Name="cancelButton" Content="{DynamicResource cancel }" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Click="CancelButton_Click" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Window> </Window>
+25 -5
View File
@@ -418,7 +418,11 @@ namespace DesktopMagic
private void ChangePrimaryColorButton_Click(object sender, RoutedEventArgs e) 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) if (colorDialog.ShowDialog() == true)
{ {
Settings.CurrentLayout.Theme.PrimaryColor = colorDialog.ResultColor; Settings.CurrentLayout.Theme.PrimaryColor = colorDialog.ResultColor;
@@ -428,7 +432,11 @@ 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", Settings.CurrentLayout.Theme.SecondaryColor); ColorDialog colorDialog = new ColorDialog("Set Secondary Color", Settings.CurrentLayout.Theme.SecondaryColor)
{
Owner = this
};
if (colorDialog.ShowDialog() == true) if (colorDialog.ShowDialog() == true)
{ {
Settings.CurrentLayout.Theme.SecondaryColor = colorDialog.ResultColor; Settings.CurrentLayout.Theme.SecondaryColor = colorDialog.ResultColor;
@@ -438,7 +446,11 @@ namespace DesktopMagic
private void ChangeBackgroundColorButton_Click(object sender, RoutedEventArgs e) 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) if (colorDialog.ShowDialog() == true)
{ {
Settings.CurrentLayout.Theme.BackgroundColor = colorDialog.ResultColor; Settings.CurrentLayout.Theme.BackgroundColor = colorDialog.ResultColor;
@@ -495,7 +507,11 @@ namespace DesktopMagic
private void NewLayoutButton_Click(object sender, RoutedEventArgs e) 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 (inputDialog.ShowDialog() == true)
{ {
if (Settings.Layouts.Any(l => l.Name.Trim() == inputDialog.ResponseText.Trim())) 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) private void PluginManagerButton_Click(object sender, RoutedEventArgs e)
{ {
PluginManager pluginManager = new PluginManager(); PluginManager pluginManager = new PluginManager
{
Owner = this
};
pluginManager.ShowDialog(); pluginManager.ShowDialog();
LoadPlugins(); LoadPlugins();
LoadLayout(Visibility != Visibility.Visible); LoadLayout(Visibility != Visibility.Visible);