Пример #1
0
        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)
                        );
                }
            }
        }
Пример #2
0
 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;
 }
Пример #3
0
        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);
        }
Пример #5
0
        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);
         }
     }
 }
Пример #7
0
 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;
 }
Пример #8
0
 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);
         }
     }
 }
Пример #10
0
 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);
         }
     }
 }
Пример #11
0
 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);
         }
     }
 }
Пример #12
0
 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);
         }
     }
 }
Пример #13
0
        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;
                }
            }
        }
Пример #14
0
        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);
        }
Пример #15
0
        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);
        }
Пример #16
0
        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;
                }
            }
        }
Пример #17
0
        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);
        }
Пример #18
0
        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)
                        );
                }
            }
        }
Пример #19
0
 public virtual void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
 }
Пример #20
0
 public virtual void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
 }
Пример #21
0
 private void ParsePluginByContainer(ConnectionPointContainer container)
 {
     _parser.ParsePluginByContainer(container);
 }
Пример #22
0
 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;
 }
Пример #23
0
 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;
 }
Пример #24
0
        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;
                }
            }
        }
Пример #25
0
 private void ParsePluginByContainer(ConnectionPointContainer container)
 {
     _parser.ParsePluginByContainer(container);
 }
Пример #26
0
 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;
 }
Пример #27
0
        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;
                }
            }
        }