Bladeren bron

注释-链接-页码交互初版

OYXH\oyxh 2 jaren geleden
bovenliggende
commit
dd60025403

+ 37 - 28
PDF Office/Styles/ContextMenuStyle.xaml

@@ -1,19 +1,20 @@
-<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
-    <!--快捷工具展开收缩-->
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <!--  快捷工具展开收缩  -->
     <ContextMenu x:Key="ExpendToolsContextMenu" FontSize="14">
         <ContextMenu.ItemContainerStyle>
             <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7"/>
-                <Setter Property="VerticalContentAlignment" Value="Center"/>
+                <Setter Property="Padding" Value="0,7,0,7" />
+                <Setter Property="VerticalContentAlignment" Value="Center" />
             </Style>
         </ContextMenu.ItemContainerStyle>
-        <MenuItem Name="ExpendMenuItem" Header="展开" IsEnabled="True">
+        <MenuItem
+            Name="ExpendMenuItem"
+            Header="展开"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
@@ -24,53 +25,61 @@
     <ContextMenu x:Key="SelectAnnotContextMenu" FontSize="14">
         <ContextMenu.ItemContainerStyle>
             <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7"/>
-                <Setter Property="VerticalContentAlignment" Value="Center"/>
+                <Setter Property="Padding" Value="0,7,0,7" />
+                <Setter Property="VerticalContentAlignment" Value="Center" />
             </Style>
         </ContextMenu.ItemContainerStyle>
-        <MenuItem Name="CutAnnotMenuItem" Header="剪切" IsEnabled="True">
+        <MenuItem
+            Name="CutAnnotMenuItem"
+            Header="剪切"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
         </MenuItem>
 
-        <MenuItem Name="CopyAnnotMenuItem" Header="复制" IsEnabled="True">
+        <MenuItem
+            Name="CopyAnnotMenuItem"
+            Header="复制"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
         </MenuItem>
 
-        <MenuItem Name="DeleteAnnotMenuItem" Header="删除" IsEnabled="True">
+        <MenuItem
+            Name="DeleteAnnotMenuItem"
+            Header="删除"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
         </MenuItem>
 
-        <MenuItem Name="NoteAnnotMenuItem" Header="笔记" IsEnabled="True">
+        <MenuItem
+            Name="NoteAnnotMenuItem"
+            Header="笔记"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
         </MenuItem>
     </ContextMenu>
-    
+
 </ResourceDictionary>

File diff suppressed because it is too large
+ 149 - 117
PDF Office/Styles/ContextMenuTextEditStyle.xaml


File diff suppressed because it is too large
+ 39 - 22
PDF Office/Styles/OutLineItemStyle.xaml


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

@@ -186,72 +186,98 @@
         </Setter>
     </Style>
 
-    <!--最近列表列表模式单选按钮-->
+    <!--  最近列表列表模式单选按钮  -->
     <Style x:Key="ListModeRadioBtnStyle" TargetType="{x:Type RadioButton}">
-        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
-        <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}"/>
-        <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}"/>
-        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
+        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
+        <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}" />
+        <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}" />
+        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type RadioButton}">
-                    <Border CornerRadius="4" x:Name="root" Background="#EEF2F3">
-                   
-                        <Grid x:Name="templateRoot" SnapsToDevicePixels="True" VerticalAlignment="Center" HorizontalAlignment="Center">
+                    <Border
+                        x:Name="root"
+                        Background="#EEF2F3"
+                        CornerRadius="4">
+
+                        <Grid
+                            x:Name="templateRoot"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            SnapsToDevicePixels="True">
 
                             <Grid.ColumnDefinitions>
-                                <ColumnDefinition Width="Auto"/>
-                                <ColumnDefinition Width="*"/>
+                                <ColumnDefinition Width="Auto" />
+                                <ColumnDefinition Width="*" />
                             </Grid.ColumnDefinitions>
-                            <Border x:Name="radioButtonBorder" Visibility="Collapsed" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="100" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1,1,2,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
+                            <Border
+                                x:Name="radioButtonBorder"
+                                Margin="1,1,2,1"
+                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                                Background="{TemplateBinding Background}"
+                                BorderBrush="{TemplateBinding BorderBrush}"
+                                BorderThickness="{TemplateBinding BorderThickness}"
+                                CornerRadius="100"
+                                Visibility="Collapsed">
                                 <Grid x:Name="markGrid" Margin="2">
-                                    <Ellipse x:Name="optionMark" Fill="{StaticResource RadioButton.Static.Glyph}" MinWidth="6" MinHeight="6" Opacity="0"/>
+                                    <Ellipse
+                                        x:Name="optionMark"
+                                        MinWidth="6"
+                                        MinHeight="6"
+                                        Fill="{StaticResource RadioButton.Static.Glyph}"
+                                        Opacity="0" />
                                 </Grid>
                             </Border>
 
-                            <ContentPresenter x:Name="contentPresenter" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
-                            </ContentPresenter>
+                            <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"/>
+                            <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
+                            <Setter Property="Padding" Value="4,-1,0,0" />
                         </Trigger>
                         <Trigger Property="IsMouseOver" Value="true">
-                            <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.MouseOver.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.MouseOver.Border}"/>
-                            <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.MouseOver.Glyph}"/>
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.MouseOver.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.MouseOver.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.MouseOver.Glyph}" />
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="false">
-                            <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Disabled.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Disabled.Border}"/>
-                            <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.Disabled.Glyph}"/>
-                            <Setter Property="Border.Background" TargetName="root">
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Disabled.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Disabled.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Disabled.Glyph}" />
+                            <Setter TargetName="root" Property="Border.Background">
                                 <Setter.Value>
-                                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
-                                        <GradientStop Color="White" Offset="0.0" />
-                                        <GradientStop Color="#CFCFCF" Offset="0.5" />
-                                        <GradientStop Color="White" Offset="0.0" />
+                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
+                                        <GradientStop Offset="0.0" Color="White" />
+                                        <GradientStop Offset="0.5" Color="#CFCFCF" />
+                                        <GradientStop Offset="0.0" Color="White" />
                                     </LinearGradientBrush>
                                 </Setter.Value>
                             </Setter>
                         </Trigger>
                         <Trigger Property="IsPressed" Value="true">
