Pārlūkot izejas kodu

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

ZhouJieSheng 2 gadi atpakaļ
vecāks
revīzija
1ad021063c
29 mainītis faili ar 959 papildinājumiem un 310 dzēšanām
  1. 116 0
      PDF Office/CustomControl/CompositeControl/ColorMenuItem.xaml
  2. 72 0
      PDF Office/CustomControl/CompositeControl/ColorMenuItem.xaml.cs
  3. 52 0
      PDF Office/DataConvert/TextAlignToCheckedConverter.cs
  4. 1 1
      PDF Office/Helper/SecurityHelper.cs
  5. 6 5
      PDF Office/Model/AnnotPanel/FontBoard.cs
  6. 8 0
      PDF Office/PDF Office.csproj
  7. 54 0
      PDF Office/Styles/RadioButtonStyle.xaml
  8. 45 6
      PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs
  9. 8 5
      PDF Office/ViewModels/Dialog/ToolsDialogs/MergeDialogViewModel.cs
  10. 6 2
      PDF Office/ViewModels/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialogViewModel.cs
  11. 16 5
      PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs
  12. 3 1
      PDF Office/ViewModels/MainContentViewModel.cs
  13. 44 19
      PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs
  14. 149 77
      PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs
  15. 32 32
      PDF Office/ViewModels/PropertyPanel/AnnotPanel/SignatureCreateDialogViewModel.cs
  16. 0 1
      PDF Office/ViewModels/TipContent/FileRestrictedTipViewModel.cs
  17. 129 21
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs
  18. 46 5
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs
  19. 67 14
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Layout.cs
  20. 7 0
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs
  21. 8 1
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs
  22. 59 14
      PDF Office/ViewModels/ViewContentViewModel.cs
  23. 1 1
      PDF Office/Views/BOTA/AnnotationContent.xaml
  24. 5 4
      PDF Office/Views/BOTA/OutLineControl.xaml
  25. 8 0
      PDF Office/Views/BOTA/OutLineControl.xaml.cs
  26. 7 3
      PDF Office/Views/Dialog/ToolsDialogs/MergeDialog.xaml
  27. 0 2
      PDF Office/Views/HomePanel/RecentFiles/DocItemControl.xaml.cs
  28. 10 23
      PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml
  29. 0 68
      PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml.cs

+ 116 - 0
PDF Office/CustomControl/CompositeControl/ColorMenuItem.xaml

@@ -0,0 +1,116 @@
+<UserControl x:Class="PDF_Office.CustomControl.CompositeControl.ColorMenuItem"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             xmlns:convert="clr-namespace:PDF_Office.DataConvert"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../Styles/CustomBtnStyle.xaml" />
+            </ResourceDictionary.MergedDictionaries>
+            <convert:ColorBrushConvert x:Key="colorBrushConvert" />
+            <convert:BoolToVisible x:Key="BoolToVisible"/>
+            <convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
+            <DataTemplate x:Key="listboxData">
+                <Grid>
+                    <Ellipse
+                    Width="20"
+                    Height="20" StrokeThickness="1"
+                    Stroke="{StaticResource color.sys.layout.divider}"
+                    Fill="{Binding Color}" 
+                    Visibility="{Binding IsTransparent,Converter={StaticResource InvertBoolToVisibleConvert}}"
+                     />
+                    <Grid Visibility="{Binding IsTransparent,Converter={StaticResource BoolToVisible}}">
+                        <Ellipse
+                    Width="20"
+                    Height="20" StrokeThickness="1" Stroke="{StaticResource color.sys.layout.divider}"
+                    Fill="White" />
+                        <Path Margin="0,0,2,2" VerticalAlignment="Center" HorizontalAlignment="Center" Data="M15 1L0.999618 14.9999" Stroke="{StaticResource color.icon.base.state.error}" StrokeThickness="1"/>
+                    </Grid>
+
+                </Grid>
+
+            </DataTemplate>
+
+            <Style x:Key="listboxItemStyle" TargetType="{x:Type ListBoxItem}">
+                <Setter Property="HorizontalContentAlignment" Value="Center" />
+                <Setter Property="Height" Value="32"/>
+                <Setter Property="Width" Value="32"/>
+                <Setter Property="Margin" Value="0,0,8,0" />
+                <Setter Property="BorderThickness"  Value="0" />
+
+                <Setter Property="Template">
+                    <Setter.Value>
+                        <ControlTemplate TargetType="{x:Type ContentControl}">
+                            <Border CornerRadius="4"
+                                x:Name="border"
+                                Padding="0,0" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{StaticResource color.item-state.sel.border.lv3}"
+                                Background="{TemplateBinding Background}">
+                                <ContentPresenter />
+                            </Border>
+                        </ControlTemplate>
+                    </Setter.Value>
+                </Setter>
+
+                <Style.Triggers>
+                    <Trigger Property="IsMouseOver" Value="True">
+                        <Setter Property="Background" Value="#e2e3e5" />
+                    </Trigger>
+                    <Trigger Property="IsMouseOver" Value="False">
+                        <Setter Property="Background" Value="Transparent" />
+                    </Trigger>
+                    <Trigger Property="IsSelected" Value="True">
+                        <Setter Property="Background" Value="#e2e3e5" />
+                        <Setter Property="BorderThickness"  Value="1" />
+                    </Trigger>
+                </Style.Triggers>
+
+            </Style>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="auto" />
+        </Grid.ColumnDefinitions>
+        <StackPanel VerticalAlignment="Center" Orientation="Horizontal" Grid.Column="1">
+            <Ellipse x:Name="ellipseBtn"
+            Width="20"
+            Height="20"
+            HorizontalAlignment="Center"
+            VerticalAlignment="Center"
+            PreviewMouseLeftButtonDown="Ellipse_PreviewMouseLeftButtonDown"  
+                >
+                <Ellipse.Fill>
+                    <DrawingBrush>
+                        <DrawingBrush.Drawing>
+                            <ImageDrawing ImageSource="../../Resources/PropertyPanel/colorIcon.png">
+                                <ImageDrawing.Rect>
+                                    <Rect Width="16" Height="16" />
+                                </ImageDrawing.Rect>
+                            </ImageDrawing>
+                        </DrawingBrush.Drawing>
+                    </DrawingBrush>
+                </Ellipse.Fill>
+            </Ellipse>
+        </StackPanel>
+
+        <ListBox
+            x:Name="ListColor"
+            Background="Transparent"
+            BorderThickness="0"
+            ItemContainerStyle="{StaticResource listboxItemStyle}"
+            ItemTemplate="{StaticResource listboxData}"
+            SelectionChanged="ListColor_SelectionChanged">
+            <ListBox.ItemsPanel>
+            <ItemsPanelTemplate>
+                <WrapPanel Orientation="Horizontal" />
+            </ItemsPanelTemplate>
+            </ListBox.ItemsPanel>
+        </ListBox>
+    </Grid>
+</UserControl>

+ 72 - 0
PDF Office/CustomControl/CompositeControl/ColorMenuItem.xaml.cs

@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.CustomControl.CompositeControl
+{
+    /// <summary>
+    /// ColorMenuItem.xaml 的交互逻辑
+    /// </summary>
+    public partial class ColorMenuItem : UserControl
+    {
+        private ObservableCollection<ColorItem> colors = new ObservableCollection<ColorItem>();
+        public event EventHandler<Color> ColorChanged;
+        public ColorMenuItem()
+        {
+            InitializeComponent();
+            colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x10)));
+            colors.Add(new ColorItem(Color.FromArgb(0xFF, 0xFF, 0x10, 0x10)));
+            colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0xFF, 0x10)));
+            colors.Add(new ColorItem(Color.FromArgb(0xFF, 0x10, 0x70, 0xFF)));
+            ListColor.ItemsSource = colors;
+        }
+
+        public List<ColorItem> ItemSource
+        {
+            get { return (List<ColorItem>)GetValue(ItemSourceProperty); }
+            set { SetValue(ItemSourceProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for ShowColorList.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty ItemSourceProperty =
+            DependencyProperty.Register("ItemSource", typeof(List<ColorItem>), typeof(ColorMenuItem), new PropertyMetadata(null, ItemSourcePropertyChanged));
+
+        private static void ItemSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            var control = d as ColorMenuItem;
+            var co = (List<ColorItem>)e.NewValue;
+            if (control != null && co != null && control.colors != null)
+            {
+                control.colors.Clear();
+                foreach (var item in co)
+                    control.colors.Add(item);
+            }
+        }
+
+        private void Ellipse_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            ColorChanged?.Invoke(ellipseBtn, Colors.Transparent);
+        }
+
+        private void ListColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var item = ListColor.SelectedItem as ColorItem;
+            if (item != null)
+            {
+                ColorChanged?.Invoke(sender, (item.Color as SolidColorBrush).Color);
+            }
+        }
+    }
+}

+ 52 - 0
PDF Office/DataConvert/TextAlignToCheckedConverter.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace PDF_Office.DataConvert
+{
+
+    public class TextAlignToCheckedConverter : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value is string)
+            {
+                if (parameter is string)
+                {
+                    var args = (string)value;
+                    if ((string)parameter == "AlignLeft" && args == "Left")
+                    {
+                        return true;
+                    }
+
+                    if ((string)parameter == "AlignCenter" && args == "Center")
+                    {
+                        return true;
+                    }
+
+                    if ((string)parameter == "AlignRight" && args == "Right")
+                    {
+                        return true;
+                    }
+
+                    if ((string)parameter == "Justify" && args == "Justify")
+                    {
+                        return true;
+                    }
+
+                }
+            }
+            return false;
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

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

