Browse Source

编辑-注释补充,代码整理

lvle 1 year ago
parent
commit
60f40fa3ba

+ 73 - 71
PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageEditPropertyViewModel.cs

@@ -20,11 +20,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
     public class ImageEditPropertyViewModel : PDFEditVM, INavigationAware
     {
         
-        #region 变量
-        //防止自动保存属性值
-        private bool isCanSave = false;
-        public event EventHandler ClearCheckedAglin;
-        #endregion
         #region 快捷键
         private void ShortCut_KeyDown(object sender, KeyEventArgs e)
         {
@@ -51,7 +46,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
 
         #endregion
-        #region 属性
+        #region 属性和变量
+        //防止自动保存属性值
+        private bool isCanSave = false;
+        public event EventHandler ClearCheckedAglin;
+
 
         #region 是否为多选内容
         private bool _isMultiSelectImage = false;
@@ -64,7 +63,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             get { return _opacity1; }
             set { SetProperty(ref _opacity1, value); }
         }
-        #region 不透明度
+
+        //不透明度
         private double _opacity;
         public double OpacityUI
         {
@@ -81,19 +81,15 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                 
             }
         }
-        #endregion
 
-        #region 是否为图片裁剪状态
+        //是否为图片裁剪状态
         private bool _isCrop = false;
         public bool IsCrop { get { return _isCrop; } set { SetProperty(ref _isCrop, value); } }
-        #endregion
 
-        #region 当前显示图像
         //选中的图像
         private System.Windows.Media.Imaging.BitmapSource _currentImg;
         public System.Windows.Media.Imaging.BitmapSource CurrentImg { get { return _currentImg; } set { SetProperty(ref _currentImg, value); } }
 
-        #endregion
 
         #endregion
 