-                            <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Pressed.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Pressed.Border}"/>
-                            <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.Pressed.Glyph}"/>
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Pressed.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Pressed.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
                         </Trigger>
                         <Trigger Property="IsChecked" Value="true">
-                            <Setter Property="Opacity" TargetName="optionMark" Value="1"/>
-                            <Setter Property="Border.Background" TargetName="root" Value="White">
-                              
-                            </Setter>
+                            <Setter TargetName="optionMark" Property="Opacity" Value="1" />
+                            <Setter TargetName="root" Property="Border.Background" Value="White" />
                         </Trigger>
                         <Trigger Property="IsChecked" Value="{x:Null}">
-                            <Setter Property="Opacity" TargetName="optionMark" Value="0.56"/>
+                            <Setter TargetName="optionMark" Property="Opacity" Value="0.56" />
 
                         </Trigger>
                     </ControlTemplate.Triggers>
@@ -260,45 +286,54 @@
         </Setter>
     </Style>
 
-    <!--悬浮灰色背景单选按钮-->
+    <!--  悬浮灰色背景单选按钮  -->
     <Style x:Key="GreyBgRadioBtnStyle" TargetType="{x:Type RadioButton}">
-        <Setter Property="BorderThickness" Value="1"/>
-        <Setter Property="Foreground" Value="#252629"/>
+        <Setter Property="BorderThickness" Value="1" />
+        <Setter Property="Foreground" Value="#252629" />
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type RadioButton}">
-                    <Border x:Name="templateRoot" Background="{TemplateBinding Background}"  CornerRadius="4" SnapsToDevicePixels="True">
+                    <Border
+                        x:Name="templateRoot"
+                        Background="{TemplateBinding Background}"
+                        CornerRadius="4"
+                        SnapsToDevicePixels="True">
 
-                            <ContentPresenter x:Name="contentPresenter" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+                        <ContentPresenter
+                            x:Name="contentPresenter"
+                            Grid.Column="1"
+                            Margin="{TemplateBinding Padding}"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Focusable="False"
+                            RecognizesAccessKey="True"
+                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
 
                     </Border>
                     <ControlTemplate.Triggers>
                         <Trigger Property="HasContent" Value="true">
-                            <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}"/>
-                            <Setter Property="Padding" Value="4,-1,0,0"/>
+                            <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
+                            <Setter Property="Padding" Value="4,-1,0,0" />
                         </Trigger>
                         <Trigger Property="IsMouseOver" Value="true">
-                            <Setter Property="Background" TargetName="templateRoot" Value="#EDEEF0"/>
+                            <Setter TargetName="templateRoot" Property="Background" Value="#EDEEF0" />
 
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="false">
-                            <Setter Property="Opacity" TargetName="templateRoot" Value="0.5"/>
-                        </Trigger>
-                        <Trigger Property="IsPressed" Value="true">
-
+                            <Setter TargetName="templateRoot" Property="Opacity" Value="0.5" />
                         </Trigger>
+                        <Trigger Property="IsPressed" Value="true" />
                         <Trigger Property="IsChecked" Value="true">
-                            <Setter Property="Background" TargetName="templateRoot">
+                            <Setter TargetName="templateRoot" Property="Background">
                                 <Setter.Value>
-                                    <SolidColorBrush Color="#CED0D4" Opacity="0.6"/>
+                                    <SolidColorBrush Opacity="0.6" Color="#CED0D4" />
                                 </Setter.Value>
                             </Setter>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="#CED0D4"/>
-                            <Setter Property="Foreground" Value="#616469"/>
-                            <Setter Property="BorderThickness" TargetName="templateRoot" Value="1"/>
-                        </Trigger>
-                        <Trigger Property="IsChecked" Value="{x:Null}">
+                            <Setter TargetName="templateRoot" Property="BorderBrush" Value="#CED0D4" />
+                            <Setter Property="Foreground" Value="#616469" />
+                            <Setter TargetName="templateRoot" Property="BorderThickness" Value="1" />
                         </Trigger>
+                        <Trigger Property="IsChecked" Value="{x:Null}" />
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
             </Setter.Value>

