Browse Source

注释-链接UI

OYXH\oyxh 2 years ago
parent
commit
f29c01f4d2

+ 49 - 0
PDF Office/Styles/ToggleButton.xaml

@@ -1,5 +1,54 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
     <!--  Design Token for subtool  -->
+    <Style x:Key="LinkToolbarTgb" TargetType="{x:Type ToggleButton}">
+        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
+        <Setter Property="Background" Value="Transparent" />
+        <Setter Property="BorderThickness" Value="0" />
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type ToggleButton}">
+                    <Border
+                        x:Name="border"
+                        Background="{TemplateBinding Panel.Background}"
+                        BorderBrush="{StaticResource color.field.border.norm}"
+                        BorderThickness="1"
+                        CornerRadius="{StaticResource border-radius.4}"
+                        SnapsToDevicePixels="True">
+                        <ContentPresenter
+                            x:Name="contentPresenter"
+                            Margin="{TemplateBinding Padding}"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Content="{TemplateBinding Content}"
+                            ContentStringFormat="{TemplateBinding ContentStringFormat}"
+                            ContentTemplate="{TemplateBinding ContentTemplate}"
+                            Focusable="False"
+                            RecognizesAccessKey="True"
+                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource color.field.border.focus}" />
+                            <!--<Setter TargetName="border" Property="Panel.Background" Value="{StaticResource color.field.border.focus}" />-->
+                        </Trigger>
+
+                        <Trigger Property="IsPressed" Value="True">
+                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource color.field.border.focus}" />
+                        </Trigger>
+                        <Trigger Property="IsChecked" Value="True">
+                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource color.field.border.focus}" />
+                        </Trigger>
+                        <Trigger Property="IsChecked" Value="False">
+                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource color.field.border.norm}" />
+                        </Trigger>
+                        <Trigger Property="IsEnabled" Value="False">
+                            <Setter TargetName="border" Property="Panel.Background" Value="Transparent" />
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
     <Style x:Key="SubToolbarTgb" TargetType="{x:Type ToggleButton}">
         <Setter Property="FocusVisualStyle" Value="{x:Null}" />
         <Setter Property="Background" Value="Transparent" />

+ 17 - 4
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -97,6 +97,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 {
                     ImagePreviewVisibility = Visibility.Collapsed;
                     BtnGOorBackVisibility = Visibility.Collapsed;
+                    BtnLocationIsEnabled = false;
                 }
                 return pageNumTextContent;
             }
@@ -314,6 +315,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private bool btnLocationIsChecked = false;
+
+        public bool BtnLocationIsChecked
+        {
+            get { return btnLocationIsChecked; }
+            set
+            {
+                SetProperty(ref btnLocationIsChecked, value);
+            }
+        }
+
         private WriteableBitmap previewImage;
 
         public WriteableBitmap PreviewImage
@@ -671,14 +683,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         /// <summary>
         /// 定位目标范围
         /// </summary>
-        /// <param name="obj"></param> 
+        /// <param name="obj"></param>
         private void LocationPage(object obj)
         {
             pdfViewer.EnableDrawSelectArea(true);
             historyPageIndex = pdfViewer.CurrentIndex;
             PageNumTextIsEnabled = false;
             isSelected = false;
-
+            BtnLocationIsChecked = true;
             bool isExist = false;
             if (region.Regions.ContainsRegionWithName(viewContentViewModel.TipContentRegionName))
             {
@@ -696,7 +708,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 region.RequestNavigate(viewContentViewModel.TipContentRegionName, "LinkAnnotTip");
             }
-            if(string.IsNullOrEmpty(PageNumTextContent))
+            //if(string.IsNullOrEmpty(PageNumTextContent))
             viewContentViewModel.ShowTip(true);
         }
 
@@ -953,7 +965,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         {
             ImagePreviewVisibility = Visibility.Visible;
             BtnGOorBackVisibility = Visibility.Visible;
-
+            BtnLocationIsEnabled = true;
             int dpiHeight = (int)ImagePreviewHeight;
             int dpiWidth = (int)ImagePreviewWidth;
             if (dpiHeight <= 0 || dpiWidth <= 0)
@@ -1107,6 +1119,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         pdfViewer.GoToPage(historyPageIndex);
                         //viewContentViewModel.LinkAnnotTipVisibility = Visibility.Collapsed;
                         viewContentViewModel.TipVisible = Visibility.Collapsed;
+                        BtnLocationIsChecked = false;
                     }
                 }
             }