@@ -145,15 +141,14 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
         private void InitCommand()
         {
+
             AddTextCommand = new DelegateCommand(AddText);
             AddImgCommand = new DelegateCommand(AddImg);
-
             ReplaceImgCommand = new DelegateCommand(ReplaceImg);
             ExportImgCommand = new DelegateCommand(ExportImg);
             CropImgCommand = new DelegateCommand(CropImg);
             ImgAlignCheckedCommand = new DelegateCommand<object>(ImgAlignChecked);
-            TranspentslidCommand = new DelegateCommand(Transpentslid);
-           
+            TranspentslidCommand = new DelegateCommand(Transpentslid);           
             AntiClockwiseCommand = new DelegateCommand(AntiClockwise);
             ClockwiseCommand = new DelegateCommand(Clockwise);
             FlipleftrightCommand = new DelegateCommand(Flipleftright);
@@ -167,6 +162,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
         #region Command实现
      
 
+        //不透明度滑动左键松开
        private void Transpentslid()
         {
             if (TextEditEvent != null && isCanSave)
@@ -189,17 +185,47 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
-
+        //点击编辑按钮,暂时保留
         private void EditImgMode()
         {
 
         }
 
+        //添加文本模式
         private void AddText()
         {
             PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
         }
 
+        //添加图片
+        private void AddImg()
+        {
+            OpenFileDialog openFileDialog = new OpenFileDialog();
+            openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
+            openFileDialog.Multiselect = true;
+            if ((bool)openFileDialog.ShowDialog())
+            {
+                if (string.IsNullOrEmpty(openFileDialog.FileName) == false)
+                {
+                    PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
+                    PDFViewer.AddPDFEditImage(openFileDialog.FileName, 500, 500);
+                }
+            }
+        }
+
+
+        //进入裁剪模式
+        private void CropMode()
+        {
+            IsCrop = true;
+            if (TextEditEvent != null)
+            {
+                TextEditEvent.ClipImage = true;
+                TextEditEvent.UpdatePDFEditByEventArgs();
+            }
+        }
+
+        //取消裁剪
         private void CancelCropImg()
         {
             if (TextEditEvent != null)
@@ -212,6 +238,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
+        //还原裁剪
         private void RestoreCropImg()
         {
             if (TextEditEvent != null)
@@ -219,6 +246,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                 TextEditEvent.RestoreClip();
             }
         }
+
+        //完成裁剪
         private void CropImg()
         {
             if (TextEditEvent != null)
@@ -231,6 +260,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
+        //导出图片
         private void ExportImg()
         {
             if (PDFViewer == null || TextEditEvent == null || TextEditEvent.EditType != ComPDFKit.PDFPage.CPDFEditType.EditImage) return;
@@ -259,21 +289,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
-        private void AddImg()
-        {
-            OpenFileDialog openFileDialog = new OpenFileDialog();
-            openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
-            openFileDialog.Multiselect = true;
-            if ((bool)openFileDialog.ShowDialog())
-            {
-                if (string.IsNullOrEmpty(openFileDialog.FileName) == false)
-                {
-                    PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
-                    PDFViewer.AddPDFEditImage(openFileDialog.FileName,500,500);
-                }
-            }
-        }
-
+        //替换裁剪
         private void ReplaceImg()
         {
             OpenFileDialog openFileDialog = new OpenFileDialog();
@@ -297,30 +313,28 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             GetImagePreView();
 
         }
-        private void CropMode()
-        {
-            IsCrop = true;
-            if (TextEditEvent != null)
-            {
-                TextEditEvent.ClipImage = true;
-                TextEditEvent.UpdatePDFEditByEventArgs();
-            }
-        }
 
+
+        //顺时针旋转
         private void Clockwise()
         {
             ImgRoateAngle(90);
         }
 
+        //逆时针旋转
         private void AntiClockwise()
         {
             ImgRoateAngle(-90);
         }
+
+        //左右翻转
         private void Flipleftright()
         {
             TextEditEvent.HorizontalMirror = true;
             TextEditEvent.UpdatePDFEditByEventArgs();
         }
+
+        //上下翻转
         private void Upsidedown()
         {
             TextEditEvent.VerticalMirror = true;
@@ -328,6 +342,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             TextEditEvent.UpdatePDFEditByEventArgs();
         }
 
+        //旋转逻辑
         private void ImgRoateAngle(int angle)
         {
             if (IsMultiSelectImage)
@@ -383,19 +398,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
             }
         }
-
-        private void ReLoadLayoutAlign(int count)
-        {
-            if (count >= 2)
-                IsLayoutAlign = true;
-            else
-                IsLayoutAlign = false;
-
-            if (count >= 3)
-                IsLayoutAvgAlign = true;
-            else
-                IsLayoutAvgAlign = false;
-        }
         #endregion
         protected List<PDFEditEvent> TextEditEventList;
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -416,6 +418,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
+
+        //获取图片参数
         private void LoadedPDFEdit()
         {
             if (TextEditEventList != null && TextEditEventList.Count > 0)
@@ -444,17 +448,17 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                     IsLayoutAlign = false;
                     IsLayoutAvgAlign = false;
                 }
-                GetPDFEdit();
+
+                var tranUI = (TextEditEvent.Transparency / (255.0 * 255.0)) * 100;
+                var temp = Math.Round((double)tranUI, 0);
+                Transpent = temp;
+                OpacityUI = temp / 100.0;
             }
         }
-        private void GetPDFEdit()
-        {
-            var tranUI = (TextEditEvent.Transparency / (255.0*255.0))*100;
-            var temp = Math.Round((double)tranUI, 0);
-            Transpent = temp;
-            OpacityUI = temp/100.0;
 
-        }
+
+
+        #region 右键菜单
         //点击空白处时
         private ContextMenu EmptyStateMenu(object sender)
         {
@@ -473,7 +477,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
         private ContextMenu SelectImgPDFEdit(object sender)
         {
             var popMenu = App.Current.FindResource("SelectImgMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu,sender);
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
             //复制
             customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
             //剪切
@@ -524,14 +528,18 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
 
             return popMenu;
-        }
+        } 
+        #endregion
+
 
+        //左键点击逻辑
         private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
         {
+            //退出编辑模式
             IsCrop = false;
         }
 
-
+        //右键逻辑
         private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
         {
 
@@ -572,7 +580,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
-
+        //属性面板图像更新
         private void GetImagePreView()
         {
             try
@@ -606,12 +614,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
          
         }
-        #region 全局
-        //private void ShowPropertyPanel(bool show = true)
-        //{
-        //    viewContentViewModel.IsPropertyOpen = show;
-        //}
-        #endregion
         public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
 
 

+ 17 - 239
PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs

@@ -29,7 +29,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
     {
 
         #region 属性
-
+        public event EventHandler ClearCheckedAglin;
         public TextEditPropertyViewModel()
         {
             InitVariable();
@@ -98,7 +98,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
         #endregion
 
-        #region Command初始化
+        #region 初始化
       
 
         private void InitCommand()
@@ -115,7 +115,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             AddImgCommand = new DelegateCommand(AddImg);
             //选择颜色
             SelectedColorCommand = new DelegateCommand<object>(SelectedColor);
-
+            //选择字体样式
             SelectedFontStyleCommand = new DelegateCommand<object>(SelectedFontStyle);
             //大小
             FontSizeChangedCommand = new DelegateCommand<object>(FontSizeChanged);
@@ -129,15 +129,17 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             ReDefineFontStyleCommand = new DelegateCommand(ReDefineFontStyle);
             //恢复默认
             RestoreDefaultStyleCommand = new DelegateCommand(RestoreDefaultStyle);
+            //文本对齐
             LayoutAlignCheckedCommand = new DelegateCommand<object>(LayoutAlignChecked);
         }
 
         #endregion
 
-        #region 文本处理
+        #region 文本处理逻辑
 
         private void AddText()
         {
+            //设置对应创建模式
             PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
         }
 
@@ -222,11 +224,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
         //设置字体样式
         private void FontFamilyChanged()
         {
-            if (string.IsNullOrEmpty(CurrentFontFamily.ValueStr) == false)
-            {
-             
-                //GetCurrentFontFamily(TextEditEvent.FontName, TextEditEvent.FontName);
-            }
             if (CurrentPresetFont != null)
             {
                 var currentItem = PresetFontList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
@@ -263,13 +260,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                         }
                     }
                 }
-                else
-                {
-                    //bool isExist = GetCurrentPresetFont(Annot);
-                    //if (isExist)
-                    //{
-                    //}
-                }
             }
         }
 
@@ -284,13 +274,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                 FontStyleItem = TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal;
                 FontWeightItem = TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal;
 
-                //Dictionary<AnnotAttrib, object> AnnotAttribDir = new Dictionary<AnnotAttrib, object>();
-                //AnnotAttribDir.Add(AnnotAttrib.IsItalic,FontStyleItem == FontStyles.Italic);
-                //AnnotAttribDir.Add(AnnotAttrib.IsBold, FontWeightItem == FontWeights.Bold);
-                //PropertyPanel.UpdateAnnotAllAttribs(AnnotAttribDir);
-                //GetFontWeights_Style(TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal, TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal);
-
-
                 if (CurrentPresetFont != null)
                 {
                     var currentItem = PresetFontList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
@@ -327,13 +310,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                             }
                         }
                     }
