Procházet zdrojové kódy

其他-找回丢失的注释代码

ZhouJieSheng před 1 rokem
rodič
revize
af33d3fec9
1 změnil soubory, kde provedl 96 přidání a 4 odebrání
  1. 96 4
      PDF Office/ViewModels/ViewContentViewModel.cs

+ 96 - 4
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -42,6 +42,9 @@ using PDF_Master.Views.PropertyPanel.ViewModular;
 using PDF_Master.Views.PropertyPanel;
 using System.Windows.Threading;
 using Dropbox.Api.Files;
+using System.Windows.Media;
+using Color = System.Windows.Media.Color;
+using PDFSettings;
 
 namespace PDF_Master.ViewModels
 {
@@ -273,7 +276,7 @@ namespace PDF_Master.ViewModels
         /// 顶部提示栏的显示状态
         /// </summary>
         public bool IsFileLocked = false;
-       
+
         public Visibility TipVisible
         {
             get { return tipVisible; }
@@ -1220,7 +1223,7 @@ namespace PDF_Master.ViewModels
                         if (PDFViewer.Document.UnlockWithPassword(result.Password))
                         {
                             PDFViewer.Document.CheckOwnerPassword(result.Password);
-                        } 
+                        }
                     }
                 }
             }
@@ -1402,7 +1405,30 @@ namespace PDF_Master.ViewModels
 
         private void SettingsEvent()
         {
-            dialogs.ShowDialog(DialogNames.SettingsDialog, null, null);
+            DialogParameters value = new DialogParameters();
+            value.Add(ParameterNames.ViewContentViewModel, this);
+
+            AnnotToolContentViewModel annotToolContent = null;
+            if (region.Regions.ContainsRegionWithName(ToolsBarContentRegionName))
+            {
+                var views = region.Regions[ToolsBarContentRegionName].Views;
+                var isHas = views.FindFirst(q => q is AnnotToolContent);
+                if (isHas is AnnotToolContent annotTool)
+                {
+                    annotToolContent = (AnnotToolContentViewModel)annotTool.DataContext;
+                }
+            }
+
+            dialogs.ShowDialog(DialogNames.SettingsDialog, null, e =>
+            {
+                var annotate = Settings.Default.AppProperties.Annotate;
+                if (annotToolContent != null)
+                {
+                    //与注释联动修改颜色
+                    UpdateFreeHand(annotate, annotToolContent);
+                    UpdateTextHighlight(annotate, annotToolContent);
+                }
+            });
             if (PDFViewer != null)
             {
                 PDFViewer.SetBackgroundBrush(new System.Windows.Media.SolidColorBrush(Settings.Default.AppProperties.InitialVIew.BackGround));
@@ -1418,6 +1444,72 @@ namespace PDF_Master.ViewModels
             }
         }
 
+        private void UpdateTextHighlight(AnnotatePropertyClass annotate, AnnotToolContentViewModel annotToolContent)
+        {
+            Color color2 = annotate.HighLightColor;
+            Color color1 = (annotToolContent.HighLightColor as SolidColorBrush).Color;
+            bool flag = ColorComparison(color2, color1);
+            if (flag)
+            {
+                annotToolContent.HighLightColor = new SolidColorBrush(color2);
+                if (string.IsNullOrEmpty(annotToolContent.StrAnnotToolChecked) == false)
+                {
+                    CreateRefreshComment(annotToolContent);
+                }
+            }
+        }
+
+        private void UpdateFreeHand(AnnotatePropertyClass annotate, AnnotToolContentViewModel annotToolContent)
+        {
+            Color color2 = annotate.FreeHandColor;
+            Color color1 = (annotToolContent.FreeHandColor as SolidColorBrush).Color;
+            bool flag = ColorComparison(color2, color1);
+
+            if (flag)
+            {
+                annotToolContent.FreeHandColor = new SolidColorBrush(color2);
+                if (annotToolContent.PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] != null)
+                {
+                    if (annotToolContent.PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] is FreehandAnnotArgs freehandAnnotArgs)
+                    {
+                        freehandAnnotArgs.InkColor = color2;
+                    }
+                }
+                if (string.IsNullOrEmpty(annotToolContent.StrAnnotToolChecked) == false)
+                {
+                    CreateRefreshComment(annotToolContent);
+                }
+            }
+        }
+
+        private void CreateRefreshComment(AnnotToolContentViewModel annotToolContent)
+        {
+            AnnotHandlerEventArgs annotArgs = null;
+            string tag = annotToolContent.StrAnnotToolChecked;
+            annotToolContent.FindAnnotTypeKey(tag, ref annotArgs);
+            if (annotArgs != null)
+            {
+                //设置点击页面会创建对应选中注释工具的注释
+                annotArgs.Author = Settings.Default.AppProperties.Description.Author;
+                PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+                PDFViewer.SetToolParam(annotArgs);
+            }
+        }
+
+        private bool ColorComparison(Color color2, Color color1)
+        {
+            if (color1.R == color2.R && color1.G == color2.G && color1.B == color2.B
+                   && color1.A == color2.A)
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+
+
         private bool CanSaveExcute()
         {
             return CanSave;
@@ -2048,7 +2140,7 @@ namespace PDF_Master.ViewModels
                     PDFViewer.Document.UnlockWithPassword(passwordInfo.OpenPassword);
                 }
 
-                if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword)&&passwordInfo.PermissionsPassword != passwordInfo.OpenPassword)
+                if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword) && passwordInfo.PermissionsPassword != passwordInfo.OpenPassword)
                 {
                     IsFileLocked = true;
                     NavigationParameters param = new NavigationParameters();