Ejemplo n.º 1
0
        private BarItem CreateDropDown(IRibbonItem item)
        {
            ICommandSubType comboSetting = item as ICommandSubType;

            BarSubItem dropItem = new BarSubItem()
            {
                Name    = item.Key,
                Caption = item.Caption
            };

            if (item.Image != null)
            {
                if (item.Image.Width > 24 || item.Image.Height > 24)
                {
                    dropItem.LargeGlyph = item.Image;
                }
                else
                {
                    dropItem.Glyph = item.Image;
                }
            }
            //for (int i = 0; i < comboSetting.GetCount(); i++)
            //{
            //    ((ICommandSubType)item).SetSubType(i);
            //    BarItem button = _ribbonManager.Items[item.Key];
            //    dropItem.LinksPersistInfo.Add(new LinkPersistInfo() { Item = button });
            //}
            BarManagerCategory category = CheckCategoryExists(item.Category);

            dropItem.Category = category;
            _ribbonManager.Items.Add(dropItem);
            return(dropItem);
        }
Ejemplo n.º 2
0
        private BarItem CreateCheckBox(IRibbonItem item)
        {
            BarCheckItem button = new BarCheckItem()
            {
                Name    = item.Key,
                Caption = item.Caption
            };

            if (item.Image != null)
            {
                if (item.Image.Width > 24 || item.Image.Height > 24)
                {
                    button.LargeGlyph = item.Image;
                }
                else
                {
                    button.Glyph = item.Image;
                }
            }
            button.Checked    = item.Checked;
            button.Tag        = item;
            button.ItemClick += ((YutaiCommand)item).OnClick;
            //开始检查Category是否存在
            BarManagerCategory category = CheckCategoryExists(item.Category);

            button.Category = category;
            _ribbonManager.Items.Add(button);
            return(button);
        }
Ejemplo n.º 3
0
        private BarManagerCategory CheckCategoryExists(string category)
        {
            int catIndex = _ribbonManager.Categories.IndexOf(category);

            if (catIndex >= 0)
            {
                return(_ribbonManager.Categories[catIndex]);
            }

            BarManagerCategory newCategory = _ribbonManager.Categories.Add(category);

            return(newCategory);
        }
Ejemplo n.º 4
0
        private BarItem CreateComboBox(IRibbonItem item)
        {
            ICommandComboBox comboSetting = item as ICommandComboBox;
            //ComboBoxEdit comboBox = new ComboBoxEdit()
            //{
            //    Name = item.Key,
            //    Caption = item.Caption
            //};
            BarEditItem comboBox = new BarEditItem()
            {
                Name    = item.Key,
                Caption = item.Caption,
                Width   = 230
            };

            RepositoryItemComboBox cmbEdit = new RepositoryItemComboBox()
            {
                Name = item.Key + "_combo", BestFitWidth = 300
            };

            //cmbEdit.Buttons.AddRange(new EditorButton[] {new EditorButton(ButtonPredefines.Combo)  });
            comboBox.Edit = cmbEdit;

            if (comboSetting.DropDownList)
            {
                //cmbEdit.AllowDropDownWhenReadOnly = DefaultBoolean.True;
                //cmbEdit.ReadOnly = true;
            }

            object[] objectItems = comboSetting.Items;
            if (objectItems != null)
            {
                for (int i = 0; i < objectItems.Length; i++)
                {
                    cmbEdit.Items.Add(objectItems[i]);
                }
            }
            comboBox.Tag = item;
            comboSetting.LinkComboBox  = comboBox;
            comboBox.EditValueChanged += ((ICommandComboBox)item).OnEditValueChanged;
            comboSetting.LinkComboBox  = comboBox;
            //开始检查Category是否存在
            BarManagerCategory category = CheckCategoryExists(item.Category);

            comboBox.Category = category;
            _ribbonManager.Items.Add(comboBox);
            return(comboBox);
        }
Ejemplo n.º 5
0
        private BarItem CreateButton(IRibbonItem item)
        {
            BarButtonItem button = new BarButtonItem()
            {
                Name    = item.Key,
                Caption = item.Caption
            };

            if (item.Image != null)
            {
                if (item.Image.Width > 24 || item.Image.Height > 24)
                {
                    button.LargeGlyph = item.Image;
                }
                else
                {
                    button.Glyph = item.Image;
                }
            }
            else
            {
                button.PaintStyle = BarItemPaintStyle.Caption;
            }
            button.Tag        = item;
            button.Enabled    = item.Enabled;
            button.Down       = item.Checked;
            button.ItemClick += ((YutaiCommand)item).OnClick;
            if (item.ItemType == RibbonItemType.Tool)
            {
                button.ButtonStyle = BarButtonStyle.Check;
                button.ItemClick  += SetCurrentTool;
            }
            else
            {
                button.ButtonStyle = BarButtonStyle.Default;
            }


            //开始检查Category是否存在
            BarManagerCategory category = CheckCategoryExists(item.Category);

            button.Category = category;
            _ribbonManager.Items.Add(button);
            return(button);
        }
