Browse Source

BOTA-空白取消选中,便签注释颜色联动效果

liyijie 1 year ago
parent
commit
c527a5bab3

+ 22 - 0
PDF Office/EventAggregators/StickyNoteEvent.cs

@@ -0,0 +1,22 @@
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace PDF_Master.EventAggregators
+{
+   
+
+    public class StickyNoteColorUnicode
+    {
+        public Brush brush { get; set; }
+        public string Unicode { get; set; }
+    }
+
+    public class StickyNoteColorEvent : PubSubEvent<StickyNoteColorUnicode>
+    {
+    }
+}

File diff suppressed because it is too large
+ 2631 - 2630
PDF Office/PDF Master.csproj


+ 144 - 144
PDF Office/ViewModels/Dialog/BOTA/AddAnnotationDialogViewModel.cs

@@ -23,152 +23,152 @@ using System.Windows.Markup;
 using System.Windows.Media;
 
 namespace PDF_Master.ViewModels.Dialog.BOTA
-{
-public class AddAnnotationDialogViewModel : BindableBase, IDialogAware
-{
-private string title = "";
-
-public string Title
-{
-get { return title; }
-set { SetProperty(ref title, value); }
-}
-
-public event Action<IDialogResult> RequestClose;
-
-    //private string markupContent;
-
-    //public string MarkupContent
-    //{
-    //    get { return markupContent; }
-    //    set
-    //    {
-    //        SetProperty(ref markupContent, value);
-    //    }
-    //}
-    private string contentText;
-
-    public string ContentText
-    {
-    get { return contentText; }
-    set
-    {
-    SetProperty(ref contentText, value);
-    }
-    }
-
-    private string annotationName;
-
-    public string AnnotationName
-    {
-    get { return annotationName; }
-    set
-    {
-    SetProperty(ref annotationName, value);
-    }
-    }
-
-    private Visibility tipVisibility = Visibility.Collapsed;
-
-    public Visibility TipVisibility
-    {
-    get { return tipVisibility; }
-    set
-    {
-    SetProperty(ref tipVisibility, value);
-    }
-    }
-
-    public AnnotationHandlerEventArgs Annotation { get; set; }
-    public AnnotAttribEvent AnnotEvent { get; set; }
-
-    public DelegateCommand CreateCommnad { get; set; }
-    public DelegateCommand CancelCommand { get; set; }
-
-    public DelegateCommand<object> LostFocusCommand { get; set; }
-
-        public DelegateCommand<object> KeyDownCommand { get; set; }
-
-            public AddAnnotationDialogViewModel()
-            {
+{
+    public class AddAnnotationDialogViewModel : BindableBase, IDialogAware
+    {
+        private string title = "";
+
+        public string Title
+        {
+            get { return title; }
+            set { SetProperty(ref title, value); }
+        }
+
+        public event Action<IDialogResult> RequestClose;
+
+        //private string markupContent;
+
+        //public string MarkupContent
+        //{
+        //    get { return markupContent; }
+        //    set
+        //    {
+        //        SetProperty(ref markupContent, value);
+        //    }
+        //}
+        private string contentText;
+
+        public string ContentText
+        {
+            get { return contentText; }
+            set
+            {
+                SetProperty(ref contentText, value);
+            }
+        }
+
+        private string annotationName;
+
+        public string AnnotationName
+        {
+            get { return annotationName; }
+            set
+            {
+                SetProperty(ref annotationName, value);
+            }
+        }
+
+        private Visibility tipVisibility = Visibility.Collapsed;
+
+        public Visibility TipVisibility
+        {
+            get { return tipVisibility; }
+            set
+            {
+                SetProperty(ref tipVisibility, value);
+            }
+        }
+
+        public AnnotationHandlerEventArgs Annotation { get; set; }
+        public AnnotAttribEvent AnnotEvent { get; set; }
+
+        public DelegateCommand CreateCommnad { get; set; }
+        public DelegateCommand CancelCommand { get; set; }
+
+        public DelegateCommand<object> LostFocusCommand { get; set; }
+
+        public DelegateCommand<object> KeyDownCommand { get; set; }
+
+        public AddAnnotationDialogViewModel()
+        {
             CancelCommand = new DelegateCommand(CancelEvent);
             CreateCommnad = new DelegateCommand(CreateEvent);
-            LostFocusCommand = new DelegateCommand<object>(LostFocusEvent);
-                KeyDownCommand = new DelegateCommand<object>(KeyDown);
-                    }
-
-                    private void KeyDown(object obj)
-                    {
-                    if (obj is CompositeCommandParameter composite)
-                    {
-                    if (composite.EventArgs is System.Windows.Input.KeyEventArgs eventArgs)
-                    {
+            LostFocusCommand = new DelegateCommand<object>(LostFocusEvent);
+            KeyDownCommand = new DelegateCommand<object>(KeyDown);
+        }
+
+        private void KeyDown(object obj)
+        {
+            if (obj is CompositeCommandParameter composite)
+            {
+                if (composite.EventArgs is System.Windows.Input.KeyEventArgs eventArgs)
+                {
                     if (eventArgs.Key == Key.Enter)
-                    {
-                    LostFocusEvent(obj);
-                    }
-                    }
-                    }
-                    }
-
-                    private void LostFocusEvent(object obj)
-                    {
-                    if (obj is CompositeCommandParameter composite)
-                    {
-                    if (composite.Parameter is TextBox textBox)
-                    {
+                    {
+                        LostFocusEvent(obj);
+                    }
+                }
+            }
+        }
+
+        private void LostFocusEvent(object obj)
+        {
+            if (obj is CompositeCommandParameter composite)
+            {
+                if (composite.Parameter is TextBox textBox)
+                {
                     Annotation.Content = textBox.Text;
                     AnnotEvent?.UpdateAttrib(AnnotAttrib.NoteText, textBox.Text);
-                    AnnotEvent?.UpdateAnnot();
-                    }
-                    }
-                    }
-
-                    private void CreateEvent()
-                    {
-                    DialogParameters valuePairs = new DialogParameters();
-                    valuePairs.Add(ParameterNames.Annotation, Annotation);
-                    valuePairs.Add(ParameterNames.AnnotEvent, AnnotEvent);
-                    RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
-                    }
-
-                    private void CancelEvent()
-                    {
-                    RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
-                    }
-
-                    public bool CanCloseDialog()
-                    {
-                    return true;
-                    }
-
-                    public void OnDialogClosed()
-                    {
-                    }
-
-                    public void OnDialogOpened(IDialogParameters parameters)
-                    {
-                    AnnotationHandlerEventArgs annotation;
-                    parameters.TryGetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation, out annotation);
-
-                        if (annotation != null)
-                        {
-                        Annotation = annotation;
-                        Dictionary<AnnotAttrib, object> annotAttribsList = annotation.AnnotHandlerEventArgs.GetAnnotAttrib();
-                            AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotation.AnnotHandlerEventArgs, annotAttribsList);
-
-                            ContentText = annotation.Content;
-                            AnnotationName = "页面" + (annotation.PageIndex + 1).ToString();
-                            if (string.IsNullOrEmpty(ContentText))
-                            {
-                            TipVisibility = Visibility.Visible;
-                            }
-                            else
-                            {
-                            TipVisibility = Visibility.Collapsed;
-                            }
-                            return;
-                            }
-                            }
-                            }
-                            }
+                    AnnotEvent?.UpdateAnnot();
+                }
+            }
+        }
+
+        private void CreateEvent()
+        {
+            DialogParameters valuePairs = new DialogParameters();
+            valuePairs.Add(ParameterNames.Annotation, Annotation);
+            valuePairs.Add(ParameterNames.AnnotEvent, AnnotEvent);
+            RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
+        }
+
+        private void CancelEvent()
+        {
+            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
+        }
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            AnnotationHandlerEventArgs annotation;
+            parameters.TryGetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation, out annotation);
+
+            if (annotation != null)
+            {
+                Annotation = annotation;
+                Dictionary<AnnotAttrib, object> annotAttribsList = annotation.AnnotHandlerEventArgs.GetAnnotAttrib();
+                AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotation.AnnotHandlerEventArgs, annotAttribsList);
+
+                ContentText = annotation.Content;
+                AnnotationName = "页面" + (annotation.PageIndex + 1).ToString();
+                if (string.IsNullOrEmpty(ContentText))
+                {
+                    TipVisibility = Visibility.Visible;
+                }
+                else
+                {
+                    TipVisibility = Visibility.Collapsed;
+                }
+                return;
+            }
+        }
+    }
+}

