コード例 #1
0
        private void EditClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                try
                {
                    if (list1.List1.SelectedItem == null)
                    {
                        return;
                    }

                    var f  = new AddTaskForm(true);
                    var al = list1.List1.SelectedItem as Alert;

                    f.CurrentAlarm = al;

                    if (f.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        var cal = f.CurrentAlarm;
                        var ev  = Settings.Default["Events"] as SortedList <long, Alert>;

                        int i = list1.List1.SelectedIndex;
                        ev.Remove(al.AlertTime.Ticks);
                        ev.Add(cal.AlertTime.Ticks, cal);
                        list1.List1.SelectedIndex = i;
                    }
                }
                catch { }
            }
        }
コード例 #2
0
        private void ButtonAddTaskClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                try
                {
                    AddTaskForm frm = new AddTaskForm();
                    try
                    {
                        if (Settings.Default.RestoreLast)
                        {
                            frm.CurrentAlarm        = Settings.Default["LastAlert"] as Alert;
                            frm.CurrentAlarm.isUsed = false;
                        }
                    }
                    catch { }

                    frm.dateTimePicker1.Value = DateTime.Now.AddHours(1);

                    if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        var   ev = Settings.Default["Events"] as SortedList <long, Alert>;
                        Alert a  = frm.CurrentAlarm;
                        ev.Add(a.AlertTime.Ticks, a);

                        Settings.Default["Events"]    = ev;
                        Settings.Default["LastAlert"] = frm.CurrentAlarm;
                        Settings.Default.Save();

                        list1.List1.SelectedIndex++;
                        FillList();
                    }
                }
                catch { }
            }
        }