+ 8 - 7
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -143,7 +143,6 @@ namespace PDF_Office.ViewModels.Tools
                         if (e.IsAnnotCreateReset == false)
                         {
                             GetSelectedAnnots(e);
-                            //PDFViewer.SetToolParam(annot);
                         }
                         else
                         {
@@ -211,13 +210,11 @@ namespace PDF_Office.ViewModels.Tools
                             }
                         }
 
-
                         if (isDifferentAnnotTyle)
                             viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
                         else
                             GetSelectedAnnots(e);
                     }
-
                 }
 
                 //注释列表同步选中
@@ -244,10 +241,9 @@ namespace PDF_Office.ViewModels.Tools
             }
             else
             {
-
-                viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                if (BtnLinkIsChecked == false)
+                    viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
             }
-
         }
 
         private bool isShapAnnot(AnnotHandlerEventArgs annot)
@@ -383,23 +379,29 @@ namespace PDF_Office.ViewModels.Tools
                                     case AnnotArgsType.AnnotSquiggly:
                                         e.PopupMenu = SelectHightAnnotMenu(selectedAnnot);
                                         break;
+
                                     case AnnotArgsType.AnnotFreehand:
                                         e.PopupMenu = SelectFreeHandAnnotMenu(sender);
                                         break;
+
                                     case AnnotArgsType.AnnotFreeText:
                                         e.PopupMenu = SelectFreeTextAnnotMenu(sender);
                                         break;
+
                                     case AnnotArgsType.AnnotSticky:
                                         e.PopupMenu = SelectStrickNoteAnnotMenu(sender);
                                         break;
+
                                     case AnnotArgsType.AnnotSquare:
                                     case AnnotArgsType.AnnotLine:
                                     case AnnotArgsType.AnnotCircle:
                                         e.PopupMenu = SelectShapeAnnotMenu(sender);
                                         break;
+
                                     case AnnotArgsType.AnnotLink:
                                         e.PopupMenu = SelectHightAnnotMenu(sender);
                                         break;
+
                                     case AnnotArgsType.AnnotStamp:
                                         e.PopupMenu = SelectHightAnnotMenu(sender);
                                         break;
@@ -419,7 +421,6 @@ namespace PDF_Office.ViewModels.Tools
 
                                 e.PopupMenu = SelectMultiAnnotMenu(sender, isHigh);
                             }
-
                         }
                         if (e.PopupMenu != null)
                         {

+ 24 - 22
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml

@@ -200,28 +200,30 @@
                             </i:Interaction.Triggers>
                         </CustomControl:TextBoxWithTip>
                     </StackPanel>
-                    <Border CornerRadius="4" Width="228"
-                            Height="32"
-                            Margin="16,30,16,0" BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="1">
-                        <ToggleButton
-                            Name="BtnLocation"
-                            BorderThickness="0" BorderBrush="Transparent"
-                            Command="{Binding LocationCommand}"
-                            IsEnabled="{Binding BtnLocationIsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                            Background="Transparent">
-                            <ToggleButton.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="定位目标区域" />
-                                </StackPanel>
-                            </ToggleButton.Content>
-                        </ToggleButton>
-                    </Border>
+                    <ToggleButton
+                        Name="BtnLocation"
+                        Width="228"
+                        Height="32"
+                        Margin="16,30,16,0"
+                        Background="Transparent"
+                        BorderBrush="Transparent"
+                        BorderThickness="0"
+                        Command="{Binding LocationCommand}"
+                        IsChecked="{Binding BtnLocationIsChecked}"
+                        IsEnabled="{Binding BtnLocationIsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        Style="{StaticResource LinkToolbarTgb}">
+                        <ToggleButton.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="定位目标区域" />
+                            </StackPanel>
+                        </ToggleButton.Content>
+                    </ToggleButton>
                     <Image
                         Name="ImagePreview"
                         Width="{Binding ImagePreviewWidth}"