+ 29 - 20
PDF Office/ViewModels/PropertyPanel/AnnotPanel/StickyNotePropertyViewModel.cs

@@ -1,12 +1,14 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using PDF_Master.CustomControl.CompositeControl;
+using PDF_Master.EventAggregators;
 using PDF_Master.Model;
 using PDF_Master.Model.AnnotPanel;
 using PDF_Master.ViewModels.Tools;
 using PDF_Master.ViewModels.Tools.AnnotManager;
 using PDFSettings;
 using Prism.Commands;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
@@ -20,8 +22,8 @@ using System.Windows.Media;
 namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 {
     public class StickyNotePropertyViewModel : BindableBase, INavigationAware
-    { 
-        //外部UI引用
+    {
+        //外部UI引用
         public string strOtherTag { get; private set; }
 
         private double _transpent;
@@ -80,11 +82,14 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
         public DelegateCommand<object> SelectedValueChangedCommand { get; set; }
         public DelegateCommand<object> StrickyNoteShapeCommand { get; set; }
-        public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
-        
-
-        public StickyNotePropertyViewModel()
+        public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
+
+        IEventAggregator eventAggregator;
+        string Unicode = "";
+        public StickyNotePropertyViewModel(IEventAggregator eventAggregator)
         {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             SelectedValueChangedCommand = new DelegateCommand<object>(SelectedValueChanged_Command);
             SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
             StrickyNoteShapeCommand = new DelegateCommand<object>(StrickyNoteShape);
@@ -94,8 +99,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             var data = StickyNoteTypes["Comment"];
             var converter = TypeDescriptor.GetConverter(typeof(Geometry));
             ExmpleData = (Geometry)converter.ConvertFrom(data);
+            eventAggregator.GetEvent<StickyNoteColorEvent>().Subscribe(SetStickyNoteColor, e => e.Unicode == Unicode);
+        }
+        private void SetStickyNoteColor(StickyNoteColorUnicode stickyNoteColorUnicode)
+        {
+            SharpColor = stickyNoteColorUnicode.brush;
         }
-
         private void InitColorItems()
         {
             ColorItems = AnnotColorList.GetColorList(ColorSelectorType.Sticky);
@@ -116,7 +125,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             if (obj != null && PropertyPanel != null)
             {
                 var color = (Color)obj;
-                SharpColor =new SolidColorBrush(color);
+                SharpColor = new SolidColorBrush(color);
                 PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Color, color);
             }
         }
@@ -145,10 +154,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 Transpent = value;
                 PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, value);
             }