Ejemplo n.º 6
0
        private BarItem CreateRibbonEditItem(IRibbonItem item)
        {
            IRibbonEditItem comboSetting = item as IRibbonEditItem;
            //ComboBoxEdit comboBox = new ComboBoxEdit()
            //{
            //    Name = item.Key,
            //    Caption = item.Caption
            //};
            BarEditItem comboBox = new BarEditItem()
            {
                Name    = item.Key,
                Caption = item.Caption,
                Width   = comboSetting.Width
            };


            RepositoryItemComboBox cmbEdit = new RepositoryItemComboBox()
            {
                Name = item.Key + "_combo", BestFitWidth = 300
            };

            //cmbEdit.Buttons.AddRange(new EditorButton[] {new EditorButton(ButtonPredefines.Combo)  });
            comboBox.Edit = cmbEdit;

            comboBox.Tag = item;
            comboSetting.RibbonEditItem = cmbEdit;
            //comboSetting.LinkComboBox = comboBox;
            //comboBox.EditValueChanged += ((ICommandComboBox)item).OnEditValueChanged;
            //comboSetting.LinkComboBox = comboBox;
            //开始检查Category是否存在
            BarManagerCategory category = CheckCategoryExists(item.Category);

            comboBox.Category = category;
            _ribbonManager.Items.Add(comboBox);
            return(comboBox);
        }
Ejemplo n.º 7
0
        private BarItem CreateBarItem(ICommand pCommand)
        {
            BarItem            item;
            BarManagerCategory category;

            if (pCommand is IBarEditItem)
            {
                item = new BarEditItem();
                RepositoryItemComboBox box = new RepositoryItemComboBox();
                item.Width = (pCommand as IBarEditItem).Width;
                (item as BarEditItem).Edit = box;
                box.AutoHeight             = false;
                box.Name = pCommand.Name + "_ItemComboBox";
                (pCommand as IBarEditItem).BarEditItem = item;
            }
            else
            {
                item = new BarButtonItem();
            }
            this.barManager1.Items.Add(item);
            item.Id      = this.barManager1.GetNewItemId();
            item.Name    = pCommand.Name;
            item.Tag     = pCommand;
            item.Caption = pCommand.Caption;
            if (pCommand.Tooltip != null)
            {
                item.Hint = pCommand.Tooltip;
            }
            else if (pCommand.Caption != null)
            {
                item.Hint = pCommand.Caption;
            }
            if (pCommand.Bitmap != 0)
            {
                try
                {
                    IntPtr hbitmap = new IntPtr(pCommand.Bitmap);
                    item.Glyph = Image.FromHbitmap(hbitmap);
                }
                catch
                {
                }
            }
            if (pCommand.Category != null)
            {
                if (pCommand.Category.Length > 0)
                {
                    category = this.barManager1.Categories[pCommand.Category];
                    if (category == null)
                    {
                        category = new BarManagerCategory(pCommand.Category, Guid.NewGuid());
                        this.barManager1.Categories.Add(category);
                    }
                    item.Category = category;
                    return(item);
                }
                category = this.barManager1.Categories["其他"];
                if (category == null)
                {
                    category = new BarManagerCategory("其他", Guid.NewGuid());
                    this.barManager1.Categories.Add(category);
                }
                item.Category = category;
                return(item);
            }
            category = this.barManager1.Categories["其他"];
            if (category == null)
            {
                category = new BarManagerCategory("其他", Guid.NewGuid());
                this.barManager1.Categories.Add(category);
            }
            item.Category = category;
            return(item);
        }
