コード例 #1
0
 public static void SortSubNodes(LogicTreeNode myNode)
 {
     foreach (LogicTreeNode subNode in myNode.subNodes)
     {
         SortSubNodes(subNode);
     }
     myNode.subNodes = SortList(myNode.subNodes);
 }
コード例 #2
0
        public LogicTreeNode Duplicate()
        {
            LogicTreeNode copy = new LogicTreeNode();
            copy = (LogicTreeNode)this.MemberwiseClone();

            copy.actions = new List<Action>();
            foreach (Action a in this.actions)
            {
                Action ac = a.DeepCopy();
                copy.actions.Add(ac);
            }
            copy.conditions = new List<Condition>();
            foreach (Condition c in this.conditions)
            {
                Condition cc = c.DeepCopy();
                copy.conditions.Add(cc);
            }
            foreach (LogicTreeNode node in this.subNodes)
            {
                copy.subNodes.Add(node.Duplicate());
            }
            return copy;
        }
コード例 #3
0
        public TreeNode PopulateTreeNode(LogicTreeNode node)
        {
            TreeNode treenode = new TreeNode(node.nodeText);  // Add the Text to the Node
            if (node.IsExpanded) { treenode.Expand(); }
            treenode.Name = node.idNum.ToString();
            if ((node.conditions.Count > 0) && (node.actions.Count > 0))
            {
                treenode.ImageIndex = 3;
                treenode.SelectedImageIndex = 3;
            }
            else if (node.conditions.Count > 0)
            {
                treenode.ImageIndex = 1;
                treenode.SelectedImageIndex = 1;
            }
            else if (node.actions.Count > 0)
            {
                treenode.ImageIndex = 2;
                treenode.SelectedImageIndex = 2;
            }
            else
            {
                treenode.ImageIndex = 0;
                treenode.SelectedImageIndex = 0;
            }

            if (node.isLink)
            {
                treenode.Text = lt.GetLogicTreeNodeById(node.linkTo).nodeText;
                node.nodeText = lt.GetLogicTreeNodeById(node.linkTo).nodeText;
            }
            treenode.ForeColor = Color.Blue;

            if (!chkShowTextOnly.Checked)
            {
                //create a string of all the conditions and actions and insert to beginning of treenode.Text
                string condactText = "";
                foreach (Condition c in node.conditions)
                {
                    condactText += "[" + c.c_script
                        + "(" + c.c_parameter_1 + ","
                        + c.c_parameter_2 + ","
                        + c.c_parameter_3 + ","
                        + c.c_parameter_4 + ")] ";
                }
                foreach (Action a in node.actions)
                {
                    condactText += "[" + a.a_script
                        + "(" + a.a_parameter_1 + ","
                        + a.a_parameter_2 + ","
                        + a.a_parameter_3 + ","
                        + a.a_parameter_4 + ")] ";
                }
                treenode.Text += "  " + condactText;
            }

            if (node.subNodes.Count == 0)
            {
                treenode.Text += " [END LOGIC TREE]";
            }

            for (int i = 0; i < node.subNodes.Count; i++)
            {
                if (node.subNodes[i].subNodes.Count >= 0)
                {
                    treenode.Nodes.Add(PopulateTreeNode(node.subNodes[i]));
                }
            }
            if (node.isLink)
            {
                treenode.ForeColor = Color.Gray;
            }
            return treenode;
        }
コード例 #4
0
 public LogicTreeNode NewContentNodeLink(int nextOrderNum)
 {
     LogicTreeNode newNode = new LogicTreeNode();
     newNode.orderNum = nextOrderNum;
     return newNode;
 }
コード例 #5
0
ファイル: LogicTree.cs プロジェクト: slowdive-fan/IB2Toolset
 public void AddNodeToRoot(LogicTreeNode contentNode)
 {
     SubNodes.Add(contentNode);
 }
コード例 #6
0
 private void loadValueForCondComboBoxes(LogicTreeNode cnod)
 {
     for (int i = 0; i < dgvCondition.Rows.Count; i++)
     {
         //AndOr column is index 1
         if (scriptList.Contains(cnod.conditions[i].c_script))
         {
             dgvCondition[3, i].Value = cnod.conditions[i].c_script;
         }
         else
         {
             prntForm.logText("[ERROR] Can't find the script that was assigned to this node, choose one from the list." + Environment.NewLine);
         }
     }
 }
