Exemple #1
0
        private void onSelectionChanged(object sender, System.EventArgs e)
        {
            bool b   = (triggerList.SelectedIndices.Count != 0);
            int  idx = -1;

            if (b)
            {
                idx = selectedIndex;
            }

            buttonUp.Enabled      = b && idx != 0;
            buttonDown.Enabled    = b && idx != triggerList.Items.Count - 1;
            buttonRemove.Enabled  = b;
            buttonReplace.Enabled = b;

            if (idx != -1)
            {
                // update the edit box
                AdvStationRule rule = selectedRule;

                if (rule.month == -1)
                {
                    monthBox.SelectedIndex = 0;
                }
                else
                {
                    monthBox.SelectedIndex = rule.month;
                }

                if (rule.day == -1)
                {
                    dayBox.SelectedIndex = 0;
                }
                else
                {
                    dayBox.SelectedIndex = rule.month;
                }

                dayOfWeekBox.SelectedIndex = rule.dayOfWeek + 1;

                hourBox.SelectedIndex = rule.hour + 1;

                if (rule.minutes == -1)
                {
                    minBox.SelectedIndex = 0;
                }
                else
                {
                    minBox.SelectedIndex = (rule.minutes / 10) + 1;
                }

                radioGo.Checked      = (rule.action == StationAction.go);
                radioPass.Checked    = (rule.action == StationAction.pass);
                radioStop.Checked    = (rule.action == StationAction.stop);
                radioReverse.Checked = (rule.action == StationAction.reverse);
            }
        }
Exemple #2
0
        private void buttonReplace_Click(object sender, System.EventArgs e)
        {
            int idx = selectedIndex;

            // update the data structure
            AdvStationRule tm = createRule();

            station.rules.set(idx, tm);

            // update the UI
            ListViewItem lvi = triggerList.Items[idx];

            updateListViewItem(tm, lvi);
        }
Exemple #3
0
        private AdvStationRule createRule()
        {
            AdvStationRule tm = new AdvStationRule();

            tm.month = (sbyte)monthBox.SelectedIndex;
            if (tm.month == 0)
            {
                tm.month = -1;
            }

            tm.day = (sbyte)dayBox.SelectedIndex;
            if (tm.day == 0)
            {
                tm.day = -1;
            }

            tm.dayOfWeek = (sbyte)(dayOfWeekBox.SelectedIndex - 1);

            tm.hour = (sbyte)(hourBox.SelectedIndex - 1);

            tm.minutes = (sbyte)(minBox.SelectedIndex * 10);
            if (tm.minutes == 0)
            {
                tm.minutes = -1;
            }
            else
            {
                tm.minutes -= 10;
            }

            if (radioPass.Checked)
            {
                tm.action = StationAction.pass;
            }
            if (radioStop.Checked)
            {
                tm.action = StationAction.stop;
            }
            if (radioGo.Checked)
            {
                tm.action = StationAction.go;
            }
            if (radioReverse.Checked)
            {
                tm.action = StationAction.reverse;
            }

            return(tm);
        }
Exemple #4
0
        private void buttonAdd_Click(object sender, System.EventArgs e)
        {
            // update the data structure
            AdvStationRule tm = createRule();

            station.rules.add(tm);

            // update the UI
            ListViewItem lvi = new ListViewItem();

            updateListViewItem(tm, lvi);
            triggerList.Items.Add(lvi);

            resetEntryBoxes();
        }
Exemple #5
0
        private void moveData(int offset)
        {
            int idx = selectedIndex;

            // update the data structure
            AdvStationRule rule = selectedRule;

            station.rules.remove(rule);
            station.rules.insert(idx + offset, rule);

            // update the UI
            ListViewItem lvi = triggerList.Items[idx];

            triggerList.Items.Remove(lvi);
            triggerList.Items.Insert(idx + offset, lvi);
        }
Exemple #6
0
        private void updateListViewItem(AdvStationRule rule, ListViewItem lvi)
        {
            lvi.SubItems.Clear();

            lvi.Tag  = rule;
            lvi.Text = numberToString(rule.month);

            lvi.SubItems.Add(numberToString(rule.day));
            if (rule.dayOfWeek == -1)
            {
                lvi.SubItems.Add("*");
            }
            else
            {
                lvi.SubItems.Add("" + Clock.dayOfWeekChar(rule.dayOfWeek));
            }
            lvi.SubItems.Add(numberToString(rule.hour));
            lvi.SubItems.Add(numberToString(rule.minutes));

            lvi.SubItems.Add(displayName(rule.action));
        }
Exemple #7
0
 public void set(int idx, AdvStationRule rule)
 {
     this.List[idx] = rule;
 }
Exemple #8
0
 public void insert(int idx, AdvStationRule rule)
 {
     this.List.Insert(idx, rule);
 }
Exemple #9
0
 public void remove(AdvStationRule rule)
 {
     this.List.Remove(rule);
 }
Exemple #10
0
 public void add(AdvStationRule rule)
 {
     this.List.Add(rule);
 }