@@ -33,7 +33,7 @@ namespace PDF_Office.Helper
                 permissionsInfo.AllowsCopying &&
                 permissionsInfo.AllowsDocumentAssembly &&
                 permissionsInfo.AllowsFormFieldEntry &&
-                permissionsInfo.AllowsCommenting)
+                permissionsInfo.AllowsCommenting||string.IsNullOrEmpty(document.FilePath) )
             {
                 return true;
             }

+ 6 - 5
PDF Office/Model/AnnotPanel/FontBoard.cs

@@ -441,13 +441,14 @@ namespace PDF_Office.Model.AnnotPanel
             }
         }
 
-        private C_TEXT_ALIGNMENT _textAlignment;
-        public C_TEXT_ALIGNMENT TextAlignmentItem
+        //文字内容对齐
+        private string _strtextAlign;
+        public string StrTextAlign
         {
-            get { return _textAlignment; }
-            set { SetProperty(ref _textAlignment, value); }
+            get { return _strtextAlign; }
+            set { SetProperty(ref _strtextAlign, value); }
         }
-
+        
         //颜色
         private Brush _fontColor = new SolidColorBrush(Colors.Black);
         public Brush FontColor

+ 8 - 0
PDF Office/PDF Office.csproj

@@ -237,6 +237,9 @@
     <Compile Include="CustomControl\CommonWritableComboBox.xaml.cs">
       <DependentUpon>CommonWritableComboBox.xaml</DependentUpon>
     </Compile>
+    <Compile Include="CustomControl\CompositeControl\ColorMenuItem.xaml.cs">
+      <DependentUpon>ColorMenuItem.xaml</DependentUpon>
+    </Compile>
     <Compile Include="CustomControl\CompositeControl\ColorSubContent.xaml.cs">
       <DependentUpon>ColorSubContent.xaml</DependentUpon>
     </Compile>
@@ -310,6 +313,7 @@
     <Compile Include="DataConvert\SignatureButtonConvert.cs" />
     <Compile Include="DataConvert\StringToDateConvert.cs" />
     <Compile Include="DataConvert\StringToVisibleConvert.cs" />
+    <Compile Include="DataConvert\TextAlignToCheckedConverter.cs" />
     <Compile Include="DataConvert\UnVisivleConvert.cs" />
     <Compile Include="DataConvert\WidthConvert.cs" />
     <Compile Include="EventAggregators\EditToolsEvent.cs" />
@@ -1170,6 +1174,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="CustomControl\CompositeControl\ColorMenuItem.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="CustomControl\CompositeControl\ColorSubContent.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 54 - 0
PDF Office/Styles/RadioButtonStyle.xaml

@@ -430,6 +430,60 @@
         </Setter>
     </Style>
 
+    <!--右键菜单,单选按钮-->
+    <Style x:Key="MenuRadioBtnStyle" TargetType="{x:Type RadioButton}">
+        <Setter Property="BorderThickness" Value="1" />
+        <Setter Property="Background" Value="Transparent" />
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type RadioButton}">
+                    <Border
+                        x:Name="templateRoot"
+                        Background="{TemplateBinding Background}"
+                        CornerRadius="0"
+                        SnapsToDevicePixels="True">
+                        <Grid>
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="20"/>
+                                <ColumnDefinition />
+                            </Grid.ColumnDefinitions>
+
+                            <Path x:Name="pathIcon" Visibility="Collapsed" Data="M11.1144 1.57308L5.71438 9.28737C5.58464 9.47271 5.37817 9.58958 5.15248 9.60543C4.9268 9.62128 4.70603 9.5344 4.55166 9.36901L0.95166 5.51187L2.04824 4.48839L5.01649 7.66866L9.88553 0.712891L11.1144 1.57308Z"
+                                  Fill="{StaticResource color.icon.base.neutral.norm.lv1}" 
+                                  />
+
+                            <ContentPresenter
+                            x:Name="contentPresenter"
+                            Grid.Column="1"
+                            Margin="{TemplateBinding Padding}"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Focusable="False"
+                            RecognizesAccessKey="True"
+                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+                        </Grid>
+                        
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="HasContent" Value="true">
+                            <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
+                            <Setter Property="Padding" Value="4,-1,0,0" />
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="true">
+                         
+                        </Trigger>
+                        <Trigger Property="IsEnabled" Value="false">
+                            <Setter TargetName="contentPresenter" Property="Opacity" Value="0.5" />
+                        </Trigger>
+                        <Trigger Property="IsPressed" Value="true" />
+                        <Trigger Property="IsChecked" Value="true">
+                            <Setter TargetName="pathIcon" Property="Visibility" Value="Visible" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
     <!--  悬浮灰色背景单选按钮  -->
     <Style x:Key="GreyBgRadioBtnStyle" TargetType="{x:Type RadioButton}">
         <Setter Property="BorderThickness" Value="1" />

+ 45 - 6
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -42,6 +42,7 @@ using System.Windows.Forms;
 using System.Windows.Markup;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
 using System.Windows.Shapes;
 using static Dropbox.Api.Files.SearchMatchType;
 using static Dropbox.Api.TeamLog.SpaceCapsType;
@@ -261,17 +262,23 @@ namespace PDF_Office.ViewModels.BOTA
                     var result = PdfViewer.RemovePageAnnot(annotation.PageIndex, annotation.AnnotIndex);
                     if (result)
                     {
-                        AnnotationListItems.Remove(annotation);
-                        var annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == annotation.PageIndex && x.AnnotIndex == annotation.AnnotIndex);
-                        CurrentAnnotationLists.Remove(annotation1);
-                        //记录是删除了哪些页面的注释,然后更新对应页面的注释即可
-                        UpdateAnnotListAfterDelete(annotation.PageIndex, annotation.AnnotIndex);
-                        PdfViewer.UndoManager.CanSave = true;
+                        RemoveItem(annotation);
+
                     }
                 }
             }
         }
 
+        public void RemoveItem(AnnotationHandlerEventArgs annotation)
+        {
+            AnnotationListItems.Remove(annotation);
+            var annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == annotation.PageIndex && x.AnnotIndex == annotation.AnnotIndex);
+            CurrentAnnotationLists.Remove(annotation1);
+            //记录是删除了哪些页面的注释,然后更新对应页面的注释即可
+            UpdateAnnotListAfterDelete(annotation.PageIndex, annotation.AnnotIndex);
+            PdfViewer.UndoManager.CanSave = true;
+        }
+
         /// <summary>
         /// 删除之后,更新
         /// </summary>
@@ -1115,6 +1122,16 @@ namespace PDF_Office.ViewModels.BOTA
                     //原型图上,目前对波浪线的类型,在注释列表不显示
                     if (item.EventType != AnnotArgsType.AnnotRedaction && item.EventType != AnnotArgsType.AnnotSquiggly)
                     {
+                        if (item.EventType == AnnotArgsType.AnnotLink)
+                        {
+                            if (item is LinkAnnotArgs link)
+                            {
+                                if (link.LinkType == LINK_TYPE.URI)
+                                {
+                                    continue;
+                                }
+                            }
+                        }
                         AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
                         if (args.AnnotHandlerEventArgs != null)
                         {
@@ -1186,6 +1203,20 @@ namespace PDF_Office.ViewModels.BOTA
 
                     int drawWidth = (int)paintRect.Width;
                     int drawHeight = (int)paintRect.Height;
+                    switch (docPage.Rotation)
+                    {
+                        case 0:
+                        case 2:
+                            drawWidth = (int)paintRect.Width;
+                            drawHeight = (int)paintRect.Height;
+                            break;
+
+                        case 1:
+                        case 3:
+                            drawWidth = (int)paintRect.Height;
+                            drawHeight = (int)paintRect.Width;
+                            break;
+                    }
                     byte[] bitmapArray = new byte[drawWidth * drawHeight * 4];
                     annot.UpdateAp();
                     annot.RenderAnnot(drawWidth, drawHeight, bitmapArray);
@@ -1195,6 +1226,14 @@ namespace PDF_Office.ViewModels.BOTA
                     BitmapImage bitmapImage = ConvertWriteableBitmapToBitmapImage(wirteBitmap, docPage.Rotation);
 
                     cPDFInk.SetRect(rawRect);
+
+                    // 测试
+                    //using (FileStream stream = new FileStream(@"C:\Users\oyxh\Desktop\images\1.png", FileMode.Create))
+                    //{
+                    //    PngBitmapEncoder bitmapEncoder = new PngBitmapEncoder();
+                    //    bitmapEncoder.Frames.Add(BitmapFrame.Create(wirteBitmap));
+                    //    bitmapEncoder.Save(stream);
+                    //}
                     return bitmapImage;
                 }
             }

+ 8 - 5
PDF Office/ViewModels/Dialog/ToolsDialogs/MergeDialogViewModel.cs

@@ -60,6 +60,10 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
             if (pdfViewer != null)
             {
                 CurrentFilePath = pdfViewer.Document.FilePath;
+
+                List<string> list = new List<string>();
+                list.Add(CurrentFilePath);
+                AddFiles(list.ToArray());
             }
         }
 
