private async void addEntry_OnClick(object sender, RoutedEventArgs e) { try { var entryDialog = new AddEntryDialog(); await entryDialog.ShowAsync(); var entry = entryDialog.FitbitEntry; if (entry == null) { if (!entryDialog.IsGoodFormat) { await informEntryIsBadFormat(); } else { await informEntryNotAdded(); } return; } await this.manageAndAddFitbitEntry(entry, entry.Date); this.updateButton_OnClickButton_Click(sender, e); } catch (FormatException) { } }
private void AddEntry() { var addEntryWindow = new AddEntryDialog(); var addEntryWindowVM = new AddEntryDialogViewModel(Time); addEntryWindow.DataContext = addEntryWindowVM; addEntryWindow.ShowDialog(); }
private static async Task handleEntryDialog(AddEntryDialog entryDialog) { if (!entryDialog.IsGoodFormat) { await informEntryIsBadFormat(); } else { await informEntryNotAdded(); } return; }
/// <summary> /// Adds an item to the <see cref="ListView"/> control. /// </summary> private void AddItem() { string value = null; using (AddEntryDialog dialog = new AddEntryDialog()) { if (dialog.ShowDialog(this) == DialogResult.OK) { value = dialog.Value; } } if (!string.IsNullOrEmpty(value)) { bool found = false; foreach (ListViewItem item in this.DataListView.Items) { if (string.Compare(item.Text, value, true, CultureInfo.CurrentCulture) == 0) { found = true; } } if (!found) { CancelEventArgs e = new CancelEventArgs(); this.OnAddingItem(e); if (!e.Cancel) { ListViewItem item = new ListViewItem(value); item.Checked = true; this.DataListView.Items.Add(item); this.OnAddedItem(EventArgs.Empty); } } } }
private async void addEntry_OnClick(object sender, RoutedEventArgs e) { try { var entryDialog = new AddEntryDialog(); await entryDialog.ShowAsync(); var entry = entryDialog.FitbitEntry; if (entry == null) { await handleEntryDialog(entryDialog); return; } await this.manageFitbitEntry(entry); this.updateButton_OnClickButton_Click(sender, e); } catch (FormatException exc) { Debug.WriteLine("FormatException source: {0}", exc.Source); } }