-        }
-
-        
-
+        }
+
+
+
         private void InitStickyNoteTypes()
         {
             StickyNoteTypes.Add("Comment", "M1.54167 2.5C0.96637 2.5 0.5 2.96637 0.5 3.54167V15.2083C0.5 15.7836 0.96637 16.25 1.54167 16.25H3.83344V19.131C3.83344 19.5239 4.25193 19.7753 4.59884 19.5908L10.8802 16.25H19.4583C20.0336 16.25 20.5 15.7836 20.5 15.2083V3.54167C20.5 2.96637 20.0336 2.5 19.4583 2.5H1.54167ZM16.75 8.4375H4.25V6.5625H16.75V8.4375ZM4.25 12.1875H11.75V10.3125H4.25V12.1875Z");
@@ -275,17 +284,17 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             if (Annot is StickyAnnotArgs)
             {
                 var annot = Annot as StickyAnnotArgs;
-                if(annot != null)
+                if (annot != null)
                 {
                     SharpColor = new SolidColorBrush(annot.Color);
                     Transpent = annot.Transparency;
-                    strOtherTag = annot.IconName;
-                    
-                }
-                
-            }
-
-           
+                    strOtherTag = annot.IconName;
+
+                }
+
+            }
+
+
         }
     }
 }

+ 1 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -180,7 +180,7 @@ namespace PDF_Master.ViewModels.Tools
 
             if (customStickyPopup == null)
             {
-                customStickyPopup = new StickyNotePopup();
+                customStickyPopup = new StickyNotePopup(events);
                 PDFViewer.SetStickyNotePop(customStickyPopup);
             }
         }