@@ -135,21 +139,20 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
             switch (index)
             {
                 case 0:
+                    //打开文件
                     AddFiles(OpenFile());
                     break;
                 case 1:
+                    //打开文件夹
                     AddFiles(OpenFileFolder());
                     break;
                 case 2:
+                    //打开当前文件
                     List<string> list = new List<string>();
 
-                    int Fileindex = App.OpenedFileList.IndexOf(CurrentFilePath);
                     for (int i = 0; i < App.OpenedFileList.Count; i++)
                     {
-                        if (i != Fileindex)
-                        {
-                            list.Add(App.OpenedFileList[i]);
-                        }
+                        list.Add(App.OpenedFileList[i]);
                     }
                     AddFiles(list.ToArray());
                     break;

+ 6 - 2
PDF Office/ViewModels/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialogViewModel.cs

@@ -19,6 +19,7 @@ using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using ComPDFKitViewer.PdfViewer;
 using Prism.Regions;
 using PDF_Office.Helper;
+using System.Diagnostics;
 
 namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.SaftyDialogs
 {
@@ -401,9 +402,12 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.SaftyDialogs
                 if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     cPDFViewer.Document.Encrypt(openPassword, permissionsPassword, permissionsInfo);
-                    cPDFViewer.Document.WriteToFilePath(sfd.FileName);
+                    cPDFViewer.Document.WriteToFilePath(sfd.FileName);  
+
                     MessageBoxEx.Show("保存成功");
-                    RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+                    DialogParameters dialogParameters = new DialogParameters();
+                    dialogParameters.Add("FilePath", sfd.FileName);
+                    RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK, dialogParameters));
                 }
                 else
                 {

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 16 - 5
PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs


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

@@ -25,6 +25,7 @@ using System.IO;
 using System.Drawing.Imaging;
 using ComPDFKit.PDFDocument;
 using static PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
+using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
 
 namespace PDF_Office.ViewModels
 {
@@ -164,7 +165,7 @@ namespace PDF_Office.ViewModels
         //关闭页签
         private void unload()
         {
-            if(PDFViewer!=null)
+            if (PDFViewer != null)
             {
                 PDFViewer.CloseDocument();
             }
@@ -316,6 +317,7 @@ namespace PDF_Office.ViewModels
         {
             PDFViewer = new CPDFViewer();
             PDFViewer.CreateDocument();
+
             PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
             if (PDFViewer.Document == null)
             {

+ 44 - 19
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -167,22 +167,26 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 switch ((string)obj)
                 {
                     case "AlignLeft":
+                        GetAnnotAlign(TextAlignment.Left);
                         PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.TextAlign, TextAlignment.Left);
                         break;
 
                     case "AlignCenter":
+                        GetAnnotAlign(TextAlignment.Center);
                         PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.TextAlign, TextAlignment.Center);
                         break;
 
                     case "AlignRight":
+                        GetAnnotAlign(TextAlignment.Right);
                         PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
                         break;
 
                     case "Justify":
+                        GetAnnotAlign(TextAlignment.Justify);
                         PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.TextAlign, TextAlignment.Justify);
                         break;
                 }
-
+                
             }
         }
 
@@ -461,7 +465,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-       
+       /// <summary>
+       /// 多选的注释
+       /// </summary>
         private List<FreeTextAnnotArgs> ConvertLists()
         {
             List<FreeTextAnnotArgs> FreeTextLists = new List<FreeTextAnnotArgs>();
@@ -491,12 +497,20 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 isNoEqualsDir.Add("FontStyleFontWeight", false);
                 isNoEqualsDir.Add("FontColor", false);
                 isNoEqualsDir.Add("FillColor", false);
+                isNoEqualsDir.Add("TextAglin", false);
 
                 foreach (var item in list)
                 {
                     if (item == list[0])
                         continue;
 
+                    if (temp.Align != item.Align)
+                    {
+                        isNoEqualsDir["TextAglin"] = true;
+                        FontVm.StrTextAlign = "None";
+                    }
+
+
                     if (temp.FontFamily != item.FontFamily)
                     {
                         isNoEqualsDir["FontFamily"] = true;
@@ -542,6 +556,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
 
                 ////以下是多选注释的属性相等时
+                if (isNoEqualsDir["TextAglin"] == false)
+                {
+                    GetAnnotAlign(temp.Align);
+                }
 
                 if (isNoEqualsDir["FontFamily"] == false)
                 {
@@ -585,24 +603,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             FontVm.GetFontWeights_Style(Annot.FontStyle, Annot.FontWeight);
 
             GetTimeFormat();
-
-
-                string str = "";
-            if (Annot.Align == TextAlignment.Left)
-                str = "AlignLeft";
-            else if (Annot.Align == TextAlignment.Center)
-                str = "AlignCenter";
-            else if (Annot.Align == TextAlignment.Right)
-                str = "AlignRight";
-            else if(Annot.Align == TextAlignment.Justify)
-                str = "AlignJustify";
-            else
-                str = "None";
-
-            BasicVm.SetStrDashStyle(str);
-
+            GetAnnotAlign(Annot.Align);
         }
 
+        //填写与签名
         private void GetTimeFormat()
         {
             if (IsFillFreeTextAnnot == false)
@@ -660,6 +664,27 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             IsCheckedTime = isTime;
         }
 
-
+        //文本内容对齐
+        private void GetAnnotAlign(TextAlignment align)
+        {
+            switch (align)
+            {
+                case TextAlignment.Left:
+                    FontVm.StrTextAlign = "Left";
+                    break;
+                case TextAlignment.Center:
+                    FontVm.StrTextAlign = "Center";
+                    break;
+                case TextAlignment.Right:
+                    FontVm.StrTextAlign = "Right";
+                    break;
+                case TextAlignment.Justify:
+                    FontVm.StrTextAlign = "Justify";
+                    break;
+                default:
+                    FontVm.StrTextAlign = "None";
+                    break;
+            }
+        }
     }
 }

+ 149 - 77
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -430,7 +430,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         private bool isLoaded = false;
         private bool isMail = false;
         private bool isSelected = false;
-
+        private bool IsAnnotSelect = true;
         private string historyBtnGOorBackTag = string.Empty;
         private int totalPage = 0;
         private int backPageIndex = 0;
@@ -590,11 +590,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
                 else
                 {
+                    BtnLocationIsEnabled = true;
                     ImagePreviewVisibility = Visibility.Collapsed;
                     BtnGOorBackVisibility = Visibility.Collapsed;
                     isSelected = false;
                 }
             }
+            else
+            {
+                BtnLocationIsEnabled = true;
+            }
         }
 
         /// <summary>
@@ -686,6 +691,18 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         /// <param name="obj"></param>
         private void LocationPage(object obj)
         {
+            //没有选择注释工具、也不是右键添加注释
+            //在阅读页,选择注释后,点击按钮
+            //需要设置相关参数
+            if (AnnotAttribEvent.IsAnnotCreateReset == false && propertyPanel.IsAddLink == false)
+            {
+                propertyPanel.IsLocationLink = true;
+
+                pdfViewer.SetMouseMode(MouseModes.AnnotCreate);
+
+                pdfViewer.SetToolParam(LinkAnnotArgs);
+            }
+
             pdfViewer.EnableDrawSelectArea(true);
             historyPageIndex = pdfViewer.CurrentIndex;
             PageNumTextIsEnabled = false;
@@ -708,8 +725,94 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 region.RequestNavigate(viewContentViewModel.TipContentRegionName, "LinkAnnotTip");
             }
-            //if(string.IsNullOrEmpty(PageNumTextContent))
+
             viewContentViewModel.ShowTip(true);
+            //AnnotAttribEvent.IsAnnotCreateReset = true;
+        }
+
+        /// <summary>
+        /// 定位目标范围完成时,触发
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void PDFViewer_CustomNotifyHandler(object sender, CustomNotityData e)
+        {
+            if (e.NotifyType == CustomNotifyType.LinkAreaLocate)
+            {
+                if (e.NotifyData is AreaLocate areaInfo)
+                {
+                    if (pdfViewer.ToolManager.CurrentAnnotArgs == null)
+                    {
+                        CleanLocationState();
+
+                        return;
+                    }
+                    if (pdfViewer.ToolManager.CurrentAnnotArgs.EventType == AnnotArgsType.AnnotLink && pdfViewer.MouseMode == MouseModes.AnnotCreate)
+                    {
+                        LinkAnnotArgs linkArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
+                        System.Windows.Size pageSize = pdfViewer.Document.GetPageSize(areaInfo.PageIndex);
+                        linkArgs.IsPositionSet = true;
+                        linkArgs.DestIndex = areaInfo.PageIndex;
+                        linkArgs.DestinationPos = new System.Windows.Point(areaInfo.Area.X, pageSize.Height - areaInfo.Area.Y);
+
+                        historyPageIndex = linkArgs.PageIndex;
+                        LinkAnnotArgs = linkArgs;
+                        //LinkAnnotArgs.PageIndex = historyPageIndex;
+                        if (linkArgs.AnnotIndex != -1)
+                        {
+                            AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
+                            AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, areaInfo.PageIndex);
+                            AnnotAttribEvent?.UpdateAnnot();
+
+                            LinkAnnotArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
+
+                            PageNumTextContent = (areaInfo.PageIndex + 1).ToString();
+                            SetImagePreview(areaInfo.PageIndex);
+
+                            //viewContentViewModel.LinkAnnotTipVisibility = Visibility.Collapsed;
+                            viewContentViewModel.TipVisible = Visibility.Collapsed;
+
+                            //await System.Threading.Tasks.Task.Delay(5);
+                            //SelectAnnotation();
+
+                            //pdfViewer.GoToPage(historyPageIndex);
+
+                            propertyPanel.IsLocationLink = false;
+                            //没有选择注释工具、也不是右键添加注释
+                            //在阅读页,选择注释后,点击按钮
+                            //需要设置相关参数
+                            if (propertyPanel.IsAddLink == false)
+                            {
+                                pdfViewer.SetMouseMode(MouseModes.PanTool);
+                            }
+                            //await System.Threading.Tasks.Task.Delay(5);
+                            pdfViewer.GoToPage(historyPageIndex);
+                            pdfViewer.SelectAnnotation(LinkAnnotArgs.PageIndex, LinkAnnotArgs.AnnotIndex);
+
+                            BtnLocationIsChecked = false;
+                        }
+                        else
+                        {
+                            CleanLocationState();
+                            return;
+                        }
+                    }
+                }
+            }
+        }
+
+        private void CleanLocationState()
+        {
+            viewContentViewModel.TipVisible = Visibility.Collapsed;
+            BtnLocationIsChecked = false;
+            propertyPanel.IsLocationLink = false;
+            //没有选择注释工具、也不是右键添加注释
+            //在阅读页,选择注释后,点击按钮
+            //需要设置相关参数
+            if (propertyPanel.IsAddLink == false)
+            {
+                pdfViewer.SetMouseMode(MouseModes.PanTool);
+            }
         }
 
         /// <summary>
