public void ParsePluginByContainer(ConnectionPointContainer container) { XmlNodeList pluginNodeList = GetPluginNodeList(container); if (pluginNodeList == null || pluginNodeList.Count == 0) { return; } if (!PluginList.ContainsKey(container.Name)) { PluginList.Add(container.Name, new List <PluginConfigItem>()); } List <PluginConfigItem> containerPluginList = PluginList[container.Name]; foreach (XmlNode node in pluginNodeList) { PluginConfigItem foundItem = null; string url = ParsePluginUrl(node); foundItem = GetPluginByUrl(containerPluginList, url); if (foundItem == null) { containerPluginList.Add( ParsePluginConfigItem(node) ); } } }
protected Image GetImageList(ConnectionPointContainer container, string menuImageIndex) { int index; if (int.TryParse(menuImageIndex, out index) && container.ImageList.Count > 0) return container.ImageList[index]; return null; }
private XmlNodeList GetPluginNodeList(ConnectionPointContainer container) { string xPath = String.Format("Plugin[starts-with(@url,'addin://{0}/')]", container.Name); XmlDocument doc = GetPluginXmlDoc(); XmlNodeList nodeList = doc.DocumentElement.SelectNodes(xPath); return(nodeList); }
private TreeView SelectNavigation(ConnectionPointContainer container, PluginMenuPath thePath) { int index = 0; if (int.TryParse(thePath.MenuIndex, out index) && index < container.Navigations.Count) { return(container.Navigations[index]); } return(null); }
protected ImageList GetImageList(ConnectionPointContainer container, string menuImageIndex) { int index; if (int.TryParse(menuImageIndex, out index) && container.ImageList.Count > 0) { return(container.ImageList[index]); } return(null); }
public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback) { if (container.Navigations != null && container.Navigations.Count > 0) { TreeView theTree = SelectNavigation(container, thePath); if (theTree != null) { AddTreeNodeIntoTree(container, theTree.Nodes, theItem, thePath, thePath.MenuPathParts, callback); } } }
private ToolBar SelectToolStrip(ConnectionPointContainer container, PluginMenuPath thePath) { int index = 0; if (int.TryParse(thePath.MenuIndex, out index) && container.ToolStrips.Count > index) return container.ToolStrips[index]; else foreach (ToolBar theToolbar in container.ToolStrips) if (theToolbar.Name == thePath.MenuIndex) return theToolbar; return null; }
public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback) { if (container.ToolStrips != null && container.ToolStrips.Count > 0) { ToolStrip theToolbar = SelectToolStrip(container, thePath); if (theToolbar != null) { AddMenuItemIntoMenu(container, theToolbar.Items, theItem, thePath, thePath.MenuPathParts, callback); } } }
public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback) { if (container.Navigations != null && container.Navigations.Count > 0) { TreeView theTree = SelectNavigation(container, thePath); if (theTree != null) { AddTreeNodeIntoTree(container, theTree.Nodes, theItem, thePath, thePath.MenuPathParts, callback); } } }
public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback) { if (container.ToolStrips != null && container.ToolStrips.Count > 0) { ToolBar theToolbar = SelectToolStrip(container, thePath); if (theToolbar != null) { AddMenuItemIntoMenu(container, theToolbar.Items, theItem, thePath, thePath.MenuPathParts, callback); } } }
public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback) { if (null != container.Menus && container.Menus.Count > 0) { Menu menu = SelectMenu(container, thePath); if (null != menu) { AddMenuItemIntoMenu(container, menu.Items, theItem, thePath, thePath.MenuPathParts, callback); } } }
public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback) { if (null != container.Menus && container.Menus.Count > 0) { Menu menu = SelectMenu(container, thePath); if (null != menu) { AddMenuItemIntoMenu(container, menu.Items, theItem, thePath, thePath.MenuPathParts, callback); } } }
protected void AddTreeNodeIntoTree(ConnectionPointContainer container, ItemCollection nodes, PluginConfigItem theItem, PluginMenuPath thePath, IList <PluginMenuItemPart> thePaths, ExecutePluginCallback callback) { if (thePaths.Count < 1) { return; } PluginMenuItemPart firstPart = thePaths[0]; PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, nodes); IList <PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths); if (!menuStruct.IsCreate) { AddTreeNodeIntoTree(container, (nodes[menuStruct.Index] as TreeViewItem).Items, theItem, thePath, otherParts, callback); } else { TreeViewItem theMenuItem = new TreeViewItem() { Header = firstPart.TextStyle.Text }; CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex)); nodes.Insert( menuStruct.Index, theMenuItem ); if (thePaths.Count > 1) { AddTreeNodeIntoTree(container, theMenuItem.Items, theItem, thePath, otherParts, callback); } else { theMenuItem.Name = theItem.Url; theMenuItem.Tag = new object[] { theItem, callback }; //theMenuItem.TreeView.NodeMouseClick -= new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick); //theMenuItem.TreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick); return; } } }
private Menu SelectMenu(ConnectionPointContainer container, PluginMenuPath thePath) { int index = 0; if (int.TryParse(thePath.MenuIndex, out index) && container.Menus.Count > index) { return(container.Menus[index]); } else { foreach (Menu theMenu in container.Menus) { if (theMenu.Name == thePath.MenuIndex) { return(theMenu); } } } return(null); }
private ToolStrip SelectToolStrip(ConnectionPointContainer container, PluginMenuPath thePath) { int index = 0; if (int.TryParse(thePath.MenuIndex, out index) && container.ToolStrips.Count > index) { return(container.ToolStrips[index]); } else { foreach (ToolStrip theToolbar in container.ToolStrips) { if (theToolbar.Name == thePath.MenuIndex) { return(theToolbar); } } } return(null); }
protected void AddTreeNodeIntoTree(ConnectionPointContainer container, TreeNodeCollection nodes, PluginConfigItem theItem, PluginMenuPath thePath, IList<PluginMenuItemPart> thePaths, ExecutePluginCallback callback) { if (thePaths.Count < 1) return; PluginMenuItemPart firstPart = thePaths[0]; PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, nodes); IList<PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths); if (!menuStruct.IsCreate) { AddTreeNodeIntoTree(container, nodes[menuStruct.Index].Nodes, theItem, thePath, otherParts, callback); } else { TreeNode theMenuItem = new TreeNode(firstPart.TextStyle.Text); CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex)); nodes.Insert( menuStruct.Index, theMenuItem ); if (thePaths.Count > 1) { AddTreeNodeIntoTree(container, theMenuItem.Nodes, theItem, thePath, otherParts, callback); } else { theMenuItem.Name = theItem.Url; theMenuItem.Tag = new object[] { theItem, callback }; theMenuItem.TreeView.NodeMouseClick -= new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick); theMenuItem.TreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick); return; } } }
public bool InitPluginParser() { if (_inited) { return(true); } _inited = false; ConnectionPointContainer container = this._pluginContext.PluginContainer; if (container == null || string.IsNullOrEmpty(container.Name)) { return(false); } try { if (!PluginList.ContainsKey(container.Name)) { ParsePluginByContainer(container); } } catch (Exception ex) { LogUtils.LogError(ex); //ShellUtils.ShowError(ex); } if (!PluginList.ContainsKey(container.Name)) { return(false); } _inited = true; return(true); }
public void ParsePluginByContainer(ConnectionPointContainer container) { XmlNodeList pluginNodeList = GetPluginNodeList(container); if (pluginNodeList == null || pluginNodeList.Count == 0) return; if (!PluginList.ContainsKey(container.Name)) PluginList.Add(container.Name, new List<PluginConfigItem>()); List<PluginConfigItem> containerPluginList = PluginList[container.Name]; foreach (XmlNode node in pluginNodeList) { PluginConfigItem foundItem = null; string url = ParsePluginUrl(node); foundItem = GetPluginByUrl(containerPluginList, url); if (foundItem == null) { containerPluginList.Add( ParsePluginConfigItem(node) ); } } }
public virtual void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback) { }
public virtual void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback) { }
private void ParsePluginByContainer(ConnectionPointContainer container) { _parser.ParsePluginByContainer(container); }
private XmlNodeList GetPluginNodeList(ConnectionPointContainer container) { string xPath = String.Format("Plugin[starts-with(@url,'addin://{0}/')]", container.Name); XmlDocument doc = GetPluginXmlDoc(); XmlNodeList nodeList = doc.DocumentElement.SelectNodes(xPath); return nodeList; }
private ToolStrip SelectMenu(ConnectionPointContainer container, PluginMenuPath thePath) { int index = 0; if (int.TryParse(thePath.MenuIndex, out index) && container.Menus.Count > index) return container.Menus[index]; else foreach (MenuStrip theMenu in container.Menus) if (theMenu.Name == thePath.MenuIndex) return theMenu; return null; }
protected void AddMenuItemIntoMenu(ConnectionPointContainer container, ToolStripItemCollection toolStripItemCollection, PluginConfigItem theItem, PluginMenuPath thePath, IList<PluginMenuItemPart> thePaths, ExecutePluginCallback callback) { if (thePaths.Count < 1) return; PluginMenuItemPart firstPart = thePaths[0]; PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, toolStripItemCollection); IList<PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths); if (!menuStruct.IsCreate) { AddMenuItemIntoMenu(container, (toolStripItemCollection[menuStruct.Index] as ToolStripMenuItem).DropDownItems, theItem, thePath, otherParts, callback); } else { if (firstPart.TextStyle.Text.Trim() == "-") { toolStripItemCollection.Insert( menuStruct.Index, new ToolStripSeparator() ); return; } ToolStripMenuItem theMenuItem = new ToolStripMenuItem(firstPart.TextStyle.Text); CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex)); toolStripItemCollection.Insert( menuStruct.Index, theMenuItem ); if (thePaths.Count > 1) { AddMenuItemIntoMenu(container, theMenuItem.DropDownItems, theItem, thePath, otherParts, callback); } else { theMenuItem.Name = theItem.Url; theMenuItem.Tag = new object[] { theItem, callback }; string[] behaviors = theItem.Behavior.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string action in behaviors) { PluginConfigItemBehaviorMode theBehavior = (PluginConfigItemBehaviorMode)Enum.Parse(typeof(PluginConfigItemBehaviorMode), action, true); switch (theBehavior) { case PluginConfigItemBehaviorMode.Click: theMenuItem.Click -= TheMenuItem_Click; theMenuItem.Click += TheMenuItem_Click; break; case PluginConfigItemBehaviorMode.MouseOver: theMenuItem.MouseMove -= new MouseEventHandler(TheMenuItem_MouseMove); theMenuItem.MouseMove += new MouseEventHandler(TheMenuItem_MouseMove); break; } } return; } } }
private void ParsePluginByContainer(ConnectionPointContainer container) { _parser.ParsePluginByContainer(container); }
private TreeView SelectNavigation(ConnectionPointContainer container, PluginMenuPath thePath) { int index = 0; if (int.TryParse(thePath.MenuIndex, out index) && index < container.Navigations.Count) return container.Navigations[index]; return null; }
protected void AddMenuItemIntoMenu(ConnectionPointContainer container, ItemCollection menuItemCollection, PluginConfigItem theItem, PluginMenuPath thePath, IList <PluginMenuItemPart> thePaths, ExecutePluginCallback callback) { if (thePaths.Count < 1) { return; } PluginMenuItemPart firstPart = thePaths[0]; PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, menuItemCollection); IList <PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths); if (!menuStruct.IsCreate) { AddMenuItemIntoMenu(container, (menuItemCollection[menuStruct.Index] as MenuItem).Items, theItem, thePath, otherParts, callback); } else { if (firstPart.TextStyle.Text.Trim() == "-") { menuItemCollection.Insert(menuStruct.Index, new Separator()); return; } MenuItem theMenuItem = new MenuItem() { Header = firstPart.TextStyle.Text }; CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex)); menuItemCollection.Insert(menuStruct.Index, theMenuItem); if (thePaths.Count > 1) { AddMenuItemIntoMenu(container, theMenuItem.Items, theItem, thePath, otherParts, callback); } else { theMenuItem.Name = theItem.Url; theMenuItem.Tag = new object[] { theItem, callback }; string[] behaviors = theItem.Behavior.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string action in behaviors) { PluginConfigItemBehaviorMode theBehavior = (PluginConfigItemBehaviorMode)Enum.Parse(typeof(PluginConfigItemBehaviorMode), action, true); switch (theBehavior) { case PluginConfigItemBehaviorMode.Click: theMenuItem.Click -= TheMenuItem_Click; theMenuItem.Click += TheMenuItem_Click; break; case PluginConfigItemBehaviorMode.MouseOver: theMenuItem.MouseMove -= TheMenuItem_MouseMove; theMenuItem.MouseMove += TheMenuItem_MouseMove; break; } } return; } } }