Beispiel #1
0
 /// <summary>
 /// 编辑一个提醒。
 /// </summary>
 /// <param name="warnIfUnselected">指定当用户未选定任何提醒时,是否发出警告。</param>
 private void editReminder(bool warnIfUnselected)
 {
     if (reminderListView.SelectedItems.Count > 0)
     {
         Reminder r = reminderListView.SelectedItems[0].Tag as Reminder;
         if (r != null)
         {
             using (ReminderForm rf = new ReminderForm(r))
             {
                 rf.ShowDialog();
                 if (rf.HasChanged)
                 {
                     ReminderManager.UpdateReminders();
                     loadToday();
                     DateTime now = DateTime.Now;
                     if (rf.Reminder.Month == now.Month && rf.Reminder.Day == now.Day ||
                         !rf.Reminder.IsEnabled ||
                         !rf.Reminder.IsFileLocked)
                     {
                         FileLockerManager.UnlockFile(r.FilePath);
                     }
                     else
                     {
                         FileLockerManager.LockFile(r.FilePath);
                     }
                     MessageBox.Show("已保存。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     monthComboBox.SelectedIndex = rf.Reminder.Month;
                     dayComboBox.SelectedIndex   = rf.Reminder.Day;
                     loadReminder();
                     loadToday();
                 }
             }
         }
     }
     else if (warnIfUnselected)
     {
         MessageBox.Show("请选择一项来修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 删除一个提醒。
 /// </summary>
 /// <param name="warnIfUnselected">指定当用户未选定任何提醒时,是否发出警告。</param>
 private void removeReminder(bool warnIfUnselected)
 {
     if (reminderListView.SelectedItems.Count > 0)
     {
         if (MessageBox.Show("删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             Reminder r = reminderListView.SelectedItems[0].Tag as Reminder;
             if (r != null)
             {
                 cachedReminders.Remove(r);
                 ReminderManager.SaveReminders(cachedReminders);
                 FileLockerManager.UnlockFile(r.FilePath);
                 loadToday();
                 loadReminder();
                 MessageBox.Show("已删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     else if (warnIfUnselected)
     {
         MessageBox.Show("请选择一项来删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 打开一个提醒对应的文件。
        /// </summary>
        /// <param name="r">要读取的提醒。</param>
        public static void DoReminder(Reminder r)
        {
            Thread worker = new Thread(new ThreadStart(() =>
            {
                if (!r.IsEnabled)
                {
                    return;
                }
                Process process;
                try
                {
                    process = Process.Start(r.FilePath);
                }
                catch (Exception)
                {
                    MessageBox.Show("打开文件失败:" + r.FilePath);
                    return;
                }
            }));

            worker.Start();
            r.LastRunYear = DateTime.Now.Year;
            ReminderManager.UpdateReminders();
        }
Beispiel #4
0
        /// <summary>
        /// 用一个提醒初始化窗体。
        /// </summary>
        /// <param name="r"></param>
        public ReminderForm(Reminder r)
        {
            InitializeComponent();

            Reminder = r;
        }
 /// <summary>
 /// 构造今日提醒控件。
 /// </summary>
 /// <param name="r">要显示的提醒。</param>
 public TodayReminderView(Reminder r)
 {
     InitializeComponent();
     Reminder = r;
 }