Ver Fonte

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

OYXH\oyxh há 2 anos atrás
pai
commit
ef66165bdc
41 ficheiros alterados com 1258 adições e 375 exclusões
  1. 1 0
      PDF Office/App.xaml
  2. 7 2
      PDF Office/CustomControl/AlertsMessage.xaml
  3. 9 2
      PDF Office/CustomControl/CompositeControl/ColorContent.xaml.cs
  4. 0 4
      PDF Office/CustomControl/SystemControl/TabablzRegionBehavior.cs
  5. 6 1
      PDF Office/Helper/ConverterHelper.cs
  6. 1 1
      PDF Office/Helper/EditToolsHelper.cs
  7. 114 0
      PDF Office/Helper/PopControlHelper.cs
  8. 1 1
      PDF Office/Model/Dialog/ConverterDialogs/ConverterDialogsModel.cs
  9. 1 1
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogModel.cs
  10. 4 0
      PDF Office/PDF Office.csproj
  11. 135 0
      PDF Office/Styles/ContextMenuFormStyle.xaml
  12. 18 0
      PDF Office/Styles/ContextMenuStyle.xaml
  13. 3 0
      PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterCSVDialogViewModel.cs
  14. 3 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterCSVViewModel.cs
  15. 1 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs
  16. 235 2
      PDF Office/ViewModels/Form/FormsToolContentViewModel.cs
  17. 6 1
      PDF Office/ViewModels/MainContentViewModel.cs
  18. 95 3
      PDF Office/ViewModels/MainWindowViewModel.cs
  19. 15 0
      PDF Office/ViewModels/PropertyPanel/FontSetModeVM.cs
  20. 138 84
      PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageEditPropertyViewModel.cs
  21. 11 2
      PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageTextEditPropertyViewModel.cs
  22. 44 43
      PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs
  23. 139 99
      PDF Office/ViewModels/Scan/ScanViwerViewModel.cs
  24. 2 2
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs
  25. 136 39
      PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs
  26. 43 41
      PDF Office/ViewModels/ViewContentViewModel.cs
  27. 13 7
      PDF Office/Views/Dialog/ConverterDialogs/ConverterCSVDialog.xaml
  28. 2 2
      PDF Office/Views/Dialog/ConverterDialogs/ConverterImgDialog.xaml
  29. 2 2
      PDF Office/Views/Dialog/ConverterDialogs/ConverterWordDialog.xaml
  30. 21 6
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterCSV.xaml
  31. 1 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterImg.xaml
  32. 6 6
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterImg.xaml.cs
  33. 2 2
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterWord.xaml
  34. 5 11
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialog.xaml
  35. 1 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialog.xaml
  36. 1 1
      PDF Office/Views/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialog.xaml
  37. 13 2
      PDF Office/Views/Form/FormsToolContent.xaml
  38. 5 1
      PDF Office/Views/MainWindow.xaml
  39. 8 0
      PDF Office/Views/MainWindow.xaml.cs
  40. 8 2
      PDF Office/Views/PropertyPanel/PDFEdit/TextEditProperty.xaml
  41. 2 2
      PDF Office/Views/Tools/TextEditToolContent.xaml

+ 1 - 0
PDF Office/App.xaml

@@ -28,6 +28,7 @@
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ImageRadioButtonDictionary.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContextMenuTextEditStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContextMenuStyle.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContextMenuFormStyle.xaml" />
                 <!--  Enable show customctrol's correctly UI in Xaml Designer  -->
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Themes/Generic.xaml" />
             </ResourceDictionary.MergedDictionaries>

+ 7 - 2
PDF Office/CustomControl/AlertsMessage.xaml

@@ -58,7 +58,12 @@
                     <ColumnDefinition />
                     <ColumnDefinition />
                 </Grid.ColumnDefinitions>
-                <CheckBox x:Name="ChbDonotAskAgain" Content="Don't ask again" Visibility="Collapsed" Checked="ChbDonotAskAgain_Checked" Unchecked="ChbDonotAskAgain_Unchecked"/>
+                <CheckBox
+                    x:Name="ChbDonotAskAgain"
+                    Checked="ChbDonotAskAgain_Checked"
+                    Content="Don't ask again"
+                    Unchecked="ChbDonotAskAgain_Unchecked"
+                    Visibility="Collapsed" />
                 <Button
                     x:Name="CancelBtn"
                     Grid.Column="2"
@@ -73,7 +78,7 @@
                     x:Name="MiddleCancelBtn"
                     Grid.Column="1"
                     Height="28"
-                    Margin="8,0,0,0"
+                    Margin="8,0,8,0"
                     BorderThickness="0"
                     Click="MiddleCancelBtn_Click"
                     Content="Do not Save"

+ 9 - 2
PDF Office/CustomControl/CompositeControl/ColorContent.xaml.cs

@@ -72,6 +72,7 @@ namespace PDF_Office.CustomControl.CompositeControl
     {
         private ObservableCollection<ColorItem> colors = new ObservableCollection<ColorItem>();
         public event EventHandler<Color> SelectedColorHandler;
+        public event RoutedEventHandler SelectedColorInvoke;
         private ColorItem ChangedColorItem;
 
         /// <summary>
@@ -114,6 +115,7 @@ namespace PDF_Office.CustomControl.CompositeControl
             SelectedColorHandler?.Invoke(this, e.Value);
             //ElcustomColor.Fill = new SolidColorBrush(e.Value);
             SelectedColor = e.Value;
+            SelectedColorInvoke?.Invoke(e.Value, null);
         }
 
         private void ListColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -122,6 +124,7 @@ namespace PDF_Office.CustomControl.CompositeControl
             {
                 var item = ListColor.SelectedItem as ColorItem;
                 SelectedColorHandler?.Invoke(this, (item.Color as SolidColorBrush).Color);
+                SelectedColorInvoke?.Invoke((item.Color as SolidColorBrush).Color, null);
             }
             
         }
@@ -130,7 +133,7 @@ namespace PDF_Office.CustomControl.CompositeControl
         {
             IsExistForContainer((ElcustomColor.Fill as SolidColorBrush).Color);
             SelectedColorHandler?.Invoke(this, (ElcustomColor.Fill as SolidColorBrush).Color);
-            
+            SelectedColorInvoke?.Invoke((ElcustomColor.Fill as SolidColorBrush).Color, null);
         }
 
         private void PnlColor_SelectedColorChanged(object sender, Color? e)
@@ -165,7 +168,11 @@ namespace PDF_Office.CustomControl.CompositeControl
             {
                 colorIem.RestoreColor();
                 if(colorIem == ListColor.SelectedItem as ColorItem)
-                SelectedColorHandler?.Invoke(this, (colorIem.Color as SolidColorBrush).Color);
+                {
+                    SelectedColorHandler?.Invoke(this, (colorIem.Color as SolidColorBrush).Color);
+                    SelectedColorInvoke?.Invoke((colorIem.Color as SolidColorBrush).Color, null);
+                }
+                
             }
                
         }

+ 0 - 4
PDF Office/CustomControl/SystemControl/TabablzRegionBehavior.cs

@@ -177,10 +177,6 @@ namespace PDF_Office.CustomControl.SystemControl
             var tabcontrol = GetTabcontrol(view);
             var proxy = GetView(view);
             tabcontrol.Items.Remove(proxy);
-            if(tabcontrol.Items.Count<=0)
-            {
-                (Window.GetWindow(tabcontrol) as MainWindow).Close();
-            }
         }
 
         private void AddView(object view)

+ 6 - 1
PDF Office/Helper/ConverterHelper.cs

@@ -13,6 +13,7 @@ using PDF_Office.CustomControl;
 using Exception = System.Exception;
 using ImageMagick;
 using System.IO.Compression;
+using System.Windows;
 
 namespace PDF_Office.Helper
 {
@@ -143,7 +144,11 @@ namespace PDF_Office.Helper
                 result = await Task.Run(() => csvConverter.Convert(outputFolder, ref outputFileName, csvOptions, pageArray, ref error, getProgress));
                 if (result)
                 {
-                    CommonHelper.ShowFileBrowser(outputFileName.Replace("/", "\\"));
+                    if (File.Exists(outputFileName))
+                        CommonHelper.ShowFileBrowser(outputFileName.Replace("/", "\\"));
+                    else
+                        MessageBox.Show("None CSV");
+                    
                 }
             }
             catch (Exception ex)

+ 1 - 1
PDF Office/Helper/EditToolsHelper.cs

@@ -171,7 +171,7 @@ namespace PDF_Office.Helper
                     }
                     else
                     {
-                        MessageBox.Show("超出页面");
+                        PageRange="1";
                     }
                     break;
                 case 3:

+ 114 - 0
PDF Office/Helper/PopControlHelper.cs

@@ -12,6 +12,7 @@ using static PDF_Office.CustomControl.ColorDropBox;
 
 namespace PDF_Office.Helper
 {
+    #region 悬浮窗口
     public class AdornerPresenter : Adorner
     {
         private VisualCollection VisualChildren;
@@ -212,4 +213,117 @@ namespace PDF_Office.Helper
         }
 
     }
+
+    #endregion
+
+    #region 自定义菜单
+    //自定义菜单:事件绑定、内容等
+
+    public class CustomPopMenu
+    {
+        public ContextMenu PopMenu { get; private set; }
+        public List<MenuItem> MenuItems { get; private set; }
+
+        public CustomPopMenu(ContextMenu popMenu)
+        {
+            PopMenu = popMenu;
+            GetMenuItems();
+        }
+
+        private void GetMenuItems()
+        {
+            if (PopMenu == null || PopMenu.Items == null)
+                return;
+
+            MenuItems = new List<MenuItem>();
+
+            foreach (var item in PopMenu.Items)
+            {
+                if (item as MenuItem != null)
+                {
+                    MenuItems.Add(item as MenuItem);
+                }
+            }
+        }
+
+        //显示或隐藏所有菜单项
+        public void AllMenuVisibility(bool isVisual)
+        {
+            if (MenuItems == null) return;
+
+            foreach (var item in MenuItems)
+            {
+                item.Visibility = (isVisual ? Visibility.Visible : Visibility.Collapsed);
+            }
+        }
+
+        private MenuItem ContainterOfIndex(int index)
+        {
+            if (MenuItems == null || MenuItems.Count < index || index < 0)
+                return null;
+
+            MenuItem menuItem = MenuItems[index] as MenuItem;
+            return menuItem;
+        }
+
+        private MenuItem ContainterOfTag(string tag)
+        {
+            if (MenuItems == null ||  string.IsNullOrEmpty(tag))
+                return null;
+            var menuItem = MenuItems.FirstOrDefault(temp => temp.Tag.ToString() == tag);
+            return menuItem;
+        }
+
+        public void SetVisibilityProperty(int index, bool isVisual)
+        {
+            var menuItem = ContainterOfIndex(index);
+            if (menuItem != null)
+            {
+                menuItem.Visibility = (isVisual?Visibility.Visible:Visibility.Collapsed);
+            }
+        }
+
+        public void SetVisibilityProperty(string tag, bool isVisual)
+        {
+            var menuItem = ContainterOfTag(tag);
+            if (menuItem != null)
+            {
+                menuItem.Visibility = (isVisual ? Visibility.Visible : Visibility.Collapsed);
+            }
+        }
+
+        public void SetTagProperty(int index, string tag)
+        {
+            var menuItem = ContainterOfIndex(index);
+            if (menuItem != null)
+            {
+                menuItem.Tag = tag;
+            }
+        }
+        public void SetHeaderProperty(int index, string header)
+        {
+            var menuItem = ContainterOfIndex(index);
+
+            if (menuItem != null)
+            {
+                menuItem.Header = header;
+            }
+        }
+
+        public void SetMenuBinding(int index, object commandTarget, ICommand command)
+        {
+            var menuItem = ContainterOfIndex(index);
+
+            if (menuItem != null)
+            {
+                menuItem.CommandTarget = (UIElement)commandTarget;
+                menuItem.Command = command;
+            }
+
+        }
+
+    }
+
+    #endregion
+
 }

