/// <summary> /// Gets the <see cref="AddInTreeNode"/> representing the specified path. /// </summary> /// <param name="path">The path of the AddIn tree node</param> /// <param name="throwOnNotFound"> /// If set to <c>true</c>, this method throws a /// <see cref="TreePathNotFoundException"/> when the path does not exist. /// If set to <c>false</c>, <c>null</c> is returned for non-existing paths. /// </param> public static AddInTreeNode GetTreeNode(string path, bool throwOnNotFound) { if (path == null || path.Length == 0) { return(rootNode); } string[] splittedPath = path.Split('/'); AddInTreeNode curPath = rootNode; int i = 0; while (i < splittedPath.Length) { if (!curPath.ChildNodes.TryGetValue(splittedPath[i], out curPath)) { if (throwOnNotFound) { throw new TreePathNotFoundException(path); } else { return(null); } } // curPath = curPath.ChildNodes[splittedPath[i]]; already done by TryGetValue ++i; } return(curPath); }
/// <summary> /// Gets the <see cref="AddInTreeNode"/> representing the specified path. /// </summary> /// <param name="path">The path of the AddIn tree node</param> /// <param name="throwOnNotFound"> /// If set to <c>true</c>, this method throws a /// <see cref="TreePathNotFoundException"/> when the path does not exist. /// If set to <c>false</c>, <c>null</c> is returned for non-existing paths. /// </param> public static AddInTreeNode GetTreeNode(string path, bool throwOnNotFound) { if (path == null || path.Length == 0) { return(rootNode); } string[] splittedPath = path.Split('/'); AddInTreeNode curPath = rootNode; for (int i = 0; i < splittedPath.Length; i++) { if (!curPath.ChildNodes.TryGetValue(splittedPath[i], out curPath)) { if (throwOnNotFound) { throw new TreePathNotFoundException(path); } else { return(null); } } } return(curPath); }
public static AddInTreeNode GetTreeNode(string path, bool throwOnNotFound) { if (path == null || path.Length == 0) { return(rootNode); } string[] splittedPath = path.Split('/'); AddInTreeNode curPath = rootNode; int i = 0; while (i < splittedPath.Length) { if (!curPath.ChildNodes.ContainsKey(splittedPath[i])) { if (throwOnNotFound) { throw new TreePathNotFoundException(path); } else { return(null); } } curPath = curPath.ChildNodes[splittedPath[i]]; ++i; } return(curPath); }
AddInTreeNode CreatePath(AddInTreeNode localRoot, string path, Properties parentPathProperties) { AddInTreeNode node = CreatePath(localRoot, path); node.PathProperties = parentPathProperties; return(node); }
public static object BuildItem(string path, object caller) { int num = path.LastIndexOf('/'); string path2 = path.Substring(0, num); string childItemID = path.Substring(num + 1); AddInTreeNode treeNode = AddInTree.GetTreeNode(path2); return(treeNode.BuildChildItem(childItemID, caller, new System.Collections.ArrayList(AddInTree.BuildItems <object>(path, caller, false)))); }
static AddInTree() { AddInTree.addIns = new System.Collections.Generic.List <AddIn>(); AddInTree.doozers = new System.Collections.Generic.Dictionary <string, IDoozer>(); AddInTree.rootNode = new AddInTreeNode(); AddInTree.conditionEvaluators = new System.Collections.Generic.Dictionary <string, IConditionEvaluator>(); AddInTree.disableMenuItem = new System.Collections.Generic.List <string>(); AddInTree.quickToolbarItem = new System.Collections.Generic.List <string>(); }
static void AddExtensionPath(ExtensionPath path) { AddInTreeNode treePath = CreatePath(rootNode, path.Name); foreach (Codon codon in path.Codons) { treePath.Codons.Add(codon); } }
/// <summary> /// Builds a single item in the addin tree. /// </summary> /// <param name="path">A path to the item in the addin tree.</param> /// <param name="caller">The owner used to create the objects.</param> /// <exception cref="TreePathNotFoundException">The path does not /// exist or does not point to an item.</exception> public static object BuildItem(string path, object caller) { int pos = path.LastIndexOf('/'); string parent = path.Substring(0, pos); string child = path.Substring(pos + 1); AddInTreeNode node = GetTreeNode(parent); return(node.BuildChildItem(child, caller, new ArrayList(BuildItems <object>(path, caller, false)))); }
public static ToolStrip CreateToolStrip(object owner, AddInTreeNode treeNode) { ToolStrip toolStrip = new ToolStrip(); toolStrip.Items.AddRange(CreateToolStripItems(owner, treeNode)); UpdateToolbar(toolStrip); // setting Visible is only possible after the items have been added new LanguageChangeWatcher(toolStrip); return(toolStrip); }
void AddExtensionPath(ExtensionPath path) { AddInTreeNode treePath = CreatePath(rootNode, path.Name); foreach (IEnumerable <Codon> innerCodons in path.GroupedCodons) { treePath.AddCodons(innerCodons); } }
private static void AddExtensionPath(ExtensionPath path) { AddInTreeNode addInTreeNode = AddInTree.CreatePath(AddInTree.rootNode, path.Name); foreach (Codon current in path.Codons) { addInTreeNode.Codons.Add(current); } }
public object BuildItem(string path, object parameter, IEnumerable <ICondition> additionalConditions) { int pos = path.LastIndexOf('/'); string parent = path.Substring(0, pos); string child = path.Substring(pos + 1); AddInTreeNode node = GetTreeNode(parent); return(node.BuildChildItem(child, parameter, additionalConditions)); }
public static System.Collections.Generic.List <T> BuildItems <T>(string path, object caller, bool throwOnNotFound) { AddInTreeNode treeNode = AddInTree.GetTreeNode(path, throwOnNotFound); if (treeNode == null) { return(new System.Collections.Generic.List <T>()); } return(treeNode.BuildChildItems <T>(caller)); }
/// <summary> /// Builds the items in the path. Ensures that all items have the type T. /// </summary> /// <param name="path">A path in the addin tree.</param> /// <param name="parameter">The owner used to create the objects.</param> /// <param name="throwOnNotFound">If true, throws a <see cref="TreePathNotFoundException"/> /// if the path is not found. If false, an empty ArrayList is returned when the /// path is not found.</param> public IReadOnlyList <T> BuildItems <T>(string path, object parameter, bool throwOnNotFound = true) { AddInTreeNode node = GetTreeNode(path, throwOnNotFound); if (node == null) { return(new List <T>()); } return(node.BuildChildItems <T>(parameter)); }
public BuildItemArgs(object caller, Codon codon, IEnumerable <ICondition> conditions, AddInTreeNode subItemNode) { if (codon == null) { throw new ArgumentNullException("codon"); } this.caller = caller; this.codon = codon; this.conditions = conditions ?? Enumerable.Empty <ICondition>(); this.subItemNode = subItemNode; }
public BuildItemArgs(object parameter, Codon codon, IReadOnlyCollection <ICondition> conditions, AddInTreeNode subItemNode) { if (codon == null) { throw new ArgumentNullException("codon"); } this.parameter = parameter; this.codon = codon; this.conditions = conditions; this.subItemNode = subItemNode; }
/// <summary> /// Builds the items in the path. Ensures that all items have the type T. /// </summary> /// <param name="path">A path in the addin tree.</param> /// <param name="caller">The owner used to create the objects.</param> /// <param name="throwOnNotFound">If true, throws a <see cref="TreePathNotFoundException"/> /// if the path is not found. If false, an empty ArrayList is returned when the /// path is not found.</param> public static List <T> BuildItems <T>(string path, object caller, bool throwOnNotFound) { AddInTreeNode node = GetTreeNode(path, throwOnNotFound); if (node == null) { return(new List <T>()); } else { return(node.BuildChildItems <T>(caller)); } }
public void Apply(IList items) { AddInTreeNode node = AddInTree.GetTreeNode(path, false); if (node != null) { foreach (object o in node.BuildChildItems(caller)) { items.Add(o); } } else { MessageService.ShowError("IncludeDoozer: AddinTree-Path not found: " + path); } }
public void Apply(IList items) { AddInTreeNode node = AddInTree.GetTreeNode(path, false); if (node != null) { foreach (object o in node.BuildChildItems <object>(caller, additionalConditions)) { items.Add(o); } } else { throw new CoreException("IncludeDoozer: AddinTree-Path not found: " + path); } }
void AddExtensionPath(ExtensionPath path) { AddInTreeNode treePath = null; if (path.ParentPathProperties != null) { treePath = CreatePath(rootNode, path.Name, path.ParentPathProperties); } else { treePath = CreatePath(rootNode, path.Name); } foreach (IEnumerable <Codon> innerCodons in path.GroupedCodons) { treePath.AddCodons(innerCodons); } }
public static ToolStripItem[] CreateToolStripItems(object owner, AddInTreeNode treeNode) { List <ToolStripItem> collection = new List <ToolStripItem>(); foreach (object item in treeNode.BuildChildItems(owner)) { if (item is ToolStripItem) { collection.Add((ToolStripItem)item); } else { ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item; collection.AddRange(submenuBuilder.BuildSubmenu(null, owner)); } } return(collection.ToArray()); }
public static AddInTreeNode GetTreeNode(string path, bool throwOnNotFound) { if (path == null || path.Length == 0) { return(AddInTree.rootNode); } string[] array = path.Split(new char[] { '/' }); AddInTreeNode addInTreeNode = AddInTree.rootNode; for (int i = 0; i < array.Length; i++) { if (!addInTreeNode.ChildNodes.TryGetValue(array[i], out addInTreeNode)) { return(null); } } return(addInTreeNode); }
public static bool ExistsTreeNode(string path) { if (path == null || path.Length == 0) { return(true); } string[] array = path.Split(new char[] { '/' }); AddInTreeNode addInTreeNode = AddInTree.rootNode; for (int i = 0; i < array.Length; i++) { if (!addInTreeNode.ChildNodes.TryGetValue(array[i], out addInTreeNode)) { return(false); } } return(true); }
/// <summary> /// Checks whether the specified path exists in the AddIn tree. /// </summary> public static bool ExistsTreeNode(string path) { if (path == null || path.Length == 0) { return(true); } string[] splittedPath = path.Split('/'); AddInTreeNode curPath = rootNode; int i = 0; while (i < splittedPath.Length) { // curPath = curPath.ChildNodes[splittedPath[i]] - check if child path exists if (!curPath.ChildNodes.TryGetValue(splittedPath[i], out curPath)) { return(false); } ++i; } return(true); }
public static bool ExistsTreeNode(string path) { if (path == null || path.Length == 0) { return(true); } string[] splittedPath = path.Split('/'); AddInTreeNode curPath = rootNode; int i = 0; while (i < splittedPath.Length) { if (!curPath.ChildNodes.ContainsKey(splittedPath[i])) { return(false); } curPath = curPath.ChildNodes[splittedPath[i]]; ++i; } return(true); }
private static AddInTreeNode CreatePath(AddInTreeNode localRoot, string path) { if (path == null || path.Length == 0) { return(localRoot); } string[] array = path.Split(new char[] { '/' }); AddInTreeNode addInTreeNode = localRoot; for (int i = 0; i < array.Length; i++) { if (!addInTreeNode.ChildNodes.ContainsKey(array[i])) { addInTreeNode.ChildNodes[array[i]] = new AddInTreeNode(); } addInTreeNode = addInTreeNode.ChildNodes[array[i]]; } return(addInTreeNode); }
static AddInTreeNode CreatePath(AddInTreeNode localRoot, string path) { if (path == null || path.Length == 0) { return(localRoot); } string[] splittedPath = path.Split('/'); AddInTreeNode curPath = localRoot; int i = 0; while (i < splittedPath.Length) { if (!curPath.ChildNodes.ContainsKey(splittedPath[i])) { curPath.ChildNodes[splittedPath[i]] = new AddInTreeNode(); } curPath = curPath.ChildNodes[splittedPath[i]]; ++i; } return(curPath); }
public object BuildItem(BuildItemArgs args) { Codon codon = args.Codon; string item = codon.Properties["item"]; string path = codon.Properties["path"]; if (item != null && item.Length > 0) { // include item return(args.AddInTree.BuildItem(item, args.Parameter, args.Conditions)); } else if (path != null && path.Length > 0) { // include path (=multiple items) AddInTreeNode node = args.AddInTree.GetTreeNode(path); return(new IncludeReturnItem(node, args.Parameter, args.Conditions)); } else { throw new CoreException("<Include> requires the attribute 'item' (to include one item) or the attribute 'path' (to include multiple items)"); } }
public IncludeReturnItem(AddInTreeNode node, object parameter, IEnumerable <ICondition> additionalConditions) { this.node = node; this.parameter = parameter; this.additionalConditions = additionalConditions; }