Ejemplo n.º 8
0
        void IMain.InitializeMenu()
        {
            Dictionary <string, BarItem>            dicMenuItems;
            List <MenuItemInfo>                     colMenuItems;
            Dictionary <string, BarManagerCategory> colMenuCategories;

            dicMenuItems      = new Dictionary <string, BarItem>();
            colMenuCategories = new Dictionary <string, BarManagerCategory>();

            mainBar.Items.Clear();
            mainBar.Images = ThemeUtils.Image16;

            using (var ctrlMenu = new SAController())
            {
                ctrlMenu.ListMenuItems(out colMenuItems);
            }
            // 1st) Add root
            m_RootCategory = new BarManagerCategory
            {
                Name = LangUtils.Translate(
                    LangType.MENU_CAPTION,
                    CONSTANTS.BUILT_IN_MENU_NAME,
                    CONSTANTS.BUILT_IN_MENU_NAME)
            };
            colMenuCategories.Add(CONSTANTS.BUILT_IN_MENU_ID, m_RootCategory);
            mainBar.Categories.Add(m_RootCategory);
            // 2nd) add root container
            BarItem newBarItem = new BarSubItem
            {
                Name    = string.Format(CONSTANTS.BAR_SUB_ITEM_FORMAT, CONSTANTS.BUILT_IN_MENU_NAME),
                Caption = LangUtils.Translate(
                    LangType.MENU_CAPTION,
                    CONSTANTS.BUILT_IN_MENU_NAME,
                    CONSTANTS.BUILT_IN_MENU_NAME)
            };

            dicMenuItems.Add(CONSTANTS.BUILT_IN_MENU_ID, newBarItem);

            foreach (MenuItemInfo item in colMenuItems)
            {
                var count = colMenuItems.Count(child => child.OwnerMenuItemID == item.MenuItemID);
                // No child create BarButtonItem, have children create Category
                if (count == 0)
                {
                    newBarItem = new BarButtonItem {
                        Tag = item
                    };
                    dicMenuItems.Add(item.MenuItemID, newBarItem);
                    newBarItem.Name = string.Format(CONSTANTS.BAR_BUTTON_ITEM_FORMAT, item.MenuItemName);
                }
                else
                {
                    newBarItem = new BarSubItem
                    {
                        Name = string.Format(CONSTANTS.BAR_SUB_ITEM_FORMAT, item.MenuItemName)
                    };
                    dicMenuItems.Add(item.MenuItemID, newBarItem);

                    var category = new BarManagerCategory
                    {
                        Name = LangUtils.Translate(
                            LangType.MENU_CAPTION,
                            item.MenuItemName,
                            item.MenuItemName)
                    };
                    colMenuCategories.Add(item.MenuItemID, category);
                    mainBar.Categories.Add(category);
                }

                newBarItem.Tag          = item;                                                          //Make tag
                newBarItem.Caption      = LangUtils.Translate(LangType.MENU_CAPTION, item.MenuItemName); // Apply caption
                newBarItem.Glyph        = LangUtils.Get16x16Image(LangType.MENU_ICON, item.MenuItemName);
                newBarItem.ItemShortcut = LangUtils.GetShortcut(LangType.MENU_HOTKEY, item.MenuItemName);

                mainBar.Items.Add(newBarItem);
            }

            foreach (MenuItemInfo item in colMenuItems)
            {
                if (!string.IsNullOrEmpty(item.OwnerMenuItemID))
                {
                    dicMenuItems[item.MenuItemID].Category = colMenuCategories[item.OwnerMenuItemID];
                    ((BarSubItem)dicMenuItems[item.OwnerMenuItemID]).LinksPersistInfo.Add(
                        new LinkPersistInfo(dicMenuItems[item.MenuItemID], item.BeginGroup == CODES.DEFMENU.BEGINGROUP.YES));
                }
            }

            mainBar.Items.Add(txtModuleID);
        }
