Browse Source

注释-链接-页面链接初版

OYXH\oyxh 2 years ago
parent
commit
4976b2485a

+ 1 - 1
PDF Office/Styles/ButtonStyle.xaml

@@ -604,7 +604,7 @@
             </Trigger>
             <Trigger Property="IsEnabled" Value="false">
                 <Setter Property="Background" Value="Transparent" />
-                <Setter Property="Opacity" Value="0.6"/>
+                <Setter Property="Opacity" Value="0.6" />
                 <Setter Property="Foreground" Value="{StaticResource color.sys.text.neutral.dis}" />
             </Trigger>
         </Style.Triggers>

+ 377 - 47
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -22,13 +22,16 @@ using static Dropbox.Api.Files.FileCategory;
 using PDF_Office.Views.PropertyPanel.AnnotPanel;
 using System.Windows.Controls;
 using PDF_Office.CustomControl;
+using System.Windows.Markup;
+using ComPDFKitViewer;
+using System.Runtime.InteropServices;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
     internal class LinkAnnotPropertyViewModel : BindableBase, INavigationAware
     {
         public AnnotAttribEvent AnnotAttribEvent { get; set; }
-        private int totalPage = 0;
+
         private AnnotPropertyPanel PropertyPanel;
         private AnnotArgsType annotType;
 
@@ -64,12 +67,35 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private string pageNumTextContent = "Enter target page";
+        private string pageNumTextContent;
 
         public string PageNumTextContent
         {
             get
             {
+                //if (string.IsNullOrEmpty(pageNumTextContent))
+                //{
+                //    return "Enter target page";
+                //}
+                //if (pageNumTextContent != "Enter target page")
+                //{
+                if (CheckPageNumVaild(out int pageNum, pageNumTextContent))
+                {
+                    if (AnnotArgs != null)
+                    {
+                        AnnotArgs.DestIndex = pageNum - 1;
+                        //BtnLocationIsEnabled = true;
+                        SetImagePreview(AnnotArgs.DestIndex);
+                    }
+                }
+                else
+                {
+                    //BtnLocationIsEnabled = false;
+                    ImagePreviewVisibility = Visibility.Collapsed;
+                    BtnGOorBackVisibility = Visibility.Collapsed;
+                }
+                //}
+
                 return pageNumTextContent;
             }
             set
@@ -78,6 +104,70 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        /// <summary>
+        /// 设置预文本内容
+        /// </summary>
+        private string pageNumPlaceHoldText = "Enter target page";
+
+        public string PageNumPlaceHoldText
+        {
+            get { return pageNumPlaceHoldText; }
+            set
+            {
+                SetProperty(ref pageNumPlaceHoldText, value);
+            }
+        }
+
+        /// <summary>
+        /// 是否显示输入框下方提示文案
+        /// </summary>
+        private Visibility showPageNumTip = Visibility.Collapsed;
+
+        public Visibility ShowPageNumTip
+        {
+            get { return showPageNumTip; }
+            set
+            {
+                SetProperty(ref showPageNumTip, value);
+            }
+        }
+
+        /// <summary>
+        /// 输入框下方提示文案
+        /// </summary>
+        private string pageNumTipText = "Page number error.";
+
+        public string PageNumTipText
+        {
+            get { return pageNumTipText; }
+            set
+            {
+                SetProperty(ref pageNumTipText, value);
+            }
+        }
+
+        private bool pageNumTextIsEnabled = false;
+
+        public bool PageNumTextIsEnabled
+        {
+            get { return pageNumTextIsEnabled; }
+            set
+            {
+                SetProperty(ref pageNumTextIsEnabled, value);
+            }
+        }
+
+        private bool btnLocationIsEnabled = false;
+
+        public bool BtnLocationIsEnabled
+        {
+            get { return btnLocationIsEnabled; }
+            set
+            {
+                SetProperty(ref btnLocationIsEnabled, value);
+            }
+        }
+
         private WriteableBitmap previewImage;
 
         public WriteableBitmap PreviewImage
@@ -89,6 +179,28 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private int imagePreviewWidth = 196;
+
+        public int ImagePreviewWidth
+        {
+            get { return imagePreviewWidth; }
+            set
+            {
+                SetProperty(ref imagePreviewWidth, value);
+            }
+        }
+
+        private int imagePreviewHeight = 256;
+
+        public int ImagePreviewHeight
+        {
+            get { return imagePreviewHeight; }
+            set
+            {
+                SetProperty(ref imagePreviewHeight, value);
+            }
+        }
+
         private Visibility imagePreviewVisibility = Visibility.Collapsed;
 
         public Visibility ImagePreviewVisibility
@@ -111,87 +223,209 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private Visibility errorNumTipsVisibility = Visibility.Collapsed;
+        private string btnGOorBackContent = "GO";
+
+        public string BtnGOorBackContent
+        {
+            get { return btnGOorBackContent; }
+            set
+            {
+                SetProperty(ref btnGOorBackContent, value);
+            }
+        }
+
+        private bool btnLinkPageIsChecked = true;
+
+        public bool BtnLinkPageIsChecked
+        {
+            get { return btnLinkPageIsChecked; }
+            set
+            {
+                SetProperty(ref btnLinkPageIsChecked, value);
+            }
+        }
+
+        private bool btnLinkWebIsChecked = false;
 
-        public Visibility ErrorNumTipsVisibility
+        public bool BtnLinkWebIsChecked
         {
-            get { return errorNumTipsVisibility; }
+            get { return btnLinkWebIsChecked; }
             set
             {
-                SetProperty(ref errorNumTipsVisibility, value);
+                SetProperty(ref btnLinkWebIsChecked, value);
             }
         }
 
-        private Visibility errorRangeTipsVisibility = Visibility.Collapsed;
+        private bool btnLinkMailIsChecked = false;
 
-        public Visibility ErrorRangeTipsVisibility
+        public bool BtnLinkMailIsChecked
         {
-            get { return errorRangeTipsVisibility; }
+            get { return btnLinkMailIsChecked; }
             set
             {
-                SetProperty(ref errorRangeTipsVisibility, value);
+                SetProperty(ref btnLinkMailIsChecked, value);
             }
         }
 
+        //private Visibility errorNumTipsVisibility = Visibility.Collapsed;
+
+        //public Visibility ErrorNumTipsVisibility
+        //{
+        //    get { return errorNumTipsVisibility; }
+        //    set
+        //    {
+        //        SetProperty(ref errorNumTipsVisibility, value);
+        //    }
+        //}
+
+        //private Visibility errorRangeTipsVisibility = Visibility.Collapsed;
+
+        //public Visibility ErrorRangeTipsVisibility
+        //{
+        //    get { return errorRangeTipsVisibility; }
+        //    set
+        //    {
+        //        SetProperty(ref errorRangeTipsVisibility, value);
+        //    }
+        //}
+        private int totalPage = 0;
+
+        private bool isLoaded = false;
+        private int historyPageIndex = 0;
+        private int backPageIndex = 0;
         private CPDFViewer pdfViewer;
         private CPDFDocument document;
         private LinkAnnotProperty linkAnnot;
         public DelegateCommand<object> LoadedCommand { get; set; }
         public DelegateCommand<object> PageNumTextChangedCommand { get; set; }
+        public DelegateCommand<object> BtnGOorBackPageCommand { get; set; }
+        public DelegateCommand<object> LocationCommand { get; set; }
+
         //public DelegateCommand<object> ToggleButtonTabCommand { get; set; }
 
         public LinkAnnotPropertyViewModel()
         {
             LoadedCommand = new DelegateCommand<object>(Loaded);
             PageNumTextChangedCommand = new DelegateCommand<object>(PageNumTextChanged);
+            BtnGOorBackPageCommand = new DelegateCommand<object>(BtnGOorBackPageEvent);
+            LocationCommand = new DelegateCommand<object>(LocationPage);
             //ToggleButtonTabCommand = new DelegateCommand<object>(ToggleButtonTabSelected);
+            isLoaded = true;
         }
 
-        //private void ToggleButtonTabSelected(object obj)
-        //{
-        //    if (obj is object[] array)
-        //    {
-        //    }
-        //}
+        private void LocationPage(object obj)
+        {
+            if (!string.IsNullOrEmpty(PageNumTextContent))
+            {
+                AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
+                AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, Convert.ToInt32(PageNumTextContent) - 1);
+                AnnotAttribEvent?.UpdateAnnot();
 
-        private void PageNumTextChanged(object obj)
+                if (AnnotArgs != null)
+                {
+                    AnnotArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
+                }
+            }
+        }
+
+        private void BtnGOorBackPageEvent(object obj)
         {
-            if (obj is TextChangedEventArgs textChangedEventArgs)
+            if (obj is object[] arry)
             {
-                if (textChangedEventArgs.Source is TextBoxWithTip textBox)
+                Button btnGOorBack = arry[0] as Button;
+                RadioButton btnLinkPage = arry[1] as RadioButton;
+                RadioButton btnLinkWeb = arry[2] as RadioButton;
+                RadioButton btnLinkMail = arry[3] as RadioButton;
+
+                if (btnLinkPage != null && btnGOorBack != null && btnLinkWeb != null && btnLinkMail != null)
                 {
-                    int pageNum = -1;
-                    if (CheckPageNumVaild(out pageNum, textBox))
+                    if (btnLinkPage.IsChecked == true)
                     {
-                        if (AnnotArgs != null)
+                        int pageIndex = Convert.ToInt32(PageNumTextContent) - 1;
+                        if (btnGOorBack.Tag.ToString() == "GO")
+                        {
+                            if (AnnotArgs != null)
+                            {
+                                historyPageIndex = AnnotArgs.PageIndex;
+                            }
+                            else
+                            {
+                                historyPageIndex = backPageIndex;
+                            }
+                            pdfViewer.GoToPage(pageIndex);
+
+                            ChangeBtnGOorBack("BACK", btnGOorBack);
+                            SetImagePreview(historyPageIndex);
+                        }
+                        else
                         {
-                            AnnotArgs.DestIndex = pageNum - 1;
-                            SetImagePreview();
+                            pdfViewer.GoToPage(historyPageIndex);
+                            ChangeBtnGOorBack("GO", btnGOorBack);
+                            SetImagePreview(pageIndex);
                         }
                     }
                 }
             }
         }
 
-        private bool CheckPageNumVaild(out int pageNum, TextBoxWithTip textBox)
+        private void ChangeBtnGOorBack(string flag, Button button)
+        {
+            switch (flag)
+            {
+                case "BACK":
+                    button.Tag = "BACK";
+                    button.Content = "BACK";
+                    break;
+
+                case "GO":
+                    button.Tag = "GO";
+                    button.Content = "GO";
+                    break;
+
+                default:
+                    break;
+            }
+        }
+
+        private void PageNumTextChanged(object obj)
+        {
+            if (obj is TextChangedEventArgs textChangedEventArgs)
+            {
+                if (textChangedEventArgs.Source is TextBoxWithTip textBox)
+                {
+                    int pageNum = -1;
+                    //if (CheckPageNumVaild(out pageNum))
+                    //{
+                    //    if (AnnotArgs != null)
+                    //    {
+                    //        AnnotArgs.DestIndex = pageNum - 1;
+                    //        SetImagePreview();
+                    //    }
+                    //}
+                }
+            }
+        }
+
+        private bool CheckPageNumVaild(out int pageNum, string text)
         {
             pageNum = -1;
-            ErrorNumTipsVisibility = Visibility.Collapsed;
-            ErrorRangeTipsVisibility = Visibility.Collapsed;
-            BtnGOorBackVisibility = Visibility.Collapsed;
-            if (string.IsNullOrEmpty(textBox.Text))
+            //ErrorNumTipsVisibility = Visibility.Collapsed;
+            //ErrorRangeTipsVisibility = Visibility.Collapsed;
+            //BtnGOorBackVisibility = Visibility.Collapsed;
+            if (string.IsNullOrEmpty(text))
             {
                 return false;
             }
-            if (textBox.Text.Trim() != string.Empty)
+            if (text.Trim() != string.Empty)
             {
-                if (!int.TryParse(textBox.Text.Trim(), out pageNum))
+                if (!int.TryParse(text.Trim(), out pageNum))
                 {
                     //ErrorNumTipsVisibility = Visibility.Visible;
                     //ErrorRangeTipsVisibility = Visibility.Collapsed;
-                    textBox.IsError = true;
-                    textBox.ShowTip = Visibility.Visible;
-                    textBox.TipText = " Page number error.";
+                    //textBox.IsError = true;
+                    //PageNumTextIsError = true;
+                    ShowPageNumTip = Visibility.Visible;
+                    PageNumTipText = " Page number error.";
                     return false;
                 }
             }
@@ -199,33 +433,35 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 //ErrorNumTipsVisibility = Visibility.Collapsed;
                 //ErrorRangeTipsVisibility = Visibility.Visible;
-                textBox.IsError = true;
-                textBox.ShowTip = Visibility.Visible;
-                textBox.TipText = "  Page number out of range.";
+                //textBox.IsError = true;
+                //PageNumTextIsError = true;
+                ShowPageNumTip = Visibility.Visible;
+                PageNumTipText = "  Page number out of range.";
                 return false;
             }
             else
             {
-                textBox.IsError = false;
-                textBox.ShowTip = Visibility.Collapsed;
+                //textBox.IsError = false;
+                //PageNumTextIsError = false;
+                ShowPageNumTip = Visibility.Collapsed;
             }
             BtnGOorBackVisibility = Visibility.Visible;
             return true;
         }
 
