public void BuildFromAction(OrAction pastAction)
        {
            Action        = pastAction;
            TBName.Text   = pastAction.Name;
            TBTimout.Text = pastAction.Timeout.ToString();

            RebuildActionList();
        }
        private void AddAction(Action action)
        {
            if (Action == null)
            {
                Action = new OrAction();
            }

            if (!LBAction.Items.Contains(action.Name))
            {
                this.Action.AddAction(action);
                RebuildActionList();
            }
            else
            {
                MessageBox.Show("Sorry '" + action.Name + "' is already asigned to another action");
                return;
            }
        }
        private Action LoadAction(StreamReader streamReader)
        {
            Action action = null;

            string line = streamReader.ReadLine();//read ActionType:
            string type = line.Substring(11);

            if (type == "Position")
            {
                PositionAction posAction = new PositionAction();
                posAction.Name           = streamReader.ReadLine().Substring(11);                            //read name:
                posAction.Timeout        = float.Parse(streamReader.ReadLine().Substring(8));                //read FBP:
                posAction.FirstBodyPart  = int.Parse(streamReader.ReadLine().Substring(4));                  //read FBP:
                posAction.Relationship   = int.Parse(streamReader.ReadLine().Substring(9));                  //read Relationship:
                posAction.SecondBodyPart = int.Parse(streamReader.ReadLine().Substring(4));                  //read SBP:
                posAction.UpperBoundsRelationshipValue = float.Parse(streamReader.ReadLine().Substring(17)); //read UpperBoundsValue:
                posAction.LowerBoundsRelationshipValue = float.Parse(streamReader.ReadLine().Substring(17)); //read LowerBoundsValue:

                action = posAction;
            }

            else if (type == "Velocity")
            {
                VelocityAction velAction = new VelocityAction();
                velAction.Name              = streamReader.ReadLine().Substring(11);             //read name:
                velAction.Timeout           = float.Parse(streamReader.ReadLine().Substring(8)); //read FBP:
                velAction.FirstBodyPart     = int.Parse(streamReader.ReadLine().Substring(4));   //read FBP:
                velAction.Relationship      = int.Parse(streamReader.ReadLine().Substring(9));   //read Relationship:
                velAction.RelationshipValue = float.Parse(streamReader.ReadLine().Substring(6)); //read RelationshipL:

                action = velAction;
            }

            else if (type == "ConditionalVelocity")
            {
                ConditionalVelocityAction velAction = new ConditionalVelocityAction();
                velAction.Name                  = streamReader.ReadLine().Substring(11);              //read name:
                velAction.Timeout               = float.Parse(streamReader.ReadLine().Substring(8));  //read FBP:
                velAction.FirstBodyPart         = int.Parse(streamReader.ReadLine().Substring(4));    //read FBP:
                velAction.VelocityRelationship  = int.Parse(streamReader.ReadLine().Substring(17));   //read VelocityRelation:
                velAction.ConditionalBodyPart   = int.Parse(streamReader.ReadLine().Substring(12));   //read ConditionBP:
                velAction.ConditionRelationship = int.Parse(streamReader.ReadLine().Substring(24));   //read ConditionalRelationship:
                velAction.RelationshipValue     = float.Parse(streamReader.ReadLine().Substring(14)); //read VelocityValue:

                if (streamReader.ReadLine() == "-----InnerAction-----")
                {
                    velAction.PassAction = ( AndAction )LoadAction(streamReader);
                }

                action = velAction;
            }

            else if (type == "And")
            {
                AndAction andAction = new AndAction();
                andAction.Name    = streamReader.ReadLine().Substring(11);             //read name:
                andAction.Timeout = float.Parse(streamReader.ReadLine().Substring(8)); //read FBP:

                while (true)
                {
                    line = streamReader.ReadLine();
                    if (line == "-----MultiEnd-----")
                    {
                        break;
                    }
                    else if (line == "-----InnerAction-----")
                    {
                        andAction.AddAction(LoadAction(streamReader));
                    }
                }

                action = andAction;
            }

            else if (type == "Or")
            {
                OrAction andAction = new OrAction();
                andAction.Name    = streamReader.ReadLine().Substring(11);             //read name:
                andAction.Timeout = float.Parse(streamReader.ReadLine().Substring(8)); //read FBP:

                while (true)
                {
                    line = streamReader.ReadLine();
                    if (line == "-----MultiEnd-----")
                    {
                        break;
                    }
                    else if (line == "-----InnerAction-----")
                    {
                        andAction.AddAction(LoadAction(streamReader));
                    }
                }

                action = andAction;
            }

            else if (type == "Time")
            {
                TimeAction timeAction = new TimeAction();
                timeAction.Name       = streamReader.ReadLine().Substring(11);              //read name:
                timeAction.Timeout    = float.Parse(streamReader.ReadLine().Substring(8));  //read FBP:
                timeAction.TimeToPass = float.Parse(streamReader.ReadLine().Substring(11)); //read TimeToPass

                action = timeAction;
            }

            return(action);
        }