public static void NextRemind(Ddl ddl, bool recalculate) { DateTime now = DateTime.Now; if (recalculate) { ddl.RemindTime = now.Date.AddDays(-1) + ddl.RemindTime.TimeOfDay; } if (ddl.IsRemind == 0) { DateTime rt = ddl.RemindTime; string[] remindIntervalString = ddl.RemindInterval.Split('/'); int[] remindInterval = { int.Parse(remindIntervalString[0]), int.Parse(remindIntervalString[1]), int.Parse(remindIntervalString[2]) }; while (rt <= now) { rt = AddTime(rt, remindInterval[0], remindInterval[1], remindInterval[2], 0, 0, 0, ddl.IsChineseCalender); } ddl.RemindTime = rt; DatabaseOperation.Update(ddl.Id, "RemindTime", rt); } else { DateTime rt = ddl.RemindTime; while (rt <= now || ddl.RemindInterval[Convert.ToInt16(rt.DayOfWeek)] != '1') { rt = rt.AddDays(1); } ddl.RemindTime = rt; DatabaseOperation.Update(ddl.Id, "RemindTime", rt); } }
public void ReloadSingleDdl() { ddl = DdlOperation.ddls.Find(d => d.Id == ddl.Id); TimeSpan leftTime = DdlOperation.leftTimesDict[ddl.Id]; percentage = 1 - leftTime.TotalSeconds / ddl.EndTime.Subtract(ddl.StartTime).TotalSeconds; string startTimeStr, endTimeStr; if (ddl.IsChineseCalender) { startTimeStr = DdlOperation.GetChineseDateTimeString(ddl.StartTime); endTimeStr = DdlOperation.GetChineseDateTimeString(ddl.EndTime); } else { startTimeStr = ddl.StartTime.ToString(); endTimeStr = ddl.EndTime.ToString(); } ddlTime.Text = startTimeStr + " —— " + endTimeStr; ddlNameTextBlock.Text = ddl.Name; ddlPriority.Value = ddl.Priority; leftTimeTextBlock.Text = (leftTime < TimeSpan.Zero ? "-" : "") + leftTime.ToString(@"d\:hh\:mm\:ss"); RefreshSingleDdl(); }
public void InitializeDdlSettingWindow(Ddl ddl) { InitializeComponent(); DdlNameTextBox.Text = ddl.Name; DdlPriority.Value = ddl.Priority; InitializeStartTime(ddl.StartTime); ChineseCheckbox.IsChecked = ddl.IsChineseCalender; InitializeEndTime(ddl.EndTime); var format = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern; if (format == "M/d/yyyy") { StartMonth.SetValue(Grid.ColumnProperty, 0); StartDay.SetValue(Grid.ColumnProperty, 1); StartYear.SetValue(Grid.ColumnProperty, 2); EndMonth.SetValue(Grid.ColumnProperty, 0); EndDay.SetValue(Grid.ColumnProperty, 1); EndYear.SetValue(Grid.ColumnProperty, 2); } else if (format == "d/M/yyyy") { StartDay.SetValue(Grid.ColumnProperty, 0); StartMonth.SetValue(Grid.ColumnProperty, 1); StartYear.SetValue(Grid.ColumnProperty, 2); EndDay.SetValue(Grid.ColumnProperty, 0); EndMonth.SetValue(Grid.ColumnProperty, 1); EndYear.SetValue(Grid.ColumnProperty, 2); } LoopCheckbox.IsChecked = ddl.IsLoop; if (ddl.IsLoop) { InitializeLoopinterval(ddl.LoopInterval); } NoticeCheckbox.IsChecked = (ddl.Inform[0] == '1'); WindowCheckbox.IsChecked = (ddl.Inform[1] == '1'); SoundCheckbox.IsChecked = (ddl.Inform[2] == '1'); RemindCheckbox.IsChecked = ddl.IsRemind != -1; if (ddl.IsRemind != -1) { InitializeRemind(ddl.RemindInterval, ddl.RemindTime); } if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name != "zh-CN") { ChineseCheckbox.Visibility = Visibility.Hidden; ChineseCheckbox.IsEnabled = false; } }
public DdlSettingWindow() { ddl = new Ddl(); ddl.Name = "New Deadline"; ddl.StartTime = DateTime.Now; ddl.EndTime = DateTime.Now.AddHours(1); ddl.Inform = "000"; ddl.IsRemind = -1; InitializeDdlSettingWindow(ddl); }
public SingleDdl(Ddl ddl) { this.ddl = ddl; TimeSpan leftTime = DdlOperation.leftTimesDict[ddl.Id]; percentage = 1 - leftTime.TotalSeconds / ddl.EndTime.Subtract(ddl.StartTime).TotalSeconds; InitializeComponent(); ReloadSingleDdl(); }
public static void AlertDdl(Ddl ddl) { if (ddl.Inform[0] == '1') { App.ShowBalloonTip(ddl.Name + "时间到!"); } if (ddl.Inform[2] == '1') { try { player.Open(new Uri(SettingOperation.alarmPath)); player.Play(); player.Volume = SettingOperation.alarmVolume / 100f; } catch (Exception) { App.ShowBalloonTip("音频加载失败!"); } } if (ddl.Inform[1] == '1') { MessageBox.Show(ddl.Name + " 时间到!"); } }
private static void NextLoop(Ddl ddl) { string[] str = ddl.LoopInterval.Split('/'); DateTime startTime = ddl.StartTime, endTime = ddl.EndTime; int[] loopInterval = new int[6]; for (int i = 0; i < 6; i++) { loopInterval[i] = int.Parse(str[i]); } startTime = endTime; endTime = AddTime(endTime, loopInterval[0], loopInterval[1], loopInterval[2], loopInterval[3], loopInterval[4], loopInterval[5], ddl.IsChineseCalender); while (endTime <= DateTime.Now) { startTime = AddTime(startTime, loopInterval[0], loopInterval[1], loopInterval[2], loopInterval[3], loopInterval[4], loopInterval[5], ddl.IsChineseCalender); endTime = AddTime(endTime, loopInterval[0], loopInterval[1], loopInterval[2], loopInterval[3], loopInterval[4], loopInterval[5], ddl.IsChineseCalender); } ddl.StartTime = startTime; ddl.EndTime = endTime; DatabaseOperation.Update(ddl); }
public static void Update(Ddl ddl, string s, object o) => sqc.Execute(@"update Ddl set " + s + "=? where id=?", o, ddl.Id);
public static void Update(Ddl ddl) => sqc.Execute(@"update Ddl set Name=?, Priority=?, StartTime=?, EndTime=?, IsChineseCalender=?, IsLoop=?, LoopInterval=?, Inform=?, IsRemind=?, RemindTime=?, RemindInterval=? where id=?", ddl.Name, ddl.Priority, ddl.StartTime, ddl.EndTime, ddl.IsChineseCalender, ddl.IsLoop, ddl.LoopInterval, ddl.Inform, ddl.IsRemind, ddl.RemindTime, ddl.RemindInterval, ddl.Id);
public static void Insert(Ddl ddl) => sqc.Insert(ddl);
public DdlSettingWindow(int id) { ddl = DdlOperation.ddls.Find(d => d.Id == id); this.id = id; InitializeDdlSettingWindow(ddl); }