private void AddGroupsRecursive(MesMenuDefinitionBase menu, MesStandardMenuItem menuModel)
        {
            List <MesMenuItemGroupDefinition> groups = _menuItemGroups
                                                       .Where(x => x.Parent == menu)
                                                       .Where(x => !_excludeMenuItemGroups.Contains(x))
                                                       .OrderBy(x => x.SortOrder)
                                                       .ToList();

            for (Int32 i = 0; i < groups.Count; i++)
            {
                MesMenuItemGroupDefinition group = groups[i];
                IOrderedEnumerable <MesMenuItemDefinition> menuItems = _menuItems
                                                                       .Where(x => x.Group == group)
                                                                       .Where(x => !_excludeMenuItems.Contains(x))
                                                                       .OrderBy(x => x.SortOrder);

                foreach (MesMenuItemDefinition menuItem in menuItems)
                {
                    MesStandardMenuItem menuItemModel = (menuItem.CommandDefinition != null)
                        ? new MesCommandMenuItem(_commandService.GetCommand(menuItem.CommandDefinition), menuModel)
                        : (MesStandardMenuItem) new MesTextMenuItem(menuItem);
                    AddGroupsRecursive(menuItem, menuItemModel);
                    menuModel.Add(menuItemModel);
                }

                if (i < groups.Count - 1 && menuItems.Any())
                {
                    menuModel.Add(new MesMenuItemSeparator());
                }
            }
        }
Beispiel #2
0
        public void BuildToolBar(MesToolBarDefinition toolBarDefinition, IMesToolBar result)
        {
            var groups = _toolBarItemGroups
                         .Where(x => x.ToolBar == toolBarDefinition)
                         .OrderBy(x => x.SortOrder)
                         .ToList();

            for (int i = 0; i < groups.Count; i++)
            {
                var group        = groups[i];
                var toolBarItems = _toolBarItems
                                   .Where(x => x.Group == group)
                                   .OrderBy(x => x.SortOrder);

                foreach (var toolBarItem in toolBarItems)
                {
                    result.Add(new MesCommandToolBarItem(toolBarItem, _commandService.GetCommand(toolBarItem.CommandDefinition), result));
                }

                if (i < groups.Count - 1 && toolBarItems.Any())
                {
                    result.Add(new MesToolBarItemSeparator());
                }
            }
        }
 public void BindKeyGestures(UIElement uiElement)
 {
     foreach (var keyboardShortcut in _keyboardShortcuts)
     {
         if (keyboardShortcut.KeyGesture != null)
         {
             uiElement.InputBindings.Add(new InputBinding(
                                             _commandService.GetTargetableCommand(_commandService.GetCommand(keyboardShortcut.CommandDefinition)),
                                             keyboardShortcut.KeyGesture));
         }
     }
 }