+ 1 - 1
PDF Office/Model/Dialog/ConverterDialogs/ConverterDialogsModel.cs

@@ -20,7 +20,7 @@ namespace PDF_Office.Model.Dialog.ConverterDialogs
         public WorksheetOptions WorksheetOpts = WorksheetOptions.ForEachPage;
         public PageAndNavigationPaneOptions PageAndNavigationPaneOpts = PageAndNavigationPaneOptions.SinglePageNavigationByBookmarks;
         public ImgType ImageType = ImgType.PNG;
-        public uint ImageDpi = 50;
+        public uint ImageDpi = 150;
         public bool IsMergeCsv = false;
     }
 

+ 1 - 1
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogModel.cs

@@ -20,7 +20,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.H
         public WorksheetOptions WorksheetOpts = WorksheetOptions.ForEachPage;
         public PageAndNavigationPaneOptions PageAndNavigationPaneOpts = PageAndNavigationPaneOptions.SinglePageNavigationByBookmarks;
         public ImgType ImageType = ImgType.PNG;
-        public uint ImageDpi = 200;
+        public uint ImageDpi = 150;
         public bool IsMergeCsv = false;
     }
 

+ 4 - 0
PDF Office/PDF Office.csproj

@@ -1166,6 +1166,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Styles\ContextMenuFormStyle.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Styles\ContextMenuStyle.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

Diff do ficheiro suprimidas por serem muito extensas
+ 135 - 0
PDF Office/Styles/ContextMenuFormStyle.xaml


+ 18 - 0
PDF Office/Styles/ContextMenuStyle.xaml

@@ -20,6 +20,24 @@
             </MenuItem.Icon>
         </MenuItem>
     </ContextMenu>
+    
+    <ContextMenu x:Key="CustomFontStyleFlyoutMenu" FontSize="14">
+        <ContextMenu.ItemContainerStyle>
+            <Style TargetType="MenuItem">
+                <Setter Property="Padding" Value="0,7,0,7" />
+                <Setter Property="VerticalContentAlignment" Value="Center" />
+            </Style>
+        </ContextMenu.ItemContainerStyle>
+        <MenuItem
+                    Name="ChangeStyleMenuItem"
+                    Header="用所选部分重新定义"
+                    IsEnabled="True" />
+        <MenuItem
+                    Name="BackStyleMenuItem"
+                    Header="恢复默认预设样式"
+                    IsEnabled="True" />
+    </ContextMenu>
+
 
     <ContextMenu x:Key="SelectAnnotContextMenu" FontSize="14">
         <ContextMenu.ItemContainerStyle>

+ 3 - 0
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterCSVDialogViewModel.cs

@@ -218,8 +218,10 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                 switch (radioButton)
                 {
                     case "ForEachPageRadioBtn":
+                        ConverterCSVModel.Options.IsMergeCsv = false;
                         break;
                     case "OnlyTableRadioBtn":
+                        ConverterCSVModel.Options.IsMergeCsv = true;
                         break;
                     default:
                         break;
@@ -250,6 +252,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                 if (currentViewer.Tag != null) { ConverterCSVModel.Pawssword = currentViewer.Tag.ToString(); }
                 ConverterCSVModel.InputPath = pdfViewer.Document.FilePath;
                 FileInfo fileinfo = new FileInfo(ConverterCSVModel.InputPath);
+                ConverterCSVModel.Options.IsMergeCsv = false;
                 ConverterCSVModel.OutputPath = fileinfo.DirectoryName;
             }
         }

+ 3 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterCSVViewModel.cs

@@ -29,8 +29,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 switch (radioButton)
                 {
                     case "ForEachPageRadioBtn":
+                        homePageConverterDialogViewModel.ConverterCSVModel.Options.IsMergeCsv = false;
                         break;
                     case "OnlyTableRadioBtn":
+                        homePageConverterDialogViewModel.ConverterCSVModel.Options.IsMergeCsv = true;
                         break;
                     default:
                         break;
@@ -47,6 +49,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             if (homePageConverterVM != null)
             {
                 homePageConverterDialogViewModel = homePageConverterVM;
+                homePageConverterDialogViewModel.ConverterCSVModel.Options.IsMergeCsv = false;
             }
         }
 

+ 1 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs

@@ -444,7 +444,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 fileNamesIndex++;
             }
             ConverterGridIsEnabled = "True";
-            HomePageBatchProcessingDialogModel.closeDialog = true;
+            HomePageBatchProcessingDialogModel.closeDialog = false;
         }
         #endregion
 

+ 235 - 2
PDF Office/ViewModels/Form/FormsToolContentViewModel.cs

@@ -12,6 +12,8 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
 
 namespace PDF_Office.ViewModels.Form
 {
@@ -39,6 +41,12 @@ namespace PDF_Office.ViewModels.Form
         private bool _isLayoutAlign = false;
         public bool IsLayoutAlign { get { return _isLayoutAlign; } set { SetProperty(ref _isLayoutAlign, value); } }
 
+        private bool _isMoreCheckedBtn = false;
+        public bool IsMoreCheckedBtn { get { return _isMoreCheckedBtn; } set { SetProperty(ref _isMoreCheckedBtn, value); } }
+
+        private bool _isAlignmentCheckedBtn = false;
+        public bool IsAlignmentCheckedBtn { get { return _isAlignmentCheckedBtn; } set { SetProperty(ref _isAlignmentCheckedBtn, value); } }
+
         #endregion
 
         #region 变量
@@ -49,6 +57,7 @@ namespace PDF_Office.ViewModels.Form
         private IRegionManager regions;
 
         private string CurrentToolBtnType;
+        
         /// <summary>
         /// 按钮和属性面板键值对
         /// </summary>
@@ -62,12 +71,24 @@ namespace PDF_Office.ViewModels.Form
         public DelegateCommand CancleCheckedCommand { get; set; }
         public DelegateCommand<string> ClickCommand { get; set; }
         public DelegateCommand<object> AlignmentCheckedCommand { get; set; }
-        
+        public DelegateCommand AlignmentClosedMenuCommand { get; set; }
+        public DelegateCommand ClosedMenuCommand { get; set; }
 
         public event EventHandler<string> UncheckedToolsBtnEvent;
+
+        #region 右键菜单
+        public DelegateCommand<object> PropertyMenuCommand { get; set; }
+        public DelegateCommand<object> CrossPageMenuCommand { get; set; }
+        public DelegateCommand<object> JumpPosMenuCommand { get; set; }
+        public DelegateCommand<object> HideNameMenuCommand { get; set; }
+        public DelegateCommand<object> SearchFormMenuCommand { get; set; }
+        public DelegateCommand<object> PrintMenuCommand { get; set; }
+        public DelegateCommand<object> DefaultValueMenuCommand { get; set; }
         
         #endregion
 
+        #endregion
+
         #region 初始化
 
         public FormsToolContentViewModel(IRegionManager regionManager)
@@ -78,9 +99,62 @@ namespace PDF_Office.ViewModels.Form
             CancleCheckedCommand = new DelegateCommand(CancleChecked);
             ClickCommand = new DelegateCommand<string>(ClickEvent);
             AlignmentCheckedCommand = new DelegateCommand<object>(AlignmentChecked);
+            ClosedMenuCommand = new DelegateCommand(ClosedMenu);
+            AlignmentClosedMenuCommand = new DelegateCommand(AlignmentClosedMenu);
             InitBtnToProperty();
+
+            //右键菜单
+            PropertyMenuCommand = new DelegateCommand<object>(PropertyMenu);
+            CrossPageMenuCommand = new DelegateCommand<object>(CrossPageMenu);
+            JumpPosMenuCommand = new DelegateCommand<object>(JumpPosMenu);
+            HideNameMenuCommand = new DelegateCommand<object>(HideNameMenu);
+            SearchFormMenuCommand = new DelegateCommand<object>(SearchFormMenu);
+            PrintMenuCommand = new DelegateCommand<object>(PrintMenu);
+            DefaultValueMenuCommand = new DelegateCommand<object>(DefaultValueMenu);
+        }
+
+        #region Command实现
+
+        #region Command右键菜单
+
+        private void PropertyMenu(object obj)
+        {
+
+        }
+        private void CrossPageMenu(object obj)
+        {
+
         }
 
+        private void JumpPosMenu(object obj)
+        {
+
+        }
+
+        private void HideNameMenu(object obj)
+        {
+
+        }
+
+        private void SearchFormMenu(object obj)
+        {
+
+        }
+
+        private void PrintMenu(object obj)
+        {
+
+        }
+
+        private void DefaultValueMenu(object obj)
+        {
+
+        }
+        
+
+        #endregion
+
+        #endregion
 
         private void InitBtnToProperty()
         {
@@ -162,6 +236,18 @@ namespace PDF_Office.ViewModels.Form
             }
         }
 
+        private void ClosedMenu()
+        {
+            IsMoreCheckedBtn = false;
+        }
+
+        private void AlignmentClosedMenu()
+        {
+            IsAlignmentCheckedBtn = false;
+        }
+
+        
+
         private void AddToPropertyPanel(string type, WidgetArgs widget = null, UpdateAttributeHelper e = null)
         {
             if (btnToProperty.ContainsKey(type))
@@ -323,6 +409,15 @@ namespace PDF_Office.ViewModels.Form
         {
             UncheckedToolsBtnEvent?.Invoke(null, CurrentToolBtnType);
             CurrentToolBtnType = "";
+            if (PDFViewer != null)
+            {
+                PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
+                PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
+                PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+                PDFViewer.AnnotCommandHandler -= PDFViewer_WidgetCommandHandler;
+                PDFViewer.AnnotCommandHandler -= PDFViewer_WidgetCommandHandler;
+            }
+            
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -343,9 +438,147 @@ namespace PDF_Office.ViewModels.Form
                 PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
                 PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
                 PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
+                PDFViewer.AnnotCommandHandler -= PDFViewer_WidgetCommandHandler;
+                PDFViewer.AnnotCommandHandler += PDFViewer_WidgetCommandHandler;
             }
         }