-                    else
-                    {
-                        //bool isExist = GetCurrentPresetFont(Annot);
-                        //if (isExist)
-                        //{
-                        //}
-                    }
                 }
             }
         }
@@ -381,7 +357,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
         //重置定义
         private void RestoreDefaultStyle()
         {
-            //var item = PresetFontList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
             var defaultlists = TextFont.GetPresetFontStyle();
             if (CurrentPresetFont.ValueStr != "Custom")
             {
@@ -396,10 +371,9 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                         currentItem.mFontWeight = defaulItem.mFontWeight;
                         currentItem.mFontFamily = defaulItem.mFontFamily;
                         currentItem.mFontSize = defaulItem.mFontSize;
-                       GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
+                        GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
                        GetCurrentFontSize(currentItem.mFontSize);
                         GetFontWeights_Style(currentItem.mFontStyle, currentItem.mFontWeight);
-
                         CurrentPresetFont = new ComboDataItem(defaulItem.mTag, defaulItem.mTagContent);
                         SelectedPresetFont();
                     }
@@ -408,6 +382,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
         }
 
+        //设置多选对齐方式
         private void LayoutAlignChecked(object obj)
         {
             if (obj != null)
@@ -447,7 +422,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
         }
 
 
-
+        //设置文本框内对齐方式
         private void TextAlignChecked(object obj)
         {
             if ((string)obj != null && TextEditEvent != null)
@@ -479,7 +454,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
-        //文本内容对齐
+        //设置文本内容对齐属性面板显示
         private void GetAnnotAlign(TextAlignment align)
         {
             switch (align)
@@ -505,6 +480,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                     break;
             }
         }
+
+        //设置文本颜色
         private void SelectedColor(object obj)
         {
             if (obj != null)
@@ -518,6 +495,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
+        //设置文本样式
         private void SelectedFontStyle(object obj)
         {
             if (obj != null && (PresetFontItem)obj != null)
@@ -528,14 +506,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
         }
 
 
+        //设置字体大小
         private void FontSizeChanged(object obj)
         {
             if (CurrentFontSize != null)
             {
                 CurrentFontSize = new ComboDataItem(TextEditEvent.FontSize);
-                //GetCurrentFontSize((int)CurrentFontSize.Value);
-                //PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FontSize,CurrentFontSize.Value);
-
             }
             if (CurrentPresetFont != null)
             {
@@ -573,80 +549,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                         }
                     }
                 }
