Exemple #1
0
 private void GetMenuKey(WinformMenu gettedMenu, ref string menuKey, ref string desc)
 {
     if (gettedMenu.Parent != null)
     {
         if (!menuKey.IsEmpty())
         {
             menuKey = gettedMenu.Parent.Name + "->" + menuKey;
         }
         else
         {
             menuKey = gettedMenu.Parent.Name;
         }
         if (!desc.IsEmpty())
         {
             desc = gettedMenu.Parent.DisplayName + "->" + desc;
         }
         else
         {
             desc = gettedMenu.Parent.DisplayName;
         }
         GetMenuKey(gettedMenu.Parent, ref menuKey, ref desc);
     }
     //else {
     //    menuKey = gettedMenu.Name;
     //    parentMenuKey = string.Empty;
     //}
 }
Exemple #2
0
 public void SetMenuStatus(WinformMenu menu, MenuStatus menuStatus)
 {
     winformMenuViewManager.SetMenuStatus(menu, menuStatus);
     EventBus.Default.Trigger(new WinFormMenuStatusChangeEventData {
         WinFormMenu = menu,
         MenuStatus  = menuStatus
     });
 }
Exemple #3
0
 /// <summary>
 /// 设置菜单的图标
 /// </summary>
 private void SetSubItemImage4Default(WinformMenu menuDefining, BarItem subItem)
 {
     if (menuDefining.DefaultEnable)
     {
         if (menuDefining.Icon != null)
         {
             if (menuDefining.Icon.Width >= 32)
             {
                 subItem.ImageOptions.LargeImage = menuDefining.Icon;
             }
             else
             {
                 subItem.ImageOptions.Image = menuDefining.Icon;
             }
         }
     }
     else
     {
         if (menuDefining.DisIcon != null)
         {
             if (menuDefining.DisIcon.Width >= 32)
             {
                 subItem.ImageOptions.LargeImage = menuDefining.DisIcon;
             }
             else
             {
                 subItem.ImageOptions.Image = menuDefining.DisIcon;
             }
         }
         else
         {
             if (menuDefining.Icon != null)
             {
                 if (menuDefining.Icon.Width >= 32)
                 {
                     subItem.ImageOptions.LargeImage = ImageHelp.ExColorDepth(menuDefining.Icon);
                 }
                 else
                 {
                     subItem.ImageOptions.Image = ImageHelp.ExColorDepth(menuDefining.Icon);
                 }
             }
         }
     }
 }
 private void addLinkItems(WinformMenu groupMenu, RibbonPageGroup pageGroup, IList <MenuOrderSetting> menuOrderSettings)
 {
     if (groupMenu.Children != null && groupMenu.Children.Count > 0)
     {
         var buts = getOrderedMenus(groupMenu.Children.ToList(), menuOrderSettings);
         foreach (WinformMenu button in buts)
         {
             if (button.IsNavigation)
             {
                 BarSubItem subItem = new BarSubItem
                 {
                     Name    = button.Name,
                     Caption = button.DisplayName
                 };
                 if (button.Icon != null)
                 {
                     subItem.ImageOptions.LargeImage = button.Icon;
                 }
                 pageGroup.ItemLinks.Add(subItem);
                 //
             }
             else
             {
                 BarButtonItem newButton = new BarButtonItem
                 {
                     Name    = button.Name,
                     Caption = button.DisplayName
                 };
                 if (button.Icon != null)
                 {
                     newButton.ImageOptions.LargeImage = button.Icon;
                 }
                 if (button.MenuEvent != null)
                 {
                     newButton.ItemClick += (object sender, ItemClickEventArgs e) =>
                     {
                         button.MenuEvent(button);
                     };
                 }
                 pageGroup.ItemLinks.Add(newButton);
             }
         }
     }
 }
