public static ContextMenuStrip CreateContextMenu(object owner, string addInTreePath) { if (addInTreePath == null) { return(null); } try { ArrayList buildItems = AddInTree.GetTreeNode(addInTreePath).BuildChildItems(owner); ContextMenuStrip contextMenu = new ContextMenuStrip(); contextMenu.Items.Add(new ToolStripMenuItem("dummy")); contextMenu.Opening += delegate { contextMenu.Items.Clear(); foreach (object item in buildItems) { if (item is ToolStripItem) { contextMenu.Items.Add((ToolStripItem)item); } else { ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item; contextMenu.Items.AddRange(submenuBuilder.BuildSubmenu(null, owner)); } } }; contextMenu.Opened += ContextMenuOpened; contextMenu.Closed += ContextMenuClosed; return(contextMenu); } catch (TreePathNotFoundException) { MessageService.ShowError("Warning tree path '" + addInTreePath + "' not found."); return(null); } }
public static void InsertAddIn(AddIn addIn) { if (addIn.Enabled) { foreach (ExtensionPath current in addIn.Paths.Values) { AddInTree.AddExtensionPath(current); } foreach (Runtime current2 in addIn.Runtimes) { if (current2.IsActive) { foreach (LazyLoadDoozer current3 in current2.DefinedDoozers) { AddInTree.Doozers.ContainsKey(current3.Name); AddInTree.Doozers.Add(current3.Name, current3); } foreach (LazyConditionEvaluator current4 in current2.DefinedConditionEvaluators) { AddInTree.ConditionEvaluators.ContainsKey(current4.Name); AddInTree.ConditionEvaluators.Add(current4.Name, current4); } } } } AddInTree.addIns.Add(addIn); }
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 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)))); }
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)); }
public void RunInitialization() { AddInTree.Load(addInFiles, disabledAddIns); // run workspace autostart commands LoggingService.Info("Running autostart commands..."); foreach (ICommand command in AddInTree.BuildItems <ICommand>("/Workspace/Autostart", null, false)) { command.Run(); } }
public void Apply(IList items) { AddInTreeNode node; try { node = AddInTree.GetTreeNode(path); foreach (object o in node.BuildChildItems(caller)) { items.Add(o); } } catch (TreePathNotFoundException) { MessageService.ShowError("IncludeDoozer: AddinTree-Path not found: " + path); } }
public void RunInitialization() { AddInTree.Load(this.addInFiles, this.disabledAddIns); foreach (ICommand current in AddInTree.BuildItems <ICommand>("/Workspace/Autostart", null, false)) { try { current.Run(null, null); } catch (System.Exception ex) { LoggingService.Error(ex.Message + "\r\n" + ex.StackTrace); } } }
/// <summary> /// Initializes the AddIn system. /// This loads the AddIns that were added to the list, /// then it executes the <see cref="ICommand">commands</see> /// in <c>/Workspace/Autostart</c>. /// </summary> public void RunInitialization() { AddInTree.Load(addInFiles, disabledAddIns); // run workspace autostart commands LoggingService.Info("Running autostart commands..."); foreach (ICommand command in AddInTree.BuildItems <ICommand>("/Workspace/Autostart", null, false)) { try { command.Run(); } catch (Exception ex) { // allow startup to continue if some commands fail MessageService.ShowError(ex); } } }
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); } }
public static ToolStrip[] CreateToolbars(object owner, string addInTreePath) { AddInTreeNode treeNode; try { treeNode = AddInTree.GetTreeNode(addInTreePath); } catch (TreePathNotFoundException) { return(null); } List <ToolStrip> toolBars = new List <ToolStrip>(); foreach (AddInTreeNode childNode in treeNode.ChildNodes.Values) { toolBars.Add(CreateToolStrip(owner, childNode)); } return(toolBars.ToArray()); }
public static void AddExternalAddIns(IList <AddIn> addIns) { List <string> addInFiles = new List <string>(); List <string> disabled = new List <string>(); LoadAddInConfiguration(addInFiles, disabled); foreach (AddIn addIn in addIns) { if (!addInFiles.Contains(addIn.FileName)) { addInFiles.Add(addIn.FileName); } addIn.Enabled = false; addIn.Action = AddInAction.Install; AddInTree.InsertAddIn(addIn); } SaveAddInConfiguration(addInFiles, disabled); }
public static void AddItemsToMenu(ToolStripItemCollection collection, object owner, string addInTreePath) { ArrayList buildItems = AddInTree.GetTreeNode(addInTreePath).BuildChildItems(owner); foreach (object item in buildItems) { if (item is ToolStripItem) { collection.Add((ToolStripItem)item); if (item is IStatusUpdate) { ((IStatusUpdate)item).UpdateStatus(); } } else { ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item; collection.AddRange(submenuBuilder.BuildSubmenu(null, owner)); } } }
public object BuildItem(object caller, Codon codon, ArrayList subItems) { string item = codon.Properties["item"]; string path = codon.Properties["path"]; if (item != null && item.Length > 0) { // include item return(AddInTree.BuildItem(item, caller)); } else if (path != null && path.Length > 0) { // include path (=multiple items) return(new IncludeReturnItem(caller, path)); } else { MessageService.ShowMessage("<Include> requires the attribute 'item' (to include one item) or the attribute 'path' (to include multiple items)"); return(null); } }
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(AddInTree.BuildItem(item, args.Caller, args.Conditions)); } else if (path != null && path.Length > 0) { // include path (=multiple items) return(new IncludeReturnItem(args.Caller, path, args.Conditions)); } else { throw new CoreException("<Include> requires the attribute 'item' (to include one item) or the attribute 'path' (to include multiple items)"); } }
public static void RemoveExternalAddIns(IList <AddIn> addIns) { List <string> addInFiles = new List <string>(); List <string> disabled = new List <string>(); LoadAddInConfiguration(addInFiles, disabled); foreach (AddIn addIn in addIns) { foreach (string identity in addIn.Manifest.Identities.Keys) { disabled.Remove(identity); } addInFiles.Remove(addIn.FileName); addIn.Action = AddInAction.Uninstall; if (!addIn.Enabled) { AddInTree.RemoveAddIn(addIn); } } SaveAddInConfiguration(addInFiles, disabled); }
public static AddInTreeNode GetTreeNode(string path) { return(AddInTree.GetTreeNode(path, true)); }
public static System.Collections.Generic.List <T> BuildItems <T>(string path, object caller) { return(AddInTree.BuildItems <T>(path, caller, true)); }
public static void Load(System.Collections.Generic.List <string> addInFiles, List <string> disabledAddIns) { System.Collections.Generic.List <AddIn> list = new System.Collections.Generic.List <AddIn>(); System.Collections.Generic.Dictionary <string, System.Version> dictionary = new System.Collections.Generic.Dictionary <string, System.Version>(); System.Collections.Generic.Dictionary <string, AddIn> dictionary2 = new System.Collections.Generic.Dictionary <string, AddIn>(); foreach (string current in addInFiles) { AddIn addIn; try { addIn = AddIn.Load(current); } catch (System.Exception ex) { addIn = new AddIn(); addIn.addInFileName = current; addIn.CustomErrorMessage = ex.Message; } if (addIn.Action == AddInAction.CustomError) { list.Add(addIn); } else { addIn.Enabled = true; if (disabledAddIns != null && disabledAddIns.Count > 0) { foreach (string current2 in addIn.Manifest.Identities.Keys) { if (disabledAddIns.Contains(current2)) { addIn.Enabled = false; break; } } } if (addIn.Enabled) { foreach (System.Collections.Generic.KeyValuePair <string, System.Version> current3 in addIn.Manifest.Identities) { if (dictionary.ContainsKey(current3.Key)) { addIn.Enabled = false; addIn.Action = AddInAction.InstalledTwice; break; } dictionary.Add(current3.Key, current3.Value); dictionary2.Add(current3.Key, addIn); } } list.Add(addIn); } } while (true) { IL_175: for (int i = 0; i < list.Count; i++) { AddIn addIn2 = list[i]; if (addIn2.Enabled) { foreach (AddInReference current4 in addIn2.Manifest.Conflicts) { System.Version version; if (current4.Check(dictionary, out version)) { AddInTree.DisableAddin(addIn2, dictionary, dictionary2); goto IL_175; } } foreach (AddInReference current5 in addIn2.Manifest.Dependencies) { System.Version version; if (!current5.Check(dictionary, out version)) { AddInTree.DisableAddin(addIn2, dictionary, dictionary2); goto IL_175; } } } } break; } foreach (AddIn current6 in list) { try { AddInTree.InsertAddIn(current6); } catch (System.Exception ex2) { MessageBox.Show(ex2.Message); } } }
public static ToolStrip CreateToolStrip(object owner, string addInTreePath) { return(CreateToolStrip(owner, AddInTree.GetTreeNode(addInTreePath))); }