void OpenMessage(ListViewItemEventArgs args) { try { var message = this.messages[args.Item]; if (message.MessageType == MessageType.Text) { var d = new ViewMessageDialog(message, this.ownName, this.ownId, this.contactName, this.contactId); d.ShowModal(); if (d.Export) { var fileName = $"Message-{this.contactId}-{message.Id}.txt"; var appDir = App.ServiceProvider.Get <ICancellation>().DataDirRoot.Parent; var exportDir = Path.Combine(appDir.FullName, "temp"); if (!Directory.Exists(exportDir)) { Directory.CreateDirectory(exportDir); } File.WriteAllText(Path.Combine(exportDir, fileName), message.ThreadText); MessageBox.Query("Message decrypted", $"The message was decrypted and saved as {Path.Combine(exportDir, fileName)}. We'll try to delete it when you quit the app!", Strings.Ok); } return; } if (message.MessageType == MessageType.File) { SaveFileToDownloads(message); } } catch (Exception e) { ErrorBox.ShowException(e); } }
async void OnAcceptPassphraseAsync(string passphrase) { if (string.IsNullOrEmpty(passphrase)) { ErrorBox.Show("The passphrase is required."); return; } var op = new LongRunningOperation(p => { }, () => { }); try { this.deviceVaultService.TryLoadDecryptAndSetMasterRandomKeyAsync(passphrase, op.Context).ConfigureAwait(false).GetAwaiter().GetResult(); await this.profileViewModel.LoadProfile(); await this.cancellation.StartWorkers(); NavigationService.ShowContactsView(); } catch (Exception ex) { var result = MockLocalization.ReplaceKey(ex.Message); if (result != ex.Message) { MessageBox.Query("Device Vault", "\r\nIncorrect Passphrase.", Strings.Ok); } else { ErrorBox.ShowException(ex); } } }
public async Task ShowError(Exception e, [CallerMemberName] string callerMemberName = "") { ErrorBox.ShowException(e); await Task.CompletedTask; }