/// <summary> /// 更新闹钟,条件:闹钟类参数的状态是Start的。 /// </summary> /// <param name="ControledClock"></param> public void UpdateRingControledClock(ControledClock ControledClock) { int removeIndex = listOrderedRingControledClock.Count(); for (int i = 0; i < listOrderedRingControledClock.Count; i++) { if (listOrderedRingControledClock[i].ID == ControledClock.ID) { removeIndex = i; break; } } if (removeIndex < listOrderedRingControledClock.Count() && listOrderedRingControledClock[removeIndex].RingTime == ControledClock.RingTime) { //如果闹铃时间没变就直接更新就好了 listOrderedRingControledClock[removeIndex].Interval = ControledClock.Interval; } else if (removeIndex < listOrderedRingControledClock.Count()) { //如果闹铃时间变了,就先移出,然后添加这个闹钟,好顺便排序 listOrderedRingControledClock.RemoveAt(removeIndex); listOrderedRingControledClock.Add(ControledClock); } else { throw new Exception("不可能找不到这个闹钟的!"); } if (removeIndex == 0) { UpdatefirstRingControledClock(); } }
public static string FormatControlledClock(ControledClock ctrlClock) { string content = ""; content += ctrlClock.RingTime.ToStandardTimeStr().RightFormatLen(ClockListRowItemWidth.RingTime); content += ctrlClock.TaskContent.RightFormatLen(ClockListRowItemWidth.TaskContent); content += ctrlClock.Interval.ToYMDFormat().ToString().RightFormatLen(ClockListRowItemWidth.Interval); content += ctrlClock.Status.RightFormatLen(ClockListRowItemWidth.Status); content += ctrlClock.ID.RightFormatLen(ClockListRowItemWidth.ID); return(content); }
/// <summary> /// 更新最先的响铃时间 /// </summary> private void UpdatefirstRingControledClock() { if (listOrderedRingControledClock.Count == 0) { return; } firstRingClock = new ControledClock() { RingTime = listOrderedRingControledClock[0].RingTime, //因为已经是排序好的闹钟 TaskContent = listOrderedRingControledClock[0].TaskContent, ID = listOrderedRingControledClock[0].ID, Interval = listOrderedRingControledClock[0].Interval, //Status = listOrderedRingControledClock[0].Status }; }
public static ControledClock GetCtrlClockFromRowString(string row) { ControledClock OperedClock = new ControledClock(); OperedClock.RingTime = row.Substring(0, ClockListRowItemWidth.RingTime - 1).ToDateTime(); //中文加英文形成的字符串,要依据位置索引来截取字符串,是很麻烦的方法,现在假设除了内容包含中文,其他都是英文的吧。好尽快完成项目 int num = row.Substring(ClockListRowItemWidth.RingTime).GetHanziNum(); OperedClock.TaskContent = row.Substring(ClockListRowItemWidth.RingTime, ClockListRowItemWidth.TaskContent - num - 1).Trim(); OperedClock.Interval = row.Substring(ClockListRowItemWidth.RingTime + ClockListRowItemWidth.TaskContent - num , ClockListRowItemWidth.Interval - 1).ToSumSecond(); OperedClock.Status = row.Substring(ClockListRowItemWidth.RingTime + ClockListRowItemWidth.TaskContent + ClockListRowItemWidth.Interval - num , ClockListRowItemWidth.Status - 1).Trim(); OperedClock.ID = row.Substring(row.Length - ClockListRowItemWidth.ID).Trim(); return(OperedClock); }
public void AddAndSetfirstring(ControledClock ControledClockToAdd) { int insertIndex = 0; for (int i = 0; i < listOrderedRingControledClock.Count; i++) { if (0 < DateTime.Compare(ControledClockToAdd.RingTime, listOrderedRingControledClock[i].RingTime)) { insertIndex = i; break; } } listOrderedRingControledClock.Insert(insertIndex, ControledClockToAdd); if (0 == insertIndex) { UpdatefirstRingControledClock(); } }