@@ -824,9 +927,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         /// </summary>
         private void SelectAnnotation()
         {
-            if (linkAnnotArgs != null && !isSelected && linkAnnotArgs.AnnotIndex >= 0)
+            if (LinkAnnotArgs != null && !isSelected && LinkAnnotArgs.AnnotIndex >= 0)
             {
-                pdfViewer.SelectAnnotation(linkAnnotArgs.PageIndex, linkAnnotArgs.AnnotIndex);
+                pdfViewer.SelectAnnotation(LinkAnnotArgs.PageIndex, LinkAnnotArgs.AnnotIndex);
                 isSelected = true;
             }
             else
@@ -1049,6 +1152,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
                 if (AnnotAttribEvent.IsAnnotCreateReset == false)
                 {
+                    //根据选择的,链接,获取对应的信息
                     GetAnnotAttribute();
                 }
 
@@ -1082,49 +1186,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        /// <summary>
-        /// 定位目标范围完成时,触发
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private async void PDFViewer_CustomNotifyHandler(object sender, CustomNotityData e)
-        {
-            if (e.NotifyType == CustomNotifyType.LinkAreaLocate)
-            {
-                if (e.NotifyData is AreaLocate areaInfo)
-                {
-                    if (pdfViewer.ToolManager.CurrentAnnotArgs.EventType == AnnotArgsType.AnnotLink && pdfViewer.MouseMode == MouseModes.AnnotCreate)
-                    {
-                        LinkAnnotArgs linkArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
-                        System.Windows.Size pageSize = pdfViewer.Document.GetPageSize(areaInfo.PageIndex);
-                        linkArgs.IsPositionSet = true;
-                        linkArgs.DestIndex = areaInfo.PageIndex;
-                        linkArgs.DestinationPos = new System.Windows.Point(areaInfo.Area.X, pageSize.Height - areaInfo.Area.Y);
-
-                        LinkAnnotArgs = linkArgs;
-                        LinkAnnotArgs.PageIndex = historyPageIndex;
-
-                        AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
-                        AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, areaInfo.PageIndex);
-                        AnnotAttribEvent?.UpdateAnnot();
-
-                        LinkAnnotArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
-
-                        PageNumTextContent = (areaInfo.PageIndex + 1).ToString();
-                        SetImagePreview(areaInfo.PageIndex);
-
-                        await System.Threading.Tasks.Task.Delay(2);
-                        SelectAnnotation();
-
-                        pdfViewer.GoToPage(historyPageIndex);
-                        //viewContentViewModel.LinkAnnotTipVisibility = Visibility.Collapsed;
-                        viewContentViewModel.TipVisible = Visibility.Collapsed;
-                        BtnLocationIsChecked = false;
-                    }
-                }
-            }
-        }
-
         /// <summary>
         /// 选择链接后,显示参数
         /// </summary>
@@ -1132,6 +1193,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         {
             if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkType))
             {
+                //设置显示的链接模块
                 SetLinkType((LINK_TYPE)AnnotAttribEvent.Attribs[AnnotAttrib.LinkType]);
             }
             if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkDestIndx) && !AnnotAttribEvent.IsAnnotCreateReset)
@@ -1146,36 +1208,38 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     LinkAnnotArgs.PageIndex = pdfViewer.CurrentIndex;
                 }
             }
-            if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkUri))
-            {
-                string linkUrl = (string)AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri];
-                if (!string.IsNullOrEmpty(linkUrl))
-                {
-                    if (linkUrl.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase))
-                    {
-                        SetLinkType(LINK_TYPE.URI, true);
-                        if (AnnotAttribEvent.IsAnnotCreateReset)
-                        {
-                            SetLinkEmail("");
-                        }
-                        else
-                        {
-                            SetLinkEmail(linkUrl.ToLower().TrimStart("mailto:".ToCharArray()));
-                        }
-                    }
-                    else
-                    {
-                        if (AnnotAttribEvent.IsAnnotCreateReset)
-                        {
-                            SetLinkUrl("");
-                        }
-                        else
-                        {
-                            SetLinkUrl(linkUrl);
-                        }
-                    }
-                }
-            }
+            //暂定 第一版 不显示邮箱、web链接模块
+          
+            //if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkUri))
+            //{
+            //    string linkUrl = (string)AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri];
+            //    if (!string.IsNullOrEmpty(linkUrl))
+            //    {
+            //        if (linkUrl.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase))
+            //        {
+            //            SetLinkType(LINK_TYPE.URI, true);
+            //            if (AnnotAttribEvent.IsAnnotCreateReset)
+            //            {
+            //                SetLinkEmail("");
+            //            }
+            //            else
+            //            {
+            //                SetLinkEmail(linkUrl.ToLower().TrimStart("mailto:".ToCharArray()));
+            //            }
+            //        }
+            //        else
+            //        {
+            //            if (AnnotAttribEvent.IsAnnotCreateReset)
+            //            {
+            //                SetLinkUrl("");
+            //            }
+            //            else
+            //            {
+            //                SetLinkUrl(linkUrl);
+            //            }
+            //        }
+            //    }
+            //}
         }
 
         private void SetLinkUrl(string url)
@@ -1222,6 +1286,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             BtnLinkPageIsChecked = false;
             BtnLinkMailIsChecked = false;
             BtnLinkWebIsChecked = false;
+            //暂定 第一版 不显示邮箱、web链接模块
+            if (linkType == LINK_TYPE.URI)
+            {
+                BtnLinkPageIsChecked = true;
+                BtnGOorBackVisibility = Visibility.Collapsed;
+                viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                return;
+            }
             switch (linkType)
             {
                 case LINK_TYPE.GOTO:

+ 32 - 32
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SignatureCreateDialogViewModel.cs

@@ -11,6 +11,7 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Drawing;
 using System.Drawing.Imaging;
+using System.Globalization;
 using System.IO;
 using System.Linq;
 using System.Text;
@@ -442,37 +443,36 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         /// <param name="fontcolor">字体颜色</param>
         /// <param name="backColor">背景颜色</param>
         /// <returns></returns>
-        private Bitmap TextToBitmap(string text, Font font, Rectangle rect, System.Drawing.Color fontcolor, System.Drawing.Color backColor)
+        private Bitmap TextToBitmap(string text, string FontFamily,double size, Rectangle rect, System.Windows.Media.Brush fontcolor, System.Drawing.Color backColor)
         {
-            Graphics g;
-            Bitmap bmp;
-            StringFormat format = new StringFormat(StringFormatFlags.NoClip);
-            if (rect == Rectangle.Empty)
-            {
-                bmp = new Bitmap(1, 1);
-                g = Graphics.FromImage(bmp);
-                //计算绘制文字所需的区域大小(根据宽度计算长度),重新创建矩形区域绘图
-                SizeF sizef = g.MeasureString(text, font, PointF.Empty, format);
+            FormattedText formatText = new FormattedText(text,
+            CultureInfo.CurrentCulture,
+            FlowDirection.LeftToRight,
+            new Typeface(new System.Windows.Media.FontFamily(FontFamily), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
+            size,
+            fontcolor, Helper.DpiHelpers.Dpi / 96F);
 
-                int width = (int)(sizef.Width + 1);
-                int height = (int)(sizef.Height + 1);
-                rect = new Rectangle(0, 0, width, height);
-                bmp.Dispose();
+            DrawingVisual drawingVisual = new DrawingVisual();
+            DrawingContext dc = drawingVisual.RenderOpen();
+            dc.DrawText(formatText,new System.Windows.Point(0,0));
+            dc.Close();
 
-                bmp = new Bitmap(width, height);
-            }
-            else
-            {
-                bmp = new Bitmap(rect.Width, rect.Height);
-            }
 
-            g = Graphics.FromImage(bmp);
+            Rect x = drawingVisual.ContentBounds;
+            Rect DrawRect = new Rect(0, 0, x.Width + 2, x.Height + 2);
+
+            RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap((int)DrawRect.Width+2, (int)DrawRect.Height+2, 96F, 96F, PixelFormats.Pbgra32);
+            renderTargetBitmap.Render(drawingVisual);
+
+            MemoryStream stream = new MemoryStream();
+            BitmapEncoder encoder = new PngBitmapEncoder();
+
+            encoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
+            encoder.Save(stream);
+
+            Bitmap bitmap = new Bitmap(stream);
 
-            //使用ClearType字体功能
-            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
-            g.FillRectangle(new SolidBrush(backColor), rect);
-            g.DrawString(text, font, new SolidBrush(fontcolor), rect, format);
-            return bmp;
+            return bitmap;
         }
 
         private void Cancel()
@@ -491,26 +491,26 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             Cancel();
                             return;
                         }
-                        System.Drawing.Color fontcolor = System.Drawing.Color.Black;
+                        System.Windows.Media.Brush fontcolor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#252629"));
                         switch (RadioButtonIndex)
                         {
                             case 1:
-                                fontcolor = System.Drawing.Color.Black;
+                                fontcolor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#252629"));
                                 break;
                             case 2:
-                                fontcolor = System.Drawing.Color.Red;
+                                fontcolor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#F3465B"));
                                 break;
                             case 3:
-                                fontcolor = System.Drawing.Color.Green;
+                                fontcolor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#273C62"));
                                 break;
                             case 4:
-                                fontcolor = System.Drawing.Color.Blue;
+                                fontcolor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#94989C"));
                                 break;
                             default:
                                 break;
                         }
 
-                        Bitmap bmp = TextToBitmap(InputText, new Font(FontNameList[fontNameIndex], 48), Rectangle.Empty, fontcolor, System.Drawing.Color.Transparent);
+                        Bitmap bmp = TextToBitmap(InputText, FontNameList[fontNameIndex], 20, Rectangle.Empty, fontcolor, System.Drawing.Color.Transparent);
                         string guid = Guid.NewGuid().ToString();
                         string path = System.IO.Path.Combine(App.CachePath.SignatureStampPath, guid);
                         bmp.Save(path, ImageFormat.Png);

+ 0 - 1
PDF Office/ViewModels/TipContent/FileRestrictedTipViewModel.cs

@@ -18,7 +18,6 @@ namespace PDF_Office.ViewModels.TipContent
         public IDialogService DialogService;
 
         private CPDFViewer PDFViewer;
-
         public DelegateCommand CloseTipCommand { get; set; }
         public DelegateCommand RestrictCommand { get; set; }
         public FileRestrictedTipViewModel(IEventAggregator eventAggregator, IDialogService dialogService)

+ 129 - 21
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -23,6 +23,8 @@ using System.Windows.Controls;
 using System.Windows.Controls.Primitives;
 using System.Windows.Media;
 using System.Diagnostics;
+using PDF_Office.Model.AnnotPanel;
+using System.Windows.Input;
 
 namespace PDF_Office.ViewModels.Tools
 {
@@ -126,7 +128,6 @@ namespace PDF_Office.ViewModels.Tools
                 PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
                 PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
                 PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
-                
             }
         }
 