-        private void SetImagePreview()
+        private void SetImagePreview(int pageIndex)
         {
             ImagePreviewVisibility = Visibility.Visible;
             BtnGOorBackVisibility = Visibility.Visible;
 
-            int dpiHeight = (int)linkAnnot.ImagePreview.Height;
-            int dpiWidth = (int)linkAnnot.ImagePreview.Width;
+            int dpiHeight = (int)ImagePreviewHeight;
+            int dpiWidth = (int)ImagePreviewWidth;
             if (dpiHeight <= 0 || dpiWidth <= 0)
             {
                 return;
             }
 
-            int pageIndex = AnnotArgs.DestIndex;
+            //int pageIndex = AnnotArgs.DestIndex;
             Rect MediaRect = GetPageRect(document, pageIndex, CPDFDisplayBox.MediaBox);
 
             System.Windows.Size pageSize = GetPageSize(document, pageIndex);
@@ -245,7 +481,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void _annotArgs_LinkDrawFinished(object sender, bool e)
         {
-            linkAnnot.SetTextBoxEnableOrNot(e, totalPage);
+            //linkAnnot.SetTextBoxEnableOrNot(e, totalPage);
+            SetTextBoxEnableOrNot(e, totalPage);
             //AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
         }
 
@@ -282,7 +519,27 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                 document = pdfViewer.Document;
                 totalPage = pdfViewer.Document.PageCount;
-                if (linkAnnot != null)
+
+                SetTextBoxEnableOrNot(false, totalPage);
+
+                if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkType))
+                {
+                    SetLinkType((LINK_TYPE)AnnotAttribEvent.Attribs[AnnotAttrib.LinkType]);
+                }
+                if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkDestIndx) && !AnnotAttribEvent.IsAnnotCreateReset)
+                {
+                    SetLinkPageNum((int)AnnotAttribEvent.Attribs[AnnotAttrib.LinkDestIndx] + 1);
+                    if (AnnotArgs == null)
+                    {
+                        backPageIndex = pdfViewer.CurrentIndex;
+                    }
+                    else
+                    {
+                        AnnotArgs.PageIndex = pdfViewer.CurrentIndex;
+                    }
+                }
+
+                if (isLoaded)
                 {
                     if (pdfViewer != null && pdfViewer.ToolManager != null && pdfViewer.ToolManager.CurrentAnnotArgs?.EventType == AnnotArgsType.AnnotLink)
                     {
@@ -291,15 +548,88 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             AnnotArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
                         }
                     }