+ 213 - 3
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -1,12 +1,222 @@
-using System;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using PDF_Office.ViewModels.Tools;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Media;
+using System.Windows;
+using System.Windows.Media.Imaging;
+using Prism.Commands;
+using PDF_Office.Helper;
+using Microsoft.Office.Interop.Word;
+using static Dropbox.Api.Files.FileCategory;
+using PDF_Office.Views.PropertyPanel.AnnotPanel;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
-    internal class LinkAnnotPropertyViewModel
+    internal class LinkAnnotPropertyViewModel : BindableBase, INavigationAware
     {
+        public AnnotAttribEvent AnnotAttribEvent { get; set; }
+        private AnnotHandlerEventArgs Annot;
+        private AnnotPropertyPanel PropertyPanel;
+        private AnnotArgsType annotType;
+
+        private LinkAnnotArgs _annotArgs;
+
+        public LinkAnnotArgs AnnotArgs
+        {
+            get
+            {
+                return _annotArgs;
+            }
+            set
+            {
+                if (_annotArgs != null)
+                {
+                    _annotArgs.LinkDrawFinished -= _annotArgs_LinkDrawFinished;
+                }
+                _annotArgs = value;
+
+                if (_annotArgs != null)
+                {
+                    _annotArgs.LinkDrawFinished += _annotArgs_LinkDrawFinished;
+                }
+            }
+        }
+
+        public AnnotArgsType AnnotType
+        {
+            get { return annotType; }
+            set
+            {
+                SetProperty(ref annotType, value);
+            }
+        }
+
+        private WriteableBitmap previewImage;
+
+        public WriteableBitmap PreviewImage
+        {
+            get { return previewImage; }
+            set
+            {
+                SetProperty(ref previewImage, value);
+            }
+        }
+
+        private CPDFViewer pdfViewer;
+        private CPDFDocument document;
+        private LinkAnnotProperty linkAnnot;
+        public DelegateCommand<object> LoadedCommand { get; set; }
+
+        public LinkAnnotPropertyViewModel()
+        {
+            LoadedCommand = new DelegateCommand<object>(Loaded);
+        }
+
+        private void _annotArgs_LinkDrawFinished(object sender, bool e)
+        {
+            linkAnnot.SetTextBoxEnableOrNot(e);
+            //AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
+        }
+
+        private void Loaded(object obj)
+        {
+            if (obj is CompositeCommandParameter composite)
+            {
+                if (composite.Parameter is LinkAnnotProperty linkAnnotProperty)
+                {
+                    linkAnnot = linkAnnotProperty;
+                    //AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
+                    int dpiHeight = (int)linkAnnot.ImagePreview.Height;
+                    int dpiWidth = (int)linkAnnot.ImagePreview.Width;
+                    if (dpiHeight <= 0 || dpiWidth <= 0)
+                    {
+                        return;
+                    }
+
+                    int pageIndex = pdfViewer.CurrentIndex;
+                    Rect MediaRect = GetPageRect(document, pageIndex, CPDFDisplayBox.MediaBox);
+
+                    System.Windows.Size pageSize = GetPageSize(document, pageIndex);
+                    double scale = Math.Min(dpiWidth / MediaRect.Width, dpiHeight / MediaRect.Height);
+                    scale = Math.Min(scale, 1);
+
+                    int cropWidth = (int)(scale * pageSize.Width);
+                    int cropHeight = (int)(scale * pageSize.Height);
+
+                    byte[] imageDatas = RenderPDFPageToArray(document, pageIndex, new Rect(0, 0, cropWidth, cropHeight), scale, true, true);
+
+                    WriteableBitmap WirteBitmap = new WriteableBitmap(cropWidth, cropHeight, 96, 96, PixelFormats.Bgra32, null);
+                    WirteBitmap.WritePixels(new Int32Rect(0, 0, cropWidth, cropHeight), imageDatas, WirteBitmap.BackBufferStride, 0);
+
+                    PreviewImage = WirteBitmap;
+                }
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
+
+            if (PropertyPanel != null && pdfViewer != null)
+            {
+                AnnotAttribEvent = PropertyPanel.AnnotEvent;
+                AnnotType = PropertyPanel.annot.EventType;
+                //AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
+                //if (Annot is ComPDFKitViewer.AnnotEvent.LineAnnotArgs lineAnnotArgs)
+                //{
+                //    AnnotArgs = lineAnnotArgs;
+                //}
+                //GetAnnotProperty();
+                //LoadPropertyHandler?.Invoke(null, Annot);
+                document = pdfViewer.Document;
+
+                if (linkAnnot != null)
+                {
+                    if (pdfViewer != null && pdfViewer.ToolManager != null && pdfViewer.ToolManager.CurrentAnnotArgs?.EventType == AnnotArgsType.AnnotLink)
+                    {
+                        if (AnnotAttribEvent.IsAnnotCreateReset)
+                        {
+                            AnnotArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
+                        }
+                    }
+                    linkAnnot.SetTextBoxEnableOrNot(!AnnotAttribEvent.IsAnnotCreateReset);
+                }
+                else
+                {
+                    AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
+                }
+            }
+        }
+
+        public byte[] RenderPDFPageToArray(CPDFDocument document, int pageIndex, Rect renderRect, double currentZoom, bool renderAnnot = false, bool renderForm = false)
+        {
+            if (renderRect.Width <= 0 || renderRect.Height <= 0 || document == null)
+            {
+                return null;
+            }
+            try
+            {
+                byte[] bmpData = new byte[(int)renderRect.Width * (int)renderRect.Height * 4];
+                currentZoom = currentZoom * 96 / 72;
+                int flag = 0;
+                if (renderAnnot)
+                {
+                    flag = 1;
+                }
+                uint bgColor = 0xFFFFFFFF;
+                CPDFPage page = document.PageAtIndex(pageIndex);
+                if (page.IsValid())
+                {
+                    page.RenderPageBitmapWithMatrix((float)currentZoom, renderRect, bgColor, bmpData, flag, renderForm);
+                }
+                return bmpData;
+            }
+            catch (Exception ex)
+            {
+                return null;
+            }
+        }
+
+        private Rect GetPageRect(CPDFDocument document, int pageIndex, CPDFDisplayBox displayBox)
+        {
+            CPDFPage currentPage = document.PageAtIndex(pageIndex);
+            Rect boundBox = currentPage.GetBoundsForBox(displayBox);
+
+            Rect boundRect = new Rect((int)(boundBox.Left / 72.0 * 96.0), (int)(boundBox.Top / 72.0 * 96.0),
+                (int)(boundBox.Width / 72.0 * 96.0), (int)(boundBox.Height / 72.0 * 96.0));
+
+            return boundRect;
+        }
+
+        private System.Windows.Size GetPageSize(CPDFDocument document, int pageIndex)
+        {
+            System.Windows.Size pageSize = document.GetPageSize(pageIndex);
+            pageSize.Width = pageSize.Width / 72.0 * 96;
+            pageSize.Height = pageSize.Height / 72.0 * 96;
+
+            return pageSize;
+        }
     }
-}
+}

+ 76 - 32
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -1,10 +1,12 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
 using PDF_Office.CustomControl;
 using PDF_Office.Helper;
 using PDF_Office.Properties;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
 using PDFSettings;
 using Prism.Mvvm;
 using Prism.Regions;