@@ -149,6 +150,7 @@ namespace PDF_Office.ViewModels.Tools
                 return false;
             }
         }
+
         //是否为高亮注释
         private bool isHightAnnot(AnnotHandlerEventArgs annot)
         {
@@ -165,7 +167,7 @@ namespace PDF_Office.ViewModels.Tools
                 return false;
             }
         }
-        
+
         private void GetSelectedAnnots(AnnotAttribEvent e)
         {
             var annot = e.AnnotItemsList[0];
@@ -229,8 +231,8 @@ namespace PDF_Office.ViewModels.Tools
 
                 case AnnotArgsType.AnnotLink:
                     //viewContentViewModel.IsCreateLink = false;
+                    //e.IsAnnotCreateReset= true;
                     GetLink(e.AnnotItemsList, e);
-
                     break;
 
                 case AnnotArgsType.AnnotSticky:
@@ -245,7 +247,7 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-        #endregion
+        #endregion 与触发事件调用相关的函数
 
         #region PDFViewer事件
 
@@ -287,7 +289,7 @@ namespace PDF_Office.ViewModels.Tools
                                 if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
                                 {
                                     var strLineAnnotTag = "";
-                                    if(e.AnnotItemsList[0] is LineAnnotArgs)
+                                    if (e.AnnotItemsList[0] is LineAnnotArgs)
                                     {
                                         var lineAnnot = e.AnnotItemsList[0] as LineAnnotArgs;
                                         if (lineAnnot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE && lineAnnot.TailLineType == C_LINE_TYPE.LINETYPE_NONE)
@@ -305,27 +307,26 @@ namespace PDF_Office.ViewModels.Tools
                                         if (item.Value == e.AnnotItemsList[0].EventType)
                                         {
                                             annot = null;//新建注释时,回到默认值
-                                            if(string.IsNullOrEmpty(strLineAnnotTag))
+                                            if (string.IsNullOrEmpty(strLineAnnotTag))
                                             {
                                                 FindAnnotTypeKey(item.Key, ref annot);
                                                 break;
                                             }
                                             else
                                             {
-                                                if(strLineAnnotTag == item.Key)
+                                                if (strLineAnnotTag == item.Key)
                                                 {
                                                     FindAnnotTypeKey(item.Key, ref annot);
                                                     break;
                                                 }
-                                                    
                                             }
-                                           
                                         }
                                     }
                                 }
                             }
                             //else
                             PDFViewer.SetToolParam(annot);
+
                             #region TO DO
 
                             //设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
@@ -394,20 +395,23 @@ namespace PDF_Office.ViewModels.Tools
             {
                 if (BtnLinkIsChecked == false)
                 {
-                    if (PDFViewer.MouseMode != MouseModes.AnnotCreate && PDFViewer.MouseMode != MouseModes.PanTool)
-                        viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                    if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
+                    {
+                        if (PDFViewer.MouseMode == MouseModes.PanTool && propertyPanel.IsAddLink == false && propertyPanel.IsLocationLink == false)
+                        {
+                            viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                        }
+                    }
                 }
-
             }
         }
 
-
         //在注释工具的状态下,右键菜单
         private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
         {
             if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
                 return;
-            
+
             switch (e.CommandType)
             {
                 case CommandType.Context:
@@ -423,12 +427,22 @@ namespace PDF_Office.ViewModels.Tools
                             if (e.AnnotEventArgsList.Count == 1)
                             {
                                 var selectedAnnot = e.AnnotEventArgsList[0];
+                                PopMenuCheckedLineDash(selectedAnnot);
                                 switch (selectedAnnot.EventType)
                                 {
                                     case AnnotArgsType.AnnotHighlight:
                                     case AnnotArgsType.AnnotUnderline:
                                     case AnnotArgsType.AnnotStrikeout:
                                     case AnnotArgsType.AnnotSquiggly:
+                                        if (selectedAnnot.EventType == AnnotArgsType.AnnotHighlight)
+                                        {
+                                            colorContent.ItemSource = AnnotColorList.GetHighlightColorList();
+                                        }
+                                        else
+                                        {
+                                            colorContent.ItemSource = AnnotColorList.GetBorderColorList();
+                                        }
+
                                         e.PopupMenu = HightAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
 
@@ -463,6 +477,8 @@ namespace PDF_Office.ViewModels.Tools
                                         e.PopupMenu = StampAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
                                 }
+
+
                             }
                             else
                             {
@@ -510,6 +526,39 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
+        //右键菜单,选中虚实线按钮状态
+        private void PopMenuCheckedLineDash(AnnotHandlerEventArgs annot)
+        {
+            if(annot != null)
+            {
+                bool isSolidLineDash = true;
+                if (annot.EventType == AnnotArgsType.AnnotFreehand)
+                {
+                    var freeHand = annot as FreehandAnnotArgs;
+                    isSolidLineDash = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
+                    FreeHandAnnotPopMenu.SetIsChecked(isSolidLineDash ? "FreeHandSolid" : "FreeHandDash", true);
+                }
+                else if(annot.EventType == AnnotArgsType.AnnotSquare)
+                {
+                    var square = annot as SquareAnnotArgs;
+                    isSolidLineDash = AnnotPropertyPanel.IsSolidStyle(square.LineDash);
+                    ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
+                }
+                else if (annot.EventType == AnnotArgsType.AnnotCircle)
+                {
+                    var circle = annot as CircleAnnotArgs;
+                    isSolidLineDash = AnnotPropertyPanel.IsSolidStyle(circle.LineDash);
+                    ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
+                }
+                else if (annot.EventType == AnnotArgsType.AnnotLine)
+                {
+                    var line = annot as LineAnnotArgs;
+                    isSolidLineDash = AnnotPropertyPanel.IsSolidStyle(line.LineDash);
+                    ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
+                }
+
+            }
+        }
         /// <summary>
         /// 内容选择工具
         /// </summary>
@@ -660,7 +709,6 @@ namespace PDF_Office.ViewModels.Tools
                                 PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
                             }
 
-
                             break;
 
                         case ActionType.Del:
@@ -720,11 +768,71 @@ namespace PDF_Office.ViewModels.Tools
                 hoverPen.DashStyle = DashStyles.Dash;
                 e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
 
-            
+                //Todo:目前ComPDFKit.Viewer没有e.Annot参数
+                //便签,显示ToolTip内容
+                //if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
+                //{
+                //    if (PDFViewer.ToolTip == null)
+                //    {
+                //        var content = e.Annot.GetContent();
+                //        if (string.IsNullOrEmpty(content) == false)
+                //        {
+                //            ToolTip TipChild = new ToolTip();
+                //            TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
+                //            TipChild.MaxWidth = 246;
+                //            TipChild.Content = content;
+                //            TipChild.Visibility = Visibility.Visible;
+                //            TipChild.IsOpen = true;
+                //            TipChild.Placement = PlacementMode.Right;
+                //            var rec = e.Annot.GetRect();
+                //            TipChild.PlacementRectangle = new Rect(rec.left, rec.top, rec.right, rec.bottom);
+                //            TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
+                //            TipChild.Placement = PlacementMode.MousePoint;
+                //            PDFViewer.ToolTip = TipChild;
+                //            oldRect = hoverRect;
+                //            PDFViewer.MouseMove -= PDFViewer_MouseMove;
+                //            PDFViewer.MouseMove += PDFViewer_MouseMove;
+                //            return;
+                //        }
+
+                //    }
+
+                //}
             }
- 
+
+            CloseAnnotToolTip();
         }
 
+
+        Rect oldRect = new Rect(0, 0, 0, 0);
+        private void CloseAnnotToolTip()
+        {
+            if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
+            {
+                ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
+                oldTips.IsOpen = false;
+                oldTips.Visibility = Visibility.Collapsed;
+                PDFViewer.ToolTip = null;
+                PDFViewer.MouseMove -= PDFViewer_MouseMove;
+                oldRect = new Rect(0, 0, 0, 0);
+            }
+        }
+
+        private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
+        {
+            if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
+            {
+                var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
+                var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
+                var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
+                if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
+                {
+                    CloseAnnotToolTip();
+                }
+            }
+        }
+
+
         #endregion PDFViewer事件
 
         #region BindingEvent事件