-                    linkAnnot.SetTextBoxEnableOrNot(!AnnotAttribEvent.IsAnnotCreateReset, totalPage);
                 }
-                else
+                if (AnnotArgs == null)
                 {
                     AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
                 }
             }
         }
 
+        private void SetLinkPageNum(int pageNum)
+        {
+            if (pageNum > 0 && pageNum <= totalPage)
+            {
+                PageNumTextContent = pageNum.ToString();
+                BtnLocationIsEnabled = true;
+                PageNumTextIsEnabled = true;
+                ImagePreviewVisibility = Visibility.Visible;
+                SetImagePreview(pageNum - 1);
+            }
+        }
+
+        public void SetLinkType(LINK_TYPE linkType, bool isMail = false)
+        {
+            BtnLinkPageIsChecked = false;
+            BtnLinkMailIsChecked = false;
+            BtnLinkWebIsChecked = false;
+            switch (linkType)
+            {
+                case LINK_TYPE.GOTO:
+                    BtnLinkPageIsChecked = true;
+                    break;
+
+                case LINK_TYPE.URI:
+                    if (isMail)
+                    {
+                        BtnLinkMailIsChecked = true;
+                    }
+                    else
+                    {
+                        BtnLinkWebIsChecked = true;
+                    }
+                    break;
+
+                default:
+                    BtnLinkPageIsChecked = true;
+                    break;
+            }
+        }
+
+        private void SetTextBoxEnableOrNot(bool enable, int totalPage)
+        {
+            this.totalPage = totalPage;
+
+            PageNumTextContent = string.Empty;
+            //PageWebText.Text = string.Empty;
+            //PageMailText.Text = string.Empty;
+
+            PageNumTextIsEnabled = enable;
+            if (PageNumTextIsEnabled == true)
+            {
+                //defaultPageNumText.Text = string.Format($"1-{totalPage}页");
+                //PageNumText.PlaceholderText = string.Format($"1-{totalPage}页");
+                PageNumPlaceHoldText = string.Format($"1-{totalPage}页");
+            }
+            else
+            {
+                //defaultPageNumText.Text = "Enter target page";
+                //PageNumText.PlaceholderText = "Enter target page";
+                PageNumPlaceHoldText = "Enter target page";
+            }
+            ShowPageNumTip = Visibility.Collapsed;
+            //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;
+
+            BtnLocationIsEnabled = enable;
+            //BtnGOorBack.IsEnabled = false;
+        }
+
         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)

