|
@@ -0,0 +1,91 @@
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.ComponentModel;
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
+using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+
|
|
|
+namespace Compdfkit_Tools.DigitalSignature.SignatureStatusBarControl
|
|
|
+{
|
|
|
+ public partial class SignatureStatusBarControl : UserControl, INotifyPropertyChanged
|
|
|
+ {
|
|
|
+ public enum SignatureStatus
|
|
|
+ {
|
|
|
+ None,
|
|
|
+ Valid,
|
|
|
+ Invalid,
|
|
|
+ Unknown
|
|
|
+ }
|
|
|
+
|
|
|
+ private string _messageString;
|
|
|
+ public string MessageString
|
|
|
+ {
|
|
|
+ get => _messageString;
|
|
|
+ set => UpdateProper(ref _messageString, value);
|
|
|
+ }
|
|
|
+ private string validString = "The signature is valid and the document has not been tampered with";
|
|
|
+ private string invalidString = "At least one signature is invalid";
|
|
|
+ private string unknownString = "There's something wrong with at least one of the signatures";
|
|
|
+
|
|
|
+ private SignatureStatus _status;
|
|
|
+ public SignatureStatus Status
|
|
|
+ {
|
|
|
+ get => _status;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _status = value;
|
|
|
+ SetStatus(_status);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public SignatureStatusBarControl(SignatureStatus status = SignatureStatus.None)
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ SetStatus(status);
|
|
|
+ DataContext = this;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetStatus(SignatureStatus status)
|
|
|
+ {
|
|
|
+ ValidBorder.Visibility = Visibility.Collapsed;
|
|
|
+ InvalidBorder.Visibility = Visibility.Collapsed;
|
|
|
+ UnknownBorder.Visibility = Visibility.Collapsed;
|
|
|
+
|
|
|
+ switch (status)
|
|
|
+ {
|
|
|
+ case SignatureStatus.None:
|
|
|
+ MessageString = "";
|
|
|
+ break;
|
|
|
+ case SignatureStatus.Valid:
|
|
|
+ ValidBorder.Visibility = Visibility.Visible;
|
|
|
+ MessageString = validString;
|
|
|
+ break;
|
|
|
+ case SignatureStatus.Invalid:
|
|
|
+ InvalidBorder.Visibility = Visibility.Visible;
|
|
|
+ MessageString = invalidString;
|
|
|
+ break;
|
|
|
+ case SignatureStatus.Unknown:
|
|
|
+ UnknownBorder.Visibility = Visibility.Visible;
|
|
|
+ MessageString = unknownString;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public event PropertyChangedEventHandler PropertyChanged;
|
|
|
+
|
|
|
+ protected void UpdateProper<T>(ref T properValue,
|
|
|
+ T newValue,
|
|
|
+ [CallerMemberName] string properName = "")
|
|
|
+ {
|
|
|
+ if (object.Equals(properValue, newValue))
|
|
|
+ return;
|
|
|
+
|
|
|
+ properValue = newValue;
|
|
|
+ OnPropertyChanged(properName);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
|
|
|
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|