Exemple #1
0
        /// <summary>
        /// 解锁今日提醒对应的文件。
        /// </summary>
        internal static void unlockToday()
        {
            Today today = Today.GetToday();

            foreach (Reminder reminder in today.TodayReminders)
            {
                try
                {
                    FileLockerManager.UnlockFile(reminder.FilePath);
                }
                catch (Exception)
                {
                    continue;
                }
            }
        }
Exemple #2
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);
     }
 }
Exemple #3
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);
     }
 }