+ 7 - 9
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -639,19 +639,17 @@ namespace PDF_Office.ViewModels.Tools
             if (annot != null)
                 propertyPanel.annot = annot;
 
+            propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
             if (annotAttribsList != null)
             {
                 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 (annotAttribEvent.IsAnnotCreateReset)
+                    //{
+                    //    propertyPanel.AnnotEvent.IsAnnotCreateReset = true;
+
+                    //}
+                    propertyPanel.AnnotEvent = annotAttribEvent;
                 }
             }
 

+ 55 - 152
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml

@@ -28,6 +28,7 @@
             <Convert:StringToVisibleConvert x:Key="StringToVisibleConvert" />
             <Convert:StringToUnVisibleConvert x:Key="StringToUnVisibleConvert" />
             <Convert:BoolToVisible x:Key="BoolToVisible" />
+            <Convert:VisibleToBoolConvert x:Key="VisibleToBoolConvert" />
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid>
@@ -47,25 +48,14 @@
                 Margin="12,0,0,0"
                 Orientation="Horizontal">
                 <RadioButton
-                    Name="LinkPageBtn"
+                    Name="BtnLinkPage"
                     Width="75"
                     Height="28"
                     VerticalContentAlignment="Center"
                     GroupName="LinkTab"
-                    IsChecked="True"
+                    IsChecked="{Binding BtnLinkPageIsChecked}"
                     Style="{StaticResource PageViewRadioBtn}"
                     Tag="Page">
