예제 #1
0
        private void ConditionTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (ConditionTree.SelectedNode == null)
            {
                PassCmdBox.Items.Clear();
                TargetStateBox.Text = "";
                activeCondition     = null;
            }
            else
            {
                activeNode            = ConditionTree.SelectedNode;
                activeCommand         = null;
                CmdProperties.Enabled = false;
                int[] nodePath = activeNode.Name.Substring(4).Split('-').Select(k => Int32.Parse(k)).ToArray();
                activeCondition = activeState.Conditions[nodePath[0]];

                for (int i = 1; i < nodePath.Length; i++)
                {
                    try
                    {
                        activeCondition = activeCondition.Subconditions[nodePath[i]];
                    } catch (Exception ex)
                    {
                        MessageBox.Show("ERROR on node path " + ConditionTree.SelectedNode.Name.Substring(4));
                        Editor.ByteProvider = new DynamicByteProvider(new byte[] { });
                        TargetStateBox.Text = "";
                        activeCondition     = null;
                        return;
                    }
                }

                TargetStateBox.Text = activeCondition.TargetState.ToString();

                activeCommand  = null;
                activeEditType = EditType.Evaluator;
                RefreshEditor();
                RefreshTitle();

                foreach (var command in activeCondition.PassCommands)
                {
                    PassCmdBox.Items.Add(command.CommandID);
                }

                PassCmdBox.SelectedItem  = null;
                EntryCmdBox.SelectedItem = null;
                ExitCmdBox.SelectedItem  = null;
                WhileCmdBox.SelectedItem = null;
            }
        }
예제 #2
0
        private void AddConditionNode(ESD.Condition condition, TreeNode parent)
        {
            string   cName = parent.Name + "-" + parent.Nodes.Count;
            TreeNode cNode = new TreeNode(cName);

            if (condition.TargetState != null)
            {
                cNode.Text = cName + " → " + condition.TargetState.ToString();
            }
            cNode.Name = cName;
            parent.Nodes.Add(cNode);
            foreach (var subcondition in condition.Subconditions)
            {
                AddConditionNode(subcondition, cNode);
            }
        }
예제 #3
0
        private void AddConditionNode(ESD.Condition condition)
        {
            int      cNum  = activeState.Conditions.IndexOf(condition);
            TreeNode cNode = new TreeNode();

            cNode.Name = "CND " + cNum;
            cNode.Text = "CND " + cNum;
            if (condition.TargetState != null)
            {
                cNode.Text += " → " + condition.TargetState.ToString();
            }
            ConditionTree.Nodes.Add(cNode);
            foreach (var subcondition in condition.Subconditions)
            {
                AddConditionNode(subcondition, cNode);
            }
        }
예제 #4
0
 private void SelectCommand(ListBox commandBox, ESD.CommandCall command)
 {
     activeEditType = EditType.Null;
     ListBox[] boxes = { EntryCmdBox, ExitCmdBox, WhileCmdBox, PassCmdBox };
     foreach (var box in boxes.Where(b => b != commandBox))
     {
         box.SelectedItem = null;
     }
     Editor.ByteProvider = new DynamicByteProvider(new byte[] { });
     activeCommand       = command;
     activeEditType      = EditType.CommandArg;
     if (commandBox != PassCmdBox)
     {
         ConditionTree.SelectedNode = null;
         activeCondition            = null;
     }
     RefreshEditor();
     RefreshTitle();
 }
예제 #5
0
        private void StateBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            activeState = null;
            if (activeStateGroup != null)
            {
                activeCondition            = null;
                ConditionTree.SelectedNode = null;
                ConditionTree.Nodes.Clear();
                Editor.ByteProvider = new DynamicByteProvider(new byte[] { });
                TargetStateBox.Clear();
                PassCmdBox.Items.Clear();
                EntryCmdBox.Items.Clear();
                ExitCmdBox.Items.Clear();
                WhileCmdBox.Items.Clear();

                if (StateBox.SelectedItem != null)
                {
                    long stateKey = (long)StateBox.SelectedItem;
                    activeState = activeStateGroup[stateKey];
                    foreach (var condition in activeState.Conditions)
                    {
                        AddConditionNode(condition);
                    }

                    foreach (var command in activeState.EntryCommands)
                    {
                        EntryCmdBox.Items.Add(command.CommandID);
                    }
                    foreach (var command in activeState.ExitCommands)
                    {
                        ExitCmdBox.Items.Add(command.CommandID);
                    }
                    foreach (var command in activeState.WhileCommands)
                    {
                        WhileCmdBox.Items.Add(command.CommandID);
                    }
                }
            }
        }
예제 #6
0
        private ESD.State CloneState(ESD.State orig)
        {
            var newState = new ESD.State();

            foreach (var v in orig.EntryCommands)
            {
                newState.EntryCommands.Add(new CommandCall()
                {
                    CommandBank = v.CommandBank,
                    CommandID   = v.CommandID,
                    Arguments   = v.Arguments,
                });
            }

            foreach (var v in orig.ExitCommands)
            {
                newState.ExitCommands.Add(new CommandCall()
                {
                    CommandBank = v.CommandBank,
                    CommandID   = v.CommandID,
                    Arguments   = v.Arguments,
                });
            }

            foreach (var v in orig.Conditions)
            {
                var newCondition = new ESD.Condition()
                {
                    Evaluator   = v.Evaluator,
                    TargetState = v.TargetState,
                };

                foreach (var vv in v.PassCommands)
                {
                    newCondition.PassCommands.Add(new CommandCall()
                    {
                        CommandBank = vv.CommandBank,
                        CommandID   = vv.CommandID,
                        Arguments   = vv.Arguments,
                    });
                }

                foreach (var vv in v.Subconditions)
                {
                    var newSubCondition = new ESD.Condition()
                    {
                        Evaluator     = vv.Evaluator,
                        TargetState   = vv.TargetState,
                        Subconditions = vv.Subconditions,
                    };

                    foreach (var vvv in vv.PassCommands)
                    {
                        newSubCondition.PassCommands.Add(new CommandCall()
                        {
                            CommandBank = vvv.CommandBank,
                            CommandID   = vvv.CommandID,
                            Arguments   = vvv.Arguments,
                        });
                    }

                    newCondition.Subconditions.Add(newSubCondition);
                }

                newState.Conditions.Add(newCondition);
            }

            return(newState);
        }