+ 3 - 1
PDF Office/Views/BOTA/AnnotationContent.xaml

@@ -69,7 +69,9 @@
                 ItemsSource="{Binding AnnotationListItems}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 SelectionChanged="AnnotationList_SelectionChanged"
-                SelectionMode="Extended">
+                SelectionMode="Extended"
+                MouseDown="ListBox_MouseDown"
+                >
                 <ListBox.ItemContainerStyle>
                     <Style TargetType="ListBoxItem">
                         <Setter Property="HorizontalContentAlignment" Value="Stretch" />

+ 11 - 3
PDF Office/Views/BOTA/AnnotationContent.xaml.cs

@@ -8,6 +8,7 @@ using Prism.Events;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.Diagnostics;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -315,10 +316,12 @@ namespace PDF_Master.Views.BOTA
         }
 
         private void AnnotationList_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
+        {
+            var a = AnnotationList.SelectedItems.Count;
             var a1 = (sender as ListBox).SelectedItems.Count;
             var a2 = (e.OriginalSource as ListBox).SelectedItems.Count;
             var a3 = (e.Source as ListBox).SelectedItems.Count;
+            Trace.WriteLine("a:" + a + "   a1:" + a1 + "  a2:" + a2 + "  a3:" + a3);
             if (a1 == 1)
             {
                 viewModel.ListBoxItemPreviewMouseLeftButtonDown.Execute((sender as ListBox).SelectedItems[0]);
@@ -382,9 +385,14 @@ namespace PDF_Master.Views.BOTA
                 if (btn != null)
                 {
                     return;
-                }
-                AnnotationList.SelectedIndex = -1;
+                }
+
+
             }
         }
+        private void ListBox_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            AnnotationList.SelectedIndex = -1;
+        }
     }
 }

+ 1 - 1
PDF Office/Views/FillAndSign/PropertyPanel/ShapFillProperty.xaml

@@ -189,7 +189,7 @@
                     </Border>
                 </Grid>
             </Grid>
-            <StackPanel Visibility="{Binding IsSelected,Converter={StaticResource InvertBoolToVisibleConvert}}" Margin="0,18,0,0">
+            <StackPanel  Margin="0,18,0,0" Visibility="Collapsed"><!--Visibility="{Binding IsSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"-->
                 <TextBlock Text="Fill Type" VerticalAlignment="Center"/>
                 <Border
                 Width="228"

+ 8 - 3
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml.cs

@@ -2,9 +2,11 @@
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Master.CustomControl.CompositeControl;
+using PDF_Master.EventAggregators;
 using PDF_Master.Helper;
 using PDF_Master.Properties;
 using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
+using Prism.Events;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
@@ -59,11 +61,13 @@ namespace PDF_Master.Views.PropertyPanel.AnnotPanel
         private ObservableCollection<ColorItem> colors = new ObservableCollection<ColorItem>();
         private Point PressPoint;
         public Point OffsetParent;
-
+        public IEventAggregator eventAggregator;
         private byte saveOpacity = 1;
-
-        public StickyNotePopup()
+        string Unicode = "";
+        public StickyNotePopup(IEventAggregator eventAggregator)
         {
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             InitializeComponent();
             AddHandler(MouseUpEvent, new MouseButtonEventHandler(StickyPopupControl_MouseUp), true);
             ContentText.AddHandler(MouseDownEvent, new MouseButtonEventHandler(StickyPopupControl_MouseDown), true);
@@ -419,6 +423,7 @@ namespace PDF_Master.Views.PropertyPanel.AnnotPanel
                 border.BorderBrush = new SolidColorBrush(color);
                 this.Background = new SolidColorBrush(Colors.Transparent);
                 this.BorderBrush = new SolidColorBrush(Colors.Transparent);
+                eventAggregator.GetEvent<StickyNoteColorEvent>().Publish(new StickyNoteColorUnicode { Unicode = Unicode, brush = new SolidColorBrush(color) });
             }
         }