@@ -21,6 +23,7 @@ namespace PDF_Office.ViewModels.Tools
     public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
     {
         #region 初始化
+
         private void BindingEvent()
         {
             propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
@@ -30,7 +33,6 @@ namespace PDF_Office.ViewModels.Tools
 
         private void InitDefaultValue()
         {
-
             InitAnnotHighlight();
             InitAnnotUnderline();
             InitAnnotSquiggly();
@@ -56,7 +58,6 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-
         private void InitAnnotUnderline()
         {
             DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
@@ -114,8 +115,7 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-        #endregion
-
+        #endregion 初始化
 
         #region 注释工具
 
@@ -128,7 +128,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             TextHighlightAnnotArgs highlightArgs = null;
 
-            if(selectedhighlightArgs == null)
+            if (selectedhighlightArgs == null)
             {
                 highlightArgs = new TextHighlightAnnotArgs();
                 highlightArgs.Color = Color.FromRgb(0xFF, 0xBB, 0x00);
@@ -154,6 +154,47 @@ namespace PDF_Office.ViewModels.Tools
             return highlightArgs;
         }
 
+        private AnnotHandlerEventArgs GetLink(LinkAnnotArgs selectedfreetextArgs = null, AnnotAttribEvent annotAttribEvent = null)
+        {
+            Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
+            LinkAnnotArgs linkArgs = new LinkAnnotArgs();
+            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLink);
+            if (annotProperty != null)
+            {
+            }
+
+            if (selectedfreetextArgs != null)
+            {
+                linkArgs.URI = selectedfreetextArgs.URI;
+                linkArgs.LinkType = selectedfreetextArgs.LinkType;
+                linkArgs.DestIndex = selectedfreetextArgs.DestIndex;
+            }
+            else
+            {
+                linkArgs.URI = string.Empty;
+                linkArgs.LinkType = LINK_TYPE.GOTO;
+                linkArgs.DestIndex = -1;
+            }
+
+            //if (viewCtrl.PdfViewer.Document != null)
+            //{
+            //    linkProperty.SetTotalPage(viewCtrl.PdfViewer.Document.PageCount);
+            //}
+            //linkProperty.SetLinkPageNum(linkArgs.DestIndex);
+            //linkProperty.SetLinkUrl(linkArgs.URI);
+            //linkProperty.SetLinkEmail(string.Empty);
+            //linkProperty.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(linkArgs, annotAttribsList);
+            //linkProperty.AnnotArgs = linkArgs;
+            //propertyPanel = linkProperty;
+            //annotArgs = linkArgs;
+            //viewCtrl.ShowPropertyPanel();
+            annotAttribsList[AnnotAttrib.LinkType] = linkArgs.LinkType;
+            annotAttribsList[AnnotAttrib.LinkUri] = linkArgs.URI;
+            annotAttribsList[AnnotAttrib.LinkDestIndx] = linkArgs.DestIndex;
+            AddToPropertyPanel("LinkAnnotProperty", "Link", linkArgs, annotAttribsList, annotAttribEvent);
+            return linkArgs;
+        }
+
         private AnnotHandlerEventArgs GetUnderLine(TextUnderlineAnnotArgs selectedunderlineArgs = null)
         {
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
@@ -180,8 +221,8 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Color] = underlineArgs.Color;
             annotAttribsList[AnnotAttrib.Transparency] = underlineArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
-          
-            AddToPropertyPanel("TextAnnotProperty", "UnderLine", underlineArgs,  annotAttribsList);
+
+            AddToPropertyPanel("TextAnnotProperty", "UnderLine", underlineArgs, annotAttribsList);
             return underlineArgs;
         }
 
@@ -212,7 +253,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = squigglyArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
 
-            AddToPropertyPanel("TextAnnotProperty", "Squiggly", squigglyArgs,  annotAttribsList);
+            AddToPropertyPanel("TextAnnotProperty", "Squiggly", squigglyArgs, annotAttribsList);
             return squigglyArgs;
         }
 
@@ -221,7 +262,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             TextStrikeoutAnnotArgs strikeoutArgs = null;
 
-            if(selectedstrikeoutArgs == null)
+            if (selectedstrikeoutArgs == null)
             {
                 strikeoutArgs = new TextStrikeoutAnnotArgs();
                 strikeoutArgs.Color = Color.FromRgb(0xFF, 0x3B, 0x30);
@@ -238,7 +279,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 strikeoutArgs = selectedstrikeoutArgs;
             }
-           
+
             annotAttribsList[AnnotAttrib.Color] = strikeoutArgs.Color;
             annotAttribsList[AnnotAttrib.Transparency] = strikeoutArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
@@ -252,7 +293,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             FreehandAnnotArgs freehandArgs = null;
 
-            if(selectedfreehandArgs == null)
+            if (selectedfreehandArgs == null)
             {
                 freehandArgs = new FreehandAnnotArgs();
                 freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
@@ -266,13 +307,12 @@ namespace PDF_Office.ViewModels.Tools
                     freehandArgs.LineWidth = annotProperty.Thickness;
                     freehandArgs.Content = annotProperty.NoteText;
                 }
-
             }
             else
             {
                 freehandArgs = selectedfreehandArgs;
             }
-            
+
             annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
             annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
             annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
@@ -325,7 +365,6 @@ namespace PDF_Office.ViewModels.Tools
                     textAlignment = TextAlignment.Center;
                 else
                     textAlignment = TextAlignment.Right;
-
             }
             else
             {
@@ -333,7 +372,6 @@ namespace PDF_Office.ViewModels.Tools
                 textAlignment = freetextArgs.Align;
             }
 
-          
             annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
             annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
             annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
@@ -378,7 +416,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             SquareAnnotArgs squareArgs = null;
 
-            if(selectedsquareArgs == null)
+            if (selectedsquareArgs == null)
             {
                 squareArgs = new SquareAnnotArgs();
 
@@ -416,7 +454,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 squareArgs = selectedsquareArgs;
             }
-            
+
             annotAttribsList[AnnotAttrib.Color] = squareArgs.LineColor;
             annotAttribsList[AnnotAttrib.FillColor] = squareArgs.BgColor;
             annotAttribsList[AnnotAttrib.LineStyle] = squareArgs.LineDash;
@@ -433,7 +471,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             CircleAnnotArgs circleAnnotArgs = null;
 
-            if(selectedcircleAnnotArgs == null)
+            if (selectedcircleAnnotArgs == null)
             {
                 circleAnnotArgs = new CircleAnnotArgs();
                 circleAnnotArgs.LineColor = Colors.Red;
@@ -469,7 +507,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 circleAnnotArgs = selectedcircleAnnotArgs;
             }