Exemple #5
0
 private void addMenusGroups(WinformMenu pageMenu, RibbonPage ribbonPage, IList <MenuOrderSetting> menuOrderSettings)
 {
     if (pageMenu.Children != null && pageMenu.Children.Count > 0)
     {
         var groupMenus = pageMenu.Children.Where(m => m.IsGroup);
         if (groupMenus != null && groupMenus.Count() > 0)
         {
             groupMenus = getOrderedMenus(groupMenus.ToList(), menuOrderSettings);
             foreach (WinformMenu groupMenu in groupMenus)
             {
                 RibbonPageGroup pageGroup = new RibbonPageGroup {
                     Text = groupMenu.DisplayName,
                     Name = groupMenu.Name
                 };
                 addLinkItems(groupMenu, pageGroup, menuOrderSettings);
                 ribbonPage.Groups.Add(pageGroup);
             }
         }
     }
 }
Exemple #6
0
 private void addLinkItems(WinformMenu groupMenu, RibbonPageGroup pageGroup, IList <MenuOrderSetting> menuOrderSettings)
 {
     if (groupMenu.Children != null && groupMenu.Children.Count > 0)
     {
         var buts = getOrderedMenus(groupMenu.Children.ToList(), menuOrderSettings);
         foreach (WinformMenu button in buts)
         {
             if (button.IsNavigation)
             {
                 BarSubItem subItem = new BarSubItem
                 {
                     Name    = button.Name,
                     Caption = button.DisplayName
                 };
                 SetSubItemImage4Default(button, subItem);
                 pageGroup.ItemLinks.Add(subItem);
             }
             else
             {
                 BarButtonItem newButton = new BarButtonItem
                 {
                     Name    = button.Name,
                     Caption = button.DisplayName
                 };
                 SetSubItemImage4Default(button, newButton);
                 if (button.MenuActionType != null)
                 {
                     IWinformAction winformAction = iocManager.Resolve(button.MenuActionType) as IWinformAction;
                     if (winformAction != null)
                     {
                         newButton.ItemClick += (object sender, ItemClickEventArgs e) =>
                         {
                             winformAction.Excute();
                         };
                     }
                 }
                 pageGroup.ItemLinks.Add(newButton);
             }
         }
     }
 }
Exemple #7
0
 private void addLinksPersistInfo(WinformMenu ButtonMenu, BarSubItem subItem, IList <MenuOrderSetting> menuOrderSettings)
 {
     if (ButtonMenu.Children != null && ButtonMenu.Children.Count > 0)
     {
         foreach (WinformMenu button in ButtonMenu.Children)
         {
             if (button.IsNavigation)
             {
                 BarSubItem subItem1 = new BarSubItem
                 {
                     Name    = button.Name,
                     Caption = button.DisplayName
                 };
                 if (button.Icon != null)
                 {
                     subItem1.ImageOptions.Image = button.Icon;
                 }
                 subItem.LinksPersistInfo.Add(new LinkPersistInfo(subItem1));
                 if (button.Children != null && button.Children.Count > 0)
                 {
                     addLinksPersistInfo(button, subItem1, menuOrderSettings);
                 }
             }
             else
             {
                 BarButtonItem buttonItem = new BarButtonItem
                 {
                     Name    = button.Name,
                     Caption = button.DisplayName
                 };
                 if (button.Icon != null)
                 {
                     buttonItem.ImageOptions.Image = button.Icon;
                 }
                 subItem.LinksPersistInfo.Add(new LinkPersistInfo(buttonItem));
             }
         }
     }
 }
