OYXH\oyxh пре 1 година
родитељ
комит
bb75615c17

+ 87 - 24
PDF Office/ViewModels/Dialog/BOTA/ScreenAnnotationDialogViewModel.cs

@@ -6,11 +6,13 @@ using ImTools;
 using Microsoft.Office.Interop.Word;
 using PDF_Master.CustomControl;
 using PDF_Master.CustomControl.CompositeControl;
+using PDF_Master.EventAggregators;
 using PDF_Master.Helper;
 using PDF_Master.Model;
 using PDF_Master.Model.BOTA;
 using Prism.Commands;
 using Prism.Common;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
@@ -102,7 +104,6 @@ namespace PDF_Master.ViewModels.Dialog.BOTA
             }
         }
 
-
         private void InitString()
         {
             T_Style = App.MainPageLoader.GetString("Annotation_DialogStyle");
@@ -113,8 +114,8 @@ namespace PDF_Master.ViewModels.Dialog.BOTA
             T_Cancel = App.MainPageLoader.GetString("Annotation_DialogNo");
         }
 
+        #endregion 文案
 
-        #endregion
         public string Title => "";
 
         public event Action<IDialogResult> RequestClose;
@@ -293,10 +294,11 @@ namespace PDF_Master.ViewModels.Dialog.BOTA
 
         public DelegateCommand CancelCommand { get; set; }
 
-        public DelegateCommand<Object> OkCommnad { get; set; }
+        public DelegateCommand<object> OkCommnad { get; set; }
 
-        public DelegateCommand<Object> CleanCommand { get; set; }
+        public DelegateCommand<object> CleanCommand { get; set; }
         public DelegateCommand<object> LoadedCommand { get; set; }
+
         public ObservableCollection<AnnotationHandlerEventArgs> AnnotationListItems { get; set; }
 
         private ObservableCollection<ColorItem> annotationColors = new ObservableCollection<ColorItem>();
@@ -345,18 +347,94 @@ namespace PDF_Master.ViewModels.Dialog.BOTA
         public List<string> Colors { get => colors; set => colors = value; }
         public List<string> Authors { get => authors; set => authors = value; }
         public List<AnnotArgsType> AnnotArgsTypes { get => annotArgsTypes; set => annotArgsTypes = value; }
+        public IEventAggregator events;
 
-        public ScreenAnnotationDialogViewModel()
+        public ScreenAnnotationDialogViewModel(IEventAggregator eventAggregator)
         {
+            events = eventAggregator;
+            //this.events.GetEvent<ScreenAnnotationEvent>().Subscribe(Loading, e => e.Unicode == App.mainWindowViewModel.SelectedItem.Unicode);
             LoadedCommand = new DelegateCommand<object>(Loaded);
             CancelCommand = new DelegateCommand(CancelEvent);
-            OkCommnad = new DelegateCommand<Object>(OkEvent);
-            CleanCommand = new DelegateCommand<Object>(CleanEvent);
+            OkCommnad = new DelegateCommand<object>(OkEvent);
+            CleanCommand = new DelegateCommand<object>(CleanEvent);
             InitString();
         }
 
         private void Loaded(object obj)
         {
+            if (obj is Object[] arrys1)
+            {
+                foreach (var item in arrys1)
+                {
+                    if (item is CustomIconToggleBtn iconToggleBtn)
+                    {
+                        string tag = iconToggleBtn.Tag.ToString();
+                        switch (tag)
+                        {
+                            case "Highlight":
+                                btnHighlight = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "FreeHand":
+                                btnFreeHand = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "AnnotSticky":
+                                btnAnnotSticky = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "AnnotStamp":
+                                btnAnnotStamp = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "SharpLine":
+                                btnSharpLine = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "SharpArrow":
+                                btnSharpArrow = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "AnnotCircle":
+                                btnAnnotCircle = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "AnnotSquare":
+                                btnAnnotSquare = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "AnnotFreeText":
+                                btnAnnotFreeText = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "AnnotStrikeout":
+                                btnAnnotStrikeout = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "Underline":
+                                btnUnderLine = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+
+                            case "AnnotLink":
+                                btnAnnotLink = iconToggleBtn;
+                                iconToggleBtns.Add(iconToggleBtn);
+                                break;
+                        }
+                    }
+                }
+                SetBtnSelectedState(arrys1);
+            }
             if (obj is CompositeCommandParameter composite)
             {
                 if (composite.Parameter is Object[] arrys)
@@ -430,22 +508,6 @@ namespace PDF_Master.ViewModels.Dialog.BOTA
                             }
                         }
                     }
