123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using ComPDFKit.PDFDocument;
- using Compdfkit_Tools.Common;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Forms;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using UserControl = System.Windows.Controls.UserControl;
- namespace Compdfkit_Tools.PDFControl
- {
- /// <summary>
- /// Interaction logic for FileGridListWithPageRangeControl.xaml
- /// </summary>
- public partial class FileGridListWithPageRangeControl : UserControl, INotifyPropertyChanged
- {
- public static readonly DependencyProperty IsEnsureProperty =
- DependencyProperty.Register(nameof(IsEnsure), typeof(bool), typeof(FileGridListWithPageRangeControl), new PropertyMetadata(false));
- public bool IsEnsure
- {
- get => (bool)GetValue(IsEnsureProperty);
- private set
- {
- SetValue(IsEnsureProperty, value);
- }
- }
- private int _fileNumText;
- public int FileNumText
- {
- get => _fileNumText;
- set
- {
- if (UpdateProper(ref _fileNumText, value))
- IsEnsure = _fileNumText > 0;
- }
- }
- private ObservableCollection<CPDFDocument> _fileInfoDataList;
- public ObservableCollection<CPDFDocument> FileInfoDataList
- {
- get { return _fileInfoDataList; }
- set
- {
- _fileInfoDataList = value;
- _fileInfoDataList.CollectionChanged += (sender, args) =>
- {
- FileNumText = _fileInfoDataList.Count;
- };
- }
- }
- public FileGridListWithPageRangeControl()
- {
- InitializeComponent();
- }
- public event PropertyChangedEventHandler PropertyChanged;
- protected virtual void OnPropertyChanged(string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- protected bool UpdateProper<T>(ref T properValue,
- T newValue,
- [CallerMemberName] string properName = "")
- {
- if (object.Equals(properValue, newValue))
- return false;
- properValue = newValue;
- OnPropertyChanged(properName);
- return true;
- }
- 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)
- {
- 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.PasswordDialog.SetShowText("Password error");
- }
- }
- }
- private void RemoveBtn_Click(object sender, RoutedEventArgs e)
- {
- }
- private void PageRangeBtn_Click(object sender, RoutedEventArgs e)
- {
- }
- }
- }
|