Ver código fonte

Only close hello there window if main window has been selected

CPKreuz 4 anos atrás
pai
commit
9e09fe5c42

+ 0 - 16
PixiEditor/Views/Dialogs/HelloTherePopup.xaml.cs

@@ -1,8 +1,6 @@
 using PixiEditor.Helpers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.ViewModels.SubViewModels.Main;
-using System;
-using System.Diagnostics;
 using System.Reflection;
 using System.Windows;
 using System.Windows.Input;
@@ -67,25 +65,11 @@ namespace PixiEditor.Views.Dialogs
             }
         }
 
-        protected override void OnDeactivated(EventArgs e)
-        {
-            CloseIfRelease();
-        }
-
         private void RecentlyOpened_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
         {
             RecentlyOpenedEmpty = FileViewModel.RecentlyOpened.Count == 0;
         }
 
-        [Conditional("RELEASE")]
-        private void CloseIfRelease()
-        {
-            if (!isClosing)
-            {
-                Close();
-            }
-        }
-
         private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
         {
             e.CanExecute = true;

+ 16 - 0
PixiEditor/Views/MainWindow.xaml.cs

@@ -6,6 +6,9 @@ using System.ComponentModel;
 using System.Windows;
 using System.Windows.Input;
 using PixiEditor.ViewModels.SubViewModels.Main;
+using System.Diagnostics;
+using System.Linq;
+using PixiEditor.Views.Dialogs;
 
 namespace PixiEditor
 {
@@ -27,6 +30,8 @@ namespace PixiEditor
             DataContext = new ViewModelMain(services.BuildServiceProvider());
 
             StateChanged += MainWindowStateChangeRaised;
+            Activated += MainWindow_Activated;
+
             MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
             DataContext.CloseAction = Close;
             Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
@@ -38,6 +43,12 @@ namespace PixiEditor
             DataContext.DiscordViewModel.Dispose();
         }
 
+        [Conditional("RELEASE")]
+        private static void CloseHelloThereIfRelease()
+        {
+            Application.Current.Windows.OfType<HelloTherePopup>().ToList().ForEach(x => x.Close());
+        }
+
         private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
         {
             e.CanExecute = true;
@@ -63,6 +74,11 @@ namespace PixiEditor
             SystemCommands.CloseWindow(this);
         }
 
+        private void MainWindow_Activated(object sender, EventArgs e)
+        {
+            CloseHelloThereIfRelease();
+        }
+
         private void MainWindowStateChangeRaised(object sender, EventArgs e)
         {
             if (WindowState == WindowState.Maximized)