-        
+
+        private void PDFViewer_WidgetCommandHandler(object sender, AnnotCommandArgs e)
+        {
+            if (e == null)
+                return;
+
+            switch (e.CommandType)
+            {
+                case CommandType.Context:
+                    if(e.CommandTarget == TargetType.WidgetView)
+                    {
+                        WidgetViewCommandArgs widgetCommand = e as WidgetViewCommandArgs;
+                        if(widgetCommand != null && widgetCommand.AnnotEvent != null )
+                        {
+                            if (widgetCommand.AnnotEvent.AnnotItemsList.Count == 1)
+                            {
+                                e.PopupMenu = SelectedFormMenu(sender);
+                            }
+                            else if(widgetCommand.AnnotEvent.AnnotItemsList.Count > 1)
+                            {
+                                e.PopupMenu = MultiSelectedFormMenu(sender);
+                            }
+                         
+                        }
+                        
+                    }
+                    else
+                    {
+                        e.PopupMenu = BlankReaMenu(sender);
+                    }
+                    break;
+                default:
+                    e.DoCommand();
+                    break;
+
+            }
+            if (e.PopupMenu != null)
+            {
+                e.Handle = true;
+            }
+        }
+
+        private void InitMenu(CustomPopMenu customMenu,object sender)
+        {
+            int index= 0;
+            //属性
+            customMenu.SetMenuBinding(index, sender, PropertyMenuCommand);
+            customMenu.SetTagProperty(index, "Property");
+            index++;
+            //复制
+            customMenu.SetMenuBinding(index, sender, ApplicationCommands.Copy);
+            customMenu.SetTagProperty(index, "Copy");
+            index++;
+            //剪切
+            customMenu.SetMenuBinding(index, sender, ApplicationCommands.Cut);
+            customMenu.SetTagProperty(index, "Cut");
+            index++;
+            //粘贴
+            customMenu.SetMenuBinding(index, sender, ApplicationCommands.Paste);
+            customMenu.SetTagProperty(index, "Paste");
+            index++;
+            //删除
+            customMenu.SetMenuBinding(index, sender, ApplicationCommands.Delete);
+            customMenu.SetTagProperty(index, "Delete");
+            index++;
+            //创建多个副本
+            customMenu.SetMenuBinding(index, sender, ApplicationCommands.Delete);
+            customMenu.SetTagProperty(index, "CreateCopy");
+            index++;
+            //跨页复制
+            customMenu.SetMenuBinding(index, sender, CrossPageMenuCommand);
+            customMenu.SetTagProperty(index, "CrossPage");
+            index++;
+            //显示跳位编号
+            customMenu.SetMenuBinding(index, sender, JumpPosMenuCommand);
+            customMenu.SetTagProperty(index, "JumpPos");
+            index++;
+            //隐藏名称
+            customMenu.SetMenuBinding(index, sender, HideNameMenuCommand);
+            customMenu.SetTagProperty(index, "HideName");
+            index++;
+            //查找
+            customMenu.SetMenuBinding(index, sender, SearchFormMenuCommand);
+            customMenu.SetTagProperty(index, "SearchForm");
+            index++;
+            //打印
+            customMenu.SetMenuBinding(index, sender, PrintMenuCommand);
+            customMenu.SetTagProperty(index, "print");
+            index++;
+            //设置当前属性为默认值
+            customMenu.SetMenuBinding(index, sender, DefaultValueMenuCommand);
+            customMenu.SetTagProperty(index, "DefaultValue");
+            index++;
+            customMenu.AllMenuVisibility(true);
+           
+        }
+
+        //点击空白处
+        private ContextMenu BlankReaMenu(object sender)
+        {
+            var popMenu = App.Current.FindResource("FormContentMenu") as ContextMenu;
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+            InitMenu(customMenu, sender);
+            customMenu.SetVisibilityProperty("Property", false);
+            customMenu.SetVisibilityProperty("Copy", false);
+            customMenu.SetVisibilityProperty("Cut", false);
+            customMenu.SetVisibilityProperty("Delete", false);
+            customMenu.SetVisibilityProperty("CreateCopy", false);
+            customMenu.SetVisibilityProperty("CrossPage", false);
+            customMenu.SetVisibilityProperty("DefaultValue", false);
+            return popMenu;
+        }
+
+        //选中一个
+        private ContextMenu SelectedFormMenu(object sender)
+        {
+            var popMenu = App.Current.FindResource("FormContentMenu") as ContextMenu;
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+            InitMenu(customMenu, sender);
+            customMenu.SetVisibilityProperty("SearchForm", false);
+            customMenu.SetVisibilityProperty("print", false);
+            return popMenu;
+        }
+
+        //多选
+        private ContextMenu MultiSelectedFormMenu(object sender)
+        {
+            var popMenu = App.Current.FindResource("FormContentMenu") as ContextMenu;
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+            InitMenu(customMenu, sender);
+            customMenu.SetVisibilityProperty("CreateCopy", false);
+            customMenu.SetVisibilityProperty("DefaultValue", false);
+            customMenu.SetVisibilityProperty("SearchForm", false);
+            customMenu.SetVisibilityProperty("print", false);
+            return popMenu;
+        }
+
         #endregion
     }
 }

+ 6 - 1
PDF Office/ViewModels/MainContentViewModel.cs

@@ -79,6 +79,10 @@ namespace PDF_Office.ViewModels
 
         public DelegateCommand RenameCommand { get; set; }
 
+        public ViewContentViewModel viewContentViewModel { get; set; }
+
+        public MainWindowViewModel mainWindowViewModel { get; set; }
+
 
         private string regionName;
 
@@ -556,8 +560,9 @@ namespace PDF_Office.ViewModels
                 {
                     await CreateFileFromOffice(filepath);
                 }
-           
             }
+
+            mainWindowViewModel = App.mainWindowViewModel;
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)

+ 95 - 3
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -18,6 +18,7 @@ using ComPDFKitViewer.PdfViewer;
 using Dragablz;
 using System.Windows;
 using Prism.Ioc;
+using PDF_Office.CustomControl;
 
 namespace PDF_Office.ViewModels
 {
@@ -37,20 +38,24 @@ namespace PDF_Office.ViewModels
                     {
                         CurrentPDFViewer = pdfviewer;
                     }
+                    else
+                    {
+                        CurrentPDFViewer = null;
+                    }
                 }
             }
         }
 
-        private double value = 0;
+        private double processvalue = 0;
         /// <summary>
         /// 进度条当前值
         /// </summary>
         public double Value
         {
-            get { return value; }
+            get { return processvalue; }
             set
             {
-                SetProperty(ref value, value);
+                SetProperty(ref processvalue, value);
             }
         }
 
@@ -81,6 +86,20 @@ namespace PDF_Office.ViewModels
             }
         }
 
+        private bool isCloseAllEnable = false;
+
+        public bool IsCloseAllEnable
+        {
+            get { return isCloseAllEnable; }
+            set
+            {
+                SetProperty(ref isCloseAllEnable, value);
+            }
+        }
+
+        public DelegateCommand CloseAllTabCommand { get; set; }
+
+
         /// <summary>
         /// 进度条关闭的事件
         /// </summary>
@@ -131,6 +150,7 @@ namespace PDF_Office.ViewModels
 
             AddTab = new DelegateCommand(AddTabItem);
             CloseOCRCommand = new DelegateCommand(closeocr);
+            CloseAllTabCommand = new DelegateCommand(()=> { closeAllTabItem(); });
 
             //第一次打开时需要自动加载Home页
             if (App.IsFirstOpen)
@@ -161,6 +181,7 @@ namespace PDF_Office.ViewModels
         private void AddTabItem()
         {
             region.RequestNavigate(RegionNames.MainRegion, "MainContent");
+            CheckViewsCount();
         }
 
         /// <summary>
@@ -174,19 +195,70 @@ namespace PDF_Office.ViewModels
                 { ParameterNames.FilePath, filePath }
             };
             region.RequestNavigate(RegionNames.MainRegion, "MainContent", parameters);
+            CheckViewsCount();
+        }
+
+
+        /// <summary>
+        /// 关闭所有页签
+        /// </summary>
+        public bool closeAllTabItem()
+        {
+            while (region.Regions[RegionNames.MainRegion].Views.Count() > 0)
+            {
+                if (CurrentPDFViewer!=null&&CurrentPDFViewer.UndoManager.CanSave)
+                {
+                    ContentResult result = ShowSaveDialog((SelectedItem.DataContext as MainContentViewModel).viewContentViewModel);
+                    if (result == ContentResult.Cancel)
+                        return false;
+                    App.OpenedFileList.Remove(CurrentPDFViewer.Document.FilePath);
+                    CurrentPDFViewer.CloseDocument();
+                }
+              
+                region.Regions[RegionNames.MainRegion].Remove(selectedItem);
+            }
+            return true;
         }
 
         public void CloseTabItem(object item)
         {
+            if (pdfViewer != null && pdfViewer.UndoManager.CanSave)
+            {
+                ContentResult result = ShowSaveDialog((SelectedItem.DataContext as MainContentViewModel).viewContentViewModel);
+                if (result == ContentResult.Cancel)
+                {
+                    return;
+                }
+                App.OpenedFileList.Remove(pdfViewer.Document.FilePath);
+                if (pdfViewer.Document != null)
+                {
+                    pdfViewer.CloseDocument();
+                }
+
+            }
             if (region.Regions[RegionNames.MainRegion].Views.Count() > 1)
             {
                 region.Regions[RegionNames.MainRegion].Remove(item);
+                CheckViewsCount();
             }
             else
             {
                 App.Current.MainWindow.Close();
             }
             return;
+
+        }
+
+        private void CheckViewsCount()
+        {
+            if(region.Regions[RegionNames.MainRegion].Views.Count()>1)
+            {
+                IsCloseAllEnable = true;
+            }
+            else
+            {
+                IsCloseAllEnable = false;
+            }
         }
 
         public void SelectItem(string filepath)
@@ -202,5 +274,25 @@ namespace PDF_Office.ViewModels
                 behavior.ActivateView(item);
             }
         }
+
+        /// <summary>
+        /// 显示关闭询问弹窗
+        /// </summary>
+        /// <param name="pdfViewer"></param>
+        /// <returns></returns>
+        private ContentResult ShowSaveDialog(ViewContentViewModel viewContentViewModel)
+        {
+            AlertsMessage alertsMessage = new AlertsMessage();
+            alertsMessage.ShowDialog("关闭提示","当前文档有为保存的操作,是否需要保存?","Cancel","No","Ok");
+            var result = alertsMessage.result;
+
+            if (result == ContentResult.Ok)
+            {
+                var isSave = viewContentViewModel.saveFile();
+                if (isSave == false)
+                    result = ContentResult.Cancel;
+            }
+            return result;
+        }
     }
 }

+ 15 - 0
PDF Office/ViewModels/PropertyPanel/FontSetModeVM.cs

@@ -202,9 +202,24 @@ namespace PDF_Office.ViewModels.PropertyPanel
             {
                 SetProperty(ref selectColor, value);
                 if (IsCanSave)
+                {
                     ChangedValue?.Invoke((selectColor as SolidColorBrush).Color, FontSetModeType.FontColor);
+                    CurrentColor = (selectColor as SolidColorBrush).Color;
+                }
+                    
+            }
+        }
+
+        private Color currentColor = Colors.Black;
+        public Color CurrentColor
+        {
+            get { return currentColor; }
+            set
+            {
+                SetProperty(ref currentColor, value);
             }
         }
