123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Runtime.CompilerServices;
- using System.Windows.Controls;
- namespace Compdfkit_Tools.PDFControl
- {
- public partial class SetEncryptionControl : UserControl, INotifyPropertyChanged
- {
- private bool _isUserPasswordEnabled;
- public bool IsUserPasswordEnabled
- {
- get => _isUserPasswordEnabled;
- set
- {
- _isUserPasswordEnabled = value;
- OnPropertyChanged();
- EncryptionSettingChanged?.Invoke(this, null);
- }
- }
- private bool _isOwnerPasswordEnabled;
- public bool IsOwnerPasswordEnabled
- {
- get => _isOwnerPasswordEnabled;
- set
- {
- _isOwnerPasswordEnabled = value;
- OnPropertyChanged();
- EncryptionSettingChanged?.Invoke(this, null);
- }
- }
-
- private string _userPassword;
- public string UserPassword
- {
- get => _userPassword;
- set
- {
- _userPassword = value;
- OnPropertyChanged();
- EncryptionSettingChanged?.Invoke(this, null);
- }
- }
-
- private string _ownerPassword;
- public string OwnerPassword
- {
- get => _ownerPassword;
- set
- {
- _ownerPassword = value;
- OnPropertyChanged();
- EncryptionSettingChanged?.Invoke(this, null);
- }
- }
-
- private bool _isAllowPrint = true;
- public bool IsAllowPrint
- {
- get => _isAllowPrint;
- set
- {
- _isAllowPrint = value;
- OnPropertyChanged();
- }
- }
-
- private bool _isAllowCopy = true;
- public bool IsAllowCopy
- {
- get => _isAllowCopy;
- set
- {
- _isAllowCopy = value;
- OnPropertyChanged();
- }
- }
- public bool ValidSetting
- {
- get
- {
- if (!IsOwnerPasswordEnabled && !IsUserPasswordEnabled)
- {
- return false;
- }
- bool validUserOption = !IsUserPasswordEnabled || !string.IsNullOrEmpty(UserPassword);
- bool validOwnerOption = !IsOwnerPasswordEnabled || !string.IsNullOrEmpty(OwnerPassword);
- return validUserOption && validOwnerOption;
- }
- }
-
-
- public event PropertyChangedEventHandler PropertyChanged;
- public event PropertyChangedEventHandler EncryptionSettingChanged;
-
- public SetEncryptionControl()
- {
- InitializeComponent();
- DataContext = this;
- }
-
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
|