From 4faed795727f80b64a062bb2226122eb0febb74e Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Tue, 28 Nov 2023 02:11:33 -0500 Subject: [PATCH] Make all windows start in the center of the screen or their parent window (#903) --- TwitchDownloaderWPF/App.xaml.cs | 5 +++- TwitchDownloaderWPF/PageChatDownload.xaml.cs | 12 ++++++++-- TwitchDownloaderWPF/PageChatRender.xaml.cs | 18 +++++++++++--- TwitchDownloaderWPF/PageChatUpdate.xaml.cs | 12 ++++++++-- TwitchDownloaderWPF/PageClipDownload.xaml.cs | 12 ++++++++-- TwitchDownloaderWPF/PageQueue.xaml.cs | 24 +++++++++++++++---- TwitchDownloaderWPF/PageVodDownload.xaml.cs | 12 ++++++++-- .../WindowMassDownload.xaml.cs | 6 ++++- TwitchDownloaderWPF/WindowUrlList.xaml.cs | 6 ++++- 9 files changed, 89 insertions(+), 18 deletions(-) diff --git a/TwitchDownloaderWPF/App.xaml.cs b/TwitchDownloaderWPF/App.xaml.cs index ef31a6cb..e9b6af74 100644 --- a/TwitchDownloaderWPF/App.xaml.cs +++ b/TwitchDownloaderWPF/App.xaml.cs @@ -31,7 +31,10 @@ protected override void OnStartup(StartupEventArgs e) var windowsThemeService = new WindowsThemeService(); ThemeServiceSingleton = new ThemeService(this, windowsThemeService); - MainWindow = new MainWindow(); + MainWindow = new MainWindow + { + WindowStartupLocation = WindowStartupLocation.CenterScreen + }; MainWindow.Show(); } diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml.cs b/TwitchDownloaderWPF/PageChatDownload.xaml.cs index 4ed52a29..aae2816b 100644 --- a/TwitchDownloaderWPF/PageChatDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageChatDownload.xaml.cs @@ -290,7 +290,11 @@ private void btnDonate_Click(object sender, RoutedEventArgs e) private void btnSettings_Click(object sender, RoutedEventArgs e) { - WindowSettings settings = new WindowSettings(); + var settings = new WindowSettings + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; settings.ShowDialog(); btnDonate.Visibility = Settings.Default.HideDonation ? Visibility.Collapsed : Visibility.Visible; } @@ -572,7 +576,11 @@ private void checkCropEnd_OnCheckStateChanged(object sender, RoutedEventArgs e) private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e) { - WindowQueueOptions queueOptions = new WindowQueueOptions(this); + var queueOptions = new WindowQueueOptions(this) + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; queueOptions.ShowDialog(); } diff --git a/TwitchDownloaderWPF/PageChatRender.xaml.cs b/TwitchDownloaderWPF/PageChatRender.xaml.cs index 08bd436b..df7a13a6 100644 --- a/TwitchDownloaderWPF/PageChatRender.xaml.cs +++ b/TwitchDownloaderWPF/PageChatRender.xaml.cs @@ -495,7 +495,11 @@ private void btnDonate_Click(object sender, RoutedEventArgs e) private void btnSettings_Click(object sender, RoutedEventArgs e) { SaveSettings(); - WindowSettings settings = new WindowSettings(); + var settings = new WindowSettings + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; settings.ShowDialog(); btnDonate.Visibility = Settings.Default.HideDonation ? Visibility.Collapsed : Visibility.Visible; } @@ -616,7 +620,11 @@ private async void SplitBtnRender_Click(object sender, RoutedEventArgs e) if (ReferenceEquals(sender, MenuItemPartialRender)) { - WindowRangeSelect window = new WindowRangeSelect(currentRender); + var window = new WindowRangeSelect(currentRender) + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; window.ShowDialog(); if (window.OK) @@ -711,7 +719,11 @@ private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e) private void EnqueueRender() { - var queueOptions = new WindowQueueOptions(this); + var queueOptions = new WindowQueueOptions(this) + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; queueOptions.ShowDialog(); } diff --git a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs index 38cb7d5d..a53de865 100644 --- a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs +++ b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs @@ -354,7 +354,11 @@ private void btnDonate_Click(object sender, RoutedEventArgs e) private void btnSettings_Click(object sender, RoutedEventArgs e) { - WindowSettings settings = new WindowSettings(); + var settings = new WindowSettings + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; settings.ShowDialog(); btnDonate.Visibility = Settings.Default.HideDonation ? Visibility.Collapsed : Visibility.Visible; } @@ -645,7 +649,11 @@ private void checkEnd_OnCheckStateChanged(object sender, RoutedEventArgs e) private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e) { - WindowQueueOptions queueOptions = new WindowQueueOptions(this); + var queueOptions = new WindowQueueOptions(this) + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; queueOptions.ShowDialog(); } } diff --git a/TwitchDownloaderWPF/PageClipDownload.xaml.cs b/TwitchDownloaderWPF/PageClipDownload.xaml.cs index 92c91e45..b5ce848b 100644 --- a/TwitchDownloaderWPF/PageClipDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageClipDownload.xaml.cs @@ -178,7 +178,11 @@ private void btnDonate_Click(object sender, RoutedEventArgs e) private void btnSettings_Click(object sender, RoutedEventArgs e) { - WindowSettings settings = new WindowSettings(); + var settings = new WindowSettings + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; settings.ShowDialog(); btnDonate.Visibility = Settings.Default.HideDonation ? Visibility.Collapsed : Visibility.Visible; } @@ -271,7 +275,11 @@ private void BtnCancel_Click(object sender, RoutedEventArgs e) private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e) { - WindowQueueOptions queueOptions = new WindowQueueOptions(this); + var queueOptions = new WindowQueueOptions(this) + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; queueOptions.ShowDialog(); } diff --git a/TwitchDownloaderWPF/PageQueue.xaml.cs b/TwitchDownloaderWPF/PageQueue.xaml.cs index d059610b..b0e2d42a 100644 --- a/TwitchDownloaderWPF/PageQueue.xaml.cs +++ b/TwitchDownloaderWPF/PageQueue.xaml.cs @@ -119,7 +119,11 @@ private void btnDonate_Click(object sender, RoutedEventArgs e) private void btnSettings_Click(object sender, RoutedEventArgs e) { - WindowSettings settings = new WindowSettings(); + var settings = new WindowSettings + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; settings.ShowDialog(); btnDonate.Visibility = Settings.Default.HideDonation ? Visibility.Collapsed : Visibility.Visible; } @@ -167,19 +171,31 @@ private void numRender_ValueChanged(object sender, HandyControl.Data.FunctionEve private void btnUrlList_Click(object sender, RoutedEventArgs e) { - WindowUrlList window = new WindowUrlList(); + var window = new WindowUrlList + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; window.ShowDialog(); } private void btnVods_Click(object sender, RoutedEventArgs e) { - WindowMassDownload window = new WindowMassDownload(DownloadType.Video); + var window = new WindowMassDownload(DownloadType.Video) + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; window.ShowDialog(); } private void btnClips_Click(object sender, RoutedEventArgs e) { - WindowMassDownload window = new WindowMassDownload(DownloadType.Clip); + var window = new WindowMassDownload(DownloadType.Clip) + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; window.ShowDialog(); } diff --git a/TwitchDownloaderWPF/PageVodDownload.xaml.cs b/TwitchDownloaderWPF/PageVodDownload.xaml.cs index 734e0863..8e366603 100644 --- a/TwitchDownloaderWPF/PageVodDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageVodDownload.xaml.cs @@ -363,7 +363,11 @@ private void btnDonate_Click(object sender, RoutedEventArgs e) private void btnSettings_Click(object sender, RoutedEventArgs e) { - WindowSettings settings = new WindowSettings(); + var settings = new WindowSettings + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; settings.ShowDialog(); btnDonate.Visibility = Settings.Default.HideDonation ? Visibility.Collapsed : Visibility.Visible; } @@ -474,7 +478,11 @@ private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e) if (ValidateInputs()) { - WindowQueueOptions queueOptions = new WindowQueueOptions(this); + var queueOptions = new WindowQueueOptions(this) + { + Owner = Application.Current.MainWindow, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; queueOptions.ShowDialog(); } else diff --git a/TwitchDownloaderWPF/WindowMassDownload.xaml.cs b/TwitchDownloaderWPF/WindowMassDownload.xaml.cs index 7c6e9514..5bf0e3d0 100644 --- a/TwitchDownloaderWPF/WindowMassDownload.xaml.cs +++ b/TwitchDownloaderWPF/WindowMassDownload.xaml.cs @@ -210,7 +210,11 @@ private void btnQueue_Click(object sender, RoutedEventArgs e) { if (selectedItems.Count > 0) { - WindowQueueOptions queue = new WindowQueueOptions(selectedItems); + var queue = new WindowQueueOptions(selectedItems) + { + Owner = this, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; if (queue.ShowDialog().GetValueOrDefault()) this.Close(); } diff --git a/TwitchDownloaderWPF/WindowUrlList.xaml.cs b/TwitchDownloaderWPF/WindowUrlList.xaml.cs index 714c6e0e..fd05c7f3 100644 --- a/TwitchDownloaderWPF/WindowUrlList.xaml.cs +++ b/TwitchDownloaderWPF/WindowUrlList.xaml.cs @@ -156,7 +156,11 @@ private async void btnQueue_Click(object sender, RoutedEventArgs e) return; } - WindowQueueOptions queue = new WindowQueueOptions(dataList); + var queue = new WindowQueueOptions(dataList) + { + Owner = this, + WindowStartupLocation = WindowStartupLocation.CenterOwner + }; if (queue.ShowDialog().GetValueOrDefault()) this.Close();