+
         private bool IsEqualComboData(ComboDataItem oldValue, ComboDataItem newValue)
         {
             if (newValue == null  || IsCanSave == false)

+ 138 - 84
PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageEditPropertyViewModel.cs

@@ -1,6 +1,7 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -18,46 +19,84 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 {
     public class ImageEditPropertyViewModel : PDFEditVM, INavigationAware
     {
+        #region 变量
+        //防止自动保存属性值
+        private bool isCanSave = false;
+        public event EventHandler ClearCheckedAglin;
+        #endregion
+
+        #region 属性
 
+        #region 是否为多选内容
+        private bool _isMultiSelectImage = false;
+        public bool IsMultiSelectImage { get { return _isMultiSelectImage; } set { SetProperty(ref _isMultiSelectImage, value); } }
+        #endregion
 
-        #region 图像属性
-        private double _transpent ;
-        public double Transpent { get { return _transpent; } set { SetProperty(ref _transpent, value);
-                if (TextEditEvent != null)
+        #region 不透明度
+        private double _transpent;
+        public double Transpent
+        {
+            get { return _transpent; }
+            set
+            {
+                SetProperty(ref _transpent, value);
+                if (TextEditEvent != null && isCanSave)
                 {
+                    if (IsMultiSelectImage)
+                    {
+                        foreach (var item in TextEditEventList)
+                        {
+                            item.Transparent = (int)(_transpent * 2.55);
+                            item.UpdatePDFEditByEventArgs();
+                        }
+                    }
+                    else
+                    {
+                        TextEditEvent.Transparent = (int)(_transpent * 2.55);
+                        TextEditEvent.UpdatePDFEditByEventArgs();
+                    }
 
-                    TextEditEvent.Transparent = (int)(_transpent*2.55);
-                    TextEditEvent.UpdatePDFEditByEventArgs();
                 }
-            } }
+            }
+        }
+        #endregion
+
+        #region 是否为图片裁剪状态
         private bool _isCrop = false;
-        public bool IsCrop{get { return _isCrop; } set{SetProperty(ref _isCrop, value); }}
+        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); }}
+        public System.Windows.Media.Imaging.BitmapSource CurrentImg { get { return _currentImg; } set { SetProperty(ref _currentImg, value); } }
+
+        #endregion
 
-        private bool _isMultiSelectImage = false;
-        public bool IsMultiSelectImage { get { return _isMultiSelectImage; } set { SetProperty(ref _isMultiSelectImage, value); }}
         #endregion
 
-        #region 图像Command
+        #region Command
+        //替换
         public DelegateCommand ReplaceImgCommand { get; set; }
+        //导出
         public DelegateCommand ExportImgCommand { get; set; }
+        //裁剪
         public DelegateCommand CropImgCommand { get; set; }
+        //对齐
         public DelegateCommand<object> ImgAlignCheckedCommand { get; set; }
 
-
-        /// <summary>
-        /// 逆时针旋转
-        /// </summary>
+        //逆时针旋转
         public DelegateCommand AntiClockwiseCommand { get; set; }
-        /// <summary>
-        /// 顺时针旋转
-        /// </summary>
+
+        //顺时针旋转
         public DelegateCommand ClockwiseCommand { get; set; }
+        //裁剪状态
         public DelegateCommand CropModeCommand { get; set; }
+        //取消裁剪状态
         public DelegateCommand CancelCropCommand { get; set; }
+        //添加文本
         public DelegateCommand AddTextCommand { get; set; }
+        //添加图片
         public DelegateCommand AddImgCommand { get; set; }
         #endregion
 
@@ -82,13 +121,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
             CropModeCommand = new DelegateCommand(CropMode);
             CancelCropCommand = new DelegateCommand(CancelCropImg);
         }
+
+        #region Command实现
+
         private void AddText()
         {
             PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
         }
 
-        #region 图像处理
-
         private void CancelCropImg()
         {
             if (TextEditEvent != null)
@@ -135,8 +175,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
                     }
                 }
 
-
-
+                var strFilePath = folder.SelectedPath + "\\0.png";
+                CommonHelper.ShowFileBrowser(strFilePath);
             }
         }
 
@@ -183,16 +223,30 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 
         private void Clockwise()
         {
-            TextEditEvent.Rotate = TextEditEvent.Rotate + 90;
-            TextEditEvent.UpdatePDFEditByEventArgs();
-            GetImagePreView();
+            ImgRoateAngle(90);
         }
 
         private void AntiClockwise()
         {
-            TextEditEvent.Rotate = TextEditEvent.Rotate - 90;
-            TextEditEvent?.UpdatePDFEditByEventArgs();
-            GetImagePreView();
+            ImgRoateAngle(-90);
+        }
+
+        private void ImgRoateAngle(int angle)
+        {
+            if (IsMultiSelectImage)
+            {
+                foreach (var item in TextEditEventList)
+                {
+                    item.Rotate = item.Rotate + angle;
+                    item.UpdatePDFEditByEventArgs();
+                }
+            }
+            else
+            {
+                TextEditEvent.Rotate = TextEditEvent.Rotate + angle;
+                TextEditEvent.UpdatePDFEditByEventArgs();
+                GetImagePreView();
+            }
         }
 
         #endregion
@@ -256,37 +310,41 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
             {
                 PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
                 PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
-                if (TextEditEventList != null && TextEditEventList.Count > 0)
+                LoadedPDFEdit();
+                isCanSave = true;
+            }
+        }
+
+        private void LoadedPDFEdit()
+        {
+            if (TextEditEventList != null && TextEditEventList.Count > 0)
+            {
+                TextEditEvent = TextEditEventList[0];
+                if (TextEditEventList.Count > 1)
                 {
-                    TextEditEvent = TextEditEventList[0];
-                    if(TextEditEventList.Count >1)
-                    {
-                       IsMultiSelectImage = true;
-                    }
-                    else
-                    {
-                        GetImagePreView();
-                    }
-                    if (TextEditEventList.Count == 2)
-                    {
-                        IsLayoutAlign = true;
-                        IsLayoutAvgAlign = false;
-                    }
-                    else if (TextEditEventList.Count > 2)
-                    {
-                        IsLayoutAlign = true;
-                        IsLayoutAvgAlign = true;
-                    }
-                    else
-                    {
-                        IsLayoutAlign = false;
-                        IsLayoutAvgAlign = false;
-                    }
-                    GetPDFEdit();
+                    IsMultiSelectImage = true;
+                }
+                else
+                {
+                    GetImagePreView();
+                }
+                if (TextEditEventList.Count == 2)
+                {
+                    IsLayoutAlign = true;
+                    IsLayoutAvgAlign = false;
+                }
+                else if (TextEditEventList.Count > 2)
+                {
+                    IsLayoutAlign = true;
+                    IsLayoutAvgAlign = true;
+                }
+                else
+                {
+                    IsLayoutAlign = false;
+                    IsLayoutAvgAlign = false;
                 }
+                GetPDFEdit();
             }
-
-          
         }
         private void GetPDFEdit()
         {
@@ -300,15 +358,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
         private ContextMenu EmptyStateMenu(object sender)
         {
             var popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
-            if (popMenu != null && popMenu.Items.Count == 3)
-            {
-                //粘贴
-                SetPopMenuItem(popMenu.Items[0] as MenuItem, sender, ApplicationCommands.Paste);
-                //添加文本
-                SetPopMenuItem(popMenu.Items[1] as MenuItem, sender, AddTextCommand);
-                //添加图像
-                SetPopMenuItem(popMenu.Items[2] as MenuItem, sender, AddImgCommand);
-            }
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+            //粘贴
+            customMenu.SetMenuBinding(0, sender, ApplicationCommands.Paste);
+            //添加文本
+            customMenu.SetMenuBinding(1, sender, AddTextCommand);
+            //添加图像
+            customMenu.SetMenuBinding(2, sender, AddImgCommand);
 
             return popMenu;
         }
@@ -316,23 +372,21 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
         private ContextMenu SelectImgPDFEdit(object sender)
         {
             var popMenu = App.Current.FindResource("SelectImgMenu") as ContextMenu;
-            if (popMenu != null && popMenu.Items.Count == 7)
-            {
-                //复制
-                SetPopMenuItem(popMenu.Items[0] as MenuItem, sender, ApplicationCommands.Copy);
-                //剪切
-                SetPopMenuItem(popMenu.Items[1] as MenuItem, sender, ApplicationCommands.Cut);
-                //粘贴
-                SetPopMenuItem(popMenu.Items[2] as MenuItem, sender, ApplicationCommands.Paste);
-                //删除
-                SetPopMenuItem(popMenu.Items[3] as MenuItem, sender, ApplicationCommands.Delete);
-                //裁剪
-                SetPopMenuItem(popMenu.Items[4] as MenuItem, sender, CropModeCommand);
-                //替换
-                SetPopMenuItem(popMenu.Items[5] as MenuItem, sender, ReplaceImgCommand);
-                //导出
-                SetPopMenuItem(popMenu.Items[6] as MenuItem, sender, ExportImgCommand);
-            }
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+            //复制
+            customMenu.SetMenuBinding(0, sender, ApplicationCommands.Copy);
+            //剪切
+            customMenu.SetMenuBinding(1, sender, ApplicationCommands.Cut);
+            //粘贴
+            customMenu.SetMenuBinding(2, sender, ApplicationCommands.Paste);
+            //删除
+            customMenu.SetMenuBinding(3, sender, ApplicationCommands.Delete);
+            //裁剪
+            customMenu.SetMenuBinding(4, sender, CropModeCommand);
+            //替换
+            customMenu.SetMenuBinding(5, sender, ReplaceImgCommand);
+            //导出
+            customMenu.SetMenuBinding(6, sender, ExportImgCommand);
             return popMenu;
         }
 
@@ -403,13 +457,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
         }
         #region 全局
 
-        public event EventHandler ClearCheckedAglin;
         #endregion
         public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
 
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
+            isCanSave = false;
             IsMultiSelectImage = false;
             TextEditEvent = null;
             ClearCheckedAglin?.Invoke(null, null);

+ 11 - 2
PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageTextEditPropertyViewModel.cs

@@ -14,13 +14,22 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 {
     public class ImageTextEditPropertyViewModel : PDFEditVM, INavigationAware
     {
+        #region 变量
+        protected List<ComPDFKitViewer.PDFEditEvent> TextEditEventList;
+        public event EventHandler ClearCheckedAglin;
+        #endregion
+
+        #region Command
         public DelegateCommand<object> ImgAlignCheckedCommand { get; set; }
+        #endregion
+
         public ImageTextEditPropertyViewModel()
         {
             ImgAlignCheckedCommand = new DelegateCommand<object>(ImgAlignChecked);
 
         }
 
+        #region Command实现
         private void ImgAlignChecked(object obj)
         {
             if (obj != null)
@@ -55,8 +64,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 
             }
         }
+        #endregion
 
-        protected List<ComPDFKitViewer.PDFEditEvent> TextEditEventList;
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
@@ -90,7 +99,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 
         public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
 
-        public event EventHandler ClearCheckedAglin;
+        
         public void OnNavigatedFrom(NavigationContext navigationContext) 
         { 
            

+ 44 - 43
PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs

@@ -2,6 +2,7 @@
 using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
 using PDF_Office.CustomControl.CompositeControl;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.PropertyPanel.AnnotPanel;
 using Prism.Commands;
@@ -68,7 +69,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
         private void InitCommand()
         {
             AddTextCommand = new DelegateCommand(AddText);
-
+            AddImgCommand = new DelegateCommand(AddImg);
             SelectedColorCommand = new DelegateCommand<object>(SelectedColor);
             SelectedFontStyleCommand = new DelegateCommand<object>(SelectedFontStyle);
             FontSizeChangedCommand = new DelegateCommand<object>(FontSizeChanged);
@@ -89,6 +90,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
             PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
         }
 
+        private void AddImg()
+        {
+            PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
+        }
+        
         private void EditTextMode()
         {
 
@@ -187,7 +193,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
                 var colorValue = (Color)obj;
                 if (colorValue != null)
                 {
-
                     SelectColor = new SolidColorBrush(colorValue);
                 }
             }
@@ -277,15 +282,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
         private ContextMenu EmptyStateMenu(object sender)
         {
             var popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
-            if (popMenu != null && popMenu.Items.Count == 3)
-            {
-                //粘贴
-                SetPopMenuItem(popMenu.Items[0] as MenuItem, sender, ApplicationCommands.Paste);
-                //添加文本
-                SetPopMenuItem(popMenu.Items[1] as MenuItem, sender, AddTextCommand);
-                //添加图像
-                SetPopMenuItem(popMenu.Items[2] as MenuItem, sender, AddImgCommand);
-            }
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+            //粘贴
+            customMenu.SetMenuBinding(0, sender, ApplicationCommands.Paste);
+            //添加文本
+            customMenu.SetMenuBinding(1, sender, AddTextCommand);
+            //添加图像
+            customMenu.SetMenuBinding(2, sender, AddImgCommand);
 
             return popMenu;
         }
@@ -294,43 +297,40 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
         private ContextMenu SelectTextBorder(object sender)
         {
             var popMenu = App.Current.FindResource("SelectTextMenu") as ContextMenu;
-            if (popMenu != null && popMenu.Items.Count == 5)
-            {
-                //编辑
-                SetPopMenuItem(popMenu.Items[0] as MenuItem, sender, EditTextModeCommand);
-                //复制
-                SetPopMenuItem(popMenu.Items[1] as MenuItem, sender, ApplicationCommands.Copy);
-                //剪切
-                SetPopMenuItem(popMenu.Items[2] as MenuItem, sender, ApplicationCommands.Cut);
-                //粘贴
-                SetPopMenuItem(popMenu.Items[3] as MenuItem, sender, ApplicationCommands.Paste);
-                //删除
-                SetPopMenuItem(popMenu.Items[4] as MenuItem, sender, ApplicationCommands.Delete);
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+            //编辑
+            customMenu.SetMenuBinding(0, sender, EditTextModeCommand);
+            //复制
+            customMenu.SetMenuBinding(1, sender, ApplicationCommands.Copy);
+            //剪切
+            customMenu.SetMenuBinding(2, sender, ApplicationCommands.Cut);
+            //粘贴
+            customMenu.SetMenuBinding(3, sender, ApplicationCommands.Paste);
+            //删除
+            customMenu.SetMenuBinding(4, sender, ApplicationCommands.Delete);
+         
+            customMenu.SetVisibilityProperty(6, false);
 
-            }
             return popMenu;
         }
-
+       
         //选中文字内容
         private ContextMenu SelectTextContent(object sender)
         {
             var popMenu = App.Current.FindResource("SelectContentMenu") as ContextMenu;
-            if (popMenu != null && popMenu.Items.Count == 6)
-            {
-                //复制
-                SetPopMenuItem(popMenu.Items[0] as MenuItem, sender, ApplicationCommands.Copy);
-                //剪切
-                SetPopMenuItem(popMenu.Items[1] as MenuItem, sender, ApplicationCommands.Cut);
-                //粘贴
-                SetPopMenuItem(popMenu.Items[2] as MenuItem, sender, ApplicationCommands.Paste);
-                //粘贴并匹配样式
-                SetPopMenuItem(popMenu.Items[3] as MenuItem, sender, ApplicationCommands.Paste);
-                //删除
-                SetPopMenuItem(popMenu.Items[4] as MenuItem, sender, ApplicationCommands.Delete);
-                ////全部选定
-                SetPopMenuItem(popMenu.Items[5] as MenuItem, sender, ApplicationCommands.SelectAll);
-
-            }
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+            //复制
+            customMenu.SetMenuBinding(0, sender, ApplicationCommands.Copy);
+            //剪切
+            customMenu.SetMenuBinding(1, sender, ApplicationCommands.Cut);
+            //粘贴
+            customMenu.SetMenuBinding(2, sender, ApplicationCommands.Paste);
+            //粘贴并匹配样式
+            customMenu.SetVisibilityProperty(3, false);
+            //删除
+            customMenu.SetMenuBinding(4, sender, ApplicationCommands.Delete);
+            //全部选定
+            customMenu.SetMenuBinding(5, sender, ApplicationCommands.SelectAll);
 
             return popMenu;
         }
@@ -497,7 +497,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 
                             if(isok)
                             {
-                                TextEditEvent.FontColor = eventColor;
+                                TextEditEvent.FontColor = setColor;
                                 TextEditEvent.UpdatePDFEditByEventArgs();
                             }
                         }
@@ -521,7 +521,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
                
                 SelectedFontWeights_Style(TextEditEvent.FontStyle, TextEditEvent.FontWeight);
                 TextAlign = TextEditEvent.TextAlign;
-                SelectColor = new SolidColorBrush(TextEditEvent.FontColor);
+
+
             }
         }
 

+ 139 - 99
PDF Office/ViewModels/Scan/ScanViwerViewModel.cs

@@ -1,6 +1,7 @@
 using ComDocumentAIKit;
 using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFPage;
+using ComPDFKit.PDFPage.Edit;
 using ComPDFKitViewer;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.EventAggregators;
@@ -209,131 +210,134 @@ namespace PDF_Office.ViewModels.Scan
             Directory.CreateDirectory(path);
 
             CPDFDocument CurrentDoc = PDFViewer.Document;
+            Task.Run(() =>
+            {
+                CErrorCode error = imEngine.SetModel(language);
 
-            CErrorCode error = imEngine.SetModel(language);
-
-            cacahe.Remove(PDFViewer.CurrentIndex);
-            string pageImagePath = Path.Combine(path, "Area");
-            Directory.CreateDirectory(pageImagePath);
-            pageImagePath = Path.Combine(pageImagePath, PDFViewer.CurrentIndex.ToString());
+                cacahe.Remove(PDFViewer.CurrentIndex);
+                string pageImagePath = Path.Combine(path, "Area");
+                Directory.CreateDirectory(pageImagePath);
+                pageImagePath = Path.Combine(pageImagePath, PDFViewer.CurrentIndex.ToString());
 
-            if (IsEnhanced)
-            {
-                BitmapImage image = new BitmapImage(new Uri(EnhancedFilePathList[PDFViewer.CurrentIndex]));
-                BgImage = new WriteableBitmap(image);
-                double zoomWidth = AreaRect.Width / ImageRect.Width;
-                double zoomHeight = AreaRect.Height / ImageRect.Height;
-                double zoomX = (AreaRect.X - ImageRect.X) / ImageRect.Width;
-                double zoomY = (AreaRect.Y - ImageRect.Y) / ImageRect.Height;
-                Int32Rect rect = new Int32Rect((int)(BgImage.Width*zoomX), (int)(BgImage.Height*zoomY), (int)(BgImage.Width*zoomWidth), (int)(BgImage.Height*zoomHeight));
-                byte[] renderData = new byte[(int)(BgImage.Width * BgImage.Height * 4)];
-
-                BgImage.CopyPixels(rect, renderData, BgImage.BackBufferStride, 0);
-
-                WriteableBitmap bitmap = new WriteableBitmap(rect.Width, rect.Height, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
-                bitmap.WritePixels(new Int32Rect(0, 0, rect.Width, rect.Height), renderData, BgImage.BackBufferStride, 0);
-                BitmapEncoder encoder = new PngBitmapEncoder();
-                encoder.Frames.Add(BitmapFrame.Create(bitmap));
-
-                using (FileStream imageStream = File.Create(pageImagePath))
+                if (IsEnhanced)
                 {
-                    encoder.Save(imageStream);
-                    imageStream.Flush();
-                }
-                error = imEngine.Process(pageImagePath);
+                    BitmapImage image = new BitmapImage(new Uri(EnhancedFilePathList[PDFViewer.CurrentIndex]));
+                    BgImage = new WriteableBitmap(image);
+                    double zoomWidth = AreaRect.Width / ImageRect.Width;
+                    double zoomHeight = AreaRect.Height / ImageRect.Height;
+                    double zoomX = (AreaRect.X - ImageRect.X) / ImageRect.Width;
+                    double zoomY = (AreaRect.Y - ImageRect.Y) / ImageRect.Height;
+                    Int32Rect rect = new Int32Rect((int)(BgImage.Width * zoomX), (int)(BgImage.Height * zoomY), (int)(BgImage.Width * zoomWidth), (int)(BgImage.Height * zoomHeight));
+                    byte[] renderData = new byte[(int)(BgImage.Width * BgImage.Height * 4)];
 
-                if (imEngine.OCRResultList == null)
-                    return;
+                    BgImage.CopyPixels(rect, renderData, BgImage.BackBufferStride, 0);
 
-                List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
-                foreach (COCRResult ocrResult in imEngine.OCRResultList)
-                {
-                    List<Point> rectPoints = new List<Point>();
-                    for (int j = 0; j < ocrResult.position.Length; j += 2)
+                    WriteableBitmap bitmap = new WriteableBitmap(rect.Width, rect.Height, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
+                    bitmap.WritePixels(new Int32Rect(0, 0, rect.Width, rect.Height), renderData, BgImage.BackBufferStride, 0);
+                    BitmapEncoder encoder = new PngBitmapEncoder();
+                    encoder.Frames.Add(BitmapFrame.Create(bitmap));
+
+                    using (FileStream imageStream = File.Create(pageImagePath))
                     {
-                        rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
+                        encoder.Save(imageStream);
+                        imageStream.Flush();
                     }
-                    int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
-                    int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
-                    int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
-                    int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
+                    error = imEngine.Process(pageImagePath);
 
-                    RectList.Add(new KeyValuePair<Rect, string>(new Rect(left + BgImage.Width * zoomX, top + BgImage.Height * zoomY, right - left, bottom - top), ocrResult.text));
-                }
-                cacahe.Add(PDFViewer.CurrentIndex, RectList);
+                    if (imEngine.OCRResultList == null)
+                        return;
 
-                if (cacahe.Count > 0)
-                {
-                    if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
+                    List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
+                    foreach (COCRResult ocrResult in imEngine.OCRResultList)
                     {
-                        TextRectList = cacahe[PDFViewer.CurrentIndex];
+                        List<Point> rectPoints = new List<Point>();
+                        for (int j = 0; j < ocrResult.position.Length; j += 2)
+                        {
+                            rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
+                        }
+                        int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
+                        int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
+                        int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
+                        int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
+
+                        RectList.Add(new KeyValuePair<Rect, string>(new Rect(left + BgImage.Width * zoomX, top + BgImage.Height * zoomY, right - left, bottom - top), ocrResult.text));
                     }
-                    else
+                    cacahe.Add(PDFViewer.CurrentIndex, RectList);
+
+                    if (cacahe.Count > 0)
                     {
-                        TextRectList = null;
+                        if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
+                        {
+                            TextRectList = cacahe[PDFViewer.CurrentIndex];
+                        }
+                        else
+                        {
+                            TextRectList = null;
+                        }
                     }
                 }
-            }
-            else
-            {
-                CPDFPage pdfPage = CurrentDoc.PageAtIndex(PDFViewer.CurrentIndex);
-                double zoomWidth = AreaRect.Width / ImageRect.Width;
-                double zoomHeight = AreaRect.Height / ImageRect.Height;
-                double zoomX = (AreaRect.X- ImageRect.X) / ImageRect.Width;
-                double zoomY = (AreaRect.Y- ImageRect.Y) / ImageRect.Height;
-
-                float zoom = (float)(DpiHelpers.Dpi / 72D);
-                int renderWidth = (int)(pdfPage.PageSize.Width* zoomWidth * zoom);
-                int renderHeight = (int)(pdfPage.PageSize.Height* zoomHeight * zoom);
-                int renderX = (int)(pdfPage.PageSize.Width* zoomX * zoom);
-                int renderY = (int)(pdfPage.PageSize.Height* zoomY * zoom);
-                byte[] renderData = new byte[renderWidth * renderHeight * 4];
-                pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(renderX, renderY, renderWidth, renderHeight), 0xFFFFFFFF, renderData, 0);
-                WriteableBitmap bitmap = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
-                bitmap.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), renderData, bitmap.BackBufferStride, 0);
-                BitmapEncoder encoder = new PngBitmapEncoder();
-                encoder.Frames.Add(BitmapFrame.Create(bitmap));
-
-                using (FileStream imageStream = File.Create(pageImagePath))
+                else
                 {
-                    encoder.Save(imageStream);
-                    imageStream.Flush();
-                }
-
-                error = imEngine.Process(pageImagePath);
+                    CPDFPage pdfPage = CurrentDoc.PageAtIndex(PDFViewer.CurrentIndex);
+                    double zoomWidth = AreaRect.Width / ImageRect.Width;
+                    double zoomHeight = AreaRect.Height / ImageRect.Height;
+                    double zoomX = (AreaRect.X - ImageRect.X) / ImageRect.Width;
+                    double zoomY = (AreaRect.Y - ImageRect.Y) / ImageRect.Height;
 
-                if (imEngine.OCRResultList == null)
-                    return;
+                    float zoom = (float)(DpiHelpers.Dpi / 72D);
+                    int renderWidth = (int)(pdfPage.PageSize.Width * zoomWidth * zoom);
+                    int renderHeight = (int)(pdfPage.PageSize.Height * zoomHeight * zoom);
+                    int renderX = (int)(pdfPage.PageSize.Width * zoomX * zoom);
+                    int renderY = (int)(pdfPage.PageSize.Height * zoomY * zoom);
+                    byte[] renderData = new byte[renderWidth * renderHeight * 4];
+                    pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(renderX, renderY, renderWidth, renderHeight), 0xFFFFFFFF, renderData, 0);
+                    WriteableBitmap bitmap = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
+                    bitmap.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), renderData, bitmap.BackBufferStride, 0);
+                    BitmapEncoder encoder = new PngBitmapEncoder();
+                    encoder.Frames.Add(BitmapFrame.Create(bitmap));
 