-            
+
             annotAttribsList[AnnotAttrib.Color] = circleAnnotArgs.LineColor;
             annotAttribsList[AnnotAttrib.FillColor] = circleAnnotArgs.BgColor;
             annotAttribsList[AnnotAttrib.LineStyle] = circleAnnotArgs.LineDash;
@@ -481,14 +519,13 @@ namespace PDF_Office.ViewModels.Tools
             return circleAnnotArgs;
         }
 
-        private AnnotHandlerEventArgs GetArrowLine(string TagStr,LineAnnotArgs selectedLineAnnotArgs = null)
+        private AnnotHandlerEventArgs GetArrowLine(string TagStr, LineAnnotArgs selectedLineAnnotArgs = null)
         {
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             LineAnnotArgs lineArgs = new LineAnnotArgs();
 
-            if(selectedLineAnnotArgs == null)
+            if (selectedLineAnnotArgs == null)
             {
-
                 lineArgs.LineColor = Colors.Red;
                 lineArgs.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
                 if (TagStr == "Line")
@@ -576,8 +613,6 @@ namespace PDF_Office.ViewModels.Tools
             if (openFileDialog.ShowDialog() == true)
             {
                 stampArgs.ImagePath = openFileDialog.FileName;
-
-              
             }
 
             AddToPropertyPanel("ImageAnnotProperty", null, stampArgs, annotAttribsList);
@@ -591,7 +626,7 @@ namespace PDF_Office.ViewModels.Tools
         /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
         /// <param name="annot">注释</param>
         /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
-        private void AddToPropertyPanel(string viewContent, string toolTag = null, AnnotHandlerEventArgs annot = null, Dictionary<AnnotAttrib, object> annotAttribsList = null)
+        private void AddToPropertyPanel(string viewContent, string toolTag = null, AnnotHandlerEventArgs annot = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null)
         {
             if (string.IsNullOrEmpty(toolTag) == false)
             {
@@ -605,16 +640,25 @@ namespace PDF_Office.ViewModels.Tools
                 propertyPanel.annot = annot;
 
             if (annotAttribsList != null)
-                propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
+            {
+                if (annot is LinkAnnotArgs && annotAttribEvent != null)
+                {
+                    propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
+                    if (annotAttribEvent.IsAnnotCreateReset)
+                    {
+                        propertyPanel.AnnotEvent.IsAnnotCreateReset = true;
+                    }
+                }
+                else
+                {
+                    propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
+                }
+            }
 
             if (string.IsNullOrEmpty(viewContent) == false)
                 viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
-
         }
 
-
-        #endregion
-
-
+        #endregion 注释工具
     }
-}
+}

+ 18 - 23
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -26,10 +26,8 @@ using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.Tools
 {
-
     public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
     {
-
         public AnnotToolContentViewModel(IRegionManager regionManager)
         {
             region = regionManager;
@@ -40,8 +38,8 @@ namespace PDF_Office.ViewModels.Tools
             InitDefaultValue();
         }
 
-
         private Dictionary<string, bool> ToolExpandDict = new Dictionary<string, bool>();
+
         public void BtnMyTools_Click(CustomIconToggleBtn annotBtn)
         {
             //不创建注释,属于注释模板
@@ -50,7 +48,6 @@ namespace PDF_Office.ViewModels.Tools
 
             if (annotBtn.IsChecked == true)
             {
-
                 switch (annotBtn.Tag.ToString())
                 {
                     case "SnapshotEdit":
@@ -112,8 +109,8 @@ namespace PDF_Office.ViewModels.Tools
                         break;
 
                     case "Link":
+                        annotArgs = GetLink();
                         break;
-
                 }
 
                 if (annotArgs != null)
@@ -122,23 +119,20 @@ namespace PDF_Office.ViewModels.Tools
                     PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
                     PDFViewer.SetToolParam(annotArgs);
                 }
-
             }
 
             //当不是注释模板,且无创建注释时,属性面板显示为空内容
-            if(isTemplateAnnot == false && annotArgs == null)
+            if (isTemplateAnnot == false && annotArgs == null)
             {
                 PDFViewer.SetMouseMode(MouseModes.PanTool);
                 viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
             }
 
             ShowPropertyPanel((bool)annotBtn.IsChecked);
-
         }
 
         private void AnnotProperty_DefaultStored(object sender, object e)
         {
-
         }
 
         private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
@@ -162,21 +156,18 @@ namespace PDF_Office.ViewModels.Tools
                             var LineTag = e[argsType] as string;
                             annotArgs = GetArrowLine(LineTag);
                             break;
-
                     }
                     if (annotArgs != null)
                     {
                         annotArgs.Author = Settings.Default.AppProperties.Description.Author;
                         PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
                         PDFViewer.SetToolParam(annotArgs);
-
                     }
                     ShowPropertyPanel();
                 }
             }
         }
 
-
         private void AnnotPropertyPanel_DataChanged(object sender, Dictionary<AnnotArgsType, object> e)
         {
             if (e != null)
@@ -239,6 +230,7 @@ namespace PDF_Office.ViewModels.Tools
                                 //  FreehandPath.Opacity = (double)e[argsType];
                             }
                             break;
+
                         case AnnotArgsType.AnnotErase:
                             if (e[argsType] is ToggleButton)
                             {
@@ -360,18 +352,15 @@ namespace PDF_Office.ViewModels.Tools
 
                 PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
                 PDFViewer.WidgetClickHander += PDFViewer_WidgetClickHander;
-
             }
         }
 
         private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
         {
-
         }
 
         private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
         {
-
         }
 
         private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
