Browse Source

Remove red outline again

Equbuxu 3 years ago
parent
commit
f68b5ef544

+ 0 - 34
PixiEditor/Helpers/Converters/DockingManagerActiveContentConverter.cs

@@ -1,34 +0,0 @@
-using PixiEditor.Models.DataHolders;
-using System;
-using System.Globalization;
-using System.Windows;
-using System.Windows.Data;
-
-namespace PixiEditor.Helpers.Converters
-{
-    class DockingManagerActiveContentConverter : IValueConverter
-    {
-        private Document cachedDocument = null;
-        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            if (value == null)
-                return DependencyProperty.UnsetValue;
-            if (value is Document document)
-            {
-                cachedDocument = document;
-                return document;
-            }
-            return DependencyProperty.UnsetValue;
-        }
-
-        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            if (value is Document document)
-                return document;
-            if (value != null && cachedDocument != null && !cachedDocument.Disposed)
-                return cachedDocument;
-            cachedDocument = null;
-            return DependencyProperty.UnsetValue;
-        }
-    }
-}

+ 18 - 0
PixiEditor/Models/Controllers/BitmapManager.cs

@@ -29,14 +29,32 @@ namespace PixiEditor.Models.Controllers
             get => activeDocument;
             set
             {
+                if (activeDocument == value)
+                    return;
                 activeDocument?.UpdatePreviewImage();
                 Document oldDoc = activeDocument;
                 activeDocument = value;
                 RaisePropertyChanged(nameof(ActiveDocument));
+                ActiveWindow = value;
                 DocumentChanged?.Invoke(this, new DocumentChangedEventArgs(value, oldDoc));
             }
         }
 
+        private object activeWindow;
+        public object ActiveWindow
+        {
+            get => activeWindow;
+            set
+            {
+                if (activeWindow == value)
+                    return;
+                activeWindow = value;
+                RaisePropertyChanged(nameof(ActiveWindow));
+                if (activeWindow is Document doc)
+                    ActiveDocument = doc;
+            }
+        }
+
         public event EventHandler<DocumentChangedEventArgs> DocumentChanged;
         public event EventHandler StopUsingTool;
 

+ 1 - 2
PixiEditor/Views/MainWindow.xaml

@@ -31,7 +31,6 @@
             <converters:IsSpecifiedTypeConverter SpecifiedType="{x:Type tools:ZoomTool}" x:Key="IsZoomToolConverter"/>
             <converters:IsSpecifiedTypeConverter SpecifiedType="{x:Type tools:MoveViewportTool}" x:Key="IsMoveViewportToolConverter"/>
             <converters:SKColorToMediaColorConverter x:Key="SKColorToMediaColorConverter"/>
-            <converters:DockingManagerActiveContentConverter x:Key="DockingManagerActiveContentConverter"/>
             <ResourceDictionary.MergedDictionaries>
                 <ResourceDictionary Source="pack://application:,,,/ColorPicker;component/Styles/DefaultColorPickerStyle.xaml" />
             </ResourceDictionary.MergedDictionaries>
@@ -258,7 +257,7 @@
         </StackPanel>
         <Grid Grid.Column="1" Grid.Row="2" Background="#303030" >
             <Grid AllowDrop="True" Drop="MainWindow_Drop">
-                <DockingManager ActiveContent="{Binding BitmapManager.ActiveDocument, Mode=TwoWay, Converter={StaticResource DockingManagerActiveContentConverter}}"
+                <DockingManager ActiveContent="{Binding BitmapManager.ActiveWindow, Mode=TwoWay}"
                                            DocumentsSource="{Binding BitmapManager.Documents}">
                     <DockingManager.Theme>
                         <avalonDockTheme:PixiEditorDockTheme />

+ 1 - 2
PixiEditor/Views/MainWindow.xaml.cs

@@ -4,7 +4,6 @@ using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.UserPreferences;
 using PixiEditor.ViewModels;
 using PixiEditor.Views.Dialogs;
-using PixiEditor.Views.UserControls;
 using System;
 using System.ComponentModel;
 using System.Diagnostics;
@@ -185,4 +184,4 @@ namespace PixiEditor
             }
         }
     }
-}
+}