-                List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
-                foreach (COCRResult ocrResult in imEngine.OCRResultList)
-                {
-                    List<Point> rectPoints = new List<Point>();
-                    for (int j = 0; j < ocrResult.position.Length; j += 2)
+                    using (FileStream imageStream = File.Create(pageImagePath))
                     {
-                        rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
+                        encoder.Save(imageStream);
+                        imageStream.Flush();
                     }
-                    int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
-                    int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
-                    int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
-                    int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
 
-                    RectList.Add(new KeyValuePair<Rect, string>(new Rect(left+ renderX, top+ renderY, right - left, bottom - top), ocrResult.text));
-                }
-                cacahe.Add(PDFViewer.CurrentIndex, RectList);
+                    error = imEngine.Process(pageImagePath);
 
-                if (cacahe.Count > 0)
-                {
-                    if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
+                    if (imEngine.OCRResultList == null)
+                        return;
+
+                    List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
+                    foreach (COCRResult ocrResult in imEngine.OCRResultList)
                     {
-                        TextRectList = cacahe[PDFViewer.CurrentIndex];
+                        List<Point> rectPoints = new List<Point>();
+                        for (int j = 0; j < ocrResult.position.Length; j += 2)
+                        {
+                            rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
+                        }
+                        int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
+                        int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
+                        int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
+                        int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
+
+                        RectList.Add(new KeyValuePair<Rect, string>(new Rect(left + renderX, top + renderY, right - left, bottom - top), ocrResult.text));
                     }
-                    else
+                    cacahe.Add(PDFViewer.CurrentIndex, RectList);
+
+                    if (cacahe.Count > 0)
                     {
-                        TextRectList = null;
+                        if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
+                        {
+                            TextRectList = cacahe[PDFViewer.CurrentIndex];
+                        }
+                        else
+                        {
+                            TextRectList = null;
+                        }
                     }
                 }
-            }
+                imEngine.Release();
+            });
             ClearDraw();
         }
 
@@ -630,5 +634,41 @@ namespace PDF_Office.ViewModels.Scan
             });
         }
 
+        public void Save()
+        {
+            for (int i = 0; i < PDFViewer.Document.PageCount; i++)
+            {
+                if (cacahe.ContainsKey(i))
+                {
+                    CPDFPage pdfPage = PDFViewer.Document.PageAtIndex(i);
+                    CPDFEditPage editPage = pdfPage.GetEditPage();
+                    editPage.BeginEdit(CPDFEditType.EditText);
+                    for (int y = textRectList.Count - 1; y >= 0; y--)
+                    {
+                        KeyValuePair<Rect, string> textBlock = textRectList[y];
+                        int fontSize = 1;
+                        Rect pdfRect = DpiHelpers.GetRawRect(textBlock.Key);
+
+                        for (; fontSize < 100; fontSize++)
+                        {
+                            Rect cmpRect = pdfPage.GetTextContentRect(fontSize, "Helvetica", textBlock.Value);
+                            if (cmpRect.Width > pdfRect.Width || cmpRect.Height > pdfRect.Height)
+                            {
+                                fontSize -= 1;
+                                break;
+                            }
+                        }
+                        //字体
+                        CPDFEditTextArea editArea = editPage.CreateNewTextArea(pdfRect, "Helvetica", fontSize, new byte[] { 0, 0, 0 });
+                        //透明度
+                        editArea.SetCharsFontTransparency(0);
+                        bool x = editArea.SetTextAreaAlign(TextAlignType.AlignChar);
+                        editArea.InsertText(textBlock.Value);
+
+                    }
+                    editPage.EndEdit();
+                }
+            }
+        }
     }
 }

+ 2 - 2
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -721,9 +721,9 @@ namespace PDF_Office.ViewModels.Tools
 
         private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
         {
-            if (e.AnnotEventArgsList == null)
+            if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
                 return;
-
+            
             // var annotlist = e.AnnotEventArgsList;
             switch (e.CommandType)
             {

+ 136 - 39
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -15,23 +15,57 @@ using PDF_Office.Model;
 using Microsoft.Win32;
 using PDF_Office.CustomControl;
 using ComPDFKitViewer;
+using System.Windows.Input;
+using PDF_Office.Helper;
 
 namespace PDF_Office.ViewModels.Tools
 {
     public class TextEditToolContentViewModel: BindableBase, INavigationAware
     {
+        #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
+        {
+            get { return _isTextEdit; }
+            set { SetProperty(ref _isTextEdit, value); }
+        }
+        private bool _isImgEdit = false;
+        public bool IsImgEdit
+        {
+            get { return _isImgEdit; }
+            set { SetProperty(ref _isImgEdit, value); }
+        }
+        #endregion
+
         #region Command
+        // 添加文本、图像
         public DelegateCommand<object> AddContentCommand { get; set; }
-
+        public DelegateCommand AddTextCommand { get; set; }
+        public DelegateCommand AddImgCommand { get; set; }
         #endregion
-        private IRegionManager regions;
-        private Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
+
+        #region 初始化
         public TextEditToolContentViewModel(IRegionManager regionManager)
         {
             regions = regionManager;
             InitCommand();
             InitBtnToProperty();
         }
+        private void InitCommand()
+        {
+            AddContentCommand = new DelegateCommand<object>(AddContent);
+            AddTextCommand = new DelegateCommand(AddText);
+            AddImgCommand = new DelegateCommand(AddImg);
+
+        }
+
         private void InitBtnToProperty()
         {
             btnToProperty.Add("Text", "TextEditProperty");
@@ -40,74 +74,77 @@ namespace PDF_Office.ViewModels.Tools
             btnToProperty.Add("PropertyPanelContent", "PropertyPanelContent");
         }
 
-        private void AddToPropertyPanel(string type,  List<PDFEditEvent> e)
-        {
-            if (btnToProperty.ContainsKey(type))
-            {
-                NavigationParameters parameters = new NavigationParameters();
-                parameters.Add(ParameterNames.PDFViewer, PDFViewer);
-                parameters.Add(ParameterNames.AnnotEvent, e);
-                System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
-                {
-                    regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type], parameters);
-                }));
-
-                ShowPropertyPanel(true);
-            }
-        }
-        private void ShowPropertyPanel(bool show = true)
-        {
-            viewContentViewModel.IsPropertyOpen = show;
-        }
-
-        private void InitCommand()
-        {
-            AddContentCommand = new DelegateCommand<object>(AddContent);
-        }
-
+        #endregion
         public void AddContent(object obj)
         {
             if (PDFViewer == null || obj == null || obj as CustomIconToggleBtn == null) return;
 
             var btn = obj as CustomIconToggleBtn;
+            EnterEditMode((bool)btn.IsChecked, btn.Tag.ToString());
+        }
 
-            if(btn.IsChecked == true)
+        private void EnterEditMode(bool isCheckMode,string modeType)
+        {
+            if (isCheckMode)
             {
-                if (btn.Tag.ToString() == "Text")
+                if (modeType == "Text")
                 {
+                    IsImgEdit = false;
+                    IsTextEdit = true;
                     PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
                 }
                 else
                 {
+                    IsImgEdit = true;
+                    IsTextEdit = false;
                     PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
                 }
             }
             else
             {
+                IsImgEdit = false;
+                IsTextEdit = false;
                 PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.None);
                 PDFViewer.SetMouseMode(MouseModes.PDFEdit);
             }
+        }
 
+        #region Command功能
 
+        private void AddText()
+        {
+            EnterEditMode(true, "Text");
         }
-        public ViewContentViewModel viewContentViewModel;
-        private CPDFViewer PDFViewer;
-        public void OnNavigatedTo(NavigationContext navigationContext)
+
+        private void AddImg()
         {
-            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            EnterEditMode(true, "Image");
+        }
 