@@ -819,8 +927,8 @@ namespace PDF_Office.ViewModels.Tools
                             break;
 
                         case AnnotArgsType.AnnotFreehand:
-            
-                            if(e[argsType] is FreehandAnnotArgs)
+
+                            if (e[argsType] is FreehandAnnotArgs)
                             {
                                 var annot = e[argsType] as FreehandAnnotArgs;
                                 if (annot != null)
@@ -835,8 +943,8 @@ namespace PDF_Office.ViewModels.Tools
                                         propertyPanel.AnnotEvents = AnnotEvents;
                                         propertyPanel.annot = annot;
                                         //手绘注释工具按钮的属性
-                                       // FreehandPath.Opacity = annot.Transparency;
-                                       // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
+                                        // FreehandPath.Opacity = annot.Transparency;
+                                        // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
                                     }
                                     PDFViewer.SetToolParam(annot);
                                 }

+ 46 - 5
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -1072,8 +1072,9 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
+        System.Windows.Controls.Primitives.Popup popup = null;
         //更改颜色
-        private void AnnotColorPalette_Menu(object obj)
+        private async void AnnotColorPalette_Menu(object obj)
         {
             if (obj as CusMenuItem != null)
             {
@@ -1086,11 +1087,45 @@ namespace PDF_Office.ViewModels.Tools
                     item.ColorSelected -= AnnotMenu_ColorSelected;
                     item.ColorSelected += AnnotMenu_ColorSelected;
                     
-                    System.Windows.Controls.Primitives.Popup popup = new System.Windows.Controls.Primitives.Popup();
+                    if(popup == null)
+                    popup = new System.Windows.Controls.Primitives.Popup();
+
+                    ContentControl window = null;
+                    if (PDFViewer.Parent as ContentControl != null)
+                        window = PDFViewer.Parent as ContentControl;
+                    else
+                        window = App.Current.MainWindow;
+
                     popup.Child = item;
-                    popup.PlacementRectangle = new Rect(Mouse.GetPosition(App.Current.MainWindow), new Size(item.Width, item.Height));
-                    popup.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
+                    popup.PlacementRectangle = new Rect(Mouse.GetPosition(window), new Size(item.Width, item.Height));
+                    popup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
+                    popup.PlacementTarget = window; 
                     popup.IsOpen = true;
+
+                    Window parentWnd = Window.GetWindow(App.Current.MainWindow);
+                    if (parentWnd != null )
+                    {
+                        parentWnd.MouseDown -= parentWnd_MouseDown;
+                        parentWnd.MouseDown += parentWnd_MouseDown;
+                    }
+
+                    while (popup.IsOpen)
+                        await Task.Delay(20);
+
+                    parentWnd.MouseDown -= parentWnd_MouseDown;
+                    popup = null;
+                }
+            }
+        }
+
+        private void parentWnd_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            var ui = Mouse.DirectlyOver as FrameworkElement;
+            if (ui != null)
+            {
+                if (popup != null)
+                {
+                    popup.IsOpen = false;
                 }
             }
         }
@@ -1120,6 +1155,12 @@ namespace PDF_Office.ViewModels.Tools
                         AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
                         AnnotEvent?.UpdateAnnot();
                     }
+                    else if(annot is TextHighlightAnnotArgs || annot is TextUnderlineAnnotArgs || annot is TextStrikeoutAnnotArgs)
+                    {
+                        var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
+                        AnnotEvent?.UpdateAnnot();
+                    }
                 }
             }
         }
@@ -1301,7 +1342,7 @@ namespace PDF_Office.ViewModels.Tools
                 {
                     var strTag = tag.ToString();
                     var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
-                    if (strTag == "ver")
+                    if (strTag == "Ver")
                     {
                         annot.SetLineVertical();
                     }

+ 67 - 14
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Layout.cs

@@ -1,12 +1,14 @@
 using ComPDFKit.PDFDocument;
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.CustomControl;
 using PDF_Office.CustomControl.CompositeControl;
 using PDF_Office.Helper;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -14,6 +16,7 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Media;
+using System.Windows.Shapes;
 
 namespace PDF_Office.ViewModels.Tools
 {
@@ -340,6 +343,7 @@ namespace PDF_Office.ViewModels.Tools
 
         #region 注释-右键菜单
 
+        ColorMenuItem colorContent;
         /// <summary>
         /// 高亮注释,右键菜单
         /// </summary>
@@ -347,15 +351,16 @@ namespace PDF_Office.ViewModels.Tools
         {
             var popMenu = new ContextMenu();
             PopMenu pop = new PopMenu(popMenu);
-            ColorContent colorContent = new ColorContent();
+            colorContent = new ColorMenuItem();
             colorContent.Name = "hightcolor";
-            colorContent.SelectedColorHandler -= colorContent_SelectedColorHandler;
-            colorContent.SelectedColorHandler += colorContent_SelectedColorHandler;
+            colorContent.ColorChanged -= colorContent_SelectedColorHandler;
+            colorContent.ColorChanged += colorContent_SelectedColorHandler;
             colorContent.VerticalAlignment = VerticalAlignment.Top;
-            colorContent.Height = 60;
+            colorContent.Margin = new Thickness(0, 0, 0, -15);
+
             var menuItem = new MenuItem();
             menuItem.Name = "hightColor";
-            menuItem.Height = colorContent.Height;
+            menuItem.Height = 20 + 15;
             menuItem.Header = colorContent;
             var hightColorStyle = App.Current.FindResource("UIElementMenuItem") as Style;
             if (hightColorStyle != null)
@@ -398,21 +403,61 @@ namespace PDF_Office.ViewModels.Tools
             return separator;
         }
 
-        private void colorContent_SelectedColorHandler(object sender, Color e)
+        private async void colorContent_SelectedColorHandler(object sender, Color e)
         {
             if (e == null) return;
 
-            var annot = (sender as FrameworkElement).DataContext as AnnotHandlerEventArgs;
-            if (annot != null)
+            if (sender is Ellipse)
+            {
+                var item = new ColorDropBoxPop();
+                item.DataContext = (sender as Ellipse).DataContext;
+                item.ColorSelected -= AnnotMenu_ColorSelected;
+                item.ColorSelected += AnnotMenu_ColorSelected;
+
+                if (popup == null)
+                    popup = new System.Windows.Controls.Primitives.Popup();
+
+                ContentControl window = null;
+                if (PDFViewer.Parent as ContentControl != null)
+                    window = PDFViewer.Parent as ContentControl;
+                else
+                    window = App.Current.MainWindow;
+
+                popup.Child = item;
+                popup.PlacementRectangle = new Rect(Mouse.GetPosition(window), new Size(item.Width, item.Height));
+                popup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
+                popup.PlacementTarget = window;
+                popup.IsOpen = true;
+
+                Window parentWnd = Window.GetWindow(App.Current.MainWindow);
+                if (parentWnd != null)
+                {
+                    parentWnd.MouseDown -= parentWnd_MouseDown;
+                    parentWnd.MouseDown += parentWnd_MouseDown;
+                }
+
+                while (popup.IsOpen)
+                    await Task.Delay(20);
+
+                parentWnd.MouseDown -= parentWnd_MouseDown;
+                popup = null;
+            }
+            else
             {
-                var test = annot as TextHighlightAnnotArgs;
-                if (test != null)
+                var annot = (sender as FrameworkElement).DataContext as AnnotHandlerEventArgs;
+                if (annot != null)
                 {
-                    var anvent = AnnotAttribEvent.GetAnnotAttribEvent(test, test.GetAnnotAttrib());
-                    anvent.UpdateAttrib(AnnotAttrib.Color, e);
-                    anvent.UpdateAnnot();
+                    var test = annot as TextHighlightAnnotArgs;
+                    if (test != null)
+                    {
+                        var anvent = AnnotAttribEvent.GetAnnotAttribEvent(test, test.GetAnnotAttrib());
+                        anvent.UpdateAttrib(AnnotAttrib.Color, e);
+                        anvent.UpdateAnnot();
+                    }
                 }
             }
+
+
         }
 
         /// <summary>
@@ -455,6 +500,8 @@ namespace PDF_Office.ViewModels.Tools
             pop.AddItem(menuItem);
 
             RadioButton radioButton = new RadioButton();
+            radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
+            radioButton.Background = new SolidColorBrush(Colors.Transparent);
             radioButton.Name = "FreeHandSolid";
             radioButton.Content = "实线";
             radioButton.GroupName = "LineStyle";
@@ -462,6 +509,8 @@ namespace PDF_Office.ViewModels.Tools
             pop.BindingEvent(pop.AddChild("FreeHandLineStyle", radioButton), FreeHandLineStyle_MenuCommand);
 
             radioButton = new RadioButton();
+            radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
+            radioButton.Background = new SolidColorBrush(Colors.Transparent);
             radioButton.Name = "FreeHandDash";
             radioButton.Content = "虚线";
             radioButton.GroupName = "LineStyle";
@@ -652,6 +701,8 @@ namespace PDF_Office.ViewModels.Tools
             pop.AddItem(menuItem);
 
             RadioButton radioButton = new RadioButton();
+            radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
+            radioButton.Background = new SolidColorBrush(Colors.Transparent);
             radioButton.Name = "ShapeSolid";
             radioButton.Content = "实线";
             radioButton.GroupName = "LineStyle";
@@ -659,6 +710,8 @@ namespace PDF_Office.ViewModels.Tools
             pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
 
             radioButton = new RadioButton();
+            radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
+            radioButton.Background = new SolidColorBrush(Colors.Transparent);
             radioButton.Name = "ShapeDash";
             radioButton.Content = "虚线";
             radioButton.GroupName = "LineStyle";
@@ -719,7 +772,7 @@ namespace PDF_Office.ViewModels.Tools
             menuItem = new MenuItem();
             menuItem.Name = "LinkDelete";
             menuItem.Header = "删除";
-            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+            pop.BindingEvent(pop.AddItem(menuItem), Link_MenuCommand);
             LinkAnnotPopMenu = pop;
         }
 

+ 7 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -23,6 +23,8 @@ namespace PDF_Office.ViewModels.Tools
     /// </summary>
     public class AnnotPropertyPanel
     {
+        public bool IsAddLink = false;
+        public bool IsLocationLink = false;
         public AnnotAttribEvent AnnotEvent { get; set; }
         public List<AnnotAttribEvent> AnnotEvents = new List<AnnotAttribEvent>();
 
@@ -240,6 +242,7 @@ namespace PDF_Office.ViewModels.Tools
                 SetProperty(ref btnHandIsChecked, value);
             }
         }
