|
@@ -1,5 +1,6 @@
|
|
|
using ComPDFKit.PDFDocument;
|
|
|
using Compdfkit_Tools.Common;
|
|
|
+using Compdfkit_Tools.Helper;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
@@ -22,6 +23,9 @@ using UserControl = System.Windows.Controls.UserControl;
|
|
|
|
|
|
namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Interaction logic for FileGridListWithPageRangeControl.xaml
|
|
|
/// </summary>
|
|
@@ -39,7 +43,14 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
SetValue(IsEnsureProperty, value);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ public class FileInfo
|
|
|
+ {
|
|
|
+ public CPDFDocument Document;
|
|
|
+ public string Name { get; set; }
|
|
|
+ public string Path { get; set; }
|
|
|
+ public string PageRange { get; set; }
|
|
|
+ public string Size { get; set; }
|
|
|
+ }
|
|
|
|
|
|
private int _fileNumText;
|
|
|
public int FileNumText
|
|
@@ -52,8 +63,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private ObservableCollection<CPDFDocument> _fileInfoDataList;
|
|
|
- public ObservableCollection<CPDFDocument> FileInfoDataList
|
|
|
+
|
|
|
+ private ObservableCollection<FileInfo> _fileInfoDataList;
|
|
|
+ public ObservableCollection<FileInfo> FileInfoDataList
|
|
|
{
|
|
|
get { return _fileInfoDataList; }
|
|
|
set
|
|
@@ -68,8 +80,8 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
public FileGridListWithPageRangeControl()
|
|
|
{
|
|
|
+ this.DataContext = this;
|
|
|
InitializeComponent();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
@@ -91,24 +103,44 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void AddFilesBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- var dialog = new OpenFileDialog();
|
|
|
- dialog.Multiselect = true;
|
|
|
- dialog.Filter = "PDF Files (*.pdf)|*.pdf";
|
|
|
- dialog.ShowDialog();
|
|
|
-
|
|
|
- foreach (string filePath in dialog.FileNames)
|
|
|
+ var openFileDialog = new OpenFileDialog();
|
|
|
+ openFileDialog.Multiselect = true;
|
|
|
+ openFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
|
|
|
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
- CPDFDocument document = CPDFDocument.InitWithFilePath(filePath);
|
|
|
- if (document.IsLocked)
|
|
|
+ foreach (string filePath in openFileDialog.FileNames)
|
|
|
{
|
|
|
- PasswordWindow passwordWindow = new PasswordWindow();
|
|
|
- passwordWindow.InitWithDocument(document);
|
|
|
- passwordWindow.Owner = Window.GetWindow(this);
|
|
|
- passwordWindow.PasswordDialog.SetShowText(filePath + " is encrypted.");
|
|
|
- passwordWindow.PasswordDialog.SetShowText("Password error");
|
|
|
+ CPDFDocument document = CPDFDocument.InitWithFilePath(filePath);
|
|
|
+ if (document.IsLocked)
|
|
|
+ {
|
|
|
+ PasswordWindow passwordWindow = new PasswordWindow();
|
|
|
+ passwordWindow.InitWithDocument(document);
|
|
|
+ passwordWindow.Owner = Window.GetWindow(this);
|
|
|
+ passwordWindow.PasswordDialog.SetShowText(filePath + " is encrypted.");
|
|
|
+ passwordWindow.ShowDialog();
|
|
|
+ if (document.IsLocked)
|
|
|
+ {
|
|
|
+ document.Release();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ FileInfoDataList.Add(new FileInfo
|
|
|
+ {
|
|
|
+ Document = document,
|
|
|
+ Name = document.FileName,
|
|
|
+ Size = CommonHelper.GetFileSize(filePath),
|
|
|
+ Path = document.FilePath,
|
|
|
+ PageRange = "1-"+document.PageCount.ToString(),
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ private void PasswordWindow_DialogClosed(object sender, PasswordEventArgs e)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
private void RemoveBtn_Click(object sender, RoutedEventArgs e)
|
|
@@ -120,5 +152,11 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ FileInfoDataList = new ObservableCollection<FileInfo>();
|
|
|
+ FileDataGrid.ItemsSource = FileInfoDataList;
|
|
|
+ }
|
|
|
}
|
|
|
}
|