Browse Source

安全 - 调整阅读页逻辑与工具栏一致

liuaoran 1 year ago
parent
commit
6996fb0872

+ 8 - 8
PDF Office/MultilingualResources/PDF Office.zh-Hant.xlf

@@ -813,11 +813,11 @@
           <target state="new">Add an Open File</target>
         </trans-unit>
         <trans-unit id="Merge_Hint" translate="yes" xml:space="preserve">
-          <source>Selected files
-Drop files here or Click “Add Files” at bottom right button. 
+          <source>Selected files
+Drop files here or Click “Add Files” at bottom right button. 
 Drag files to reorder as you need.</source>
-          <target state="new">Selected files
-Drop files here or Click “Add Files” at bottom right button. 
+          <target state="new">Selected files
+Drop files here or Click “Add Files” at bottom right button. 
 Drag files to reorder as you need.</target>
         </trans-unit>
         <trans-unit id="Merge_ItemPages" translate="yes" xml:space="preserve">
@@ -1394,16 +1394,16 @@ Drag files to reorder as you need.</target>
           <note from="MultilingualBuild" annotates="source" priority="2">阅读页底部工具栏-缩放菜单适应页面选项</note>
         </trans-unit>
         <trans-unit id="Convert_PDFToCSVADocment" translate="yes" xml:space="preserve">
-          <source>Create a single worksheet for
+          <source>Create a single worksheet for
 a document</source>
-          <target state="new">Create a single worksheet for
+          <target state="new">Create a single worksheet for
 a document</target>
           <note from="MultilingualBuild" annotates="source" priority="2">PDF转CSV-所有表格转为一个CSV文件</note>
         </trans-unit>
         <trans-unit id="Convert_PDFToCSVEachForm" translate="yes" xml:space="preserve">
-          <source>Create worksheets for each
+          <source>Create worksheets for each
 form</source>
-          <target state="new">Create worksheets for each
+          <target state="new">Create worksheets for each
 form</target>
           <note from="MultilingualBuild" annotates="source" priority="2">PDF转CSV-每个表格转为一个CSV文件</note>
         </trans-unit>

File diff suppressed because it is too large
+ 2633 - 2632
PDF Office/PDF Master.csproj


+ 3 - 3
PDF Office/Strings/MainPage/MainPage.Designer.cs

@@ -918,8 +918,8 @@ namespace PDF_Master.Strings.MainPage {
         }
         
         /// <summary>
