private void TsmiSetCurrentValue_Click(object sender, EventArgs e) { bool allTimers = true, allAlarms = true; foreach (ClockVM c in MyClocks) { if (c.Model is TimerData) { allAlarms = false; } else { allTimers = false; } } if (allTimers) { var d = new TimeSpanPromptWindow(); d.Owner = MainWindow; d.UserTimeSpan = (TimeSpan)MyClock.CurrentValue; if ((bool)d.ShowDialog()) { foreach (ClockVM c in MyClocks) { c.CurrentValue = d.UserTimeSpan; } } } else if (allAlarms) { var d = new DateTimePromptWindow(); d.Owner = MainWindow; d.UserDateTime = (DateTime)MyClock.CurrentValue; if ((bool)d.ShowDialog()) { foreach (ClockVM c in MyClocks) { c.CurrentValue = d.UserDateTime; } } } else { MessageBox.Show(MainWindow, "Cannot set current value because there are clocks of different types selected.", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void TsmiUpdateToCustom_Click(object sender, EventArgs e) { if (MyClocks.Count == 0) { return; } bool allTimers = true, allAlarms = true; foreach (ClockVM c in MyClocks) { if (c.Model is TimerData) { allAlarms = false; } else { allTimers = false; } } if (allTimers) { var tspd = new TimeSpanPromptWindow(); tspd.Owner = MainWindow; if ((bool)tspd.ShowDialog()) { foreach (ClockVM c in MyClocks) { c.ResetToValue = tspd.UserTimeSpan; } } } else if (allAlarms) { var dtp = new DateTimePromptWindow(); dtp.Owner = MainWindow; if ((bool)dtp.ShowDialog()) { foreach (ClockVM c in MyClocks) { c.ResetToValue = dtp.UserDateTime; } } } }