Browse Source

综合-补充、优化功能

OYXH\oyxh 2 years ago
parent
commit
6e4d1044fe

+ 9 - 1
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -995,7 +995,15 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 document = pdfViewer.Document;
                 totalPage = pdfViewer.Document.PageCount;
 
-                SetTextBoxEnableOrNot(false, totalPage);
+
+                if (viewContentViewModel.IsCreateLink)
+                {
+                    SetTextBoxEnableOrNot(true, totalPage);
+                }
+                else
+                {
+                    SetTextBoxEnableOrNot(false, totalPage);
+                }
                 if (AnnotAttribEvent.IsAnnotCreateReset == false)
                 {
                     GetAnnotAttribute();

+ 17 - 1
PDF Office/ViewModels/PropertyPanel/ViewModular/ReadViewContentViewModel.cs

@@ -9,6 +9,7 @@ using System.Collections.Generic;
 using System.Drawing;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
 
@@ -21,6 +22,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
 
         public CPDFViewer PDFViewer { get; set; }
 
+        private Visibility pressEscTip = Visibility.Visible;
+
+        public Visibility PressEscTip
+        {
+            get { return pressEscTip; }
+            set
+            {
+                SetProperty(ref pressEscTip, value);
+            }
+        }
+
         private bool canSave;
 
         /// <summary>
@@ -115,13 +127,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.ViewModular
         {
         }
 
-        public void OnNavigatedTo(NavigationContext navigationContext)
+        public async void OnNavigatedTo(NavigationContext navigationContext)
         {
             var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
             if (pdfview != null)
             {
                 PDFViewer = pdfview;
+                PressEscTip = Visibility.Visible;
                 LoadFile();
+
+                await System.Threading.Tasks.Task.Delay(3000);
+                PressEscTip = Visibility.Collapsed;
             }
         }
 

+ 1 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -674,6 +674,7 @@ namespace PDF_Office.ViewModels.Tools
 
             if (string.IsNullOrEmpty(viewContent) == false)
             {
+
                 viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
             }
         }

+ 6 - 3
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -144,6 +144,7 @@ namespace PDF_Office.ViewModels.Tools
                         break;
 
                     case "Link":
+                        viewContentViewModel.IsCreateLink = false;
                         annotArgs = GetLink();
                         break;
                 }
@@ -688,7 +689,9 @@ namespace PDF_Office.ViewModels.Tools
                                 break;
 
                             case AnnotArgsType.AnnotLink:
+                                viewContentViewModel.IsCreateLink = false;
                                 GetLink(annot as LinkAnnotArgs, e);
+
                                 break;
 
                             case AnnotArgsType.AnnotSticky:
