Esempio n. 1
0
 private ScheduleItem CreateScheduleItem(ScheduleForm dialog)
 {
     ScheduleItem dest = new ScheduleItem();
     dest.First = dialog.First;
     dest.Last = dialog.Last;
     dest.ProfileName = dialog.ProfileName;
     dest.ACValues = dialog.PowerSetting;
     return dest;
 }
Esempio n. 2
0
        /* ----------------------------------------------------------------- */
        /// PropertyButton_Click
        /* ----------------------------------------------------------------- */
        private void PropertyButton_Click(object sender, EventArgs e)
        {
            ListView control = this.ScheduleListView;
            if (control.SelectedItems.Count <= 0) return;

            ScheduleForm dialog = new ScheduleForm(this._setting.Scheme);
            if (this._schedule.ContainsKey(control.SelectedItems[0].Text)) {
                ScheduleItem item = this._schedule[control.SelectedItems[0].Text];
                if (control.SelectedItems[0].Text == DEFAULT_SETTING_NAME) dialog.DefaultSetting = true;
                else {
                    dialog.First = item.First;
                    dialog.Last = item.Last;
                }

                if (this._setting.Scheme.Find(item.ProfileName) == null) {
                    dialog.PowerSetting = item.ACValues;
                    dialog.ProfileName = CUSTOM_PROFILE;
                }
                else dialog.ProfileName = item.ProfileName;
            }

            if (dialog.ShowDialog(this) == DialogResult.OK) {
                ScheduleItem item = this.CreateScheduleItem(dialog);
                string key = dialog.DefaultSetting ? DEFAULT_SETTING_NAME : dialog.First.ToString(TIME_FORMAT) + " - " + dialog.Last.ToString(TIME_FORMAT);
                ListViewItem row = null;
                if (dialog.DefaultSetting) {
                    foreach (ListViewItem pos in this.ScheduleListView.Items) {
                        if (pos.Text == DEFAULT_SETTING_NAME) {
                            row = pos;
                            break;
                        }
                    }
                }
                else {
                    row = control.SelectedItems[0];
                    this._schedule.Remove(control.SelectedItems[0].Text);
                }
                this.UpdateSchedule(key, item, row);
                this._status = CloseStatus.Confirm;
            }
            dialog.Dispose();
        }
Esempio n. 3
0
 /* ----------------------------------------------------------------- */
 /// CreateButton_Click
 /* ----------------------------------------------------------------- */
 private void CreateButton_Click(object sender, EventArgs e)
 {
     ScheduleForm dialog = new ScheduleForm(this._setting.Scheme);
     dialog.First = DateTime.Parse("00:00");
     dialog.Last  = DateTime.Parse("23:59");
     if (dialog.ShowDialog(this) == DialogResult.OK) {
         ScheduleItem item = this.CreateScheduleItem(dialog);
         string key = dialog.DefaultSetting ? DEFAULT_SETTING_NAME : dialog.First.ToString(TIME_FORMAT) + " - " + dialog.Last.ToString(TIME_FORMAT);
         ListViewItem row = null;
         foreach (ListViewItem pos in this.ScheduleListView.Items) {
             if (key == pos.Text) {
                 row = pos;
                 break;
             }
         }
         this.UpdateSchedule(key, item, row);
         this._status = CloseStatus.Confirm;
     }
     dialog.Dispose();
 }