public static void AddControledClockInfoToFile(ControledClock ctrlClock) { string fileName = "./InfoSaved/需要控制的闹钟信息.txt"; //FileStream fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8); string content = ""; content += string.Format("响铃时间".RightFormatLen(ClockListRowItemWidth.RingTime, ' ')); content += string.Format("闹钟内容".RightFormatLen(ClockListRowItemWidth.TaskContent, ' ')); content += string.Format("闹钟间隔".RightFormatLen(ClockListRowItemWidth.Interval, ' ')); content += string.Format("状态".RightFormatLen(ClockListRowItemWidth.Status, ' ')); content += string.Format("ID".RightFormatLen(ClockListRowItemWidth.ID)); content += "\r\n" + ControledClock.FormatControlledClock(ctrlClock); sw.Write(content); sw.Flush(); sw.Close(); }
private void BindListBox() { listBox1.Items.Clear(); string content = ""; content += string.Format("响铃时间".RightFormatLen(ClockListRowItemWidth.RingTime, ' ')); content += string.Format("闹钟内容".RightFormatLen(ClockListRowItemWidth.TaskContent, ' ')); content += string.Format("闹钟间隔".RightFormatLen(ClockListRowItemWidth.Interval, ' ')); content += string.Format("状态".RightFormatLen(ClockListRowItemWidth.Status, ' ')); content += string.Format("ID".RightFormatLen(ClockListRowItemWidth.ID)); listBox1.Items.Add(content); //对listControlClock进行响铃时间的ASC排序 List <ControledClock> listOrder = listControlClock.OrderBy(a => a.RingTime).ToList() .OrderBy(a => a.Status).ToList(); foreach (ControledClock ctrlClock in listOrder) { listBox1.Items.Add(ControledClock.FormatControlledClock(ctrlClock)); } }