소스 검색

孙浩楠-插入页面指定到第一页前不显示页面和,删除page框中的数字再次点击报错

zhuyi 1 년 전
부모
커밋
ffcc5a9449
1개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 6
      Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageInsert/CPDFPageInsertUI.xaml.cs

+ 6 - 6
Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageInsert/CPDFPageInsertUI.xaml.cs

@@ -25,7 +25,7 @@ namespace Compdfkit_Tools.PDFControlUI
             }
         }
 
-        private int _customPageIndex;
+        private int _customPageIndex = 1;
         public int CustomPageIndex
         {
             get => _customPageIndex;
@@ -94,7 +94,7 @@ namespace Compdfkit_Tools.PDFControlUI
 
             if (filePath != string.Empty)
             {
-                CPDFDocument pdfDoc=CPDFDocument.InitWithFilePath(filePath);
+                CPDFDocument pdfDoc = CPDFDocument.InitWithFilePath(filePath);
                 if (pdfDoc.IsLocked)
                 {
                     PasswordWindow passwordWindow = new PasswordWindow();
@@ -114,15 +114,15 @@ namespace Compdfkit_Tools.PDFControlUI
                 {
                     WritableComboBoxControl.MaxPageIndex = pdfDoc.PageCount;
                     FilePathTextBox.Text = filePath;
-                    PasswordChanged?.Invoke(sender, string.Empty); 
+                    PasswordChanged?.Invoke(sender, string.Empty);
                     SelectedFileChanged?.Invoke(sender, filePath);
-                } 
+                }
             }
         }
 
         private void PasswordWindow_DialogClosed(object sender, PasswordEventArgs e)
         {
-            if(e.DialogResult != string.Empty)
+            if (e.DialogResult != string.Empty)
             {
                 password = e.DialogResult;
                 PasswordChanged?.Invoke(sender, e.DialogResult);
@@ -148,7 +148,7 @@ namespace Compdfkit_Tools.PDFControlUI
 
         public void CustomPageLocationChange(int index = -2)
         {
-            if (index == -2 && PageTextBox.Text != null)
+            if (index == -2 && !string.IsNullOrEmpty(PageTextBox.Text))
             {
                 index = int.Parse(PageTextBox.Text);
             }