@@ -746,7 +749,7 @@ namespace PDF_Office.ViewModels.Tools
                     {
                         if (e.PressOnSelectedText)
                         {
-                            e.PopupMenu = NoneSelectAnnotContextMenu(sender);
+                            e.PopupMenu = NoneSelectAnnotContextMenu(sender, e);
                             if (e.PopupMenu != null)
                             {
                                 e.Handle = true;
@@ -784,7 +787,7 @@ namespace PDF_Office.ViewModels.Tools
             return popMenu;
         }
 
-        private ContextMenu NoneSelectAnnotContextMenu(object sender)
+        private ContextMenu NoneSelectAnnotContextMenu(object sender, AnnotCommandArgs annotCommand)
         {
             var popMenu = new ContextMenu();
 
@@ -801,7 +804,7 @@ namespace PDF_Office.ViewModels.Tools
             menuItem = new MenuItem();
             menuItem.CommandTarget = (UIElement)sender;
             menuItem.Header = "创建链接";
-            menuItem.CommandParameter = this;
+            menuItem.CommandParameter = new object[] { this, annotCommand };
             menuItem.Command = viewContentViewModel.CreateLinkCommand;
             menuItem.Click += MenuItem_Click;
             popMenu.Items.Add(menuItem);

+ 33 - 11
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -26,6 +26,7 @@ using PDF_Office.Views.EditTools.Background;
 using PDF_Office.Views.Dialog;
 using PDF_Office.Helper;
 using System.Security.Policy;
+using System.Windows.Documents;
 
 namespace PDF_Office.ViewModels
 {
@@ -43,6 +44,8 @@ namespace PDF_Office.ViewModels
 
         public IEventAggregator events;
 
+        public bool IsCreateLink { get => isCreateLink; set => isCreateLink = value; }
+
         public string ViwerRegionName { get; set; }
 
         /// <summary>
@@ -70,6 +73,17 @@ namespace PDF_Office.ViewModels
 
         public string BackgroundContentRegionName { get; set; }
 
+        private Visibility readModelTip = Visibility.Collapsed;
+
+        public Visibility ReadModelTip
+        {
+            get { return readModelTip; }
+            set
+            {
+                SetProperty(ref readModelTip, value);
+            }
+        }
+
         /// <summary>
         /// 底部工具栏 RegionName
         /// </summary>
@@ -413,6 +427,7 @@ namespace PDF_Office.ViewModels
         }
 
         private string linkAnnotTipText = "Please use the scroll bar, thumbnail tool to locate the target page, click or box the area to select the target range";
+        private bool isCreateLink = false;
 
         public string LinkAnnotTipText
         {
@@ -518,18 +533,22 @@ namespace PDF_Office.ViewModels
         /// <param name="obj"></param>
         private void CreateLinkEvent(object obj)
         {
-            if (obj is AnnotToolContentViewModel toolContentViewModel)
+            if (obj is object[] objArry)
             {
-                LinkAnnotArgs linkArgs = new LinkAnnotArgs();
-                linkArgs.URI = string.Empty;
-                linkArgs.LinkType = LINK_TYPE.GOTO;
-                linkArgs.DestIndex = PDFViewer.CurrentIndex;
-                linkArgs.PageIndex = PDFViewer.CurrentIndex;
-                linkArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
-                AnnotHandlerEventArgs annotArgs = toolContentViewModel.GetLink(linkArgs);
-                PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
-                PDFViewer.SetToolParam(annotArgs);
-                this.IsPropertyOpen = true;
+                if (objArry[0] is AnnotToolContentViewModel toolContentViewModel && objArry[1] is AnnotCommandArgs annotCommand)
+                {
+                    LinkAnnotArgs linkArgs = new LinkAnnotArgs();
+                    linkArgs.URI = string.Empty;
+                    linkArgs.LinkType = LINK_TYPE.GOTO;
+                    linkArgs.PageIndex = annotCommand.PageIndex;
+                    //linkArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
+                    this.IsCreateLink = true;
+                    AnnotHandlerEventArgs annotArgs = toolContentViewModel.GetLink(linkArgs);
+                    PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+                    PDFViewer.SetToolParam(annotArgs);
+                    this.IsPropertyOpen = true;
+
+                }
             }
         }
 
@@ -808,6 +827,9 @@ namespace PDF_Office.ViewModels
             //isInPageEdit = false;
 
             IsLoading = Visibility.Collapsed;
+            ReadModelTip = Visibility.Visible;
+            await Task.Delay(3000);
+            ReadModelTip = Visibility.Collapsed;
         }
 
         #region PDFViewer鼠标滚轮缩放事件

+ 1 - 0
PDF Office/Views/PropertyPanel/ViewModular/ReadModeContent.xaml

@@ -27,6 +27,7 @@
             <convert:ObjectConvert x:Key="ObjectConvert" />
         </ResourceDictionary>
     </UserControl.Resources>
+
     <StackPanel Name="ParentPanel" Orientation="Horizontal">
 
         <RepeatButton

+ 22 - 15
PDF Office/Views/PropertyPanel/ViewModular/ReadViewContent.xaml

@@ -17,37 +17,39 @@
     prism:ViewModelLocator.AutoWireViewModel="True"
     KeyDown="UserControl_KeyDown"
     mc:Ignorable="d">
-    <i:Interaction.Triggers>
-        <i:EventTrigger EventName="Loaded">
-            <prism:InvokeCommandAction Command="{Binding Load}" />
-        </i:EventTrigger>
-    </i:Interaction.Triggers>
+
     <Grid>
         <ContentControl
             x:Name="PDFViewerContent"
             HorizontalAlignment="Stretch"
             prism:RegionManager.RegionName="{Binding ReadRegionName}" />
-        <TextBlock
-            x:Name="PressEscTip"
+        <Border
             Width="316"
             Height="40"
-            Padding="11"
             VerticalAlignment="Top"
             Background="{StaticResource color.sys.layout.dark.bg}"
-            Foreground="#FFFFFFFF"
-            Text="Enter reading mode, you can press ESC to exit"
-            TextAlignment="Center" />
+            CornerRadius="4"
+            Visibility="{Binding PressEscTip}">
+            <TextBlock
+                x:Name="PressEscTip"
+                Padding="11"
+                Foreground="#FFFFFFFF"
+                Text="Enter reading mode, you can press ESC to exit"
+                TextAlignment="Center" />
+        </Border>
+
         <!--  阅读模式下的页面控件  -->
-        <ContentControl
-            x:Name="ReadModeContent"
+        <Border
             Height="44"
             Margin="0,0,0,5"
             HorizontalAlignment="Center"
             VerticalAlignment="Bottom"
-            prism:RegionManager.RegionName="{Binding ReadModeRegionName}"
+            CornerRadius="4"
             MouseEnter="RectangleReadMode_MouseEnter"
             MouseLeave="ReadModeContent_MouseLeave"
-            Visibility="{Binding ReadModeContentVisibility}" />
+            Visibility="{Binding ReadModeContentVisibility}">
+            <ContentControl x:Name="ReadModeContent" prism:RegionManager.RegionName="{Binding ReadModeRegionName}" />
+        </Border>
 
         <Rectangle
             x:Name="RectangleReadMode"
@@ -60,4 +62,9 @@
             MouseEnter="RectangleReadMode_MouseEnter"
             Visibility="{Binding RectangleReadModeVisibility}" />
     </Grid>
+    <!--<i:Interaction.Triggers>
+    <i:EventTrigger EventName="Loaded">
+    <prism:InvokeCommandAction Command="{Binding Load}" />
+    </i:EventTrigger>
+    </i:Interaction.Triggers>-->
 </UserControl>

+ 16 - 1
PDF Office/Views/ViewContent.xaml

@@ -368,7 +368,7 @@
                 <ContentControl Height="{Binding ElementName=Scroller, Path=ViewportHeight}" prism:RegionManager.RegionName="{Binding PropertyRegionName}" />
             </ScrollViewer>
             <Border
-                Name="ViewContentTipPanel"
+                Name="LinkAnnotTip"
                 Grid.Column="2"
                 Width="{Binding ElementName=PDFViewerContent, Path=Width}"
                 Margin="0,0,17,0"
@@ -397,6 +397,21 @@
                         Text="Please use the scroll bar, thumbnail tool to locate the target page, click or box the area to select the target range" />
                 </WrapPanel>
             </Border>
+            <Border
+                Grid.Column="2"
+                Width="145"
+                Height="40"
+                VerticalAlignment="Top"
+                Background="{StaticResource color.sys.layout.dark.bg}" CornerRadius="4" Visibility="{Binding ReadModelTip}">
+                <TextBlock
+                    x:Name="ReadModelTip"
+                    Padding="11"
+                    VerticalAlignment="Top"
+                    Background="{StaticResource color.sys.layout.dark.bg}"
+                    Foreground="#FFFFFFFF"
+                    Text="Exit reading mode"
+                    TextAlignment="Center" />
+            </Border>
         </Grid>
 
         <!--  用于显示页面编辑、水印、背景、标记密文等功能的区域  -->