+
         private bool btnShowAnnotIsChecked = true;
 
         public bool BtnShowAnnotIsChecked
@@ -289,6 +292,7 @@ namespace PDF_Office.ViewModels.Tools
         public DelegateCommand AddBookMarkCommand { get; set; }
 
         public DelegateCommand<object> HandCommand { get; set; }
+
         #region 注释 - 右键菜单
 
         //公共
@@ -322,6 +326,9 @@ namespace PDF_Office.ViewModels.Tools
         //ESC
         public DelegateCommand EscCommand { get; set; }
 
+        //链接
+        public DelegateCommand<object> Link_MenuCommand { get; set; }
+
         #endregion 注释 - 右键菜单
 
         #endregion 事件

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

@@ -76,6 +76,7 @@ namespace PDF_Office.ViewModels.Tools
             HandCommand = new DelegateCommand<object>(Hand_Click);
             //ESC
             EscCommand = new DelegateCommand(Esc_KeyDown);
+
             #region 注释 - 右键菜单
 
             //公共command
@@ -96,6 +97,8 @@ namespace PDF_Office.ViewModels.Tools
             ShapeLineDirect_MenuCommand = new DelegateCommand<object>(ShapeLineDirect_Menu);
             //图章
             StampExportPicture_MenuCommand = new DelegateCommand<object>(StampExportPicture_Menu);
+            //链接
+            Link_MenuCommand = new DelegateCommand<object>(Link_Menu);
 
             #endregion 注释 - 右键菜单
         }
@@ -103,7 +106,6 @@ namespace PDF_Office.ViewModels.Tools
         private void Esc_KeyDown()
         {
             PDFViewer.SetMouseMode(MouseModes.None);
-
         }
 
         private void Hand_Click(object obj)
@@ -190,6 +192,8 @@ namespace PDF_Office.ViewModels.Tools
             }
             else
             {
+                propertyPanel.IsAddLink = false;
+                propertyPanel.IsLocationLink = false;
                 PDFViewer.ToolManager.EnableClickCreate = false;
             }
 
@@ -224,6 +228,8 @@ namespace PDF_Office.ViewModels.Tools
                 AnnotHandlerEventArgs annotHandler = null;
                 string str = menuItem.Tag.ToString();
                 viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                propertyPanel.IsAddLink = false;
+                propertyPanel.IsLocationLink = false;
                 if (str == AddAnnotType.AnnotFreehand.ToString())
                 {
                     annotHandler = GetFreehand();
@@ -254,6 +260,7 @@ namespace PDF_Office.ViewModels.Tools
                 }
                 if (str == AddAnnotType.AnnotLink.ToString())
                 {
+                    propertyPanel.IsAddLink = true;
                     annotHandler = GetLink();
                 }
                 if (str == AddAnnotType.AnnotStamp.ToString())

+ 59 - 14
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -1559,7 +1559,7 @@ namespace PDF_Office.ViewModels
                         cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
                     }
                     //方案一
-                    if (true)
+                    if (false)
                     {
                         PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
                         AlertsMessage alertsMessage = new AlertsMessage();
@@ -1569,25 +1569,69 @@ namespace PDF_Office.ViewModels
                         else
                             return false;
                     }
-                    else
+                    else if (false)
                     {
                         //方案二
-                        string currentPath = PDFViewer.Document.FilePath;
-                        string tempPath = PDFViewer.Document.FilePath + ".temp.pdf";
+                        try
+                        {
+                            string currentPath = PDFViewer.Document.FilePath;
+                            string tempPath = PDFViewer.Document.FilePath + ".temp.pdf";
+                            //PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
+                            PDFViewer.Document.WriteToFilePath(tempPath);
+                            PDFViewer.CloseDocument();
+                            PDFViewer.InitDocument(tempPath);
+                            PDFViewer.Document.UnlockWithPassword(permissionsPassword);
+                            PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
+                            PDFViewer.Document.WriteToFilePath(currentPath);
+                            PDFViewer.CloseDocument();
+                            PDFViewer.InitDocument(currentPath);
+                            System.IO.File.Delete(tempPath);
+                            PDFViewer.Document.UnlockWithPassword(permissionsPassword);
+                            CanSave = false;
+                            return true;
+                        }
+                        catch
+                        {
+                            return false;
+                        }
+
+                    }
+                    else if(false)
+                    {
+                        //方案三
                         PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
-                        PDFViewer.Document.WriteToFilePath(tempPath);
-                        PDFViewer.InitDocument(tempPath);
-                        //PDFViewer.Document.UnlockWithPassword(permissionsPassword);
-                        //PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
-                        PDFViewer.Document.WriteToFilePath(currentPath);
-                        System.IO.File.Delete(tempPath);
-                        PDFViewer.CloseDocument();
-                        PDFViewer.InitDocument(currentPath);
-                        PDFViewer.Document.UnlockWithPassword(permissionsPassword);
+                        if (PDFViewer.Document.WriteToFilePath(PDFViewer.Document.FilePath))
+                        {
+                            DoAfterSaveAs(PDFViewer.Document.FilePath);
+                            return true;
+                        }
+                        else
+                        {
+                            return false;
+                        }
                     }
                 }
 
-                bool result = PDFViewer.Document.WriteToLoadedPath();
+                bool result;
+                if (SecurityInfo.IsPasswordChanged)
+                {
+                    string openPassword = null;
+                    string permissionsPassword = null;
+                    CPDFPermissionsInfo cPDFPermissionsInfo = CreateDefaultPermissionsInfo();
+                    if (SecurityInfo.NeedOpenPassword)
+                    {
+                        openPassword = SecurityInfo.OpenPassword;
+                    }
+
+                    if (SecurityInfo.NeedPermissionsPassword)
+                    {
+                        permissionsPassword = SecurityInfo.PermissionsPassword;
+                        cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
+                    }
+                    PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
+                }
+                //result = PDFViewer.Document.WriteToLoadedPath();
+                result = PDFViewer.Document.WriteToFilePath(PDFViewer.Document.FilePath);
                 if (result)
                 {
                     PDFViewer.UndoManager.CanSave = false;
@@ -1634,6 +1678,7 @@ namespace PDF_Office.ViewModels
                                           SettingHelper.SetFileInfo(info);
                                       }
                                   });
+                    PDFViewer.ReloadDocument();
                 }
                 else
                 {

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

@@ -256,7 +256,7 @@
                                     Name="MenuCollapseAll"
                                     Click="MenuCollapseAll_Click"
                                     Header="全部折叠" />
-                                <MenuItem Name="MenuSort">
+                                <MenuItem Name="MenuSort" Visibility="Collapsed">
                                     <MenuItem.Header>
                                         <TextBlock Name="MenuSortText" Text="排序" />
                                     </MenuItem.Header>

+ 5 - 4
PDF Office/Views/BOTA/OutLineControl.xaml

@@ -79,10 +79,6 @@
                                         <Setter Property="VerticalContentAlignment" Value="Center" />
                                     </Style>
                                 </ContextMenu.ItemContainerStyle>
-                                <MenuItem
-                                    Name="MenuDeleteAll"
-                                    Command="{Binding DeleteAllCommand}"
-                                    Header="Delete All Outline" />
                                 <MenuItem
                                     Name="MenuExpandAll"
                                     Command="{Binding ExpandAllCommand}"
@@ -93,6 +89,10 @@
                                     Command="{Binding CollapseAllCommand}"
                                     CommandParameter="{Binding Outlinelist}"
                                     Header="一键折叠" />
+                                <MenuItem
+                                    Name="MenuDeleteAll"
+                                    Command="{Binding DeleteAllCommand}"
+                                    Header="Delete All Outline" />
                             </ContextMenu>
                         </customcontrol:PathButton.ContextMenu>
                     </customcontrol:PathButton>
@@ -274,6 +274,7 @@
                                     HorizontalAlignment="Left"
                                     VerticalAlignment="Center"
                                     IsVisibleChanged="ReName_IsVisibleChanged"
+                                    KeyDown="ReName_KeyDown"
                                     Style="{StaticResource TextBoxStyleRadius}" />
                             </Grid>
                         </Grid>

+ 8 - 0
PDF Office/Views/BOTA/OutLineControl.xaml.cs

@@ -466,5 +466,13 @@ namespace PDF_Office.Views.BOTA
         {
             onDrop = false;
         }
+
+        private void ReName_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key==Key.Enter)
+            {
+                OutlineView.Focus();
+            }
+        }
     }
 }

+ 7 - 3
PDF Office/Views/Dialog/ToolsDialogs/MergeDialog.xaml

