Пример #1
0
 private void FillComboBoxValue(ToolStripComboBox item, ToolStripItemXmlElement itemEle)
 {
     foreach (XmlNode node in itemEle.ChildNodes)
     {
         if (node.NodeType != XmlNodeType.Element)
         {
             continue;
         }
         ItemValueXmlElement ele = (ItemValueXmlElement)node;
         if (!string.IsNullOrEmpty(ele.InnerText))
         {
             item.Items.Add(ele.InnerText);
             if (ele.IsDefault)
             {
                 item.Text = ele.InnerText;
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// 递归子程序(BuildToolStripItem)
        /// </summary>
        private void BuildToolStripItemSubMethod(ToolStripItemXmlElement itemEle, ToolStripItem item, DropControlType controlType)
        {
            ToolStripItem subItem = null;

            if (itemEle.HasChildNodes)
            {
                foreach (XmlNode node in itemEle.ChildNodes)
                {
                    if (node.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    ToolStripItemXmlElement subItemEle = (ToolStripItemXmlElement)node;
                    if (subItemEle.Name.ToUpper() != "TOOLSTRIPITEM")
                    {
                        continue;
                    }
                    subItem = BuildToolStripItem(subItemEle);
                    switch (controlType)
                    {
                    case DropControlType.MenuItem:
                        ((ToolStripMenuItem)item).DropDownItems.Add(subItem);
                        break;

                    case DropControlType.SplitButton:
                        ((ToolStripSplitButton)item).DropDownItems.Add(subItem);
                        break;

                    case DropControlType.DropDownButton:
                        ((ToolStripDropDownButton)item).DropDownItems.Add(subItem);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Пример #3
0
        private ToolStripItem MenuItemHelper(ToolStripItem returnItem, ToolStripItemXmlElement itemEle)
        {
            switch (itemEle.MenuControlType)
            {
            case MenuItemType.ComboBox: {
                ToolStripComboBox item = new ToolStripComboBox();
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.MenuDisplayStyle;
                returnItem        = item;
                break;
            }

            case MenuItemType.TextBox: {
                ToolStripTextBox item = new ToolStripTextBox();
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.MenuDisplayStyle;
                returnItem        = item;
                break;
            }

            case MenuItemType.MenuItem: {
                ToolStripMenuItem item = new ToolStripMenuItem(itemEle.TextString);
                BuildToolStripItemSubMethod(itemEle, item, DropControlType.MenuItem);
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.MenuDisplayStyle;
                returnItem        = item;
                break;
            }

            case MenuItemType.Separator: {
                ToolStripSeparator item = new ToolStripSeparator();
                returnItem = item;
                break;
            }
            }
            return(returnItem);
        }
Пример #4
0
        private ToolStripItem ToolStripItemHelper(ToolStripItem returnItem, ToolStripItemXmlElement itemEle)
        {
            switch (itemEle.ToolBarControlType)
            {
            case ToolStripItemType.Button: {
                ToolStripButton item = new ToolStripButton(this.ToSimpleText(itemEle.TextString));
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.ToolBarDisplayStyle;
                returnItem        = item;
                break;
            }

            case ToolStripItemType.Label: {
                ToolStripLabel item = new ToolStripLabel(itemEle.TextString);
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.ToolBarDisplayStyle;
                returnItem        = item;
                break;
            }

            case ToolStripItemType.SplitButton: {
                ToolStripSplitButton item = new ToolStripSplitButton(itemEle.TextString);
                BuildToolStripItemSubMethod(itemEle, item, DropControlType.SplitButton);
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.ToolBarDisplayStyle;
                returnItem        = item;
                break;
            }

            case ToolStripItemType.DropDownButton: {
                ToolStripDropDownButton item = new ToolStripDropDownButton(itemEle.TextString);
                BuildToolStripItemSubMethod(itemEle, item, DropControlType.DropDownButton);
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.ToolBarDisplayStyle;
                returnItem        = item;
                break;
            }

            case ToolStripItemType.ComboBox: {
                ToolStripComboBox item = new ToolStripComboBox();
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.ToolBarDisplayStyle;
                this.FillComboBoxValue(item, itemEle);
                returnItem = item;
                break;
            }

            case ToolStripItemType.TextBox: {
                ToolStripTextBox item = new ToolStripTextBox();
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.ToolBarDisplayStyle;
                returnItem        = item;
                break;
            }

            case ToolStripItemType.ProgressBar: {
                ToolStripProgressBar item = new ToolStripProgressBar();
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.ToolBarDisplayStyle;
                returnItem        = item;
                break;
            }

            case ToolStripItemType.MenuItem: {
                ToolStripMenuItem item = new ToolStripMenuItem(itemEle.TextString);
                BuildToolStripItemSubMethod(itemEle, item, DropControlType.MenuItem);
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.MenuDisplayStyle;
                returnItem        = item;
                break;
            }

            case ToolStripItemType.StatusLabel: {
                ToolStripStatusLabel item = new ToolStripStatusLabel(itemEle.TextString);
                item.Name         = itemEle.Fucation;
                item.DisplayStyle = itemEle.ToolBarDisplayStyle;
                returnItem        = item;
                break;
            }

            case ToolStripItemType.Separator: {
                ToolStripSeparator item = new ToolStripSeparator();
                returnItem = item;
                break;
            }
            }
            return(returnItem);
        }
Пример #5
0
        /// <summary>
        /// 建立ToolStripItem
        /// </summary>
        virtual internal ToolStripItem BuildToolStripItem(XmlElement element)
        {
            ToolStripItem returnItem = null;

            if (element.Name.ToUpper() == "TOOLSTRIPITEM")
            {
                ToolStripItemXmlElement itemEle = (ToolStripItemXmlElement)element;
                switch (itemEle.Place)
                {
                case ControlPlace.Menu: {
                    if (this._striptype == StripType.Menu || this._striptype == StripType.ContextMenu)
                    {
                        returnItem = MenuItemHelper(returnItem, itemEle);
                    }
                    break;
                }

                case ControlPlace.ToolBar: {
                    if (this._striptype == StripType.Status || this._striptype == StripType.ToolBar)
                    {
                        returnItem = ToolStripItemHelper(returnItem, itemEle);
                    }
                    break;
                }

                case ControlPlace.MenuAndToolbar: {
                    switch (this._striptype)
                    {
                    case StripType.Menu:
                    case StripType.ContextMenu:
                        returnItem = MenuItemHelper(returnItem, itemEle);
                        break;

                    case StripType.Status:
                    case StripType.ToolBar:
                        returnItem = ToolStripItemHelper(returnItem, itemEle);
                        break;

                    default:
                        break;
                    }
                    break;
                }

                case ControlPlace.Nothing:
                default:
                    Debug.Fail("开发期错误: 定义了无效的控件放置位置");
                    break;
                }//switch
                switch (itemEle.Fucation)
                {
                case "isDelete":
                    ((ToolStripMenuItem)returnItem).Checked = false;
                    break;

                case "isNotDelete":
                    ((ToolStripMenuItem)returnItem).Checked = true;
                    break;

                case "isPublish":
                    ((ToolStripMenuItem)returnItem).Checked = true;
                    break;

                case "isNotPublish":
                    ((ToolStripMenuItem)returnItem).Checked = true;
                    break;

                case "isModify":
                    ((ToolStripMenuItem)returnItem).Checked = true;
                    break;

                case "isNotModify":
                    ((ToolStripMenuItem)returnItem).Checked = true;
                    break;

                case "isAdvertisement":
                    ((ToolStripMenuItem)returnItem).Checked = true;
                    break;

                case "isNotAdadvertisement":
                    ((ToolStripMenuItem)returnItem).Checked = true;
                    break;

                default:
                    break;
                }
            }//if
            return(returnItem);
        }