-            if (PDFViewer != null)
+        #endregion
+        private void AddToPropertyPanel(string type,  List<PDFEditEvent> e)
+        {
+            if (btnToProperty.ContainsKey(type))
             {
-                PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
-                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
+                NavigationParameters parameters = new NavigationParameters();
+                parameters.Add(ParameterNames.PDFViewer, PDFViewer);
+                parameters.Add(ParameterNames.AnnotEvent, e);
+                System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+                {
+                    regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type], parameters);
+                }));
 
+                ShowPropertyPanel(true);
             }
         }
+        private void ShowPropertyPanel(bool show = true)
+        {
+            viewContentViewModel.IsPropertyOpen = show;
+        }
 
         private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
         {
-  
+
             if (e != null && e.Count > 0)
             {
                 bool isText = false;
@@ -148,6 +185,63 @@ namespace PDF_Office.ViewModels.Tools
 
         }
 
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+
+            if (PDFViewer != null)
+            {
+                PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
+
+                PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+                PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
+            }
+        }
+
+        private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
+        {
+            if (e == null)
+                return;
+
+            switch (e.CommandType)
+            {
+                case CommandType.Context:
+
+                    if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)//点击空白区域
+                    {
+                        e.PopupMenu = EmptyStateMenu(sender);
+
+                    }
+                    break;
+                default:
+                    e.DoCommand();
+                    break;
+
+            }
+            if (e.PopupMenu != null)
+            {
+                e.Handle = true;
+            }
+        }
+
+        //点击空白处时
+        private ContextMenu EmptyStateMenu(object sender)
+        {
+            var popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu);
+
+            //粘贴
+            customMenu.SetMenuBinding(0, sender, ApplicationCommands.Paste);
+            //添加文本
+            customMenu.SetMenuBinding(1, sender, AddTextCommand);
+            //添加图像
+            customMenu.SetMenuBinding(2, sender, AddImgCommand);
+
+            return popMenu;
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -156,7 +250,10 @@ namespace PDF_Office.ViewModels.Tools
       
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
+            IsImgEdit = false;
+            IsTextEdit = false;
             PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+            PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
             ShowPropertyPanel(false);
         }
 

+ 43 - 41
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -28,6 +28,7 @@ using PDF_Office.Helper;
 using System.Security.Policy;
 using System.Windows.Documents;
 using ComPDFKit.PDFDocument;
+using PDFSettings.Settings;
 
 namespace PDF_Office.ViewModels
 {
@@ -927,6 +928,7 @@ namespace PDF_Office.ViewModels
             if (mainVM != null)
             {
                 mainViewModel = mainVM;
+                mainViewModel.viewContentViewModel = this;
             }
             var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
             if (pdfview != null)
@@ -1042,7 +1044,7 @@ namespace PDF_Office.ViewModels
         /// <summary>
         /// 已有路径文档的保存逻辑
         /// </summary>
-        private bool saveFile()
+        public bool saveFile()
         {
             try
             {
@@ -1089,46 +1091,46 @@ namespace PDF_Office.ViewModels
                     PDFViewer.UndoManager.CanSave = false;
                     App.Current.Dispatcher.Invoke(() =>
                                   {
-                                      //TODO:更新缩略图
-                                      //OpenFileInfo info = SettingHelper.GetFileInfo(PdfViewer.Document.FilePath);
-                                      //try
-                                      //{
-                                      //    if (!string.IsNullOrEmpty(info.ThumbImgPath) && !PdfViewer.Document.IsEncrypted)//加密的文档不获取缩略图
-                                      //    {
-                                      //        var size = PdfViewer.Document.GetPageSize(0);
-                                      //        System.Drawing.Bitmap bitmap = ToolMethod.RenderPageBitmapNoWait(PdfViewer.Document, (int)size.Width, (int)size.Height, 0, true, true);
-                                      //        string folderPath = System.IO.Path.Combine(App.CurrentPath, "CoverImage");
-                                      //        if (File.Exists(folderPath))
-                                      //            File.Delete(folderPath);
-                                      //        DirectoryInfo folder = new DirectoryInfo(folderPath);
-                                      //        if (!folder.Exists)
-                                      //            folder.Create();
-                                      //        string imagePath = info.ThumbImgPath;
-                                      //        if (!File.Exists(imagePath))//由加密文档变为非加密文档时 新建一个路径
-                                      //        {
-                                      //            string imageName = Guid.NewGuid().ToString();
-                                      //            imagePath = System.IO.Path.Combine(folderPath, imageName);
-                                      //            using (FileStream stream = new FileStream(imagePath, FileMode.Create))
-                                      //            {
-                                      //                bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
-                                      //            }
-                                      //        }
-                                      //        else
-                                      //        {
-                                      //            using (FileStream stream = new FileStream(imagePath, FileMode.Open))
-                                      //            {
-                                      //                bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
-                                      //            }
-                                      //        }
-                                      //        info.ThumbImgPath = imagePath;
-                                      //        SettingHelper.SetFileInfo(info);
-                                      //    }
-                                      //}
-                                      //catch
-                                      //{
-                                      //    info.ThumbImgPath = null;
-                                      //    SettingHelper.SetFileInfo(info);
-                                      //}
+                                      //保存时更新缩略图
+                                      OpenFileInfo info = SettingHelper.GetFileInfo(PDFViewer.Document.FilePath);
+                                      try
+                                      {
+                                          if (!string.IsNullOrEmpty(info.ThumbImgPath) && !PDFViewer.Document.IsEncrypted)//加密的文档不获取缩略图
+                                          {
+                                              var size = PDFViewer.Document.GetPageSize(0);
+                                              System.Drawing.Bitmap bitmap = ToolMethod.RenderPageBitmapNoWait(PDFViewer.Document, (int)size.Width, (int)size.Height, 0, true, true);
+                                              string folderPath = System.IO.Path.Combine(App.CurrentPath, "CoverImage");
+                                              if (File.Exists(folderPath))
+                                                  File.Delete(folderPath);
+                                              DirectoryInfo folder = new DirectoryInfo(folderPath);
+                                              if (!folder.Exists)
+                                                  folder.Create();
+                                              string imagePath = info.ThumbImgPath;
+                                              if (!File.Exists(imagePath))//由加密文档变为非加密文档时 新建一个路径
+                                              {
+                                                  string imageName = Guid.NewGuid().ToString();
+                                                  imagePath = System.IO.Path.Combine(folderPath, imageName);
+                                                  using (FileStream stream = new FileStream(imagePath, FileMode.Create))
+                                                  {
+                                                      bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                                                  }
+                                              }
+                                              else
+                                              {
+                                                  using (FileStream stream = new FileStream(imagePath, FileMode.Open))
+                                                  {
+                                                      bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
+                                                  }
+                                              }
+                                              info.ThumbImgPath = imagePath;
+                                              SettingHelper.SetFileInfo(info);
+                                          }
+                                      }
+                                      catch
+                                      {
+                                          info.ThumbImgPath = null;
+                                          SettingHelper.SetFileInfo(info);
+                                      }
                                   });
                 }
                 else

+ 13 - 7
PDF Office/Views/Dialog/ConverterDialogs/ConverterCSVDialog.xaml

@@ -30,20 +30,26 @@
                 </Grid>
                 <Grid Grid.Column="1">
                     <StackPanel Margin="18,16,0,0">
-                        <StackPanel>
-                            <!--<RadioButton
+                        <TextBlock
+                                Width="60"
+                                Height="20"
+                                HorizontalAlignment="Left"
+                                Text="CSV设置:" />
+                        <StackPanel Margin="0,8,0,0">
+                            <RadioButton
+                                IsChecked="True"
                                 Name="ForEachPageRadioBtn"
                                 Command="{Binding RadioButtonCommand}"
                                 CommandParameter="{Binding ElementName=ForEachPageRadioBtn, Path=Name}">
-                                <TextBlock Text="将每个页面转换为一个单独的文档" />
-                            </RadioButton>-->
+                                <TextBlock Text="为每个表格创建工作表" />
+                            </RadioButton>
                             <RadioButton
-                                IsChecked="True"
+                                
                                 Name="OnlyTableRadioBtn"
                                 Margin="0,6,0,0"
                                 Command="{Binding RadioButtonCommand}"
-                                CommandParameter="{Binding ElementName=ForTheDocRadioBtn, Path=Name}">
-                                <TextBlock Text="只提取表格" />
+                                CommandParameter="{Binding ElementName=OnlyTableRadioBtn, Path=Name}">
+                                <TextBlock Text="为文档创建单个工作表" />
                             </RadioButton>
                         </StackPanel>
                         <StackPanel Margin="0,14,0,0" Orientation="Vertical">

+ 2 - 2
PDF Office/Views/Dialog/ConverterDialogs/ConverterImgDialog.xaml

@@ -45,7 +45,7 @@
                                 ItemsSource="{Binding ImageTypeFamily}"
                                 SelectedIndex="{Binding ImageTypeSelectedIndex, Mode=TwoWay}"
                                 />
-                            <ComboBox
+                            <!--<ComboBox
                                 Name="ImageDPIComboBox"
                                 Width="228"
                                 Height="32"
@@ -53,7 +53,7 @@
                                 HorizontalAlignment="Left"
                                 ItemsSource="{Binding ImageDPIFamily}"
                                 SelectedIndex="{Binding ImageDPISelectedIndex, Mode=TwoWay}"
-                                />
+                                />-->
                         </StackPanel>
                         <StackPanel Margin="0,16,0,0">
                             <TextBlock

+ 2 - 2
PDF Office/Views/Dialog/ConverterDialogs/ConverterWordDialog.xaml

@@ -31,10 +31,10 @@
                         <StackPanel Orientation="Vertical" Margin="0,16,0,0" HorizontalAlignment="Left">
                             <TextBlock Text="版面设置:" Width="60" Height="20" HorizontalAlignment="Left"/>
                             <StackPanel Orientation="Horizontal" Margin="0,7,0,0">
-                                <RadioButton Name="FlowingTextRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=FlowingTextRadioBtn,Path=Name}" IsChecked="True">
+                                <RadioButton Name="FlowingTextRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=FlowingTextRadioBtn,Path=Name}" IsEnabled="False">
                                     <TextBlock Text="保留流排文本"/>
                                 </RadioButton>
-                                <RadioButton  Margin="15,0,0,0" Name="PageLayoutRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=PageLayoutRadioBtn,Path=Name}">
+                                <RadioButton  Margin="15,0,0,0" Name="PageLayoutRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=PageLayoutRadioBtn,Path=Name}" IsChecked="True">
                                     <TextBlock Text="保留页面布局"/>
                                 </RadioButton>
                             </StackPanel>

+ 21 - 6
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterCSV.xaml

@@ -4,12 +4,27 @@
              xmlns:prism="http://prismlibrary.com/"             
              prism:ViewModelLocator.AutoWireViewModel="True">
     <Grid>
-        <StackPanel Width="245">
-            <!--<RadioButton Name="ForEachPageRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=ForEachPageRadioBtn,Path=Name}">
-                <TextBlock Text="将每个页面转换为一个单独的文档"/>
-            </RadioButton>-->
-            <RadioButton Margin="0,6,0,0" Name="OnlyTableRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=ForTheDocRadioBtn,Path=Name}" IsChecked="True">
-                <TextBlock Text="只提取表格"/>
+        
+        <StackPanel Width="245" >
+            <TextBlock
+                                Width="60"
+                                Height="20"
+                                HorizontalAlignment="Left"
+                                Text="CSV设置:" />
+            <RadioButton
+                                IsChecked="True"
+                                Name="ForEachPageRadioBtn"
+                                Command="{Binding RadioButtonCommand}"
+                                CommandParameter="{Binding ElementName=ForEachPageRadioBtn, Path=Name}"
+                Margin="0,8,0,0">
+                <TextBlock Text="为每个表格创建工作表" />
+            </RadioButton>
+            <RadioButton
+                                Name="OnlyTableRadioBtn"
+                                Margin="0,6,0,0"
+                                Command="{Binding RadioButtonCommand}"
+                                CommandParameter="{Binding ElementName=OnlyTableRadioBtn, Path=Name}">
+                <TextBlock Text="为文档创建单个工作表" />
             </RadioButton>
         </StackPanel>
     </Grid>

+ 1 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterImg.xaml

@@ -7,7 +7,7 @@
         <StackPanel Width="245">
             <TextBlock Text="文件类型" Height="20" Width="48" HorizontalAlignment="Left" />
             <ComboBox Name="ImageTypeComboBox" Height="32" Width="228" HorizontalAlignment="Left" Margin="0,8,0,0" ItemsSource="{Binding ImageTypeFamily}" SelectedIndex="0" SelectionChanged="ImageTypeComboBox_SelectionChanged"></ComboBox>
-            <ComboBox Name="ImageDPIComboBox" Height="32" Width="228" HorizontalAlignment="Left" Margin="0,8,0,0" ItemsSource="{Binding ImageDPIFamily}" SelectedIndex="0" SelectionChanged="ImageDPIComboBox_SelectionChanged"></ComboBox>
+            <!--<ComboBox Name="ImageDPIComboBox" Height="32" Width="228" HorizontalAlignment="Left" Margin="0,8,0,0" ItemsSource="{Binding ImageDPIFamily}" SelectedIndex="0" SelectionChanged="ImageDPIComboBox_SelectionChanged"></ComboBox>-->
         </StackPanel>
     </Grid>
 </UserControl>

+ 6 - 6
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterImg.xaml.cs

@@ -25,14 +25,14 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.H
 
 
        
-        private void ImageDPIComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            if (((HomePageConverterImgViewModel)this.DataContext).homePageConverterDialogViewModel == null)
-                return;
+        //private void ImageDPIComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        //{
+        //    if (((HomePageConverterImgViewModel)this.DataContext).homePageConverterDialogViewModel == null)
+        //        return;
 
-            ((HomePageConverterImgViewModel)this.DataContext).UpdateImageDpi(ImageDPIComboBox.SelectedIndex);
+        //    ((HomePageConverterImgViewModel)this.DataContext).UpdateImageDpi(ImageDPIComboBox.SelectedIndex);
             
             
-        }
+        //}
     }
 }