@@ -384,29 +373,38 @@ namespace PDF_Office.ViewModels.Tools
                     switch (annot.EventType)
                     {
                         case AnnotArgsType.AnnotHighlight:
+                            e.IsAnnotCreateReset = false;
                             GetHighLight(annot as TextHighlightAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotUnderline:
                             GetUnderLine(annot as TextUnderlineAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotStrikeout:
                             GetStrikeout(annot as TextStrikeoutAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotSquiggly:
                             GetSquiggly(annot as TextSquigglyAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotFreehand:
                             GetFreehand(annot as FreehandAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotFreeText:
                             GetFreetext(annot as FreeTextAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotSquare:
                             GetRect(annot as SquareAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotCircle:
                             GetCircle(annot as CircleAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotLine:
                             bool isLine = true;
                             if (e.Attribs.ContainsKey(AnnotAttrib.LineStart))
@@ -430,6 +428,10 @@ namespace PDF_Office.ViewModels.Tools
                                 GetArrowLine("Arrow", annot as LineAnnotArgs);
 
                             break;
+
+                        case AnnotArgsType.AnnotLink:
+                            GetLink(annot as LinkAnnotArgs, e);
+                            break;
                     }
 
                     ShowPropertyPanel();
@@ -440,12 +442,10 @@ namespace PDF_Office.ViewModels.Tools
                 // PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
                 //  viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
             }
-
         }
 
         private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
         {
-
             if (e.AnnotEventArgsList == null)
                 return;
 
@@ -468,14 +468,12 @@ namespace PDF_Office.ViewModels.Tools
                         {
                             e.Handle = true;
                         }
-
                     }
 
                     break;
             }
         }
 
-
         private ContextMenu SelectAnnotContextMenu(object sender)
         {
             var popMenu = App.Current.FindResource("SelectAnnotContextMenu") as ContextMenu;
@@ -498,7 +496,6 @@ namespace PDF_Office.ViewModels.Tools
                 //menuItem = popMenu.Items[2] as MenuItem;
                 //menuItem.CommandTarget = (UIElement)sender;
                 //menuItem.Command = ApplicationCommands.no;
-
             }
             return popMenu;
         }
@@ -527,7 +524,5 @@ namespace PDF_Office.ViewModels.Tools
         {
             viewContentViewModel.IsPropertyOpen = show;
         }
-
     }
-
-}
+}

+ 3 - 2
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -471,7 +471,7 @@ namespace PDF_Office.ViewModels
             ToolsBarContentVisible = Visibility.Collapsed;
             ConverterBarContentVisible = Visibility.Collapsed;
             TextEditToolContentVisible = Visibility.Collapsed;
-        
+
             switch (currentBar)
             {
                 case "TabItemAnnotation":
@@ -508,7 +508,7 @@ namespace PDF_Office.ViewModels
 
         private void PDFEditMode(string currentBar)
         {
-            if(currentBar == "TabItemEdit")
+            if (currentBar == "TabItemEdit")
             {
                 if (PDFViewer != null)
                 {
@@ -772,6 +772,7 @@ namespace PDF_Office.ViewModels
                 //传其他参数:文档类,空注释面板;
                 parameters.Add(ParameterNames.PDFViewer, PDFViewer);
                 parameters.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
+
                 region.RequestNavigate(PropertyRegionName, Content, parameters);
             }
          ));

+ 204 - 69
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml

@@ -2,20 +2,84 @@
     x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.LinkAnnotProperty"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:AnnotPanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
     xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-    xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel"
+    xmlns:data="clr-namespace:ComPDFKit.PDFDocument;assembly=ComPDFKit.Desk"
+    xmlns:helper="clr-namespace:PDF_Office.Helper"
+    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+    xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-    d:DesignHeight="450"
+    xmlns:prism="http://prismlibrary.com/"
+    xmlns:property="clr-namespace:PDF_Office.Properties"
+    d:DataContext="{d:DesignInstance Type=AnnotPanel:LinkAnnotPropertyViewModel}"
+    d:DesignHeight="680"
     d:DesignWidth="260"
-    mc:Ignorable="d">
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    mc:Ignorable="d" Name="LinkAnnotPropertyContent">
     <UserControl.Resources>
         <ResourceDictionary>
-            <!--<ResourceDictionary.MergedDictionaries>
-            <ResourceDictionary Source="../Resources/Style/ToggleButtonStyle.xaml" />
-            </ResourceDictionary.MergedDictionaries>-->
+            <Convert:ObjectConvert x:Key="ObjectConvert" />
             <Convert:StringToVisibleConvert x:Key="StringToVisibleConvert" />
             <Convert:StringToUnVisibleConvert x:Key="StringToUnVisibleConvert" />
+            <SolidColorBrush x:Key="Button.Static.Background" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Static.Border" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.MouseOver.Background" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.MouseOver.Border" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Pressed.Background" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Pressed.Border" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Disabled.Background" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Disabled.Border" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="Transparent" />
+            <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
+                <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
+                <Setter Property="Background" Value="{StaticResource Button.Static.Background}" />
+                <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}" />
+                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
+                <Setter Property="BorderThickness" Value="1" />
+                <Setter Property="HorizontalContentAlignment" Value="Center" />
+                <Setter Property="VerticalContentAlignment" Value="Center" />
+                <Setter Property="Padding" Value="1" />
+                <Setter Property="Template">
+                    <Setter.Value>
+                        <ControlTemplate TargetType="{x:Type Button}">
+                            <Border
+                                x:Name="border"
+                                Background="{TemplateBinding Background}"
+                                BorderBrush="{TemplateBinding BorderBrush}"
+                                BorderThickness="{TemplateBinding BorderThickness}"
+                                SnapsToDevicePixels="true">
+                                <ContentPresenter
+                                    x:Name="contentPresenter"
+                                    Margin="{TemplateBinding Padding}"
+                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                                    Focusable="False"
+                                    RecognizesAccessKey="True"
+                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+                            </Border>
+                            <ControlTemplate.Triggers>
+                                <Trigger Property="IsDefaulted" Value="true">
+                                    <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
+                                </Trigger>
+                                <Trigger Property="IsMouseOver" Value="true">
+                                    <Setter TargetName="border" Property="Background" Value="{StaticResource Button.MouseOver.Background}" />
+                                    <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.MouseOver.Border}" />
+                                </Trigger>
+                                <Trigger Property="IsPressed" Value="true">
+                                    <Setter TargetName="border" Property="Background" Value="{StaticResource Button.Pressed.Background}" />
+                                    <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}" />
+                                </Trigger>
+                                <Trigger Property="IsEnabled" Value="false">
+                                    <Setter TargetName="border" Property="Background" Value="{StaticResource Button.Disabled.Background}" />
+                                    <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Disabled.Border}" />
+                                    <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{StaticResource Button.Disabled.Foreground}" />
+                                </Trigger>
+                            </ControlTemplate.Triggers>
+                        </ControlTemplate>
+                    </Setter.Value>
+                </Setter>
+            </Style>
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid>
@@ -30,7 +94,7 @@
                 LineHeight="24">
                 Hyperlink
             </TextBlock>
