3using System.Collections.Generic;
5using System.Threading.Tasks;
7using System.Windows.Input;
28 private readonly
Command downloadAttachment;
29 private readonly
Command removeAttachment;
64 set => this.id.Value = value;
72 get => this.legalId.Value;
73 set => this.legalId.Value = value;
81 get => this.contentType.Value;
82 set => this.contentType.Value = value;
90 get => this.fileName.Value;
91 set => this.fileName.Value = value;
99 get => this.url.Value;
100 set => this.url.Value = value;
108 get => this.signature.Value;
109 set => this.signature.Value = value;
117 get => this.timestamp.Value;
118 set => this.timestamp.Value = value;
132 return this.contractModel?.CanDownloadAttachment ??
false;
142 string Extension = Path.GetExtension(this.
FileName);
143 if (Extension.StartsWith(
"."))
144 Extension = Extension[1..];
146 SaveFileDialog Dialog =
new()
149 CheckFileExists =
false,
150 CheckPathExists =
true,
151 CreatePrompt =
false,
152 DefaultExt = Extension,
153 Filter =
"Similar Files (*." + Extension +
")|*." + Extension,
154 OverwritePrompt =
true,
155 Title =
"Save Attachment"
158 bool? Result = Dialog.ShowDialog(
MainWindow.currentInstance);
159 if (!Result.HasValue || !Result.Value)
164 KeyValuePair<string, TemporaryFile> P = await this.contractModel.ContractsClient.GetAttachmentAsync(this.
Url,
SignWith.CurrentKeys);
167 using FileStream Destination = File.Create(Dialog.FileName);
170 await Temp.CopyToAsync(Destination);
191 return this.contractModel?.CanUploadAttachment ??
false;
201 if (MessageBox.Show(
"Are you sure you want to remove the attachment " +
this.Id +
"?",
"Confirm",
202 MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.No) != MessageBoxResult.Yes)
209 Contract Contract = await this.contractModel.ContractsClient.RemoveContractAttachmentAsync(this.
Id);
211 await this.contractModel.SetContract(
Contract);
Interaction logic for MainWindow.xaml
static void MouseHourglass()
Displays an hourglass cursor (or similar for waiting purposes).
static void ErrorBox(string ErrorMessage)
Displays an error message on the screen, on the main UI thread.
static void SuccessBox(string Message)
Displays a success message on the screen, on the main UI thread.
Defines a custom command.
Contains information about an attachment
string ContentType
Internet Content-Type of attachment.
string Id
ID of attachment
AttachmentInfo(ContractModel ContractModel, Attachment Attachment)
Contains information about a client signature
bool CanExecuteRemoveAttachment()
If the user is allowed to remove an attachment.
ICommand DownloadAttachment
Allows the user to download an attachment.
async Task ExecuteDownloadAttachment()
Downloads an attachment.
bool CanExecuteDownloadAttachment()
If the user is allowed to download an attachment.
ICommand RemoveAttachment
Allows the user to remove an attachment.
async Task ExecuteRemoveAttachment()
Removes an attachment.
string Url
URL of content.
string FileName
File name of attachment.
Attachment Attachment
Reference to attachment object.
DateTime Timestamp
Timestamp
Abstract base class for view models
Generic class for properties
Contains a reference to an attachment assigned to a legal object.
string LegalId
Legal ID of uploader of the attachment
string FileName
Filename of attachment.
string ContentType
Internet Content Type of binary attachment.
DateTime Timestamp
Timestamp of signature. If no signature, value is DateTime.MinValue
string Url
URL to retrieve attachment, if provided.
byte[] Signature
Binary signature of the attachment, generated by an approved legal identity of the account-holder....
Contains the definition of a contract
Abstract base class of signatures
Class managing the contents of a temporary file. When the class is disposed, the temporary file is de...
SignWith
Options on what keys to use when signing data.