public void AddNewRecord() { var openData = new OpenCryptoKeysData() { CanTrade = CanTrade, CanWithdraw = CanWithdraw, IPs = IPs, Passphrase = Passphrase }; if (UseExpireDate) { openData.ExpireDate = ExpireDate; } var encrypted = EncryptedRecordDataModel <OpenCryptoKeysData> .Create(EncryptedDictionary, Display, Key ?? string.Empty, Secret ?? string.Empty, openData); Records.Add(encrypted); if (EncryptedDictionary.KeyPassword != null) { EncryptedDictionary.EncryptAll(); EncryptedDictionary.Save(FilenameSecret); OpenRecords.Add(new OpenRecordDataModel <OpenCryptoKeysData>() { Display = Display, PairingKey = encrypted.PairingKey, OpenData = openData }); SaveOpenRecords(FilenameOpen); } Display = Key = Secret = Passphrase = IPs = null; UseExpireDate = CanTrade = CanWithdraw = false; foreach (var value in new string[] { nameof(Display), nameof(Key), nameof(Secret), nameof(Passphrase), nameof(IPs), nameof(UseExpireDate), nameof(CanTrade), nameof(CanWithdraw) }) { PropertyChanged(this, new PropertyChangedEventArgs(value)); } }
public void DeleteRecord(EncryptedRecordDataModel <OpenCryptoKeysData> record) { for (int i = OpenRecords.Count - 1; i >= 0; --i) { if (OpenRecords[i].PairingKey == record.PairingKey) { OpenRecords.RemoveAt(i); break; } } SaveOpenRecords(FilenameOpen); for (int i = Records.Count - 1; i >= 0; --i) { if (Records[i].PairingKey == record.PairingKey) { Records.RemoveAt(i); break; } } record.Remove(); EncryptedDictionary.Save(FilenameSecret); }
public void AddNewRecord() { var encrypted = EncryptedRecordDataModel <object> .Create(EncryptedDictionary, Display, Key ?? string.Empty, Secret ?? string.Empty, null); Records.Add(encrypted); if (EncryptedDictionary.KeyPassword != null) { EncryptedDictionary.EncryptAll(); EncryptedDictionary.Save("secrets.json"); OpenRecords.Add(new OpenRecordDataModel <object>() { Display = Display, PairingKey = encrypted.PairingKey }); SaveOpenRecords("open_data.json"); } Display = Key = Secret = null; foreach (var value in new string[] { nameof(Display), nameof(Key), nameof(Secret) }) { PropertyChanged(this, new PropertyChangedEventArgs(value)); } }