private void Login(object sender, RoutedEventArgs e) { Button btn = sender as Button; if (btn.Tag.ToString() == "icons/login.png") { LoginDialogWindow ldw = new LoginDialogWindow(); ldw.Owner = this; if (ldw.ShowDialog() == true) { if (View.Filter != null) { View.Filter = null; } loginButton.Tag = "icons/logout.png"; } } else if (btn.Tag.ToString() == "icons/logout.png") { View.Filter = (object o) => { Post en = o as Post; return(!en.IsEncrypted(en.Name)); }; loginButton.Tag = "icons/login.png"; } }
private void Decipher(object sender, RoutedEventArgs e) { if (keyTextBox.Text != string.Empty) { int key = 0; try { key = int.Parse(keyTextBox.Text); int index = entryListBox.SelectedIndex; Post en = EntryList1[index]; if (en.IsEncrypted(EntryList1[index].Name)) { try { Post temp = new DecoratorEncryption(en, key); // wywołanie dekoratora w celu odszyfrowania wpisu en.Amount = temp.Amount; en.Category = temp.Category; en.Description = temp.Description; en.PostDate = temp.PostDate; en.Name = temp.Name; EntryList1[index] = en; entryListBox.Items.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Błędny kod", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (FormatException) { MessageBox.Show("Niewłaściwe znaki w kluczu!", "Błąd!", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public MainWindow() { InitializeComponent(); entryListBox.ItemsSource = EntryList1; this.Attach(new BalanceLabel(this)); this.Attach(new ExpensesChart(this)); this.Attach(new IncomesChart(this)); View.Filter = (object o) => { Post en = o as Post; return(en.IsEncrypted(en.Name)); }; }
public override bool IsEncrypted(string text) { return(decorated.IsEncrypted(text)); }