-                    //btnHighlight = arrys[0] as CustomIconToggleBtn;
-                    //btnFreeHand = arrys[1] as CustomIconToggleBtn;
-                    //btnAnnotSticky = arrys[2] as CustomIconToggleBtn;
-                    //btnAnnotStamp = arrys[3] as CustomIconToggleBtn;
-                    //btnSharpLine = arrys[4] as CustomIconToggleBtn;
-                    //btnSharpArrow = arrys[5] as CustomIconToggleBtn;
-                    //btnAnnotCircle = arrys[6] as CustomIconToggleBtn;
-                    //btnAnnotSquare = arrys[7] as CustomIconToggleBtn;
-                    //btnAnnotFreeText = arrys[8] as CustomIconToggleBtn;
-                    //btnAnnotStrikeout = arrys[9] as CustomIconToggleBtn;
-                    //btnUnderLine = arrys[10] as CustomIconToggleBtn;
-                    //btnAnnotLink = arrys[11] as CustomIconToggleBtn;
-                    //for (int i = 0; i < arrys.Length - 2; i++)
-                    //{
-                    //    iconToggleBtns.Add(arrys[i] as CustomIconToggleBtn);
-                    //}
                     SetBtnSelectedState(arrys);
                 }
             }
@@ -742,7 +804,6 @@ namespace PDF_Master.ViewModels.Dialog.BOTA
 
         private void CancelEvent()
         {
-            
             RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
         }
 
@@ -799,10 +860,12 @@ namespace PDF_Master.ViewModels.Dialog.BOTA
             {
                 this.AnnotArgsTypes = annotArgsTypes;
             }
+
             if (AnnotationListItems.Count <= 0)
             {
                 return;
             }
+
             foreach (var item in AnnotationListItems)
             {
                 AnnotationAuthor.Add(new AuthorItem(item.Author));

+ 3 - 1
PDF Office/Views/Dialog/BOTA/ScreenAnnotationDialog.xaml

@@ -16,7 +16,8 @@
     d:DataContext="{d:DesignInstance Type=dialogBOTA:ScreenAnnotationDialogViewModel}"
     prism:Dialog.WindowStyle="{StaticResource DialogWindowStyle}"
     prism:ViewModelLocator.AutoWireViewModel="True"
-    mc:Ignorable="d">
+    mc:Ignorable="d" Loaded="UserControl_Loaded">
+
     <UserControl.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
@@ -189,6 +190,7 @@
             </Style>
         </ResourceDictionary>
     </UserControl.Resources>
+
     <customControl:DialogContent Header="{Binding Title}">
         <customControl:DialogContent.Content>
             <Grid>

+ 30 - 0
PDF Office/Views/Dialog/BOTA/ScreenAnnotationDialog.xaml.cs

@@ -1,4 +1,7 @@
 using PDF_Master.CustomControl;
+using PDF_Master.EventAggregators;
+using PDF_Master.ViewModels.Dialog.BOTA;
+using Prism.Events;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -21,9 +24,36 @@ namespace PDF_Master.Views.Dialog.BOTA
     /// </summary>
     public partial class ScreenAnnotationDialog : UserControl
     {
+        public IEventAggregator events;
+
         public ScreenAnnotationDialog()
         {
             InitializeComponent();
+
+            //events = eventAggregator;
+
+            //this.events.GetEvent<ScreenAnnotationEvent>().Publish(new ScreenAnnotationArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, Arrys = objects });
+        }
+
+        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            Object[] objects = new Object[]{
+                BtnHighlight ,
+                BtnFreeHand ,
+                BtnAnnotSticky ,
+                BtnAnnotStamp ,
+                BtnSharpLine ,
+                BtnSharpArrow ,
+                BtnAnnotCircle,
+                BtnAnnotSquare,
+                BtnAnnotFreeText,
+                BtnAnnotStrikeout,
+                BtnUnderLine,
+                BtnAnnotLink,
+                ListColor,
+                ListAuthor
+            };
+            (this.DataContext as ScreenAnnotationDialogViewModel).LoadedCommand.Execute(objects);
         }
     }
 }