-                    <!--<ToggleButton.CommandParameter>
-                    <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
-                    <MultiBinding.Bindings>
-                    <Binding ElementName="LinkPageBtn" />
-                    -->
-                    <!--<Binding ElementName="LinkWebBtn" />
-                    <Binding ElementName="LinkMailBtn" />-->
-                    <!--
-                    </MultiBinding.Bindings>
-                    </MultiBinding>
-                    </ToggleButton.CommandParameter>-->
                     <StackPanel>
                         <Path
                             Margin="8,8,8,8"
@@ -92,13 +82,13 @@
                 </RadioButton>
 
                 <RadioButton
-                    Name="LinkWebBtn"
+                    Name="BtnLinkWeb"
                     Width="75"
                     Height="28"
                     VerticalContentAlignment="Center"
                     Background="Transparent"
                     GroupName="LinkTab"
-                    IsChecked="False"
+                    IsChecked="{Binding BtnLinkWebIsChecked}"
                     Style="{StaticResource PageViewRadioBtn}"
                     Tag="Web">
                     <StackPanel>
@@ -132,13 +122,13 @@
                 </RadioButton>
 
                 <RadioButton
-                    Name="LinkMailBtn"
+                    Name="BtnLinkMail"
                     Width="75"
                     Height="28"
                     VerticalContentAlignment="Center"
                     Background="Transparent"
                     GroupName="LinkTab"