-            <StackPanel Margin="12,0,0,0" Orientation="Horizontal">
+            <StackPanel Margin="12,0,0,0" Orientation="Horizontal" Name="ToggleButtonTab">
                 <ToggleButton
                     Name="LinkPageBtn"
                     Width="75"
@@ -136,12 +200,12 @@
                 X2="232"
                 Y1="0"
                 Y2="0" />
-            <Grid Height="100">
-                <StackPanel Name="LinkPagePanel">
+            <Grid MinWidth="260">
+                <StackPanel Name="LinkPagePanel" Visibility="Visible">
                     <TextBlock
-                        x:Name="PageNumberText"
+                        x:Name="TxtPage"
                         Height="20"
-                        Margin="12,12,0,4"
+                        Margin="16,12,0,4"
                         FontFamily="Segoe UI"
                         FontSize="12"
                         Foreground="#616469"
@@ -149,25 +213,38 @@
                         Text="Page" />
                     <StackPanel Orientation="Horizontal">
                         <Grid>
-                            <TextBox
-                                Name="PageNumText"
-                                Width="199"
+                            <Border
+                                Width="228"
                                 Height="32"
-                                Margin="12,0,0,0"
-                                Padding="12,0,0,0"
-                                VerticalContentAlignment="Center"
-                                Background="#FFFFFF"
+                                Margin="16,0"
+                                Background="LightGray"
                                 BorderBrush="#1770F4"
-                                IsEnabled="True"
-                                MaxLength="7" />
+                                BorderThickness="1"
+                                CornerRadius="4" Name="BorderPageNumText">
+                                <TextBox
+                                    Name="PageNumText"
+                                    VerticalContentAlignment="Center"
+                                    Background="Transparent"
+                                    BorderThickness="0"
+                                    IsEnabled="False" />
+                            </Border>
+                            <TextBlock
+                                x:Name="defaultPageNumText"
+                                Margin="25,0,0,0"
+                                VerticalAlignment="Center"
+                                FontSize="14"
+                                Foreground="Gray"
+                                IsHitTestVisible="False"
+                                Visibility="{Binding ElementName=PageNumText, Path=Text, Converter={StaticResource StringToUnVisibleConvert}, Mode=OneWay}">
+                                输入目标页码
+                            </TextBlock>
                             <Button
-                                Width="16"
-                                Height="16"
-                                Margin="0,8,8,8"
+                                Width="18"
+                                Height="18"
+                                Margin="0,0,18,0"
                                 HorizontalAlignment="Right"
                                 VerticalAlignment="Center"
                                 Background="Transparent"
-
                                 Tag="PageNumText"
                                 Visibility="{Binding ElementName=PageNumText, Path=Text, Converter={StaticResource StringToVisibleConvert}}">
                                 <Button.Content>
@@ -212,45 +289,76 @@
                         Visibility="Collapsed">
                         Page number out of range.
                     </TextBlock>
+                    <Button
+                        Name="BtnLocation"
+                        Width="228"
+                        Height="32"
+                        Margin="16,16,16,0"
+                        IsEnabled="False"
+                        Style="{StaticResource Btn.cta}">
+                        <Button.Content>
+                            <StackPanel Orientation="Horizontal">
+                                <Path
+                                    Name="PathLocation"
+                                    HorizontalAlignment="Left"
+                                    VerticalAlignment="Center"
+                                    Data="M15.064 6.88052L13.5661 6.49468L9.57748 11.6857L10.2156 13.8898C10.3593 14.3863 9.74722 14.7479 9.38174 14.3824L6.59721 11.5979L0.0145727 15.9711L4.38786 9.38851L1.60356 6.60421C1.23807 6.23873 1.59967 5.62665 2.09615 5.77038L4.30107 6.40871L9.49166 2.42039L9.10576 0.92227C8.97879 0.42937 9.58359 0.0840825 9.9435 0.443993L15.5423 6.04277C15.9022 6.40268 15.5569 7.00748 15.064 6.88052Z"
+                                    Fill="#616469" />
+                                <TextBlock Margin="10,0" Text="Locate the target page" />
+                            </StackPanel>
+                        </Button.Content>
+                    </Button>
+                    <Image
+                        Name="ImagePreview"
+                        Width="196"
+                        Height="254"
+                        Margin="32,0"
+                        Source="{Binding PreviewImage}"  Visibility="Collapsed" />
                 </StackPanel>
                 <StackPanel Name="LinkWebPanel" Visibility="Collapsed">
                     <TextBlock
                         Height="20"
-                        Margin="12,12,0,4"
+                        Margin="16,12,0,4"
                         FontFamily="Segoe UI"
-                        FontSize="14"
-                        LineHeight="20">
-                        URL
-                    </TextBlock>
+                        FontSize="12"
+                        Foreground="#616469"
+                        LineHeight="20"
+                        Text="URL" />
                     <Grid>
-                        <TextBox
-                            Name="PageWebText"
-                            Width="232"
+                        <Border
+                            Width="228"
                             Height="32"
