private void Button_Item_CPYUN(object sender, RoutedEventArgs e) { Button button = sender as Button; EncryptedEntry entry = button.DataContext as EncryptedEntry; Clipboard.SetData(DataFormats.Text, entry.Decrypt.Usernames.ElementAtOrDefault(0)?.Name); }
//edit button private void Button_Item_Edit(object sender, RoutedEventArgs e) { Button button = sender as Button; EncryptedEntry entry = button.DataContext as EncryptedEntry; Router.instance.DisplayPage(Router.Pages.EditNew, entry); }
//select button private void Button_Item_Select(object sender, RoutedEventArgs e) { Button button = sender as Button; EncryptedEntry entry = button.DataContext as EncryptedEntry; Clipboard.SetData(DataFormats.Text, entry.Id); }
private void _init() { if (PasswordSystem.Instance.NotInitOrLocked()) { _route(Pages.Unlock); } else { SetContentView(Resource.Layout.activity_main); _entries = FindViewById <ListView>(Resource.Id.entries); List <EncryptedEntry> e = PasswordSystem.Instance.ReadDatabase().OrderBy(s => s.Id).ToList(); EntriesAdapter a = new EntriesAdapter(Application.Context, e); _entries.Adapter = a; _entries.ItemClick += (s, ev) => { EncryptedEntry item = a.GetItem(ev.Position); string ds = item.DecryptAsString(); Intent intent = new Intent(this, typeof(EntryView)); intent.PutExtra("asString", ds); StartActivity(intent); }; //_entries.Invalidate(); } }
//delete button private void Button_Item_Delete(object sender, RoutedEventArgs e) { Button button = sender as Button; EncryptedEntry entry = button.DataContext as EncryptedEntry; MessageBoxResult dialogResult = System.Windows.MessageBox.Show("Delete " + entry.Id + "?", "Delete", MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { File.Delete(System.IO.Path.Combine(PasswordSystem.Instance.Settings.DB_PATH, entry.Filename)); _getData(); } }
public List <EncryptedEntry> ReadDatabase() { string[] ss = FileHelper.ListFiles(Settings.DB_PATH); List <EncryptedEntry> ret = new List <EncryptedEntry>(ss.Length); int cnt = 0; foreach (string s in ss) { string enc = s; string id = Decrypt(enc); string encryptedContent = File.ReadAllText(Path.Combine(Settings.DB_PATH, enc)); EncryptedEntry e = new EncryptedEntry(id, encryptedContent, enc); string decryptedContent = this.header.DecryptWithHeaderPassword(encryptedContent); ret.Add(e); cnt++; } _cachedList = ret; SelectedEntry = null; return(ret); }
public bool TrySelect(string id) { if (_cachedList == null) { return(false); } if (SelectedEntry != null && SelectedEntry.Id == id) { return(true); } foreach (EncryptedEntry e in _cachedList) { if (e.Id == id) { SelectedEntry = e; return(true); } } return(false); }
public void Select(EncryptedEntry e) { SelectedEntry = e; }