コード例 #7
0
        public void AddNode()
        {
            try
            {
                LogicTreeNode chdnod = lt.GetLogicTreeNodeById(Convert.ToInt32(treeView1.SelectedNode.Name));
                if (!chdnod.isLink)
                {
                    PushToUndoStack();

                    lt.NextIdNum++;

                    //ContentNode Stuff
                    LogicTreeNode newNode = new LogicTreeNode();
                    newNode = newNode.NewContentNode(lt.NextIdNum);
                    newNode.orderNum = treeView1.SelectedNode.Nodes.Count;
                    LogicTreeNode pnod = lt.GetLogicTreeNodeById(Convert.ToInt32(treeView1.SelectedNode.Name));
                    pnod.IsExpanded = true;
                    pnod.AddNodeToSubNode(newNode);

                    refreshTreeView();
                    TreeNode[] tn = treeView1.Nodes.Find(lt.NextIdNum.ToString(), true);
                    if (tn[0] != null)
                    {
                        treeView1.SelectedNode = tn[0];
                        currentSelectedNode = tn[0];
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("add node failed: " + ex.ToString());
            }
        }
コード例 #8
0
 private LogicTreeNode createLinkNode(LogicTreeNode copiedNode)
 {
     lt.NextIdNum++;
     LogicTreeNode copy = new LogicTreeNode();
     copy.nodeText = copiedNode.nodeText;
     copy.idNum = lt.NextIdNum;
     return copy;
 }
コード例 #9
0
        private void btnCondMoveDown_Click(object sender, EventArgs e)
        {
            int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
            LogicTreeNode chdnod = new LogicTreeNode();
            chdnod = lt.GetLogicTreeNodeById(cnod);
            int oldIndex = getIndexOfSelectedCondition();
            int newIndex = oldIndex + 1;

            if ((newIndex < chdnod.conditions.Count) && (oldIndex >= 0))
            {
                var item = chdnod.conditions[oldIndex];
                chdnod.conditions.RemoveAt(oldIndex);
                //newIndex--; // the actual index could have shifted due to the removal
                chdnod.conditions.Insert(newIndex, item);
                setupConditionsDataGridView();
            }
        }
コード例 #10
0
 public void CopyNodes()
 {
     try
     {
         int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
         int prnod = Convert.ToInt32(treeView1.SelectedNode.Parent.Name);
         LogicTreeNode chdnod = new LogicTreeNode();
         chdnod = lt.GetLogicTreeNodeById(cnod);
         if (!chdnod.isLink)
         {
             copyToClipboardNode = Convert.ToInt32(treeView1.SelectedNode.Name);
             copyToClipboardNodeParentNode = Convert.ToInt32(treeView1.SelectedNode.Parent.Name);
             prntForm.logText("You selected idNum = " + copyToClipboardNode.ToString() + " to copy to the clipboard");
         }
     }
     catch { MessageBox.Show("copy node failed"); }
 }
コード例 #11
0
        private void setupConditionsDataGridView()
        {
            int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
            LogicTreeNode chdnod = new LogicTreeNode();
            chdnod = lt.GetLogicTreeNodeById(cnod);

            dgvCondition.DataSource = chdnod.conditions;
            dgvCondition.AutoGenerateColumns = false;

            DataGridViewColumn column0 = new DataGridViewCheckBoxColumn();
            //column0.DataPropertyName = "Select";
            column0.HeaderText = "Select";
            column0.Name = "select";
            column0.Width = 45;

            DataGridViewColumn columnA = new DataGridViewButtonColumn();
            columnA.DataPropertyName = "c_btnAndOr";
            columnA.HeaderText = "AndOr";
            columnA.Name = "c_btnAndOr";
            columnA.Width = 45;

            DataGridViewColumn columnB = new DataGridViewCheckBoxColumn();
            columnB.DataPropertyName = "c_not";
            columnB.HeaderText = "Not";
            columnB.Name = "c_not";
            columnB.Width = 35;

            DataGridViewComboBoxColumn selScript = new DataGridViewComboBoxColumn();
            selScript.Items.Add("none");
            foreach (string script in scriptList)
            {
                selScript.Items.Add(script);
            }
            selScript.DefaultCellStyle.NullValue = "none";
            selScript.Name = "selectScript";
            selScript.Width = 150;

            DataGridViewColumn columnD = new DataGridViewTextBoxColumn();
            columnD.DataPropertyName = "c_parameter_1";
            columnD.HeaderText = "Parameter 1";
            columnD.Name = "c_parameter_1";
            columnD.Width = 130;

            DataGridViewColumn columnE = new DataGridViewTextBoxColumn();
            columnE.DataPropertyName = "c_parameter_2";
            columnE.HeaderText = "Parameter 2";
            columnE.Name = "c_parameter_2";
            columnE.Width = 130;

            DataGridViewColumn columnF = new DataGridViewTextBoxColumn();
            columnF.DataPropertyName = "c_parameter_3";
            columnF.HeaderText = "Parameter 3";
            columnF.Name = "c_parameter_3";
            columnF.Width = 130;

            DataGridViewColumn columnG = new DataGridViewTextBoxColumn();
            columnG.DataPropertyName = "c_parameter_4";
            columnG.HeaderText = "Parameter 4";
            columnG.Name = "c_parameter_4";
            columnG.Width = 130;

            dgvCondition.Columns.Clear();
            dgvCondition.Columns.Add(column0);
            dgvCondition.Columns.Add(columnA);
            dgvCondition.Columns.Add(columnB);
            //dgvCondition.Columns.Add(columnC);
            dgvCondition.Columns.Add(selScript);
            dgvCondition.Columns.Add(columnD);
            dgvCondition.Columns.Add(columnE);
            dgvCondition.Columns.Add(columnF);
            dgvCondition.Columns.Add(columnG);
            loadAndOrButtonValues(chdnod);
            loadValueForCondComboBoxes(chdnod);
            //loadSelectScriptButtonValues();
        }
コード例 #12
0
        public LogicTreeNode DuplicateContentNode(int nextIdNum)
        {
            LogicTreeNode newNode = new LogicTreeNode();
            newNode.nodeText = this.nodeText;
            newNode.linkTo = this.linkTo;
            newNode.IsExpanded = this.IsExpanded;

            newNode.actions = new List<Action>();
            foreach (Action a in this.actions)
            {
                Action ac = a.DeepCopy();
                newNode.actions.Add(ac);
            }
            newNode.conditions = new List<Condition>();
            foreach (Condition c in this.conditions)
            {
                Condition cc = c.DeepCopy();
                newNode.conditions.Add(cc);
            }

            return newNode;
        }
コード例 #13
0
 public void AddNodeToSubNode(LogicTreeNode contentNode)
 {
     subNodes.Add(contentNode);
 }
コード例 #14
0
 public void RemoveNodeFromSubNode(LogicTreeNode contentNode)
 {
     bool returnvalue = subNodes.Remove(contentNode);
 }
コード例 #15
0
 public void ResetOrderNumBasedOnIndex(LogicTreeNode node)
 {
     //ContentNode returnNode = new ContentNode();
     for (int i = 0; i < node.subNodes.Count; i++)
     {
         node.subNodes[i].orderNum = i;
     }
     foreach (LogicTreeNode n in node.subNodes)
     {
         ResetOrderNumBasedOnIndex(n);
     }
     //return returnNode;
 }
コード例 #16
0
        private void btnActMoveDown_Click(object sender, EventArgs e)
        {
            int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
            LogicTreeNode chdnod = new LogicTreeNode();
            chdnod = lt.GetLogicTreeNodeById(cnod);
            int oldIndex = getIndexOfSelectedAction();
            int newIndex = oldIndex + 1;

            if ((newIndex < chdnod.actions.Count) && (oldIndex >= 0))
            {
                var item = chdnod.actions[oldIndex];
                chdnod.actions.RemoveAt(oldIndex);
                chdnod.actions.Insert(newIndex, item);
                setupActionsDataGridView();
            }
        }
コード例 #17
0
 public LogicTreeNode duplicateNode(LogicTreeNode copiedNode)
 {
     lt.NextIdNum++;
     prntForm.logText("NextIdNum = " + lt.NextIdNum.ToString());
     LogicTreeNode copy = new LogicTreeNode();
     copy = copiedNode.DuplicateContentNode(lt.NextIdNum);
     //copy.conversationText = copiedNode.conversationText;
     copy.idNum = lt.NextIdNum;
     foreach (LogicTreeNode node in copiedNode.subNodes)
     {
         copy.subNodes.Add(duplicateNode(node));
     }
     return copy;
 }
コード例 #18
0
        private void btnCondMoveUp_Click(object sender, EventArgs e)
        {
            int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
            LogicTreeNode chdnod = new LogicTreeNode();
            chdnod = lt.GetLogicTreeNodeById(cnod);
            int oldIndex = getIndexOfSelectedCondition();
            int newIndex = oldIndex - 1;

            if (newIndex >= 0)
            {
                var item = chdnod.conditions[oldIndex];
                chdnod.conditions.RemoveAt(oldIndex);
                chdnod.conditions.Insert(newIndex, item);
                setupConditionsDataGridView();
            }
        }
コード例 #19
0
 public LogicTreeNode duplicateNodeKeepIds(LogicTreeNode copiedNode)
 {
     LogicTreeNode copy = new LogicTreeNode();
     copy = copiedNode.DuplicateContentNode();
     foreach (LogicTreeNode node in copiedNode.subNodes)
     {
         copy.subNodes.Add(duplicateNodeKeepIds(node));
     }
     return copy;
 }
コード例 #20
0
 public void FollowLink()
 {
     try
     {
         int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
         LogicTreeNode chdnod = new LogicTreeNode();
         chdnod = lt.GetLogicTreeNodeById(cnod);
         TreeNode[] tn = treeView1.Nodes.Find(chdnod.linkTo.ToString(), true);
         //TreeNode[] tn = treeView1.Nodes.Find(f_convo.NextIdNum.ToString(), true);
         if (tn[0] != null)
         {
             treeView1.SelectedNode = tn[0];
             currentSelectedNode = tn[0];
         }
     }
     catch { MessageBox.Show("follow link node failed"); }
 }
コード例 #21
0
 public void PasteAsLink()
 {
     pasteFromClipboardNode = Convert.ToInt32(treeView1.SelectedNode.Name);
     try
     {
         int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
         LogicTreeNode chdnod = new LogicTreeNode();
         chdnod = lt.GetLogicTreeNodeById(cnod);
         if (!chdnod.isLink)
         {
             PushToUndoStack();
             //MessageBox.Show("You selected idNum = " + pasteFromClipboardNode.ToString() + " to paste as link from the clipboard");
             LogicTreeNode copy = createLinkNode(lt.GetLogicTreeNodeById(copyToClipboardNode));
             copy.linkTo = copyToClipboardNode;
             LogicTreeNode subcnt = lt.GetLogicTreeNodeById(pasteFromClipboardNode);
             copy.orderNum = subcnt.subNodes.Count;
             lt.GetLogicTreeNodeById(pasteFromClipboardNode).AddNodeToSubNode(copy);
             refreshTreeView();
         }
     }
     catch { MessageBox.Show("paste as link node failed"); }
 }
コード例 #22
0
 private void loadAndOrButtonValues(LogicTreeNode cnod)
 {
     for (int i = 0; i < dgvCondition.Rows.Count; i++)
     {
         //AndOr column is index 1
         dgvCondition[1, i].Value = cnod.conditions[i].c_btnAndOr;
     }
 }
コード例 #23
0
 public void PasteAsRelocatedNodes()
 {
     int relocateFromClipboardToThisNode = Convert.ToInt32(treeView1.SelectedNode.Name);
     try
     {
         //get the clipboardNode
         LogicTreeNode clipboardNode = lt.GetLogicTreeNodeById(copyToClipboardNode);
         LogicTreeNode clipboardNodeParentNode = lt.GetLogicTreeNodeById(copyToClipboardNodeParentNode);
         LogicTreeNode relocateToNode = lt.GetLogicTreeNodeById(relocateFromClipboardToThisNode);
         //add this node to the relocateToNode's subNodes list
         //remove
         int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
         LogicTreeNode chdnod = new LogicTreeNode();
         chdnod = lt.GetLogicTreeNodeById(cnod);
         if (!chdnod.isLink)
         {
             PushToUndoStack();
             prntForm.logText("You selected idNum = " + relocateFromClipboardToThisNode.ToString() + " to relocate from the clipboard");
             LogicTreeNode copy = duplicateNodeKeepIds(clipboardNode);
             //ContentNode copy = f_convo.GetContentNodeById(copyToClipboardNode).Clone();
             relocateToNode.AddNodeToSubNode(copy);
             clipboardNodeParentNode.RemoveNodeFromSubNode(clipboardNode);
             //f_convo.GetContentNodeById(pasteFromClipboardNode).AddNodeToSubNode(copy);
             //f_convo.GetContentNodeById(prnod).RemoveNodeFromSubNode(f_convo.GetContentNodeById(rnod));
             refreshTreeView();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("paste node failed: " + ex.ToString());
     }
 }
コード例 #24
0
 private void LogicTreeEditor_Load(object sender, EventArgs e)
 {
     // load the file that has the selected node name if it exists
     string filenameOnly = mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json";
     string dirFullPath = prntForm._mainDirectory + "\\modules\\" + mod.moduleName + "\\logictree";
     if (File.Exists(dirFullPath + "\\" + filenameOnly))
     {
         openFile(dirFullPath, filenameOnly);
         if (lt == null)
         {
             lt = new LogicTree();
             lt.Filename = filenameOnly;
             LogicTreeNode contentNode = new LogicTreeNode();
             contentNode.idNum = lt.NextIdNum;
             contentNode.nodeText = "root";
             lt.AddNodeToRoot(contentNode);
             TreeNode mainNode = new TreeNode();
             mainNode.Name = "0";
             mainNode.Text = "root";
             treeView1.Nodes.Add(mainNode);
         }
         else
         {
             //initializeConditionsTab();
             //initializeActionsTab();
         }
     }
     else
     {
         lt.Filename = filenameOnly;
         LogicTreeNode contentNode = new LogicTreeNode();
         contentNode.idNum = lt.NextIdNum;
         contentNode.nodeText = "root";
         lt.AddNodeToRoot(contentNode);
         TreeNode mainNode = new TreeNode();
         mainNode.Name = "0";
         mainNode.Text = "root";
         treeView1.Nodes.Add(mainNode);
     }
     currentSelectedNode = null;
     SortLogicTree(lt);
     ResetOrderNumBasedOnIndex(lt.SubNodes[0]);
     prntForm.openLogicTreesList.Add(lt);
     fillScriptList();
 }
コード例 #25
0
 public void PasteNodes()
 {
     pasteFromClipboardNode = Convert.ToInt32(treeView1.SelectedNode.Name);
     try
     {
         int cnod = Convert.ToInt32(treeView1.SelectedNode.Name);
         LogicTreeNode chdnod = new LogicTreeNode();
         chdnod = lt.GetLogicTreeNodeById(cnod);
         if (!chdnod.isLink)
         {
             PushToUndoStack();
             prntForm.logText("You selected idNum = " + pasteFromClipboardNode.ToString() + " to paste from the clipboard");
             LogicTreeNode copy = duplicateNode(lt.GetLogicTreeNodeById(copyToClipboardNode));
             lt.GetLogicTreeNodeById(pasteFromClipboardNode).AddNodeToSubNode(copy);
             refreshTreeView();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("paste node failed: " + ex.ToString());
     }
 }
コード例 #26
0
ファイル: LogicTree.cs プロジェクト: slowdive-fan/IB2Toolset
 public void RemoveNodeFromRoot(LogicTreeNode contentNode)
 {
     SubNodes.Remove(contentNode);
 }
コード例 #27
0
 public LogicTreeNode NewContentNode(int nextIdNum)
 {
     LogicTreeNode newNode = new LogicTreeNode();
     //newNode.passRefs(game);
     newNode.idNum = nextIdNum;
     return newNode;
 }