private static IList <PluginMenuPath> ParsePluginMenuPaths(XmlNode node)
        {
            List <PluginMenuPath> pathList = new List <PluginMenuPath>();

            foreach (XmlNode theConnectionPointNode in node.SelectNodes("ConnectionPoints/ConnectionPoint"))
            {
                PluginMenuPath point = new PluginMenuPath();
                point.LocateType = (PluginMenuPathLocateType)(Enum.Parse(
                                                                  typeof(PluginMenuPathLocateType),
                                                                  XmlUtils.GetXmlAttribute(theConnectionPointNode, "menuType"))
                                                              );
                point.MenuIndex      = XmlUtils.GetXmlAttribute(theConnectionPointNode, "menuIndex");
                point.MenuImageIndex = XmlUtils.GetXmlAttribute(theConnectionPointNode, "menuImageIndex");
                point.MenuPathParts  = new List <PluginMenuItemPart>();
                foreach (XmlNode addNode in theConnectionPointNode.SelectNodes("add"))
                {
                    PluginMenuItemPart thePart = new PluginMenuItemPart();
                    thePart.Locate    = XmlUtils.GetXmlAttribute(addNode, "locate");
                    thePart.TextStyle = ParsePluginTextStyle(XmlUtils.GetXmlAttribute(addNode, "text"));
                    point.MenuPathParts.Add(thePart);
                }
                pathList.Add(point);
            }
            return(pathList);
        }
        protected PluginMenuPartStruct GetMenuItemIndex(PluginMenuItemPart theMenuItemPart, TreeNodeCollection nodes)
        {
            PluginMenuPartStruct theMenuItem = new PluginMenuPartStruct();
            int    index         = 0;
            string menuItemIndex = GetMenuItemIndex(theMenuItemPart.Locate);
            PluginMenuItemLocateType menuItemLocationType = (PluginMenuItemLocateType)(
                Enum.Parse(typeof(PluginMenuItemLocateType),
                           GetMenuItemLocator(theMenuItemPart.Locate),
                           true
                           )
                );

            theMenuItem.IsCreate = menuItemLocationType == PluginMenuItemLocateType.Create;

            if (int.TryParse(menuItemIndex, out index))
            {
                theMenuItem.Index = PluginMenuItemPartLocator.GetMenuLocatorIndex(menuItemLocationType, index, nodes.Count);
            }
            else if (menuItemIndex.Length == 0)
            {
                theMenuItem.Index = nodes.Count;
            }
            else
            {
                int realIndex = GetMenuItemIndexById(nodes, menuItemIndex);
                theMenuItem.Index = PluginMenuItemPartLocator.GetMenuLocatorIndex(
                    menuItemLocationType,
                    realIndex,
                    nodes.Count
                    );
                // Make only support ID
                if (menuItemLocationType == PluginMenuItemLocateType.Make)
                {
                    if (realIndex >= 0 && realIndex < nodes.Count)
                    {
                        theMenuItem.IsCreate = false;
                    }
                    else
                    {
                        theMenuItem.IsCreate = true;
                    }
                }
            }
            theMenuItem.Exist = theMenuItem.Index < nodes.Count &&
                                theMenuItem.Index >= 0;

            return(theMenuItem);
        }
 protected virtual void CreateMenuEndItem(PluginMenuItemPart firstPart, TreeNode theMenuItem, ImageList theImageList)
 {
     theMenuItem.Text        = firstPart.TextStyle.Text;
     theMenuItem.ToolTipText = firstPart.TextStyle.ToolTipText;
     if (firstPart.TextStyle.Image != null)
     {
         try
         {
             string image = firstPart.TextStyle.Image;
             LoadImage(theImageList, image);
             theMenuItem.ImageKey         = image;
             theMenuItem.SelectedImageKey = image;
         }
         catch { }
     }
 }
 protected virtual void CreateMenuEndItem(PluginMenuItemPart firstPart, TreeNode theMenuItem, ImageList theImageList)
 {
     theMenuItem.Text = firstPart.TextStyle.Text;
     theMenuItem.ToolTipText = firstPart.TextStyle.ToolTipText;
     if (firstPart.TextStyle.Image != null)
     {
         try
         {
             string image = firstPart.TextStyle.Image;
             LoadImage(theImageList, image);
             theMenuItem.ImageKey = image;
             theMenuItem.SelectedImageKey = image;
         }
         catch { }
     }
 }
 protected override void CreateMenuEndItem(PluginMenuItemPart firstPart, ToolStripMenuItem theMenuItem, ImageList theImageList)
 {
     if (firstPart.TextStyle.ButtonType == null)
     {
         theMenuItem.Text        = firstPart.TextStyle.Text;
         theMenuItem.ToolTipText = firstPart.TextStyle.ToolTipText;
         if (firstPart.TextStyle.Image != null)
         {
             try
             {
                 string image = firstPart.TextStyle.Image;
                 LoadImage(theImageList, image);
                 theMenuItem.ImageKey = image;
             }
             catch { }
         }
     }
     else
     {
         theMenuItem = ReflectUtils.CreateInstance(firstPart.TextStyle.ButtonType)
                       as ToolStripMenuItem;
         theMenuItem.Text        = firstPart.TextStyle.Text;
         theMenuItem.ToolTipText = firstPart.TextStyle.ToolTipText;
         if (firstPart.TextStyle.Image != null)
         {
             try
             {
                 string image = firstPart.TextStyle.Image;
                 LoadImage(theImageList, image);
                 theMenuItem.ImageKey = image;
             }
             catch { }
         }
         if (firstPart.TextStyle.Tag != null)
         {
             try
             {
                 theMenuItem.Alignment = (ToolStripItemAlignment)(Enum.Parse(
                                                                      typeof(ToolStripItemAlignment), firstPart.TextStyle.Tag.Split(',')[0], true
                                                                      ));
             }
             catch { }
         }
     }
 }
 protected void CreateMenuEndItem(PluginMenuItemPart firstPart, ToolBar theMenuItem, Image theImageList)
 {
     if (firstPart.TextStyle.ButtonType == null)
     {
         theMenuItem.Header = firstPart.TextStyle.Text;
         theMenuItem.ToolTip = firstPart.TextStyle.ToolTipText;
         if (firstPart.TextStyle.Image != null)
         {
             try
             {
                 string image = firstPart.TextStyle.Image;
                 LoadImage(theImageList, image);
                 //theMenuItem.ImageKey = image;
             }
             catch { }
         }
     }
     else
     {
         theMenuItem = ReflectUtils.CreateInstance(firstPart.TextStyle.ButtonType)
         as ToolBar;
         theMenuItem.Header = firstPart.TextStyle.Text;
         theMenuItem.ToolTip = firstPart.TextStyle.ToolTipText;
         if (firstPart.TextStyle.Image != null)
         {
             try
             {
                 string image = firstPart.TextStyle.Image;
                 LoadImage(theImageList, image);
                 //theMenuItem.ImageKey = image;
             }
             catch { }
         }
         if (firstPart.TextStyle.Tag != null)
         {
             try
             {
                 //theMenuItem.Alignment = (ToolStripItemAlignment)(Enum.Parse(
                 //    typeof(ToolStripItemAlignment), firstPart.TextStyle.Tag.Split(',')[0], true
                 //    ));
             }
             catch { }
         }
     }
 }
        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;
                }
            }
        }
