Browse Source

compdfkit(demo) - link注释自动清空, 禁用非链接模式下链接右键

liuaoran 1 year ago
parent
commit
69082a1be6

+ 0 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml

@@ -11,6 +11,5 @@
     <Grid>
             <Border x:Name="AnnotationPanelContainer" Background="#FFFFFF"></Border>
         <TextBlock x:Name="EmptyMessage" Text="The annotation panel has escaped" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
-
     </Grid>
 </UserControl>

+ 2 - 4
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFLinkUI.xaml

@@ -7,6 +7,7 @@
              xmlns:cpdfcommon="clr-namespace:compdfkit_tools.Common"
              mc:Ignorable="d" 
              Loaded="UserControl_Loaded"
+             Unloaded="UserControl_Unloaded"
              d:DesignHeight="450" d:DesignWidth="800">
     <UserControl.Resources>
         <cpdfcommon:StringToVisibilityConvert x:Key="StringToVisibilityConvert"></cpdfcommon:StringToVisibilityConvert>
@@ -429,14 +430,12 @@
                     <Grid IsEnabled="{Binding InputEnable}">
                         <TextBox Style="{DynamicResource TextBoxStyle1}" Height="28"  x:Name="UrlText" VerticalContentAlignment="Center" TextChanged="UrlText_TextChanged" VerticalAlignment="Center" Margin="16"/>
                         <TextBlock Text="https://www.compdf.com/" VerticalAlignment="Center"  Margin="22" Visibility="{Binding ElementName=UrlText, Path=Text, Converter={StaticResource StringToVisibilityConvert}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
-                        <Rectangle Fill="#BBB"   Margin="22" Height="20"  Visibility="{Binding InputEnable, Converter={StaticResource BoolToCollapsedConverter}}"></Rectangle>
                     </Grid>
                 </TabItem>
                 <TabItem Style="{DynamicResource TabItemStyle1}" Header="Go To Pages">
                     <Grid IsEnabled="{Binding InputEnable}">
                         <TextBox Style="{DynamicResource TextBoxStyle1}" Height="28"  x:Name="PageText" VerticalContentAlignment="Center" TextChanged="PageText_TextChanged" VerticalAlignment="Center" Margin="16,0,16,0" Grid.ColumnSpan="2"/>
-                        <TextBlock Text="{Binding PagePromptText}" VerticalAlignment="Center"  Margin="22,0,22,0" Visibility="{Binding ElementName=PageText, Path=Text, Converter={StaticResource StringToVisibilityConvert}}" IsHitTestVisible="False"  Foreground="#BBB" Grid.ColumnSpan="2"></TextBlock>
-                        <Rectangle Fill="#BBB" Visibility="{Binding InputEnable, Converter={StaticResource BoolToCollapsedConverter}}" Margin="22" Height="20"></Rectangle>
+                        <TextBlock Text="{Binding PagePromptText, Mode=OneWay}" VerticalAlignment="Center"  Margin="22,0,22,0" Visibility="{Binding ElementName=PageText, Path=Text, Converter={StaticResource StringToVisibilityConvert}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
                     </Grid>
                 </TabItem>
                 <TabItem Style="{DynamicResource TabItemStyle1}" Header="Email">
@@ -447,7 +446,6 @@
                         </Grid.ColumnDefinitions>
                         <TextBox Style="{DynamicResource TextBoxStyle1}" Height="28" x:Name="EmailText" VerticalContentAlignment="Center"  TextChanged="EmailText_TextChanged" VerticalAlignment="Center" Margin="16,0,16,0" Grid.ColumnSpan="2"/>
                         <TextBlock Text="support@compdf.com" VerticalAlignment="Center"  Margin="22,0,22,0" Visibility="{Binding ElementName=EmailText, Path=Text, Converter={StaticResource StringToVisibilityConvert}}" IsHitTestVisible="False"  Foreground="#BBB" Grid.ColumnSpan="2"></TextBlock>
-                        <Rectangle Fill="#BBB" Visibility="{Binding InputEnable, Converter={StaticResource BoolToCollapsedConverter}}"  Margin="22" Height="20" Grid.ColumnSpan="2"></Rectangle>
                     </Grid>
                 </TabItem>
             </TabControl>

+ 8 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFLinkUI.xaml.cs

@@ -112,6 +112,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationUI
             EmailText.Text = "";
             SaveBtn.IsEnabled = true;
             totalPage = PageCount;
+            PagePromptText = "Add a Page Number Between 1 ~ " + totalPage;
             if (AttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkDestIndx))
             {
                 int pageNum = (int)AttribEvent.Attribs[AnnotAttrib.LinkDestIndx] + 1;
@@ -425,5 +426,12 @@ namespace compdfkit_tools.Annotation.PDFAnnotationUI
                     break;
             }
         }
+
+        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
+        {
+            UrlText.Text = string.Empty;
+            PageText.Text = string.Empty;   
+            EmailText.Text = string.Empty;
+        }
     }
 }

+ 4 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/BarControl/CPDFAnnotationBarControl.xaml.cs

@@ -27,6 +27,8 @@ namespace compdfkit_tools.PDFControl
         public event EventHandler<CPDFAnnotationType> AnnotationPropertyChanged;
         public event EventHandler AnnotationCancel;
 
+        public string CurrentMode = string.Empty;
+
         public CPDFAnnotationBarControl()
         {
             InitializeComponent();
@@ -337,10 +339,12 @@ namespace compdfkit_tools.PDFControl
             if ((bool)(sender as ToggleButton).IsChecked)
             {
                 AnnotationPropertyChanged?.Invoke(sender, CPDFAnnotationDictionary.GetAnnotationFromTag[(sender as ToggleButton).Tag.ToString()]);
+                CurrentMode = (sender as ToggleButton).Tag.ToString();
             }
             else
             {
                 AnnotationCancel?.Invoke(sender, EventArgs.Empty);
+                CurrentMode = string.Empty;
             }
         }
 

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit/MainPage.xaml.cs

@@ -235,7 +235,7 @@ namespace compdfkit
                     {
                         e.Handle = true;
                         e.PopupMenu = new ContextMenu();
-                        if (e.PressOnLink)
+                        if (e.PressOnLink && AnnotationBarControl.CurrentMode == "Link")
                         {
                             e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
                             MenuItem propertyMenu = new MenuItem();