Browse Source

便签-优化 属性面板 、弹窗 联动变化

OYXH\oyxh 1 year ago
parent
commit
28e4fa1667
1 changed files with 38 additions and 7 deletions
  1. 38 7
      PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml.cs

+ 38 - 7
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml.cs

@@ -67,26 +67,57 @@ namespace PDF_Master.Views.PropertyPanel.AnnotPanel
 
         public StickyNotePopup(IEventAggregator eventAggregator)
         {
-            this.eventAggregator = eventAggregator;
-            
+            this.eventAggregator = eventAggregator;
+
             InitializeComponent();
             AddHandler(MouseUpEvent, new MouseButtonEventHandler(StickyPopupControl_MouseUp), true);
             ContentText.AddHandler(MouseDownEvent, new MouseButtonEventHandler(StickyPopupControl_MouseDown), true);
             Loaded += StickyPopupControl_Loaded;
             ContentText.GotFocus += ContentText_GotFocus;
             ContentText.LostFocus += ContentText_LostFocus;
-            eventAggregator.GetEvent<StickyNotePopupColorEvent>().Subscribe(SetStickyNotePopupColor, e => 
+            eventAggregator.GetEvent<StickyNotePopupColorEvent>().Subscribe(SetStickyNotePopupColor, e =>
             e.Unicode == Unicode);
             colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x10)));
             colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0x10, 0x10)));
             colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0xFF, 0x10)));
             colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0x70, 0xFF)));
             ListColor.ItemsSource = colors;
-        }
+        }
+
         private void SetStickyNotePopupColor(StickyNoteColorUnicode stickyNoteColorUnicode)
         {
             border.BorderBrush = stickyNoteColorUnicode.brush;
-        }
+            //if (ListColor.SelectedItem is ColorItem colorItem)
+            //{
+            //    var color = (colorItem.Color as SolidColorBrush).Color;
+            //    if (color.A != GetCurrentAnnot.Color.A ||
+            //        color.R != GetCurrentAnnot.Color.R ||
+            //        color.G != GetCurrentAnnot.Color.G ||
+            //        color.B != GetCurrentAnnot.Color.B
+            //        )
+            //    {
+            //        ListColor.SelectedIndex = -1;
+            //    }
+            //}
+            foreach (var item in colors)
+            {
+                var colorItem = (item.Color as SolidColorBrush).Color;
+                if (colorItem.A == GetCurrentAnnot.Color.A &&
+                    colorItem.R == GetCurrentAnnot.Color.R &&
+                    colorItem.G == GetCurrentAnnot.Color.G &&
+                    colorItem.B == GetCurrentAnnot.Color.B
+                    )
+                {
+                    ListColor.SelectedItem = item;
+                    return;
+                }
+                else
+                {
+                    ListColor.SelectedIndex = -1;
+                }
+            }
+        }
+
         private void ContentText_LostFocus(object sender, RoutedEventArgs e)
         {
             e.Handled = true;
@@ -481,11 +512,11 @@ namespace PDF_Master.Views.PropertyPanel.AnnotPanel
 
         private void StickyPopupExt_PreviewKeyDown(object sender, KeyEventArgs e)
         {
-            if(e.Key==Key.Delete)
+            if (e.Key == Key.Delete)
             {
                 BtnDelete_Click(null, null);
             }
-            if(e.Key==Key.Enter)
+            if (e.Key == Key.Enter)
             {
                 CloseText_MouseUp(this, null);
                 GetPDFViewer.PreviewMouseLeftButtonDown -= GetPDFViewer_LeftButtonDown;