Beispiel #8
0
 protected virtual void CreateMenuEndItem(PluginMenuItemPart firstPart, MenuItem theMenuItem, Image theImageList)
 {
     if (firstPart.TextStyle.ButtonType == null)
     {
         theMenuItem.Header  = firstPart.TextStyle.Text;
         theMenuItem.ToolTip = firstPart.TextStyle.ToolTipText;
         if (firstPart.TextStyle.Image != null)
         {
             try
             {
                 string image = firstPart.TextStyle.Image;
                 LoadImage(theImageList, image);
                 //theMenuItem.ImageKey = image;
             }
             catch { }
         }
     }
 }
        protected PluginMenuPartStruct GetMenuItemIndex(PluginMenuItemPart theMenuItemPart, TreeNodeCollection nodes)
        {
            PluginMenuPartStruct theMenuItem = new PluginMenuPartStruct();
            int index = 0;
            string menuItemIndex = GetMenuItemIndex(theMenuItemPart.Locate);
            PluginMenuItemLocateType menuItemLocationType = (PluginMenuItemLocateType)(
                Enum.Parse(typeof(PluginMenuItemLocateType),
                    GetMenuItemLocator(theMenuItemPart.Locate),
                    true
                    )
                );
            theMenuItem.IsCreate = menuItemLocationType == PluginMenuItemLocateType.Create;

            if (int.TryParse(menuItemIndex, out index))
            {
                theMenuItem.Index = PluginMenuItemPartLocator.GetMenuLocatorIndex(menuItemLocationType, index, nodes.Count);
            }
            else if (menuItemIndex.Length == 0)
            {
                theMenuItem.Index = nodes.Count;
            }
            else
            {
                int realIndex = GetMenuItemIndexById(nodes, menuItemIndex);
                theMenuItem.Index = PluginMenuItemPartLocator.GetMenuLocatorIndex(
                    menuItemLocationType,
                    realIndex,
                    nodes.Count
                    );
                // Make only support ID
                if (menuItemLocationType == PluginMenuItemLocateType.Make)
                {
                    if (realIndex >= 0 && realIndex < nodes.Count)
                        theMenuItem.IsCreate = false;
                    else
                        theMenuItem.IsCreate = true;
                }
            }
            theMenuItem.Exist = theMenuItem.Index < nodes.Count
                    && theMenuItem.Index >= 0;

            return theMenuItem;
        }