Exemple #8
0
        /// <summary>
        /// 设置菜单状态
        /// </summary>
        /// <param name="menu"></param>
        /// <param name="menuStatus"></param>
        public void SetMenuStatus(WinformMenu menu, MenuStatus menuStatus)
        {
            if (menu.MenuType == MenuType.Page)
            {
                if (menu.UIObject is RibbonPage)
                {
                    RibbonPage page = (RibbonPage)menu.UIObject;
                    switch (menuStatus)
                    {
                    case MenuStatus.Available:
                        page.Visible = true;
                        break;

                    case MenuStatus.Disable:     // page 设置disable。那么所有的子条目将都设置为disable
                        page.Visible = true;
                        break;

                    case MenuStatus.Hidden:
                        page.Visible = false;
                        break;
                    }
                }
            }
            else if (menu.MenuType == MenuType.Group)
            {
                if (menu.UIObject is RibbonPageGroup)
                {
                    RibbonPageGroup group = (RibbonPageGroup)menu.UIObject;
                    switch (menuStatus)
                    {
                    case MenuStatus.Available:
                        group.Enabled = true;
                        group.Visible = true;
                        break;

                    case MenuStatus.Disable:     //
                        group.Enabled = false;
                        group.Visible = true;
                        break;

                    case MenuStatus.Hidden:
                        group.Enabled = false;
                        group.Visible = false;
                        break;
                    }
                }
            }
            else if (menu.MenuType == MenuType.Navigation)
            {
                if (menu.UIObject is BarSubItem)
                {
                    BarSubItem barSubItem = menu.UIObject as BarSubItem;
                    switch (menuStatus)
                    {
                    case MenuStatus.Available:
                        barSubItem.Enabled = true;
                        break;

                    case MenuStatus.Disable:
                        barSubItem.Enabled = false;
                        break;

                    case MenuStatus.Hidden:
                        barSubItem.Enabled = false;
                        break;
                    }
                }
                else if (menu.UIObject is BarButtonItem)
                {
                    BarButtonItem barButtonItem = menu.UIObject as BarButtonItem;
                    switch (menuStatus)
                    {
                    case MenuStatus.Available:
                        barButtonItem.Enabled = true;
                        break;

                    case MenuStatus.Disable:
                        barButtonItem.Enabled = false;
                        break;

                    case MenuStatus.Hidden:
                        barButtonItem.Enabled = false;
                        break;
                    }
                }
            }
            if (menu.Children != null && menu.Children.Count > 0)
            {
                SetMenuStatus(menu.Children, MenuStatus.Disable);
            }
        }
        /// <summary>
        /// 设置菜单状态
        /// </summary>
        /// <param name="menu"></param>
        /// <param name="menuStatus"></param>
        public void SetMenuStatus(WinformMenu menu, MenuStatus menuStatus)
        {
            if (menu.MenuType == MenuType.Page)
            {
                if (menu.UIObject is RibbonPage)
                {
                    RibbonPage page = (RibbonPage)menu.UIObject;
                    switch (menuStatus)
                    {
                    case MenuStatus.Available:
                        page.Visible = true;
                        break;

                    case MenuStatus.Disable:

                        page.Visible = false;
                        break;

                    case MenuStatus.Hidden:
                        page.Visible = false;
                        break;
                    }
                }
            }
            else if (menu.MenuType == MenuType.Group)
            {
                if (menu.UIObject is RibbonPageGroup)
                {
                    RibbonPageGroup group = (RibbonPageGroup)menu.UIObject;
                    switch (menuStatus)
                    {
                    case MenuStatus.Available:
                        group.Enabled = true;
                        group.Visible = true;
                        break;

                    case MenuStatus.Disable:
                        group.Enabled = false;
                        group.Visible = true;
                        break;

                    case MenuStatus.Hidden:
                        group.Enabled = false;
                        group.Visible = false;
                        break;
                    }
                }
            }
            else if (menu.MenuType == MenuType.Navigation)
            {
                if (menu.UIObject is BarSubItem)
                {
                    BarSubItem barSubItem = menu.UIObject as BarSubItem;
                    switch (menuStatus)
                    {
                    case MenuStatus.Available:
                        barSubItem.Enabled = true;
                        break;

                    case MenuStatus.Disable:
                        barSubItem.Enabled = false;
                        break;

                    case MenuStatus.Hidden:
                        barSubItem.Enabled = false;
                        break;
                    }
                }
                else if (menu.UIObject is BarButtonItem)
                {
                    BarButtonItem barButtonItem = menu.UIObject as BarButtonItem;
                    switch (menuStatus)
                    {
                    case MenuStatus.Available:
                        barButtonItem.Enabled = true;
                        break;

                    case MenuStatus.Disable:
                        barButtonItem.Enabled = false;
                        break;

                    case MenuStatus.Hidden:
                        barButtonItem.Enabled = false;
                        break;
                    }
                }
            }
        }