-                else
-                {
-                    //bool isExist = GetCurrentPresetFont(Annot);
-                    //if (isExist)
-                    //{
-                    //}
-                }
             }
-            //if (obj != null)
-            //{
-            //    var item = (ComboBoxItem)obj;
-            //    var content = (string)item.Content;
-            //    if (content != null)
-            //    {
-            //        var intData = int.Parse(content);
-            //        //TextFontSize = intData;
-            //    }
-            //}
         }
 
 
         #endregion
 
-
-        #region 布局处理
-        private void ImgAlignChecked(object obj)
-        {
-            if (obj != null)
-            {
-                switch ((string)obj)
-                {
-                    case "AlignLeft":
-                        PDFViewer.SetPDFEditAligment(AlignModes.AlignLeft);
-                        break;
-                    case "AlignHorizonCenter":
-                        PDFViewer.SetPDFEditAligment(AlignModes.AlignHorizonCenter);
-                        break;
-                    case "AlignRight":
-                        PDFViewer.SetPDFEditAligment(AlignModes.AlignRight);
-                        break;
-                    case "DistributeHorizontal":
-                        PDFViewer.SetPDFEditAligment(AlignModes.DistributeHorizontal);
-                        break;
-                    case "AlignTop":
-                        PDFViewer.SetPDFEditAligment(AlignModes.AlignTop);
-                        break;
-                    case "AlignVerticalCenter":
-                        PDFViewer.SetPDFEditAligment(AlignModes.AlignVerticalCenter);
-                        break;
-                    case "AlignBottom":
-                        PDFViewer.SetPDFEditAligment(AlignModes.AlignBottom);
-                        break;
-                    case "DistributeVertical":
-                        PDFViewer.SetPDFEditAligment(AlignModes.DistributeVertical);
-                        break;
-                }
-
-            }
-        }
-
-        private void ReLoadLayoutAlign(int count)
-        {
-            if (count >= 2)
-                IsLayoutAlign = true;
-            else
-                IsLayoutAlign = false;
-
-            if (count >= 3)
-                IsLayoutAvgAlign = true;
-            else
-                IsLayoutAvgAlign = false;
-        }
-        #endregion
-
         #region 右键菜单
 
         //点击空白处时
@@ -664,86 +572,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             return popMenu;
         }
 
