internal static void AddFunction(TreeNode node) { string name = string.Empty; string desc = string.Empty; string code = string.Empty; if (!new UserFunction(true).InitShow(ref name, ref desc, ref code)) { return; } string targetName; int index = 0; TreeNode pn = node.Parent; if (node.Tag == null /*|| pn == null*/) { pn = node; targetName = (pn.Level > 0) ? targetName = "<m+>": targetName = "<m>"; targetName += pn.Text; } else { index = node.Index + 1; targetName = node.Text + "<d>"; } if (!AddFuncToFile(targetName, name, desc, code, fnUserFile)) { MessageBox.Show("Could not add function.", "Error"); return; } if (UserFunction.highlight) { SyntaxFile.AddKeyWord(GetKeyWord(code)); } var newNode = new TreeNode(name); newNode.ToolTipText = desc; newNode.Tag = code; newNode.NodeFont = new Font("Arial", 8, FontStyle.Bold); newNode.ForeColor = ColorTheme.TreeNameFunction; pn.Nodes.Insert(index, newNode); newNode.EnsureVisible(); }
internal static void DeleteNode(TreeNode node) { if (MessageBox.Show("Do you want to delete this item?", "Delete", MessageBoxButtons.YesNo) == DialogResult.No) { return; } bool IsNode = (node.Tag == null); if (!DeleteNodeToFile(IsNode, node.Text, fnUserFile)) { MessageBox.Show("It was not possible to delete this item.", "Error"); return; } if (!IsNode) { SyntaxFile.RemoveKeyWord(GetKeyWord((string)node.Tag)); } node.Remove(); }