private void LoadQrCode_Click(object sender, RoutedEventArgs e) { var dialog = new OpenFileDialog { Filter = "IMG Files| *.jpg;*jpeg;*png", ValidateNames = true, Multiselect = false }; var dr = dialog.ShowDialog(); if (dr.HasValue && dr.Value) { try { this.Code.Text = Decode(dialog.FileName).Text; if (!Qr.IsValid(this.Code.Text)) { this.ErrorHint.Content = "Please enter valid uri."; this.ErrorHint.Visibility = Visibility.Visible; } else { this.ErrorHint.Visibility = Visibility.Hidden; } } catch (Exception ex) { this.ErrorHint.Visibility = Visibility.Visible; this.ErrorHint.Content = ex.Message; } } }
public void RemoveQr(Qr qr) { lock (_lock) { if (qrs.RemoveQr(qr)) { Save(); } } }
public void AddQr(Qr qr) { lock (_lock) { if (qrs.AddQr(qr)) { Save(); } } }
private void Save_Click(object sender, RoutedEventArgs e) { if (!Qr.IsValid(this.Code.Text)) { this.ErrorHint.Content = "Please enter valid uri."; this.ErrorHint.Visibility = Visibility.Visible; return; } DB.Instance.AddQr(new Qr(this.Code.Text)); this.Close(); }