Ejemplo n.º 9
0
        private BarItem method_1(MenuItemDef menuItemDef_0)
        {
            ICommand           command = null;
            BarManagerCategory category;

            if ((menuItemDef_0.Path != null) && (menuItemDef_0.ClassName != null))
            {
                try
                {
                    if (menuItemDef_0.Path[1] != ':')
                    {
                        menuItemDef_0.Path = Application.StartupPath + @"\" + menuItemDef_0.Path;
                    }
                    if (File.Exists(menuItemDef_0.Path))
                    {
                        command = this.method_0(menuItemDef_0.Path).LoadClass(menuItemDef_0.ClassName) as ICommand;
                        if (command != null)
                        {
                            // command.OnCreate(null);
                            if (menuItemDef_0.SubType != null)
                            {
                                try
                                {
                                    int subType = int.Parse(menuItemDef_0.SubType);
                                    (command as ICommandSubType).SetSubType(subType);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            if (command == null)
            {
                return(null);
            }
            BarItem item = null;

            item = this.popupMenu_0.Manager.Items[menuItemDef_0.Name];
            if (item != null)
            {
                return(item);
            }
            item = new BarButtonItem();
            this.popupMenu_0.Manager.Items.Add(item);
            item.Id      = this.popupMenu_0.Manager.GetNewItemId();
            item.Name    = menuItemDef_0.Name;
            item.Tag     = command;
            item.Caption = command.Caption;
            if (menuItemDef_0.Caption != null)
            {
                item.Caption = menuItemDef_0.Caption;
            }
            item.Enabled = command.Enabled;
            if (command.Tooltip != null)
            {
                item.Hint = command.Tooltip;
            }
            if ((menuItemDef_0.BitmapPath == null) && (command.Bitmap != 0))
            {
                try
                {
                    IntPtr hbitmap = new IntPtr(command.Bitmap);
                    Bitmap bitmap  = Image.FromHbitmap(hbitmap);
                    bitmap.MakeTransparent();
                    item.Glyph = bitmap;
                    goto Label_01E8;
                }
                catch
                {
                    goto Label_01E8;
                }
            }
            if (menuItemDef_0.BitmapPath != null)
            {
                item.Glyph = new Bitmap(menuItemDef_0.BitmapPath);
            }
Label_01E8:
            if (command.Category != null)
            {
                if (command.Category.Length > 0)
                {
                    category = this.popupMenu_0.Manager.Categories[command.Category];
                    if (category == null)
                    {
                        category = new BarManagerCategory(command.Category, Guid.NewGuid());
                        this.popupMenu_0.Manager.Categories.Add(category);
                    }
                    item.Category = category;
                    return(item);
                }
                category = this.popupMenu_0.Manager.Categories["其他"];
                if (category == null)
                {
                    category = new BarManagerCategory("其他", Guid.NewGuid());
                    this.popupMenu_0.Manager.Categories.Add(category);
                }
                item.Category = category;
                return(item);
            }
            category = this.popupMenu_0.Manager.Categories["其他"];
            if (category == null)
            {
                category = new BarManagerCategory("其他", Guid.NewGuid());
                this.popupMenu_0.Manager.Categories.Add(category);
            }
            item.Category = category;
            return(item);
        }
Ejemplo n.º 10
0
        private void method_6(object object_0, XmlNode xmlNode_0, bool bool_1)
        {
            int       num;
            Exception exception;
            string    str = "0";

            string[] strArray = this.method_7(xmlNode_0, out str);
            ICommand command  = null;

            if ((strArray[4] != null) && (strArray[5] != null))
            {
                try
                {
                    if ((AppConfigInfo.UserID != "admin") &&
                        !this.sysGrants_0.StaffIsHasMenuPri(this.menuInfoHelper_0, strArray[4], strArray[5]))
                    {
                        return;
                    }
                    if (strArray[4][1] != ':')
                    {
                        strArray[4] = Application.StartupPath + @"\" + strArray[4];
                    }
                    if (File.Exists(strArray[4]))
                    {
                        command = this.method_10(strArray[4]).LoadClass(strArray[5]) as ICommand;
                        if (command != null)
                        {
                            if (command is IToolContextMenu)
                            {
                                (command as IToolContextMenu).PopuMenu = this.ipopuMenuWrap_0;
                            }
                            if (strArray[6] != null)
                            {
                                try
                                {
                                    num = int.Parse(strArray[6]);
                                    (command as ICommandSubType).SetSubType(num);
                                }
                                catch
                                {
                                    Logger.Current.Error("", null,
                                                         string.Format("创建{0}中的类{1}的子命令设置失败", strArray[4], strArray[5]));
                                }
                            }
                            if ((strArray[14] != null) && bool.Parse(strArray[14]))
                            {
                                // this.iframework_0.Application.AddCommands(command);
                            }
                        }
                        else
                        {
                            Logger.Current.Error("", null,
                                                 string.Format("创建{0}中的类{1}的失败,无法创建该工具", strArray[4], strArray[5]));
                        }
                    }
                    else
                    {
                        Logger.Current.Error("", null, string.Format("文件{0}不存在!", strArray[4]));
                    }
                }
                catch (Exception exception1)
                {
                    exception = exception1;
                    Logger.Current.Error("", exception, string.Format("创建{0}中的类{1}的失败", strArray[4], strArray[5]));
                }
            }
            else if (strArray[8] != null)
            {
                try
                {
                    if ((AppConfigInfo.UserID != "admin") &&
                        !this.sysGrants_0.StaffIsHasMenuPri(this.menuInfoHelper_0, strArray[8]))
                    {
                        return;
                    }
                    command = Activator.CreateInstance(Type.GetTypeFromProgID(strArray[8])) as ICommand;
                    if (command != null)
                    {
                        if (command is IToolContextMenu)
                        {
                            (command as IToolContextMenu).PopuMenu = this.ipopuMenuWrap_0;
                        }
                        if (strArray[6] != null)
                        {
                            try
                            {
                                num = int.Parse(strArray[6]);
                                (command as ICommandSubType).SetSubType(num);
                            }
                            catch
                            {
                                Logger.Current.Error("", null,
                                                     string.Format("创建{0}中的类{1}的子命令设置失败", strArray[4], strArray[5]));
                            }
                        }
                        if ((strArray[14] != null) && bool.Parse(strArray[14]))
                        {
                            //this.iframework_0.Application.AddCommands(command);
                        }
                    }
                    else
                    {
                        Logger.Current.Error("", null, string.Format("创建{0}中的类{1}的失败,无法创建该工具", strArray[4], strArray[5]));
                    }
                }
                catch (Exception exception2)
                {
                    exception = exception2;
                    Logger.Current.Error("", exception, "创建" + strArray[4] + "中的类" + strArray[5] + "失败");
                }
            }
            else if (strArray[10] != null)
            {
                try
                {
                    int    index    = strArray[10].IndexOf(',');
                    string typeName = strArray[10].Substring(0, index);
                    string str3     = strArray[10].Substring(index + 1).Trim();
                    command = this.method_11(str3).CreateInstance(typeName) as ICommand;
                    if (command != null)
                    {
                        if (command is IToolContextMenu)
                        {
                            (command as IToolContextMenu).PopuMenu = this.ipopuMenuWrap_0;
                        }
                        if (strArray[6] != null)
                        {
                            try
                            {
                                num = int.Parse(strArray[6]);
                                (command as ICommandSubType).SetSubType(num);
                            }
                            catch
                            {
                                Logger.Current.Error("", null,
                                                     string.Format("创建{0}中的类{1}的子命令设置失败", strArray[4], strArray[5]));
                            }
                        }
                        if ((strArray[14] != null) && bool.Parse(strArray[14]))
                        {
                            //   this.iframework_0.Application.AddCommands(command);
                        }
                    }
                    else
                    {
                        Logger.Current.Error("", null, string.Format("创建{0}中的类{1}的失败,无法创建该工具", strArray[4], strArray[5]));
                    }
                }
                catch (Exception exception3)
                {
                    exception = exception3;
                    Logger.Current.Error("", exception, "创建" + strArray[4] + "中的类" + strArray[5] + "失败");
                }
            }
            if ((strArray[0] != null) || (command != null))
            {
                if (command is ICommandLine)
                {
                    if ((command as ICommandLine).CommandName != null)
                    {
                        strArray[0] = (command as ICommandLine).CommandName;
                    }
                }
                else if ((command != null) && (command.Name != null))
                {
                    strArray[0] = command.Name;
                }
                BarItem item = null;
                if (strArray[0].Length > 0)
                {
                    item = this.barManager_0.Items[strArray[0]];
                }
                if (item == null)
                {
                    BarManagerCategory category;
                    string             caption;
                    if (command != null)
                    {
                        command.OnCreate((object)this.iframework_0.Application);
                    }
                    if ((str != "0") && (command != null))
                    {
                        this.list_0.Add(command);
                    }
                    if (xmlNode_0.ChildNodes.Count > 0)
                    {
                        item = new BarSubItem();
                        this.barManager_0.Items.Add(item);
                        if (object_0 is Bar)
                        {
                            category = this.barManager_0.Categories["弹出式菜单"];
                            if (category == null)
                            {
                                category = new BarManagerCategory("弹出式菜单", Guid.NewGuid());
                                this.barManager_0.Categories.Add(category);
                            }
                            item.Category = category;
                        }
                        else if (object_0 is BarSubItem)
                        {
                            caption  = (object_0 as BarSubItem).Caption;
                            category = this.barManager_0.Categories[caption];
                            if (category == null)
                            {
                                category = new BarManagerCategory(caption, Guid.NewGuid());
                                this.barManager_0.Categories.Add(category);
                            }
                            item.Category = category;
                        }
                    }
                    else
                    {
                        if (command is IBarEditItem)
                        {
                            if ((command as IBarEditItem).Style == BarEditStyle.ComboBoxEdit)
                            {
                                item = new BarEditItem();
                                RepositoryItemComboBox box = new RepositoryItemComboBox();
                                (item as BarEditItem).Edit = box;
                                box.AutoHeight             = false;
                                box.Name = command.Name + "_ItemComboBox";
                                (command as IBarEditItem).BarEditItem = new YTComboxBarItem(item);
                                item.Width = (command as IBarEditItem).Width;
                            }
                            else
                            {
                                if ((command as IBarEditItem).Style != BarEditStyle.ButtonEdit)
                                {
                                    return;
                                }
                                item = new BarButtonItem();
                                (command as IBarEditItem).BarEditItem = new JLKButtonBarItem(item);
                                item.Width = (command as IBarEditItem).Width;
                            }
                        }
                        else if (command is IToolControl)
                        {
                            item = new BarButtonItem();
                        }
                        else
                        {
                            item = new BarButtonItem();
                        }
                        this.barManager_0.Items.Add(item);
                    }
                    item.Id   = this.barManager_0.GetNewItemId();
                    item.Name = strArray[0];
                    item.Tag  = command;
                    if (strArray[1] != null)
                    {
                        item.Caption = strArray[1];
                    }
                    if (command != null)
                    {
                        if (strArray[11] != null)
                        {
                            item.Hint = strArray[11];
                        }
                        else if (command.Tooltip != null)
                        {
                            item.Hint = command.Tooltip;
                        }
                        else if (command.Caption != null)
                        {
                            item.Hint = command.Caption;
                        }
                        if ((command is IShortcut) && (strArray[9] == null))
                        {
                            item.ItemShortcut = new BarShortcut((command as IShortcut).Keys);
                        }
                        if (((strArray[12] == null) && (strArray[13] == null)) && (command.Bitmap != 0))
                        {
                            try
                            {
                                IntPtr hbitmap = new IntPtr(command.Bitmap);
                                Bitmap bitmap  = Image.FromHbitmap(hbitmap);
                                bitmap.MakeTransparent();
                                item.Glyph = bitmap;
                            }
                            catch
                            {
                            }
                        }
                        if (strArray[1] == null)
                        {
                            item.Caption = command.Caption;
                        }
                        if (command.Category != null)
                        {
                            if (command.Category.Length > 0)
                            {
                                category = this.barManager_0.Categories[command.Category];
                                if (category == null)
                                {
                                    category = new BarManagerCategory(command.Category, Guid.NewGuid());
                                    this.barManager_0.Categories.Add(category);
                                }
                                item.Category = category;
                            }
                            else
                            {
                                category = this.barManager_0.Categories["其他"];
                                if (category == null)
                                {
                                    category = new BarManagerCategory("其他", Guid.NewGuid());
                                    this.barManager_0.Categories.Add(category);
                                }
                                item.Category = category;
                            }
                        }
                        else
                        {
                            category = this.barManager_0.Categories["其他"];
                            if (category == null)
                            {
                                category = new BarManagerCategory("其他", Guid.NewGuid());
                                this.barManager_0.Categories.Add(category);
                            }
                            item.Category = category;
                        }
                    }
                    else if (strArray[11] != null)
                    {
                        item.Hint = strArray[11];
                    }
                    try
                    {
                        if (strArray[9] != null)
                        {
                            KeysConverter converter;
                            if (!(item is BarSubItem))
                            {
                                converter = new KeysConverter();
                                converter.ConvertFromString(strArray[9]).ToString();
                                item.ItemShortcut = new BarShortcut((Keys)converter.ConvertFromString(strArray[9]));
                            }
                            else if (item is BarSubItem)
                            {
                                caption = (item as BarSubItem).Caption;
                                string[] strArray3 = strArray[9].Split(new char[] { '+' });
                                if ((strArray3.Length == 2) && (strArray3[0].ToLower() == "alt"))
                                {
                                    (item as BarSubItem).Caption = caption + "(&" + strArray3[1] + ")";
                                }
                                else
                                {
                                    converter = new KeysConverter();
                                    converter.ConvertFromString(strArray[9]).ToString();
                                    item.ItemShortcut = new BarShortcut((Keys)converter.ConvertFromString(strArray[9]));
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                    if (strArray[13] != null)
                    {
                        item.Glyph = new Bitmap(strArray[13]);
                        (item.Glyph as Bitmap).MakeTransparent();
                    }
                    else if (strArray[12] != null)
                    {
                        MemoryStream stream = new MemoryStream(Convert.FromBase64String(strArray[12]));
                        try
                        {
                            item.Glyph = Image.FromStream(stream) as Bitmap;
                        }
                        catch (Exception exception4)
                        {
                            exception4.ToString();
                        }
                        finally
                        {
                            if (stream != null)
                            {
                                stream.Dispose();
                            }
                        }
                    }
                }
                for (int i = 0; i < xmlNode_0.ChildNodes.Count; i++)
                {
                    this.method_6(item, xmlNode_0.ChildNodes[i], bool_1);
                }
                BarItemLink link = null;
                if (object_0 is Bar)
                {
                    if (strArray[3] != null)
                    {
                        if (bool.Parse(strArray[3]))
                        {
                            if (item is BarSubItem)
                            {
                                if ((item as BarSubItem).ItemLinks.Count > 0)
                                {
                                    link = (object_0 as Bar).AddItem(item);
                                }
                                else
                                {
                                    this.barManager_0.Items.Remove(item);
                                }
                            }
                            else
                            {
                                link = (object_0 as Bar).AddItem(item);
                            }
                        }
                    }
                    else if (item is BarSubItem)
                    {
                        if ((item as BarSubItem).ItemLinks.Count > 0)
                        {
                            link = (object_0 as Bar).AddItem(item);
                        }
                        else
                        {
                            this.barManager_0.Items.Remove(item);
                        }
                    }
                    else
                    {
                        link = (object_0 as Bar).AddItem(item);
                    }
                }
                else if (object_0 is BarSubItem)
                {
                    if (strArray[3] != null)
                    {
                        if (bool.Parse(strArray[3]))
                        {
                            if (item is BarSubItem)
                            {
                                if ((item as BarSubItem).ItemLinks.Count > 0)
                                {
                                    link = (object_0 as BarSubItem).AddItem(item);
                                }
                                else
                                {
                                    this.barManager_0.Items.Remove(item);
                                }
                            }
                            else
                            {
                                link = (object_0 as BarSubItem).AddItem(item);
                            }
                        }
                    }
                    else if (item is BarSubItem)
                    {
                        if ((item as BarSubItem).ItemLinks.Count > 0)
                        {
                            link = (object_0 as BarSubItem).AddItem(item);
                        }
                        else
                        {
                            this.barManager_0.Items.Remove(item);
                        }
                    }
                    else
                    {
                        link = (object_0 as BarSubItem).AddItem(item);
                    }
                }
                if ((link != null) && (strArray[2] != null))
                {
                    link.BeginGroup = bool.Parse(strArray[2]);
                }
                if (((strArray[7] != null) && (this.popupMenu_0 != null)) && !bool_1)
                {
                    try
                    {
                        if (bool.Parse(strArray[7]))
                        {
                            if (strArray[2] != null)
                            {
                                this.popupMenu_0.AddItem(item).BeginGroup = bool.Parse(strArray[2]);
                            }
                            else
                            {
                                this.popupMenu_0.AddItem(item);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private void method_5(Bar bar_0, ICommand icommand_0, bool bool_1, int int_0)
        {
            if (icommand_0 is ICommandSubType)
            {
                (icommand_0 as ICommandSubType).SetSubType(int_0);
            }
            icommand_0.OnCreate(this.iframework_0.Application);
            if (icommand_0 is IToolContextMenu)
            {
                (icommand_0 as IToolContextMenu).PopuMenu = this.ipopuMenuWrap_0;
            }
            string name = icommand_0.Name;

            if ((icommand_0 is ICommandLine) && ((icommand_0 as ICommandLine).CommandName != null))
            {
                name = (icommand_0 as ICommandLine).CommandName;
            }
            BarItem item = null;

            item = this.barManager_0.Items[name];
            if (item == null)
            {
                if (icommand_0 is IBarEditItem)
                {
                    if ((icommand_0 as IBarEditItem).Style == BarEditStyle.ComboBoxEdit)
                    {
                        item = new BarEditItem();
                        RepositoryItemComboBox box = new RepositoryItemComboBox();
                        (item as BarEditItem).Edit = box;
                        box.AutoHeight             = false;
                        box.Name = icommand_0.Name + "_ItemComboBox";
                        (icommand_0 as IBarEditItem).BarEditItem = new YTComboxBarItem(item);
                        item.Width = (icommand_0 as IBarEditItem).Width;
                    }
                    else
                    {
                        if ((icommand_0 as IBarEditItem).Style != BarEditStyle.ButtonEdit)
                        {
                            return;
                        }
                        item = new BarButtonItem();
                        (icommand_0 as IBarEditItem).BarEditItem = new JLKButtonBarItem(item);
                        item.Width = (icommand_0 as IBarEditItem).Width;
                    }
                }
                else if (icommand_0 is IToolControl)
                {
                    item = new BarButtonItem();
                }
                else
                {
                    item = new BarButtonItem();
                }
                this.barManager_0.Items.Add(item);
                item.Id      = this.barManager_0.GetNewItemId();
                item.Name    = name;
                item.Tag     = icommand_0;
                item.Caption = icommand_0.Caption;
                if (icommand_0 != null)
                {
                    BarManagerCategory category;
                    if (icommand_0.Tooltip != null)
                    {
                        item.Hint = icommand_0.Tooltip;
                    }
                    else if (icommand_0.Caption != null)
                    {
                        item.Hint = icommand_0.Caption;
                    }
                    if (icommand_0 is IShortcut)
                    {
                        item.ItemShortcut = new BarShortcut((icommand_0 as IShortcut).Keys);
                    }
                    if (icommand_0.Bitmap != 0)
                    {
                        try
                        {
                            IntPtr hbitmap = new IntPtr(icommand_0.Bitmap);
                            Bitmap bitmap  = Image.FromHbitmap(hbitmap);
                            bitmap.MakeTransparent();
                            item.Glyph = bitmap;
                        }
                        catch
                        {
                        }
                    }
                    if (icommand_0.Category != null)
                    {
                        if (icommand_0.Category.Length > 0)
                        {
                            category = this.barManager_0.Categories[icommand_0.Category];
                            if (category == null)
                            {
                                category = new BarManagerCategory(icommand_0.Category, Guid.NewGuid());
                                this.barManager_0.Categories.Add(category);
                            }
                            item.Category = category;
                        }
                        else
                        {
                            category = this.barManager_0.Categories["其他"];
                            if (category == null)
                            {
                                category = new BarManagerCategory("其他", Guid.NewGuid());
                                this.barManager_0.Categories.Add(category);
                            }
                            item.Category = category;
                        }
                    }
                    else
                    {
                        category = this.barManager_0.Categories["其他"];
                        if (category == null)
                        {
                            category = new BarManagerCategory("其他", Guid.NewGuid());
                            this.barManager_0.Categories.Add(category);
                        }
                        item.Category = category;
                    }
                }
            }
            BarItemLink link = bar_0.AddItem(item);

            if (link != null)
            {
                link.BeginGroup = bool_1;
            }
        }
Ejemplo n.º 12
0
        private void Init()
        {
            BarManagerCategory category = null;

            if (this.m_pBarManager != null)
            {
                category = this.m_pBarManager.Categories["界面风格"];
            }
            else if (this.m_ribbonctrl != null)
            {
                category = this.m_ribbonctrl.Categories["界面风格"];
            }
            if (category == null)
            {
                category = new BarManagerCategory("界面风格", Guid.NewGuid());
                if (this.m_pBarManager != null)
                {
                    this.m_pBarManager.Categories.Add(category);
                }
                else if (this.m_ribbonctrl != null)
                {
                    this.m_ribbonctrl.Categories.Add(category);
                }
            }
            this.iPaintStyle         = new BarSubItem();
            this.ipsDefault          = new BarButtonItem();
            this.ipsWXP              = new BarButtonItem();
            this.ipsOXP              = new BarButtonItem();
            this.ipsO2K              = new BarButtonItem();
            this.ipsO3               = new BarButtonItem();
            this.ipsO7               = new BarButtonItem();
            this.iPaintStyle.Caption = "界面风格";
            if (this.m_pBarManager != null)
            {
                this.iPaintStyle.Id = this.m_pBarManager.GetNewItemId();
            }
            this.iPaintStyle.Name       = "iPaintStyle";
            this.iPaintStyle.Category   = category;
            this.iPaintStyle.UseOwnFont = true;
            this.ipsDefault.Caption     = "默认风格";
            if (this.m_pBarManager != null)
            {
                this.ipsDefault.Id = this.m_pBarManager.GetNewItemId();
            }
            this.ipsDefault.Description = "Default";
            this.ipsDefault.Name        = "ipsDefault";
            this.ipsDefault.Category    = category;
            this.ipsDefault.ItemClick  += new ItemClickEventHandler(this.ips_ItemClick);
            this.ipsWXP.Caption         = "Windows XP";
            this.ipsWXP.Glyph           =
                new Bitmap(
                    base.GetType().Assembly.GetManifestResourceStream("Yutai.ArcGIS.Controls.PaintStyle.WindowsXP.bmp"));
            this.ipsWXP.Description = "WindowsXP";
            if (this.m_pBarManager != null)
            {
                this.ipsWXP.Id = this.m_pBarManager.GetNewItemId();
            }
            this.ipsWXP.Name       = "ipsWXP";
            this.ipsWXP.Category   = category;
            this.ipsWXP.ItemClick += new ItemClickEventHandler(this.ips_ItemClick);
            this.ipsOXP.Caption    = "Office XP";
            this.ipsOXP.Glyph      =
                new Bitmap(
                    base.GetType().Assembly.GetManifestResourceStream("Yutai.ArcGIS.Controls.PaintStyle.OfficeXP.bmp"));
            this.ipsOXP.Description = "OfficeXP";
            this.ipsOXP.Name        = "ipsOXP";
            if (this.m_pBarManager != null)
            {
                this.ipsOXP.Id = this.m_pBarManager.GetNewItemId();
            }
            this.ipsOXP.Category   = category;
            this.ipsOXP.ItemClick += new ItemClickEventHandler(this.ips_ItemClick);
            this.ipsO2K.Caption    = "Office 2000";
            this.ipsO2K.Glyph      =
                new Bitmap(
                    base.GetType().Assembly.GetManifestResourceStream("Yutai.ArcGIS.Controls.PaintStyle.Office2000.bmp"));
            this.ipsO2K.Description = "Office2000";
            this.ipsO2K.Name        = "ipsO2K";
            this.ipsO2K.Category    = category;
            if (this.m_pBarManager != null)
            {
                this.ipsO2K.Id = this.m_pBarManager.GetNewItemId();
            }
            this.ipsO2K.ItemClick += new ItemClickEventHandler(this.ips_ItemClick);
            this.ipsO3.Caption     = "Office 2003";
            this.ipsO3.Glyph       =
                new Bitmap(
                    base.GetType().Assembly.GetManifestResourceStream("Yutai.ArcGIS.Controls.PaintStyle.Office2003.bmp"));
            this.ipsO3.Description = "Office2003";
            this.ipsO3.Name        = "ipsO3";
            if (this.m_pBarManager != null)
            {
                this.ipsO3.Id = this.m_pBarManager.GetNewItemId();
            }
            this.ipsO3.Category    = category;
            this.ipsO3.ItemClick  += new ItemClickEventHandler(this.ips_ItemClick);
            this.ipsO7.Caption     = "Office 2007";
            this.ipsO7.Description = "Office2007";
            this.ipsO7.Name        = "ipsO7";
            if (this.m_pBarManager != null)
            {
                this.ipsO7.Id = this.m_pBarManager.GetNewItemId();
            }
            this.ipsO7.Category   = category;
            this.ipsO7.ItemClick += new ItemClickEventHandler(this.ips_ItemClick);
            if (this.m_pBarManager != null)
            {
                this.m_pBarManager.Items.Add(this.iPaintStyle);
                if (this.m_pBarManager.MainMenu != null)
                {
                    this.m_pBarManager.MainMenu.AddItem(this.iPaintStyle);
                }
                else if (this.m_pBarManager.Bars.Count > 0)
                {
                    this.m_pBarManager.Bars[0].AddItem(this.iPaintStyle);
                }
            }
            else if (this.m_ribbonctrl != null)
            {
                this.m_ribbonctrl.Items.Add(this.iPaintStyle);
                this.m_ribbonctrl.Toolbar.ItemLinks.Add(this.iPaintStyle);
            }
            this.iPaintStyle.AddItem(this.ipsDefault);
            this.iPaintStyle.AddItem(this.ipsWXP);
            this.iPaintStyle.AddItem(this.ipsOXP);
            this.iPaintStyle.AddItem(this.ipsO2K);
            this.iPaintStyle.AddItem(this.ipsO3);
        }