Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            BuildAndGesture CAB = new BuildAndGesture();

            if (CAB.ShowDialog() == DialogResult.OK)
            {
                Action.PassAction     = CAB.Action;
                TBActionEndPoint.Text = Action.PassAction.Name;
                BEdit.Enabled         = true;
            }
        }
        private void BBuild_Click(object sender, EventArgs e)
        {
            if (CBActionType.SelectedIndex == 0)
            {
                BuildPositionAction bsp = new BuildPositionAction();

                if (bsp.ShowDialog() == DialogResult.OK)
                {
                    AddAction(bsp.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 1)
            {
                BuildVelocityAction velocityAction = new BuildVelocityAction();

                if (velocityAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(velocityAction.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 2)
            {
                BuildAndGesture andAction = new BuildAndGesture();

                if (andAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(andAction.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 3)
            {
                BuildOrGesture orAction = new BuildOrGesture();

                if (orAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(orAction.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 4)
            {
                BuildTimeAction timeAction = new BuildTimeAction();

                if (timeAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(timeAction.Action);
                }
            }
        }
        private void BEdit_Click(object sender, EventArgs e)
        {
            if (LBAction.SelectedItem != null)
            {
                Action action = Action.GetAction(LBAction.SelectedItem.ToString());

                try
                {
                    Action.Timeout = float.Parse(TBTimout.Text);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Timeout value must be a float");
                    return;
                }

                Action updatedAction = null;

                if (action.GetType().ToString().Contains("PositionAction"))
                {
                    BuildPositionAction bsp = new BuildPositionAction();
                    bsp.BuildFromAction(( PositionAction )action);

                    if (bsp.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = bsp.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("VeloctiyAction"))
                {
                    BuildVelocityAction velocityAction = new BuildVelocityAction();
                    velocityAction.BuildFromAction(( VelocityAction )action);

                    if (velocityAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = velocityAction.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("AndAction"))
                {
                    BuildAndGesture andAction = new BuildAndGesture();
                    andAction.BuildFromAction(( AndAction )action);

                    if (andAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = andAction.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("OrAction"))
                {
                    BuildOrGesture orAction = new BuildOrGesture();
                    orAction.BuildFromAction(( OrAction )action);

                    if (orAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = orAction.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("TimeAction"))
                {
                    BuildTimeAction timeAction = new BuildTimeAction();
                    timeAction.BuildFromAction(( TimeAction )action);

                    if (timeAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = timeAction.Action;
                    }
                }

                if (updatedAction != null)
                {
                    Action.ReplaceAction(action, updatedAction);
                    RebuildActionList();
                }
            }
            else
            {
                MessageBox.Show("Select an action to edit");
            }
        }
        private void BEdit_Click(object sender, EventArgs e)
        {
            if (LBActions.SelectedItem != null)
            {
                Gesture currentGesture = GetGesture(GetSelectedNodeSkeliton(), TVGesturesSkel1.SelectedNode.Text);
                Action  action         = currentGesture.GetAction(LBActions.SelectedItem.ToString());
                Action  updatedAction  = null;

                if (action.GetType().ToString().Contains("PositionAction"))
                {
                    BuildPositionAction bsp = new BuildPositionAction();
                    bsp.BuildFromAction(( PositionAction )action);

                    if (bsp.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = bsp.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("ConditionalVelocityAction"))
                {
                    ConditionalActionBuilder velocityAction = new ConditionalActionBuilder();
                    velocityAction.BuildFromAction(( ConditionalVelocityAction )action);

                    if (velocityAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = velocityAction.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("VelocityAction"))
                {
                    BuildVelocityAction velocityAction = new BuildVelocityAction();
                    velocityAction.BuildFromAction(( VelocityAction )action);

                    if (velocityAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = velocityAction.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("AndAction"))
                {
                    BuildAndGesture andAction = new BuildAndGesture();
                    andAction.BuildFromAction(( AndAction )action);

                    if (andAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = andAction.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("OrAction"))
                {
                    BuildOrGesture orAction = new BuildOrGesture();
                    orAction.BuildFromAction(( OrAction )action);

                    if (orAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = orAction.Action;
                    }
                }

                else if (action.GetType().ToString().Contains("TimeAction"))
                {
                    BuildTimeAction timeAction = new BuildTimeAction();
                    timeAction.BuildFromAction(( TimeAction )action);

                    if (timeAction.ShowDialog() == DialogResult.OK)
                    {
                        updatedAction = timeAction.Action;
                    }
                }

                if (updatedAction != null)
                {
                    currentGesture.ReplaceAction(action, updatedAction);
                    RebuildActionList();
                }
            }
            else
            {
                MessageBox.Show("Select an action to edit");
            }
        }
        private void BBuild_Click(object sender, EventArgs e)
        {
            if (CBActionType.SelectedIndex == 0)
            {
                BuildPositionAction bsp = new BuildPositionAction();

                if (bsp.ShowDialog() == DialogResult.OK)
                {
                    AddAction(GetSelectedNodeSkeliton(), bsp.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 1)
            {
                BuildVelocityAction velocityAction = new BuildVelocityAction();

                if (velocityAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(GetSelectedNodeSkeliton(), velocityAction.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 2)
            {
                ConditionalActionBuilder cAction = new ConditionalActionBuilder();

                if (cAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(GetSelectedNodeSkeliton(), cAction.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 3)
            {
                BuildAndGesture andAction = new BuildAndGesture();

                if (andAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(GetSelectedNodeSkeliton(), andAction.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 4)
            {
                BuildOrGesture orAction = new BuildOrGesture();

                if (orAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(GetSelectedNodeSkeliton(), orAction.Action);
                }
            }

            else if (CBActionType.SelectedIndex == 5)
            {
                BuildTimeAction timeAction = new BuildTimeAction();

                if (timeAction.ShowDialog() == DialogResult.OK)
                {
                    AddAction(GetSelectedNodeSkeliton(), timeAction.Action);
                }
            }
        }