-                            Margin="12,0,12,0"
-                            Padding="12,0,25,0"
-                            HorizontalAlignment="Left"
-                            VerticalContentAlignment="Center"
-                            Background="Gray"
-                            BorderBrush="#FFE2E3E6"
-                            IsEnabled="False" />
+                            Margin="16,0"
+                            Background="#FFFFFF"
+                            BorderBrush="#1770F4"
+                            BorderThickness="1"
+                            CornerRadius="4" Name="BorderPageWebText">
+                            <TextBox
+                                Name="PageWebText"
+                                VerticalContentAlignment="Center"
+                                Background="Transparent"
+                                BorderThickness="0"
+                                IsEnabled="True" />
+                        </Border>
                         <TextBlock
                             x:Name="defaultPageWebText"
                             Margin="25,0,0,0"
                             VerticalAlignment="Center"
                             FontSize="14"
                             Foreground="Gray"
-                            IsHitTestVisible="False">
+                            IsHitTestVisible="False"
+                            Visibility="{Binding ElementName=PageWebText, Path=Text, Converter={StaticResource StringToUnVisibleConvert}, Mode=OneWay}">
                             https://www.pdfreaderpro.com
                         </TextBlock>
                         <Button
-                            Width="16"
-                            Height="16"
-                            Margin="0,8,18,8"
+                            Width="18"
+                            Height="18"
+                            Margin="0,0,18,0"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Background="Transparent"
-                            Tag="PageWebText">
+                            Tag="PageWebText"
+                            Visibility="{Binding ElementName=PageWebText, Path=Text, Converter={StaticResource StringToVisibleConvert}}">
                             <Button.Content>
                                 <Path Fill="#333333">
                                     <Path.Data>
@@ -286,34 +394,43 @@
                         Email
                     </TextBlock>
                     <Grid>
-                        <TextBox
-                            Name="PageMailText"
-                            Width="232"
+                        <Border
+                            Width="228"
                             Height="32"
-                            Margin="12,0,12,0"
-                            Padding="12,0,0,0"
-                            HorizontalAlignment="Left"
-                            VerticalContentAlignment="Center"
-                            Background="Gray"
-                            BorderBrush="#FFE2E3E6"
-                            IsEnabled="False" />
+                            Margin="16,0"
+                            Background="#FFFFFF"
+                            BorderBrush="#1770F4"
+                            BorderThickness="1"
+                            CornerRadius="4" Name="BorderPageMailText">
+                            <TextBox
+                                Name="PageMailText"
+                                Width="232"
+                                Height="32"
+                                HorizontalAlignment="Left"
+                                VerticalContentAlignment="Center"
+                                Background="Transparent"
+                                BorderBrush="Transparent"
+                                IsEnabled="False" />
+                        </Border>
                         <TextBlock
                             x:Name="defaultPageMailText"
                             Margin="25,0,0,0"
                             VerticalAlignment="Center"
                             FontSize="14"
                             Foreground="Gray"
-                            IsHitTestVisible="False">
+                            IsHitTestVisible="False"
+                            Visibility="{Binding ElementName=PageMailText, Path=Text, Converter={StaticResource StringToUnVisibleConvert}, Mode=OneWay}">
                             support@pdfreaderpro.com
                         </TextBlock>
                         <Button
-                            Width="16"
-                            Height="16"
-                            Margin="0,8,18,8"
+                            Width="18"
+                            Height="18"
+                            Margin="0,0,18,0"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             Background="Transparent"
-                            Tag="PageMailText">
+                            Tag="PageMailText"
+                            Visibility="{Binding ElementName=PageMailText, Path=Text, Converter={StaticResource StringToVisibleConvert}}">
                             <Button.Content>
                                 <Path Fill="#333333">
                                     <Path.Data>
@@ -341,18 +458,36 @@
                     </TextBlock>
                 </StackPanel>
             </Grid>
+
             <Button
-                Name="SaveBtn"
-                Width="120"
-                Height="32"
-                Background="#273C62"
-                BorderThickness="0"
+                Background="Transparent"
+                BorderBrush="Transparent"
+                Content="GO"
                 FontSize="16"
-                Foreground="White"
-                IsEnabled="False"
-                Tag="go">
-                <!--<TextBlock x:Name="GoText" Foreground="White">Go</TextBlock>-->
-            </Button>
+                Name="BtnGOorBack"
+                Foreground=" #1770F4"
+                Style="{StaticResource ButtonStyle1}" Visibility="Collapsed" />
         </StackPanel>
     </Grid>
+    <i:Interaction.Triggers>
+        <i:EventTrigger EventName="Loaded">
+            <helper:AdvancedInvokeCommandAction
+                Command="{Binding LoadedCommand}"
+                PassEventArgsToCommand="True" CommandParameter="{Binding ElementName=LinkAnnotPropertyContent}">
+                <!--<helper:AdvancedInvokeCommandAction.CommandParameter>
+                <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
+                <MultiBinding.Bindings>
+                <Binding ElementName="ImagePreview" />
+                <Binding ElementName="LinkPagePanel" />
+                <Binding ElementName="LinkWebPanel" />
+                <Binding ElementName="LinkMailPanel" />
+                <Binding ElementName="LinkPagePanel" />
+                <Binding ElementName="LinkPagePanel" />
+                <Binding ElementName="LinkPagePanel" />
+                </MultiBinding.Bindings>
+                </MultiBinding>
+                </helper:AdvancedInvokeCommandAction.CommandParameter>-->
+            </helper:AdvancedInvokeCommandAction>
+        </i:EventTrigger>
+    </i:Interaction.Triggers>
 </UserControl>

+ 18 - 2
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using ComPDFKitViewer.AnnotEvent;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -24,5 +25,20 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         {
             InitializeComponent();
         }
+
+        internal void SetTextBoxEnableOrNot(bool enable)
+        {
+            PageNumText.Text = string.Empty;
+            PageWebText.Text = string.Empty;
+            PageMailText.Text = string.Empty;
+            PageNumText.IsEnabled = enable;
+            BorderPageNumText.Background = enable ? Brushes.White : Brushes.LightGray;
+            PageWebText.IsEnabled = enable;
+            BorderPageWebText.Background = enable ? Brushes.White : Brushes.LightGray;
+            PageMailText.IsEnabled = enable;
+            BorderPageMailText.Background = enable ? Brushes.White : Brushes.LightGray;
+            BtnGOorBack.IsEnabled = false;
+            BtnLocation.IsEnabled = enable;
+        }
     }
-}
+}