public static DateTime?ShowIgnoreDialog() { var dialog = new IgnoreDialog(); var now = DateTime.Now; dialog.calendar.MinDate = new DateTime(now.Year, now.Month, 1); dialog.ShowDialog(); if (dialog.DialogResult == DialogResult.OK) { return(dialog.SelectedDate); } return(null); }
private void llAdd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (IgnoreDialog.ShowIgnoreDialog() is not DateTime date) { return; } if (this.ignoredDates.Any(ig => ig.Date == date.Date)) { MessageBox.Show("Esta data já foi adicionada anteriormente!"); //Seleciona a data adicionada this.lbIgnoredDays.SelectedIndex = this.ignoredDates.IndexOf(date); return; } this.ignoredDates.Add(date); this.ReorderDates(); //Seleciona a data adicionada this.lbIgnoredDays.SelectedIndex = this.ignoredDates.IndexOf(date); }
private void CmsIgnoreDay_Click(object sender, EventArgs e) { if (this.dataApps.CurrentApp is not AppController app) { return; } if (IgnoreDialog.ShowIgnoreDialog() is not DateTime date) { return; } var dates = app.Settings.IgnoredDates ?? Array.Empty <DateTime>(); if (dates.Any(ig => ig.Date == date.Date)) { MessageBox.Show("Esta data já foi adicionada anteriormente!"); return; } Array.Resize(ref dates, dates.Length + 1); dates[^ 1] = date;