-        ///   查找类似 Selected files
-        ///Drop files here or Click “Add Files” at bottom right button. 
+        ///   查找类似 Selected files
+        ///Drop files here or Click “Add Files” at bottom right button. 
         ///Drag files to reorder as you need. 的本地化字符串。
         /// </summary>
         public static string Merge_Hint {
@@ -3251,7 +3251,7 @@ namespace PDF_Master.Strings.MainPage {
         }
         
         /// <summary>
-        ///   查找类似 ege : 1,3-5,10 的本地化字符串。
+        ///   查找类似 ege :  1,3-5, 10 的本地化字符串。
         /// </summary>
         public static string WritableComboBox_CustomRangeEge {
             get {

+ 3 - 3
PDF Office/Strings/MainPage/MainPage.resx

@@ -421,8 +421,8 @@ form</value>
     <value>Add an Open File</value>
   </data>
   <data name="Merge_Hint" xml:space="preserve">
-    <value>Selected files
-Drop files here or Click “Add Files” at bottom right button. 
+    <value>Selected files
+Drop files here or Click “Add Files” at bottom right button. 
 Drag files to reorder as you need.</value>
   </data>
   <data name="Merge_ItemPages" xml:space="preserve">
@@ -1226,7 +1226,7 @@ Drag files to reorder as you need.</value>
     <value>Custom Range</value>
   </data>
   <data name="WritableComboBox_CustomRangeEge" xml:space="preserve">
-    <value>ege : 1,3-5,10</value>
+    <value>ege :  1,3-5, 10</value>
   </data>
   <data name="WritableComboBox_EvenPage" xml:space="preserve">
     <value>Even Pages</value>

+ 1 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs

@@ -398,7 +398,7 @@ namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             HomePagePrinterModRegionName = Guid.NewGuid().ToString();
 
             CancelCommand = new DelegateCommand(Cancel);
-            ConfirmPrintCommand = new DelegateCommand(ConfirmPrint);
+            ConfirmPrintCommand = new DelegateCommand(ConfirmPrint); 
             ChangePrintModCommand = new DelegateCommand<object>(ChangePrintMod);
             SetPaperCommand = new DelegateCommand(SetPaper);
             SelectPrinterCommand = new DelegateCommand<object>(SelectPrinter);

+ 1 - 1
PDF Office/ViewModels/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialogViewModel.cs

@@ -20,7 +20,7 @@ using ComPDFKitViewer.PdfViewer;
 using Prism.Regions;
 using PDF_Master.Helper;
 using System.Diagnostics;
-
+            
 namespace PDF_Master.ViewModels.Dialog.ToolsDialogs.SaftyDialogs
 {
     public class SetPasswordDialogViewModel : BindableBase, IDialogAware

+ 5 - 5
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -105,13 +105,13 @@ namespace PDF_Master.ViewModels.Tools
         private void PDFViewer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
             if (e.ClickCount == 1)
-            {
+            {
                 //不禁止取消选中注释
                 PDFViewer.DisableClearSelectAnnot(false);
 
                 PropertyPanel.IsSharpAnnotSelected = true;
                 //PDFViewer.ClearSelectAnnots();
-                //BOTA所有列表都需要响应 单击阅读页取消多选
+                //BOTA所有列表都需要响应 单击阅读页取消多选
                 if (viewContentViewModel.OpenBOTA == true)
                 {
                     this.events.GetEvent<CleanSelectAllEvent>().Publish(new CleanSelectAllArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsCleanSelectAll = true });
@@ -138,7 +138,7 @@ namespace PDF_Master.ViewModels.Tools
                         {
                             var point = e.GetPosition(ui);
                             int pageIndex = 0;
-                            Point pagePoint = new Point(0, 0);
+                            Point pagePoint = new Point(0, 0);
 
                             PDFViewer.ConvertViewPointToPage(point, out pageIndex, out pagePoint);
                             if (pagePoint.X >= rect.Left && pagePoint.X <= rect.Right && pagePoint.Y >= rect.Top && pagePoint.Y <= rect.Bottom)
@@ -428,8 +428,8 @@ namespace PDF_Master.ViewModels.Tools
                             }
 
                             GetSelectedAnnots(e);
-                            SelectedSignature(e.AnnotItemsList);
-
+                            SelectedSignature(e.AnnotItemsList);
+
                             if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty
                                 && annot.EventType != AnnotArgsType.AnnotStamp && StrAnnotToolChecked != "Signature"
                                 && annot.EventType != AnnotArgsType.AnnotLink)

+ 5 - 5
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -126,12 +126,12 @@ namespace PDF_Master.ViewModels.Tools
             Link_MenuCommand = new DelegateCommand<object>(Link_Menu);
 
             #endregion 注释 - 右键菜单
-        }
-
+        }
+
         #endregion 初始化
-
+
         #region 注释工具栏 -》Command实现
-
+
         private void ShowOrHiddenAnnot_Click(CustomIconToggleBtn annotBtn)
         {
             if (annotBtn == null || annotBtn.Tag == null) return;
@@ -157,7 +157,7 @@ namespace PDF_Master.ViewModels.Tools
             }
         }
 
-        //手型工具
+        //手型工具
         private void Hand_Click()
         {
             HandToolIsCheckedEvent(BtnHandIsChecked);

+ 0 - 1
PDF Office/ViewModels/Tools/ToolsBarContentViewModel.cs

@@ -187,7 +187,6 @@ namespace PDF_Master.ViewModels.Tools
             }
         }
 
-
         private void OpenCompressDialog()
         {
             DialogParameters value = new DialogParameters();

+ 40 - 20
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -41,6 +41,7 @@ using PDF_Master.Model.FillAndSign;
 using PDF_Master.Views.PropertyPanel.ViewModular;
 using PDF_Master.Views.PropertyPanel;
 using System.Windows.Threading;
+using Dropbox.Api.Files;
 
 namespace PDF_Master.ViewModels
 {
@@ -271,6 +272,8 @@ namespace PDF_Master.ViewModels
         /// <summary>
         /// 顶部提示栏的显示状态
         /// </summary>
+        public bool IsFileLocked = false;
+       
         public Visibility TipVisible
         {
             get { return tipVisible; }
@@ -1164,7 +1167,11 @@ namespace PDF_Master.ViewModels
         /// </summary>
         private void decrypt()
         {
-            if (!PDFViewer.Document.IsEncrypted)
+            ///无可用安全性设置的原因:
+            ///文件本身无安全性设置,且没有设置过密码
+            ///文件安全性已经被重置
+            ///
+            if ((!PDFViewer.Document.IsEncrypted && !SecurityInfo.IsPasswordChanged) || (SecurityInfo.IsPasswordRemoved))
             {
                 MessageBoxEx.Show("No security settings available ");
             }
@@ -1175,14 +1182,24 @@ namespace PDF_Master.ViewModels
                 {
                     if (result.Password != null)
                     {
-                        string filePath = PDFViewer.Document.FilePath;
-                        PDFViewer.Document.Release();
-                        PDFViewer.InitDocument(filePath);
-                        PDFViewer.Document.UnlockWithPassword(result.Password);
+                        PDFViewer.Document.CheckOwnerPassword(result.Password);
                     }
+                    ShowLeftTip(false);
                     DialogParameters value = new DialogParameters();
                     value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
-                    dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
+                    value.Add(ParameterNames.ViewContentViewModel, this);
+                    dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e =>
+                    {
+                        if (e.Result == ButtonResult.OK)
+                        {
+                            if (SecurityInfo.IsPasswordRemoved)
+                            {
+                                PDFViewer.UndoManager.CanSave = true;
+                            }
+                            ShowLeftTip(false);
+                            region.RequestNavigate(TipContentRegionName, "RemoveSecuritySuccessTip");
+                        }
+                    });
                 }
             }
         }
@@ -1199,10 +1216,10 @@ namespace PDF_Master.ViewModels
                 {
                     if (result.Password != null)
                     {
-                        string filePath = PDFViewer.Document.FilePath;
-                        PDFViewer.Document.Release();
-                        PDFViewer.InitDocument(filePath);
-                        PDFViewer.Document.UnlockWithPassword(result.Password);
+                        if (PDFViewer.Document.UnlockWithPassword(result.Password))
+                        {
+                            PDFViewer.Document.CheckOwnerPassword(result.Password);
+                        } 
                     }
                 }
             }
@@ -2017,18 +2034,22 @@ namespace PDF_Master.ViewModels
             CanSave = PDFViewer.UndoManager.CanSave;
             CanUndo = PDFViewer.UndoManager.CanUndo;
             CanRedo = PDFViewer.UndoManager.CanRedo;
-            // if (passwordInfo != null && (!string.IsNullOrEmpty(passwordInfo.OpenPassword) || !string.IsNullOrEmpty(passwordInfo.PermissionsPassword)))
-            if (passwordInfo != null && (!string.IsNullOrEmpty(passwordInfo.OpenPassword)))
+            if (passwordInfo != null && (!string.IsNullOrEmpty(passwordInfo.OpenPassword) || !string.IsNullOrEmpty(passwordInfo.PermissionsPassword)))
             {
                 if (!string.IsNullOrEmpty(passwordInfo.OpenPassword))
                 {
                     PDFViewer.Document.UnlockWithPassword(passwordInfo.OpenPassword);
                 }
-                SecurityHelper.CheckHaveAllPermissions(PDFViewer.Document);
-                //if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword))
-                //{
-                //    PDFViewer.Document.UnlockWithPassword(passwordInfo.PermissionsPassword);
-                //}
+
+                if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword)&&passwordInfo.PermissionsPassword != passwordInfo.OpenPassword)
+                {
+                    IsFileLocked = true;
+                    NavigationParameters param = new NavigationParameters();
+                    param.Add(ParameterNames.PDFViewer, PDFViewer);
+                    param.Add(ParameterNames.ViewContentViewModel, this);
+                    ShowLeftTip(true);
+                    region.RequestNavigate(LeftTipContentRegionName, "FileRestrictedTip", param);
+                }
             }
             else
             {
@@ -2142,7 +2163,6 @@ namespace PDF_Master.ViewModels
         /// </summary>
         public bool saveFile()
         {
-            bool isFileLocked = false;
             try
             {
                 if (string.IsNullOrEmpty(PDFViewer.Document.FilePath) || mainViewModel.NewFile)
@@ -2225,7 +2245,7 @@ namespace PDF_Master.ViewModels
                                 if (!string.IsNullOrEmpty(permissionsPassword) && openPassword != permissionsPassword)
                                 {
                                     //PDFViewer.Document.CheckOwnerPassword(permissionsPassword);
-                                    isFileLocked = true;
+                                    IsFileLocked = true;
                                     NavigationParameters param = new NavigationParameters();
                                     param.Add(ParameterNames.PDFViewer, PDFViewer);
                                     param.Add(ParameterNames.ViewContentViewModel, this);
@@ -2346,7 +2366,7 @@ namespace PDF_Master.ViewModels
             catch { return false; }
             finally
             {
-                if (!isFileLocked)
+                if (!IsFileLocked)
                 {
                     ShowLeftTip(false);
                 }

+ 4 - 4
PDF Office/Views/Dialog/ConverterDialogs/ConverterCSVDialog.xaml

@@ -91,10 +91,10 @@
         </cus:DialogContent.Content>
         <cus:DialogContent.BottmBar>
             <Grid>
-                <!--<Button Background="WhiteSmoke" Width="98" Height="32" Margin="0,0,400,0" Command="{Binding BatchConverterCommand}"  Style="{StaticResource btn.sec}">
-                    <Border>
-                        <TextBlock Text="批量处理" ></TextBlock>
-                    </Border>
+                <!--<Button Background="WhiteSmoke" Width="98" Height="32" Margin="0,0,400,0" Command="{Binding BatchConverterCommand}"  Style="{StaticResource btn.sec}">
+                    <Border>
+                        <TextBlock Text="批量处理" ></TextBlock>
+                    </Border>
                 </Button>-->
                 <Button
                     Width="98"

+ 2 - 2
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialog.xaml

@@ -112,7 +112,7 @@
                                 <TextBlock Text="{Binding T_PrintSettings}" FontFamily="Segoe UI" FontSize="12" Foreground="#616469"/>
                                 <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                                     <StackPanel Orientation="Horizontal">
-                                        <TextBlock Text="Page range:" FontFamily="Segoe UI" FontSize="14" Height="22" Width="80"></TextBlock>
+                                        <TextBlock Text="Page range" FontFamily="Segoe UI" FontSize="14" Height="22" Width="82"></TextBlock>
                                         <cus:WritableComboBox  x:Name="PageRangeComboBox" Loaded="PageRangeComboBox_Loaded" Text="{Binding CustomRangeString, Mode=TwoWay}" Width="132" Height="32" Margin="16,0,0,0" MaxPageRange="{Binding MaxPageRange, Mode=TwoWay}"  SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}">
                                             <i:Interaction.Triggers>
                                                 <i:EventTrigger EventName="SelectionChanged">
@@ -136,7 +136,7 @@
                                     </StackPanel>
                                 </StackPanel>
                                 <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                                    <TextBlock Text="{Binding T_PrintContent}" FontFamily="Segoe UI" FontSize="14" Height="22" Width="80"></TextBlock>
+                                    <TextBlock Text="{Binding T_PrintContent}" FontFamily="Segoe UI" FontSize="14" Height="22" Width="82"></TextBlock>
                                     <ComboBox Name="PrintContentCbx" Width="377" Height="32" Margin="16,0,16,0"  ItemsSource="{Binding PrintContentList}"  SelectedIndex="{Binding PrintContentIndex}" >
                                         <i:Interaction.Triggers>
                                             <i:EventTrigger EventName="SelectionChanged">

+ 4 - 4
PDF Office/Views/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialog.xaml

@@ -57,7 +57,7 @@
                                     <ColumnDefinition></ColumnDefinition>
                                     <ColumnDefinition Width="24"></ColumnDefinition>
                                 </Grid.ColumnDefinitions>
-                                <Grid Grid.Column="0">
+                                <Grid Grid.Column="0" Margin="8,0,0,0">
                                     <TextBlock Text="{TemplateBinding help:PasswordBoxHelper.DisplayText}" Grid.Column="1" VerticalAlignment="Center" Foreground="#BBB"
                                            Name="markText" Visibility="Collapsed" FontSize="12" />
                                     <ScrollViewer x:Name="PART_ContentHost" Focusable="false"
@@ -103,7 +103,7 @@
                                     <ColumnDefinition></ColumnDefinition>
                                     <ColumnDefinition Width="24"></ColumnDefinition>
                                 </Grid.ColumnDefinitions>
-                                <Grid Grid.Column="0">
+                                <Grid Grid.Column="0" Margin="8,0,0,0">
                                     <TextBlock Text="{TemplateBinding help:PasswordBoxHelper.DisplayText}" Grid.Column="1" VerticalAlignment="Center" Foreground="#BBB"
                                            Name="markText" Visibility="Collapsed" FontSize="12" />
                                     <ScrollViewer x:Name="PART_ContentHost" Focusable="false"
@@ -149,7 +149,7 @@
                                     <ColumnDefinition></ColumnDefinition>
                                     <ColumnDefinition Width="24"></ColumnDefinition>
                                 </Grid.ColumnDefinitions>
-                                <Grid Grid.Column="0">
+                                <Grid Grid.Column="0"  Margin="8,0,0,0">
                                     <TextBlock Text="{TemplateBinding help:PasswordBoxHelper.DisplayText}" Grid.Column="1" VerticalAlignment="Center" Foreground="#BBB"
                                            Name="markText" Visibility="Collapsed" FontSize="12" />
                                     <ScrollViewer x:Name="PART_ContentHost" Focusable="false"
@@ -195,7 +195,7 @@
                                     <ColumnDefinition></ColumnDefinition>
                                     <ColumnDefinition Width="24"></ColumnDefinition>
                                 </Grid.ColumnDefinitions>
-                                <Grid Grid.Column="0">
+                                <Grid Grid.Column="0"  Margin="8,0,0,0">
                                     <TextBlock Text="{TemplateBinding help:PasswordBoxHelper.DisplayText}" Grid.Column="1" VerticalAlignment="Center" Foreground="#BBB"
                                            Name="markText" Visibility="Collapsed" FontSize="12" />
                                     <ScrollViewer x:Name="PART_ContentHost" Focusable="false"