-                    IsChecked="False"
+                    IsChecked="{Binding BtnLinkMailIsChecked}"
                     Style="{StaticResource PageViewRadioBtn}"
                     Tag="Mail">
                     <StackPanel>
@@ -156,18 +146,18 @@
                     </StackPanel>
                 </RadioButton>
             </StackPanel>
-            <Line
-                Width="232"
-                Margin="0,4,0,0"
-                HorizontalAlignment="Center"
-                Stroke="#1A000000"
-                StrokeThickness="1"
-                X1="0"
-                X2="232"
-                Y1="0"
-                Y2="0" />
+            <!--<Line
+            Width="232"
+            Margin="0,4,0,0"
+            HorizontalAlignment="Center"
+            Stroke="#1A000000"
+            StrokeThickness="1"
+            X1="0"
+            X2="232"
+            Y1="0"
+            Y2="0" />-->
             <Grid MinWidth="260">
-                <StackPanel Name="LinkPagePanel" Visibility="{Binding ElementName=LinkPageBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
+                <StackPanel Name="LinkPagePanel" Visibility="{Binding ElementName=BtnLinkPage, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
                     <TextBlock
                         x:Name="TxtPage"
                         Height="20"
@@ -198,106 +188,21 @@
                                 Width="228"
                                 Margin="16,0"
                                 VerticalContentAlignment="Center"