-        //选中文字的框
-        private ContextMenu SelectTextBorder(object sender)
-        {
-            var popMenu = App.Current.FindResource("SelectTextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //编辑
-            customMenu.SetMenuBinding(0, EditTextModeCommand);
-
-
-            //复制
-            customMenu.SetMenuBinding(1, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(2, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(3, ApplicationCommands.Paste);
-            //删除
-            customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
-
-            return popMenu;
-        }
-        //多选文本框
-        private ContextMenu SelectMoreText(object sender)
-        {
-            var popMenu = App.Current.FindResource("SelectMoreTextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-
-            //复制
-            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
-            //删除
-            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
-
-            return popMenu;
-        }
-
-        //选中文字内容
-        private ContextMenu SelectTextContent(object sender)
-        {
-            var popMenu = App.Current.FindResource("SelectContentMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //复制
-            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
-            //粘贴并匹配样式
-            customMenu.SetVisibilityProperty(3, false);
-            //删除
-            customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
-            //全部选定
-            customMenu.SetMenuBinding(5, ApplicationCommands.SelectAll);
-
-            return popMenu;
-        }
-
-        //编辑中右键
-        private ContextMenu EditTextContent(object sender)
-        {
-            var popMenu = App.Current.FindResource("NoneSelectContentMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            ////复制
-            //customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            ////剪切
-            //customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //全部选定
-            customMenu.SetMenuBinding(0, ApplicationCommands.SelectAll);
-            //粘贴
-            customMenu.SetMenuBinding(1, ApplicationCommands.Paste);
-            //粘贴并匹配样式
-            customMenu.SetVisibilityProperty(2, false);
-            ////删除
-            //customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
-
 
-            return popMenu;
-        }
         #endregion
 
 
@@ -761,32 +590,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             switch (e.CommandType)
             {
                 case CommandType.Context:
-
-
-                    //  if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
-                    // {
-                    //     //文字编辑
-                    //     if (e.PressOnBorder == true)
-                    //     {
-                    //         e.PopupMenu = SelectTextBorder(sender);
-                    //     }
-
-                    //      else if(e.PressOnSelectedText == true)
-                    //     {
-                    //         e.PopupMenu = SelectTextContent(sender);
-                    //     }
-
-                    //     else if(e.SelectText=="")
-                    //     {
-                    //         e.PopupMenu= EditTextContent(sender);
-                    //     }
-                    //     else
-                    //     {
-                    //         e.PopupMenu = SelectTextContent(sender);
-                    //     }
-
-                    // }
-                    //else
                     if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
                     {
                         e.PopupMenu = EmptyStateMenu(sender);
@@ -826,11 +629,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
             return popMenu;
         }
-
-        #region 全局
-
-        public event EventHandler ClearCheckedAglin;
-        #endregion
         #endregion
 
         protected List<PDFEditEvent> TextEditEventList;
@@ -876,6 +674,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
+        //文本内容改变触发
         private void FontMode_ChangedValue(object sender, FontSetModeType e)
         {
             if (sender != null)
@@ -955,6 +754,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
+        //获取文本参数
         private void GetPDFEdit()
         {
 
@@ -966,10 +766,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             FontWeightItem = TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal;
             GetFontWeights_Style(FontStyleItem, FontWeightItem);
          
-
+            //判断样式列表中是否存在对应样式
             bool isExist = false;
-            //List<PresetFontItem> presetFontItems = TextFont.GetCachePresetFontList();
-             //遍历样式
             foreach (var item in PresetFontList)
             {
                 if (TextEditEvent.FontSize == item.mFontSize && TextEditEvent.IsBold == (item.mFontWeight == FontWeights.Bold) && TextEditEvent.IsItalic == (item.mFontStyle == FontStyles.Italic)
@@ -1013,15 +811,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                     {
                         if (item.mTag != "Custom")
                         {
-                            //CurrentFontSize = new ComboDataItem(TextEditEvent.FontSize);
                             GetCurrentFontSize(item.mFontSize);
                             if (item.mFontFamily != null)
                             {
-                                //CurrentFontFamily = new ComboDataItem(TextEditEvent.FontName, TextEditEvent.FontName);
                                 GetCurrentFontFamily(item.mFontFamily.ToString(), item.mFontFamily.ToString());
                             }
-                            //FontStyleItem = item.mFontStyle;
-                            //FontWeightItem = item.mFontWeight;
                             GetFontWeights_Style(TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal, TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal);
                         }
                       
@@ -1050,22 +844,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             TextAlign = TextEditEvent.TextAlign;
             TextEditEvent.UpdatePDFEditByEventArgs();
         
-        //if (TextEditEvent != null && TextEditEventList.Count == 1)
-        //{
-        //    SelectColor = new SolidColorBrush(TextEditEvent.FontColor);
-
-        //    GetCurrentFontSize((int)TextEditEvent.FontSize);
-
-        //    if (TextEditEvent.FontName != null)
-        //    {
-        //        GetCurrentFontFamily(TextEditEvent.FontName, TextEditEvent.FontName);
-        //    }
-
-        //    GetFontWeights_Style(TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal, TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal);
-        //    TextAlign = TextEditEvent.TextAlign;
-
-
-        //}
     }
 
         public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }

+ 29 - 11
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -23,14 +23,11 @@ namespace PDF_Master.ViewModels.Tools
 {
     public class TextEditToolContentViewModel: BindableBase, INavigationAware
     {
-        #region 变量
+        #region 属性与变量
         public ViewContentViewModel viewContentViewModel;
         private CPDFViewer PDFViewer;
         private IRegionManager regions;
         private Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
-        #endregion
-
-        #region 属性
 
         private bool _isTextEdit = false;
         public bool IsTextEdit
@@ -175,9 +172,6 @@ namespace PDF_Master.ViewModels.Tools
                         if (PDFViewer.ToolManager != null && PDFViewer.GetPDFEditCreateType() == ComPDFKit.PDFPage.CPDFEditType.EditText)
                         {
                             PDFViewer.RemovePDFEditEmptyText();
-                            //PDFViewer.SetMouseMode(MouseModes.PDFEdit);
-                            //PDFViewer.ReloadDocument();
-                            //ShowPropertyPanel(true);
                             //只有在有画框的时候才进行
                             if (PDFViewer.MouseMode == MouseModes.PDFEdit&& PDFViewer.ToolManager.HasTool == true)
                             {
@@ -190,9 +184,6 @@ namespace PDF_Master.ViewModels.Tools
                         {
 
                             PDFViewer.RemovePDFEditEmptyText();
-                            //PDFViewer.SetMouseMode(MouseModes.PDFEdit);
-                            //PDFViewer.ReloadDocument();
-                            //ShowPropertyPanel(true);
                             if (PDFViewer.MouseMode == MouseModes.PDFEdit&&PDFViewer.ToolManager.HasTool == true)
                             {
                                 PDFViewer.RemoveTool(false);
@@ -215,6 +206,9 @@ namespace PDF_Master.ViewModels.Tools
 
         }
         #endregion
+
+
+        //模式选择进入
         public void AddContent(object obj)
         {
             if (PDFViewer == null || obj == null || obj as CustomIconToggleBtn == null) return;
@@ -222,10 +216,13 @@ namespace PDF_Master.ViewModels.Tools
             var btn = obj as CustomIconToggleBtn;
             EnterEditMode((bool)btn.IsChecked, btn.Tag.ToString());
         }
+        //编辑按钮逻辑,暂时保留
         private void EditTextMode()
         {
 
         }
+        
+        //对应模式的逻辑
         private void EnterEditMode(bool isCheckMode,string modeType)
         {
             if (isCheckMode)
@@ -234,7 +231,10 @@ namespace PDF_Master.ViewModels.Tools
                 {
                     IsImgEdit = false;
                     IsTextEdit = true;
+
+                    //只框选文本
                     PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.EditText);
+
                     PDFViewer.SetMouseMode(MouseModes.PDFEdit);
                     PDFViewer.ReloadDocument();
                     PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
@@ -244,7 +244,10 @@ namespace PDF_Master.ViewModels.Tools
                 {
                     IsImgEdit = true;
                     IsTextEdit = false;
+
+                    //只框选图像
                     PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
+
                     PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
                     PDFViewer.SetMouseMode(MouseModes.PDFEdit);
                     PDFViewer.ReloadDocument();
@@ -255,7 +258,10 @@ namespace PDF_Master.ViewModels.Tools
                 IsImgEdit = false;
                 IsTextEdit = false;
                 PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.None);
+
+                //文本和图像都框选
                 PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.EditText | ComPDFKit.PDFPage.CPDFEditType.EditImage);
+
                 PDFViewer.SetMouseMode(MouseModes.PDFEdit);
                 PDFViewer.ReloadDocument();
 
@@ -275,6 +281,10 @@ namespace PDF_Master.ViewModels.Tools
         }
 
         #endregion
+
+
+
+        //传参数给属性面板
         private void AddToPropertyPanel(string type,  List<PDFEditEvent> e)
         {
             if (btnToProperty.ContainsKey(type))
@@ -294,6 +304,8 @@ namespace PDF_Master.ViewModels.Tools
                
             }
         }
+
+        //控制属性面板是否展示
         private void ShowPropertyPanel(bool show = true)
         {
             viewContentViewModel.IsPropertyOpen = show;
@@ -320,7 +332,7 @@ namespace PDF_Master.ViewModels.Tools
                 PDFViewer.CustomNotifyHandler -= PDFViewer_CustomNotifyHandler;
                 PDFViewer.CustomNotifyHandler += PDFViewer_CustomNotifyHandler;
 
-                //选中
+                //粘贴后选中
                 PDFViewer.PDFEditHandler -= PDFViewer_PDFEditHandler;
                 PDFViewer.PDFEditHandler += PDFViewer_PDFEditHandler;
 
@@ -334,6 +346,8 @@ namespace PDF_Master.ViewModels.Tools
             PDFViewer.SelectPDFEdit(e,true);
         }
 
+
+        //左键激活逻辑
         private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
         {
         
@@ -380,6 +394,7 @@ namespace PDF_Master.ViewModels.Tools
 
         }
 
+        //右键点击逻辑
         private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
         {
             if (e == null)
@@ -436,6 +451,9 @@ namespace PDF_Master.ViewModels.Tools
                 e.Handle = true;
             }
         }
+
+
+        //图片添加逻辑
         private void PDFViewer_CustomNotifyHandler(object sender, CustomNotityData e)
         {