Beispiel #10
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;
                }
            }
        }
 protected virtual void CreateMenuEndItem(PluginMenuItemPart firstPart, MenuItem theMenuItem, Image theImageList)
 {
     if (firstPart.TextStyle.ButtonType == null)
     {
         theMenuItem.Header = firstPart.TextStyle.Text;
         theMenuItem.ToolTip = firstPart.TextStyle.ToolTipText;
         if (firstPart.TextStyle.Image != null)
         {
             try
             {
                 string image = firstPart.TextStyle.Image;
                 LoadImage(theImageList, image);
                 //theMenuItem.ImageKey = image;
             }
             catch { }
         }
     }
 }
Beispiel #12
0
 private static IList<PluginMenuPath> ParsePluginMenuPaths(XmlNode node)
 {
     List<PluginMenuPath> pathList = new List<PluginMenuPath>();
     foreach (XmlNode theConnectionPointNode in node.SelectNodes("ConnectionPoints/ConnectionPoint"))
     {
         PluginMenuPath point = new PluginMenuPath();
         point.LocateType = (PluginMenuPathLocateType)(Enum.Parse(
             typeof(PluginMenuPathLocateType),
             XmlUtils.GetXmlAttribute(theConnectionPointNode, "menuType"))
             );
         point.MenuIndex = XmlUtils.GetXmlAttribute(theConnectionPointNode, "menuIndex");
         point.MenuImageIndex = XmlUtils.GetXmlAttribute(theConnectionPointNode, "menuImageIndex");
         point.MenuPathParts = new List<PluginMenuItemPart>();
         foreach (XmlNode addNode in theConnectionPointNode.SelectNodes("add"))
         {
             PluginMenuItemPart thePart = new PluginMenuItemPart();
             thePart.Locate = XmlUtils.GetXmlAttribute(addNode, "locate");
             thePart.TextStyle = ParsePluginTextStyle(XmlUtils.GetXmlAttribute(addNode, "text"));
             point.MenuPathParts.Add(thePart);
         }
         pathList.Add(point);
     }
     return pathList;
 }