-                                IsEnabled="False"
-                                ShowTip="Collapsed"
-                                Text="Enter target page"
-                                TipText=" Page number error.">
-                                <i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="TextChanged">
-                                        <i:InvokeCommandAction Command="{Binding PageNumTextChangedCommand}" PassEventArgsToCommand="True" />
-                                    </i:EventTrigger>
-                                </i:Interaction.Triggers>
-                            </CustomControl:TextBoxWithTip>
-                            <!--<Border
-                            Name="BorderPageNumText"
-                            Width="228"
-                            Height="32"
-                            Margin="16,0"
-                            Background="LightGray"
-                            BorderBrush="#1770F4"
-                            BorderThickness="1"
-                            CornerRadius="4">
-                            <TextBox
-                            Name="PageNumText"
-                            VerticalContentAlignment="Center"
-                            Background="Transparent"
-                            BorderThickness="0"
-                            IsEnabled="False">
-                            <i:Interaction.Triggers>
-                            <i:EventTrigger EventName="TextChanged">
-                            <i:InvokeCommandAction Command="{Binding PageNumTextChangedCommand}" PassEventArgsToCommand="True" />
-                            </i:EventTrigger>
-                            </i:Interaction.Triggers>
-                            </TextBox>
-                            </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}">
-                            Enter target page
-                            </TextBlock>
-                            <Button
-                            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>
-                            <Path Fill="#333333">
-                            <Path.Data>
-                            M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,
-                            14.9852814 L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
-                            </Path.Data>
-                            <Path.RenderTransform>
-                            <TransformGroup>
-                            <TranslateTransform X="-8" />
-                            <RotateTransform Angle="45" />
-                            <TranslateTransform X="13" />
-                            </TransformGroup>
-                            </Path.RenderTransform>
-                            </Path>
-                            </Button.Content>
-                            </Button>-->
+                                IsEnabled="{Binding PageNumTextIsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                IsError="{Binding ElementName=PageNumText, Path=ShowTip, Converter={StaticResource VisibleToBoolConvert}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                PlaceHoldText="{Binding PageNumPlaceHoldText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                ShowTip="{Binding ShowPageNumTip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                Text="{Binding PageNumTextContent, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                TipText="{Binding PageNumTipText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                         </Grid>
-
-                        <!--<TextBlock
-                        Name="PageNumBlock"
-                        Height="20"
-                        Margin="8,0,0,0"
-                        VerticalAlignment="Center"
-                        FontFamily="Segoe UI"
-                        FontSize="14"
-                        LineHeight="20"
-                        TextAlignment="Center" />-->
                     </StackPanel>
-                    <!--<TextBlock
-                    Name="ErrorNumTips"
-                    Margin="12,0,0,0"
-                    Foreground="Red"
-                    Visibility="{Binding ErrorNumTipsVisibility}">
-                    Page number error.
-                    </TextBlock>
-                    <TextBlock
-                    Name="ErrorRangeTips"
-                    Margin="12,0,0,0"
-                    Foreground="Red"
-                    Visibility="{Binding ErrorRangeTipsVisibility}">
-                    Page number out of range.
-                    </TextBlock>-->
                     <Button
                         Name="BtnLocation"
                         Width="228"
                         Height="32"
                         Margin="16,16,16,0"
-                        IsEnabled="False"
-                        Style="{StaticResource Btn.cta}">
+                        IsEnabled="{Binding BtnLocationIsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        Style="{StaticResource btn.sec-icon}" Command="{Binding LocationCommand}">
                         <Button.Content>
                             <StackPanel Orientation="Horizontal">
                                 <Path
@@ -305,20 +210,20 @@
                                     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="White" />
+                                    Fill=" #616469" />
                                 <TextBlock Margin="10,0" Text="Locate the target page" />
                             </StackPanel>
                         </Button.Content>
                     </Button>
                     <Image
                         Name="ImagePreview"
-                        Width="196"
-                        Height="254"
+                        Width="{Binding ImagePreviewWidth}"
+                        Height="{Binding ImagePreviewHeight}"
                         Margin="32"
                         Source="{Binding PreviewImage}"
                         Visibility="{Binding ImagePreviewVisibility}" />
                 </StackPanel>
-                <StackPanel Name="LinkWebPanel" Visibility="{Binding ElementName=LinkWebBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
+                <StackPanel Name="LinkWebPanel" Visibility="{Binding ElementName=BtnLinkWeb, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
                     <TextBlock
                         Height="20"
                         Margin="16,12,0,4"
@@ -388,7 +293,7 @@
                         Invalid link.
                     </TextBlock>
                 </StackPanel>
-                <StackPanel Name="LinkMailPanel" Visibility="{Binding ElementName=LinkMailBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
+                <StackPanel Name="LinkMailPanel" Visibility="{Binding ElementName=BtnLinkMail, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
                     <TextBlock
                         Height="20"
                         Margin="16,12,0,4"
@@ -467,33 +372,31 @@
                 x:Name="BtnGOorBack"
                 Background="Transparent"
                 BorderThickness="0"
-                Content="GO"
+                Command="{Binding BtnGOorBackPageCommand}"
+                Content="{Binding BtnGOorBackContent}"
                 FontSize="16"
-                Foreground="#1770F4"
-                Style="{StaticResource Btn.cta}"
-                Visibility="{Binding BtnGOorBackVisibility}" />
+                Style="{StaticResource btn.link}"
+                Tag="GO"
+                Visibility="{Binding BtnGOorBackVisibility}">
+                <Button.CommandParameter>
+                    <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
+                        <MultiBinding.Bindings>
+                            <Binding ElementName="BtnGOorBack" />
+                            <Binding ElementName="BtnLinkPage" />
+                            <Binding ElementName="BtnLinkWeb" />
+                            <Binding ElementName="BtnLinkMail" />
+                        </MultiBinding.Bindings>
+                    </MultiBinding>
+                </Button.CommandParameter>
+            </Button>
         </StackPanel>
     </Grid>
-    <i:Interaction.Triggers>
-        <i:EventTrigger EventName="Loaded">
-            <helper:AdvancedInvokeCommandAction
-                Command="{Binding LoadedCommand}"
-                CommandParameter="{Binding ElementName=LinkAnnotPropertyContent}"
-                PassEventArgsToCommand="True">
-                <!--<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>
+    <!--<i:Interaction.Triggers>
+    <i:EventTrigger EventName="Loaded">
+    <helper:AdvancedInvokeCommandAction
+    Command="{Binding LoadedCommand}"
+    CommandParameter="{Binding ElementName=LinkAnnotPropertyContent}"
+    PassEventArgsToCommand="True" />
+    </i:EventTrigger>
+    </i:Interaction.Triggers>-->
 </UserControl>

+ 3 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml.cs

@@ -59,7 +59,9 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             BorderPageMailText.Background = enable ? Brushes.White : Brushes.LightGray;
 
             BtnGOorBack.IsEnabled = false;
-            BtnLocation.IsEnabled = enable;
+            //BtnLocation.IsEnabled = enable;
         }
+
+
     }
 }