+ 2 - 2
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterWord.xaml

@@ -7,10 +7,10 @@
         <StackPanel Orientation="Vertical" Margin="0,16,0,0" HorizontalAlignment="Left" Width="245">
             <TextBlock Text="版面设置:" Width="60" Height="20" HorizontalAlignment="Left"/>
             <StackPanel Orientation="Horizontal" Margin="0,7,0,0">
-                <RadioButton Name="FlowingTextRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=FlowingTextRadioBtn,Path=Name}" IsChecked="True">
+                <RadioButton Name="FlowingTextRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=FlowingTextRadioBtn,Path=Name}" IsEnabled="False">
                     <TextBlock Text="保留流排文本"/>
                 </RadioButton>
-                <RadioButton  Margin="16,0,0,0" Name="PageLayoutRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=PageLayoutRadioBtn,Path=Name}">
+                <RadioButton  Margin="16,0,0,0" Name="PageLayoutRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=PageLayoutRadioBtn,Path=Name}"  IsChecked="True" >
                     <TextBlock Text="保留页面布局"/>
                 </RadioButton>
             </StackPanel>

Diff do ficheiro suprimidas por serem muito extensas
+ 5 - 11
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialog.xaml


+ 1 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialog.xaml

@@ -155,7 +155,7 @@
                     </StackPanel>
                 </StackPanel>
             </Grid>
-            <Grid Grid.Row="1" Margin="15,0,0,0">
+            <Grid Grid.Row="1" Margin="15,0,0,0" Visibility="Hidden">
                 <StackPanel >
                     <TextBlock Text="OCR"/>
                     <CheckBox Name="NeedOCRCheckBox" Margin="0,7,0,0">

+ 1 - 1
PDF Office/Views/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialog.xaml

@@ -245,7 +245,7 @@
                         <PasswordBox Style="{StaticResource OpenPasswordBoxStyle}" help:PasswordBoxHelper.Password="{Binding OpenPassword, Mode=TwoWay , UpdateSourceTrigger=PropertyChanged}" help:PasswordBoxHelper.DisplayText="{Binding OpenPasswordMsg, Mode=TwoWay}" Grid.ColumnSpan="2">
                         </PasswordBox>
                         <TextBox Style="{StaticResource OpenPasswordTextBoxStyle}" Text="{Binding OpenPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  Grid.ColumnSpan="2"  Visibility="{Binding OpenTextVisibility, Mode=TwoWay}" help:PasswordBoxHelper.DisplayText="{Binding OpenPasswordMsg, Mode=TwoWay}" ></TextBox>
-                        <CheckBox IsChecked="{Binding IsOpenPasswordDisplayed,Mode=TwoWay}" x:Name="DisplayOpenPasswordChk" Style="{StaticResource EyeCheckbox}" Height="16" Grid.Column="1" HorizontalAlignment="Left" Panel.ZIndex="1" Command="{Binding DisplayPasswordCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}"></CheckBox>
+                        <CheckBox IsChecked="{Binding IsOpenPasswordDisplayed,Mode=TwoWay}" x:Name="DisplayOpenPasswordChk" Style="{StaticResource EyeCheckbox}" Height="16" Grid.Column="1" HorizontalAlignment="Left" Panel.ZIndex="1" Command="{Binding DisplayPasswordCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}" Cursor="Hand"></CheckBox>
                     </Grid>
 
                     <CheckBox Grid.Column="1" Height="56" VerticalAlignment="Bottom"></CheckBox>

+ 13 - 2
PDF Office/Views/Form/FormsToolContent.xaml

@@ -156,7 +156,7 @@
                 Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
             <RadioButton
                 Name="BtnAlignment"
-                Width="44"
+                Width="44" IsChecked="{Binding IsAlignmentCheckedBtn}"
                 Click="BtnAlignment_Click"
                 Initialized="BtnAlignment_Initialized">
                 <StackPanel Orientation="Horizontal">
@@ -233,11 +233,17 @@
                                 </i:EventTrigger>
                             </i:Interaction.Triggers>
                         </cus:MenuItemWithPath>
+
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Closed">
+                                <i:InvokeCommandAction Command="{Binding AlignmentClosedMenuCommand}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </ContextMenu>
                    
                 </RadioButton.ContextMenu>
             </RadioButton>
-            <RadioButton Name="BtnMore" Width="44" Click="BtnMore_Click" Initialized="BtnMore_Initialized">
+            <RadioButton Name="BtnMore" IsChecked="{Binding IsMoreCheckedBtn}" Width="44" Click="BtnMore_Click" Initialized="BtnMore_Initialized">
                 <StackPanel Orientation="Horizontal">
                     <Grid>
                         <Path
@@ -262,6 +268,11 @@
                         <MenuItem Header="Importing data" />
                         <MenuItem Header="Exporting data" />
                         <MenuItem Header="Automatic form recognition" />
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Closed">
+                                <i:InvokeCommandAction Command="{Binding ClosedMenuCommand}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </ContextMenu>
                 </RadioButton.ContextMenu>
             </RadioButton>

+ 5 - 1
PDF Office/Views/MainWindow.xaml

@@ -19,6 +19,7 @@
     prism:ViewModelLocator.AutoWireViewModel="True"
     Activated="Window_Activated"
     Closed="Window_Closed"
+    Closing="Window_Closing"
     SizeChanged="Window_SizeChanged"
     Style="{StaticResource WindowStyle}"
     UseLayoutRounding="True"
@@ -138,7 +139,10 @@
                                             Command="{Binding DataContext.CloseTab}"
                                             CommandParameter="{Binding}"
                                             Header="Close Tab" />
-                                        <MenuItem Header="Close All Tab" />
+                                        <MenuItem
+                                            Command="{Binding DataContext.mainWindowViewModel.CloseAllTabCommand}"
+                                            Header="Close All Tab"
+                                            IsEnabled="{Binding DataContext.mainWindowViewModel.IsCloseAllEnable}" />
                                         <MenuItem Header="Open In New Window" Visibility="Collapsed" />
                                     </ContextMenu>
                                 </Grid.ContextMenu>

+ 8 - 0
PDF Office/Views/MainWindow.xaml.cs

@@ -143,5 +143,13 @@ namespace PDF_Office.Views
                 TabablzControl.Focus();
             }
         }
+
+        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+        {
+            if (!(DataContext as MainWindowViewModel).closeAllTabItem())
+            {
+                e.Cancel = true;
+            }
+        }
     }
 }

+ 8 - 2
PDF Office/Views/PropertyPanel/PDFEdit/TextEditProperty.xaml

@@ -376,8 +376,14 @@
                             <cusColor:ColorContent
                                 x:Name="FontColorBox"
                                 Width="56"
-                                HorizontalAlignment="Right" SelectedColor="{Binding SelectColor}"
-                                ShowColorList="Collapsed" />
+                                HorizontalAlignment="Right" SelectedColor="{Binding CurrentColor}"
+                                ShowColorList="Collapsed" >
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="SelectedColorInvoke">
+                                        <i:InvokeCommandAction Command="{Binding SelectedColorCommand}" CommandParameter="{Binding ElementName=FontColorBox, Path=SelectedColor}" />
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </cusColor:ColorContent>
                         </Grid>
                     </StackPanel>
                 </StackPanel>

+ 2 - 2
PDF Office/Views/Tools/TextEditToolContent.xaml

@@ -15,7 +15,7 @@
     <Grid>
         <Border BorderBrush="{StaticResource color.sys.layout.divider}" BorderThickness="0,1,0,1">
             <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
-                <customControl:CustomIconToggleBtn
+                <customControl:CustomIconToggleBtn IsChecked="{Binding IsTextEdit}"
                     x:Name="BtnAddText"
                     Height="28"
                     Padding="4,0"
@@ -40,7 +40,7 @@
                             Text="Add Text" />
                     </StackPanel>
                 </customControl:CustomIconToggleBtn>
-                <customControl:CustomIconToggleBtn
+                <customControl:CustomIconToggleBtn IsChecked="{Binding IsImgEdit}"
                     x:Name="BtnAddImage"
                     Height="28"
                     Margin="8,0"