@@ -115,8 +115,12 @@
                                 Icon="pack://application:,,,/PDF Office;component/Resources/Dialog/AddImage.png"  
                                 IconPress="pack://application:,,,/PDF Office;component/Resources/Dialog/AddImageSuspend.png"  
                                 IconMouseOver="pack://application:,,,/PDF Office;component/Resources/Dialog/AddImageSuspend.png"   Command="{Binding AddFilesCommand}" CommandParameter="0"/>
-                    <TextBlock Text="Selected files" FontSize="14" FontFamily="Segoe UI" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                    <TextBlock Text="Drop files here or Click Add Files at bottom right button. You can drag files to reorder as you need." FontSize="14" FontFamily="Segoe UI" HorizontalAlignment="Center" TextAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap"/>
+                    <TextBlock Margin="0,8,0,0" Text="Selected files" FontSize="14" FontFamily="Segoe UI" 
+                               FontWeight="Regular" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                    <TextBlock Width="418" Margin="0,2,0,0" Text="Drop files here or Click Add Files at bottom right button. You can drag files to reorder as you need." 
+                               FontSize="12" FontFamily="Segoe UI" HorizontalAlignment="Center" FontWeight="Regular"
+                               Foreground="{StaticResource color.sys.text.neutral.lv3}"
+                               TextAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap"/>
                 </StackPanel>
                 <ListView x:Name="MergeView" AllowDrop="True"
                 ItemContainerStyle="{StaticResource ListViewItemStyle1}"
@@ -280,7 +284,7 @@
                     </i:EventTrigger>
                 </i:Interaction.Triggers>
             </ComboBoxItem>
-            <ComboBoxItem Tag="1">
+            <ComboBoxItem Tag="1" Visibility="Collapsed">
                 <TextBlock Text="添加文件夹"/>
                 <i:Interaction.Triggers>
                     <i:EventTrigger EventName="PreviewMouseUp">

+ 0 - 2
PDF Office/Views/HomePanel/RecentFiles/DocItemControl.xaml.cs

@@ -49,9 +49,7 @@ namespace PDF_Office.Views.HomePanel.RecentFiles
                     CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources//FilesType/ic_propertybar_file_png_Large.png");
                     tempdoc.Release();
                 }
-                  
             }
         }
-
     }
 }

+ 10 - 23
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml

@@ -22,6 +22,7 @@
             <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
             <Convert:BoolToVisible x:Key="BoolToVisible"/>
             <Convert:CheckToVisibleMutiConvert x:Key="CheckToVisibleMutiConvert"/>
+            <Convert:TextAlignToCheckedConverter x:Key="TextAlignToCheckedConverter"/>
             <Style x:Key="line1Style" TargetType="{x:Type Line}">
                 <Setter Property="Visibility">
                     <Setter.Value>
@@ -187,8 +188,9 @@
                                     Background="Transparent"
                                     Foreground="#616469"
                                     GroupName="TextAlign"
-                                    IsChecked="True"
+                                    IsChecked="{Binding FontVm.StrTextAlign,Mode=OneWay,Converter={StaticResource TextAlignToCheckedConverter},ConverterParameter=AlignLeft}"
                                     Style="{DynamicResource GreyBgRadioBtnStyle}"
+                                    Command="{Binding TextAlignCheckedCommand}" CommandParameter="{Binding ElementName=TextAlignLeftBtn, Path=Tag}" 
                                     Tag="AlignLeft">
                                 <RadioButton.Content>
                                     <Grid Width="32" Height="32">
@@ -220,13 +222,7 @@
                                         </Canvas>
                                     </Grid>
                                 </RadioButton.Content>
-                                <i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="Checked">
-                                        <i:InvokeCommandAction Command="{Binding TextAlignCheckedCommand}" CommandParameter="{Binding ElementName=TextAlignLeftBtn, Path=Tag}" />
-                                    </i:EventTrigger>
-                                </i:Interaction.Triggers>
                             </RadioButton>
-
                             <RadioButton
                                     x:Name="TextAlignCenterBtn"
                                     Width="32"
@@ -237,6 +233,8 @@
                                     Foreground="#616469"
                                     GroupName="TextAlign"
                                     Style="{DynamicResource GreyBgRadioBtnStyle}"
+                                    IsChecked="{Binding FontVm.StrTextAlign,Mode=OneWay,Converter={StaticResource TextAlignToCheckedConverter},ConverterParameter=AlignCenter}"
+                                    Command="{Binding TextAlignCheckedCommand}" CommandParameter="{Binding ElementName=TextAlignCenterBtn, Path=Tag}" 
                                     Tag="AlignCenter">
                                 <RadioButton.Content>
                                     <Grid Width="32" Height="32">
@@ -270,11 +268,6 @@
                                         </Canvas>
                                     </Grid>
                                 </RadioButton.Content>
-                                <i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="Checked">
-                                        <i:InvokeCommandAction Command="{Binding TextAlignCheckedCommand}" CommandParameter="{Binding ElementName=TextAlignCenterBtn, Path=Tag}" />
-                                    </i:EventTrigger>
-                                </i:Interaction.Triggers>
                             </RadioButton>
 
                             <RadioButton
@@ -287,7 +280,9 @@
                                     Foreground="#616469"
                                     GroupName="TextAlign"
                                     Style="{DynamicResource GreyBgRadioBtnStyle}"
-                                    Tag="AlignRight">
+                                    IsChecked="{Binding FontVm.StrTextAlign,Mode=OneWay,Converter={StaticResource TextAlignToCheckedConverter},ConverterParameter=AlignRight}"
+                                    Command="{Binding TextAlignCheckedCommand}" CommandParameter="{Binding ElementName=TextAlignRightBtn, Path=Tag}" 
+                                   Tag="AlignRight">
                                 <RadioButton.Content>
                                     <Grid Width="32" Height="32">
                                         <Canvas Margin="5,10,0,0">
@@ -320,11 +315,6 @@
                                         </Canvas>
                                     </Grid>
                                 </RadioButton.Content>
-                                <i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="Checked">
-                                        <i:InvokeCommandAction Command="{Binding TextAlignCheckedCommand}" CommandParameter="{Binding ElementName=TextAlignRightBtn, Path=Tag}" />
-                                    </i:EventTrigger>
-                                </i:Interaction.Triggers>
                             </RadioButton>
 
                             <RadioButton
@@ -338,6 +328,8 @@
                                     Foreground="#616469"
                                     GroupName="TextAlign"
                                     Style="{DynamicResource GreyBgRadioBtnStyle}"
+                                    IsChecked="{Binding FontVm.StrTextAlign,Mode=OneWay,Converter={StaticResource TextAlignToCheckedConverter},ConverterParameter=Justify}"
+                                    Command="{Binding TextAlignCheckedCommand}" CommandParameter="{Binding ElementName=TextAlignBtn, Path=Tag}" 
                                     Tag="Justify">
                                 <RadioButton.Content>
                                     <Grid Width="32" Height="32">
@@ -369,11 +361,6 @@
                                         </Canvas>
                                     </Grid>
                                 </RadioButton.Content>
-                                <i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="Checked">
-                                        <i:InvokeCommandAction Command="{Binding TextAlignCheckedCommand}" CommandParameter="{Binding ElementName=TextAlignBtn, Path=Tag}" />
-                                    </i:EventTrigger>
-                                </i:Interaction.Triggers>
                             </RadioButton>
                         </StackPanel>
                         <cusColor:ColorContent

+ 0 - 68
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml.cs

@@ -23,77 +23,9 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
     /// </summary>
     public partial class FreetextAnnotProperty : UserControl
     {
-        private FreetextAnnotPropertyViewModel ViewModel => DataContext as FreetextAnnotPropertyViewModel;
         public FreetextAnnotProperty()
         {
             InitializeComponent();
-
-            this.Loaded += usercontrol_Loaded;
-            this.Unloaded += usercontrol_Unloaded;
-          
         }
-
-        private void usercontrol_Loaded(object sender, RoutedEventArgs e)
-        {
-            //FontFamilyBox.SelectedIndex = 0;
-            //FontStyleBox.SelectedIndex = 0;
-            //FontSizeBox.SelectedIndex = 0;
-            //ThicknessBox.SelectedIndex = 0;
-            BindingEvent();
-            if(ViewModel != null && string.IsNullOrEmpty(ViewModel.BasicVm.strDashStyle) == false)
-            {
-                var str = ViewModel.BasicVm.strDashStyle;
-                if (str == "AlignLeft")
-                {
-                    TextAlignLeftBtn.IsChecked = true;
-                }
-                else if(str == "AlignCenter")
-                {
-                    TextAlignCenterBtn.IsChecked = true;
-                }
-                else if (str == "AlignRight")
-                {
-                    TextAlignRightBtn.IsChecked = true;
-                }
-                else if (str == "AlignJustify")
-                {
-                    TextAlignBtn.IsChecked = true;
-                }
-                else
-                {
-                    TextAlignLeftBtn.IsChecked = false;
-                    TextAlignCenterBtn.IsChecked = false;
-                    TextAlignRightBtn.IsChecked = false;
-                    TextAlignBtn.IsChecked = false;
-                }
-            }
-        }
-
-        private void usercontrol_Unloaded(object sender, RoutedEventArgs e)
-        {
-            UnBindingEvent();
-        }
-
-        private void BindingEvent()
-        {
-            UnBindingEvent();
-            //ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged;
-        }
-
-        private void UnBindingEvent()
-        {
-           // ThicknessBox.SelectionChanged -= ThicknessBox_SelectionChanged;
-        }
-
-        private void ThicknessBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            var listItem = ThicknessBox.ItemContainerGenerator.ContainerFromItem(ThicknessBox.SelectedItem) as ComboBoxItem;
-            if (listItem != null)
-                ThicknessText.Text = listItem.Content.ToString();
-            else
-                ThicknessText.Text = "1";
-           
-        }
-
     }
 }