Exemplo n.º 1
0
        private void _cb_opcode_SelectedIndexChanged(object sender, EventArgs e)
        {
            _gb_edit.Enabled = true;

            NavigationInstruction ni = (NavigationInstruction)(NavigationInstruction)_lv_navigation.SelectedItems[0].Tag;

            ni.opcode = (NavigationInstruction.navigation_command)_cb_opcode.SelectedIndex;

            // already a navigationcommand on the panel? delete it so we can add a new one.
            if (tableLayoutPanel.Controls.Count > 1)
            {
                tableLayoutPanel.Controls.RemoveAt(1);
            }

            // Add the correct usercontrol
            Control c;

            if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CIRCLE_REL)
            {
                c = new NavigationCommands.CircleRel(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FLY_TO_REL)
            {
                c = new NavigationCommands.FlyToRel(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CIRCLE_ABS)
            {
                c = new NavigationCommands.CircleAbs(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FLY_TO_ABS)
            {
                c = new NavigationCommands.FlyToAbs(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FROM_TO_REL)
            {
                c = new NavigationCommands.FromToRel(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.GOTO)
            {
                c = new NavigationCommands.Goto(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FLARE_TO_ABS)
            {
                c = new NavigationCommands.FlareToAbs(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FLARE_TO_REL)
            {
                c = new NavigationCommands.FlareToRel(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.GLIDE_TO_ABS)
            {
                c = new NavigationCommands.GlideToAbs(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.GLIDE_TO_REL)
            {
                c = new NavigationCommands.GlideToRel(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FROM_TO_ABS)
            {
                c = new NavigationCommands.FromToAbs(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CLIMB)
            {
                c = new NavigationCommands.Climb(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.UNTIL_GR)
            {
                c = new NavigationCommands.UntilGr(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.UNTIL_SM)
            {
                c = new NavigationCommands.UntilSm(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.UNTIL_EQ)
            {
                c = new NavigationCommands.UntilEq(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.UNTIL_NE)
            {
                c = new NavigationCommands.UntilNe(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.IF_GR)
            {
                c = new NavigationCommands.IfGr(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.IF_SM)
            {
                c = new NavigationCommands.IfSm(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.IF_EQ)
            {
                c = new NavigationCommands.IfEq(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.IF_NE)
            {
                c = new NavigationCommands.IfNe(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.SERVO_SET)
            {
                c = new NavigationCommands.ServoSet(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.SERVO_TRIGGER)
            {
                c = new NavigationCommands.ServoTrigger(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.BLOCK)
            {
                c = new NavigationCommands.Block(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.SET_LOITER_POSITION)
            {
                c = new NavigationCommands.SetLoiterPosition(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.LOITER_CIRCLE)
            {
                c = new NavigationCommands.LoiterCircle(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CIRCLE_TO_REL)
            {
                c = new NavigationCommands.CircleToRel(ni);
            }
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CIRCLE_TO_ABS)
            {
                c = new NavigationCommands.CircleToAbs(ni);
            }
            else //if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.EMPTY)
            {
                c = new NavigationCommands.Empty(ni);
            }

            // add our edit-control
            tableLayoutPanel.Controls.Add(c);
            tableLayoutPanel.SetCellPosition(c, new TableLayoutPanelCellPosition(0, 0));

            // Do some lay-outin'
            c.Anchor = AnchorStyles.None;
            tableLayoutPanel.RowStyles[0].Height = c.Height;
            tableLayoutPanel.Height = _btn_set.Height + c.Height + 30;
        }
Exemplo n.º 2
0
        private void _cb_opcode_SelectedIndexChanged(object sender, EventArgs e)
        {
            _gb_edit.Enabled = true;

            NavigationInstruction ni = (NavigationInstruction)(NavigationInstruction)_lv_navigation.SelectedItems[0].Tag;

            ni.opcode = (NavigationInstruction.navigation_command)_cb_opcode.SelectedIndex;

            // already a navigationcommand on the panel? delete it so we can add a new one.
            if (tableLayoutPanel.Controls.Count > 1)
                tableLayoutPanel.Controls.RemoveAt(1);

            // Add the correct usercontrol
            Control c;
            if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CIRCLE_REL)
                c = new NavigationCommands.CircleRel(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FLY_TO_REL)
                c = new NavigationCommands.FlyToRel(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CIRCLE_ABS)
                c = new NavigationCommands.CircleAbs(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FLY_TO_ABS)
                c = new NavigationCommands.FlyToAbs(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FROM_TO_REL)
                c = new NavigationCommands.FromToRel(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.GOTO)
                c = new NavigationCommands.Goto(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FLARE_TO_ABS)
                c = new NavigationCommands.FlareToAbs(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FLARE_TO_REL)
                c = new NavigationCommands.FlareToRel(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.GLIDE_TO_ABS)
                c = new NavigationCommands.GlideToAbs(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.GLIDE_TO_REL)
                c = new NavigationCommands.GlideToRel(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.FROM_TO_ABS)
                c = new NavigationCommands.FromToAbs(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CLIMB)
                c = new NavigationCommands.Climb(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.UNTIL_GR)
                c = new NavigationCommands.UntilGr(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.UNTIL_SM)
                c = new NavigationCommands.UntilSm(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.UNTIL_EQ)
                c = new NavigationCommands.UntilEq(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.UNTIL_NE)
                c = new NavigationCommands.UntilNe(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.IF_GR)
                c = new NavigationCommands.IfGr(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.IF_SM)
                c = new NavigationCommands.IfSm(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.IF_EQ)
                c = new NavigationCommands.IfEq(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.IF_NE)
                c = new NavigationCommands.IfNe(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.SERVO_SET)
                c = new NavigationCommands.ServoSet(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.SERVO_TRIGGER)
                c = new NavigationCommands.ServoTrigger(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.BLOCK)
                c = new NavigationCommands.Block(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.SET_LOITER_POSITION)
                c = new NavigationCommands.SetLoiterPosition(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.LOITER_CIRCLE)
                c = new NavigationCommands.LoiterCircle(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CIRCLE_TO_REL)
                c = new NavigationCommands.CircleToRel(ni);
            else if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.CIRCLE_TO_ABS)
                c = new NavigationCommands.CircleToAbs(ni);
            else //if (_cb_opcode.SelectedIndex == (int)NavigationInstruction.navigation_command.EMPTY)
                c = new NavigationCommands.Empty(ni);

            // add our edit-control
            tableLayoutPanel.Controls.Add(c);
            tableLayoutPanel.SetCellPosition(c, new TableLayoutPanelCellPosition(0, 0));

            // Do some lay-outin'
            c.Anchor = AnchorStyles.None;
            tableLayoutPanel.RowStyles[0].Height = c.Height;
            tableLayoutPanel.Height = _btn_set.Height + c.Height + 30;
        }