private void SetFocusOnNewPage(bool fireChanged = false)
        {
            var          visibleItems  = PositionedMenuItems.OfType <GridListItem>().Where(item => item.IsVisible && item.Enabled);
            GridListItem nextFocusItem = null;
            int          gridCol       = BeginNavigation == NavigationTypeEnum.PageLeft ? -1 : 100;

            foreach (GridListItem item in visibleItems)
            {
                if (BeginNavigation == NavigationTypeEnum.PageLeft && (nextFocusItem == null || item.GridColumn + item.GridColumnSpan > gridCol))
                {
                    gridCol       = item.GridColumn + item.GridColumnSpan;
                    nextFocusItem = item;
                }
                if ((BeginNavigation == NavigationTypeEnum.PageRight || BeginNavigation == NavigationTypeEnum.None) && (nextFocusItem == null || item.GridColumn < gridCol))
                {
                    gridCol       = item.GridColumn;
                    nextFocusItem = item;
                }
            }
            PositionedMenuItems.OfType <GridListItem>().ToList().ForEach(item => item.Selected = item == nextFocusItem);
            if (fireChanged)
            {
                PositionedMenuItems.FireChange();
            }
        }
Beispiel #2
0
        protected void CreatePositionedItems()
        {
            _positionedItems.Clear();
            int x = 0;

            foreach (var menuItem in MenuItems)
            {
                object action;
                if (!menuItem.AdditionalProperties.TryGetValue(Consts.KEY_ITEM_ACTION, out action))
                {
                    continue;
                }
                WorkflowAction wfAction = action as WorkflowAction;
                if (wfAction == null)
                {
                    continue;
                }

                // intercept the menu item commands, so we can set the item as LastSelectedItem
                // since the menu items are recreated when an sub screen is opened we have to check if the item is already intercepted each time
                if (!(menuItem.Command is MenuItemCommandInterceptor))
                {
                    menuItem.Command = new MenuItemCommandInterceptor(this, menuItem);
                }

                // Under "others" all items are places, that do not fit into any other category
                if (CurrentKey == MenuSettings.MENU_NAME_OTHERS)
                {
                    bool found = _menuSettings.Settings.MenuItems.Keys.Any(key => _menuSettings.Settings.MenuItems[key].ContainsKey(wfAction.ActionId));
                    if (!found)
                    {
                        GridListItem gridItem = new GridListItem(menuItem)
                        {
                            GridColumn     = x % MenuSettings.DEFAULT_NUM_COLS,
                            GridRow        = (x / MenuSettings.DEFAULT_NUM_COLS) * MenuSettings.DEFAULT_ROWSPAN_SMALL,
                            GridRowSpan    = MenuSettings.DEFAULT_ROWSPAN_SMALL,
                            GridColumnSpan = MenuSettings.DEFAULT_COLSPAN_SMALL,
                        };
                        _positionedItems.Add(gridItem);
                        x += MenuSettings.DEFAULT_COLSPAN_SMALL;
                    }
                }
                else
                {
                    GridPosition gridPosition;
                    if (Positions.TryGetValue(wfAction.ActionId, out gridPosition))
                    {
                        GridListItem gridItem = new GridListItem(menuItem)
                        {
                            GridRow        = gridPosition.Row,
                            GridColumn     = gridPosition.Column,
                            GridRowSpan    = gridPosition.RowSpan,
                            GridColumnSpan = gridPosition.ColumnSpan,
                        };
                        _positionedItems.Add(gridItem);
                    }
                }
            }
            _positionedItems.FireChange();
        }
Beispiel #3
0
        protected void CreatePositionedItems(ItemsList list, string currentKey, IDictionary <Guid, GridPosition> gridPositions)
        {
            list.Clear();

            int       x         = 0;
            ItemsList menuItems = GetHomeMenuItems();

            lock (menuItems.SyncRoot)
            {
                foreach (var menuItem in menuItems)
                {
                    object action;
                    if (!menuItem.AdditionalProperties.TryGetValue(Consts.KEY_ITEM_ACTION, out action))
                    {
                        continue;
                    }
                    WorkflowAction wfAction = action as WorkflowAction;
                    if (wfAction == null)
                    {
                        continue;
                    }

                    // Under "others" all items are places, that do not fit into any other category
                    if (currentKey == MenuSettings.MENU_NAME_OTHERS)
                    {
                        bool found = IsManuallyPositioned(wfAction);
                        if (!found)
                        {
                            GridListItem gridItem = new GridListItem(menuItem)
                            {
                                GridColumn     = x % MenuSettings.DEFAULT_NUM_COLS,
                                GridRow        = x / MenuSettings.DEFAULT_NUM_COLS * MenuSettings.DEFAULT_ROWSPAN_SMALL,
                                GridRowSpan    = MenuSettings.DEFAULT_ROWSPAN_SMALL,
                                GridColumnSpan = MenuSettings.DEFAULT_COLSPAN_SMALL,
                            };
                            list.Add(gridItem);
                            x += MenuSettings.DEFAULT_COLSPAN_SMALL;
                        }
                    }
                    else
                    {
                        GridPosition gridPosition;
                        if (gridPositions.TryGetValue(wfAction.ActionId, out gridPosition))
                        {
                            GridListItem gridItem = new GridListItem(menuItem)
                            {
                                GridRow        = gridPosition.Row,
                                GridColumn     = gridPosition.Column,
                                GridRowSpan    = gridPosition.RowSpan,
                                GridColumnSpan = gridPosition.ColumnSpan,
                            };
                            list.Add(gridItem);
                        }
                    }
                }
            }
            list.FireChange();
        }
Beispiel #4
0
        protected override FrameworkElement PrepareItemContainer(object dataItem)
        {
            FrameworkElement container = base.PrepareItemContainer(dataItem);
            GridListItem     gli       = dataItem as GridListItem;

            if (gli != null)
            {
                Grid.SetColumn(container, gli.GridColumn);
                Grid.SetColumnSpan(container, gli.GridColumnSpan);
                Grid.SetRow(container, gli.GridRow);
                Grid.SetRowSpan(container, gli.GridRowSpan);
            }
            return(container);
        }
    protected void CreatePositionedItems()
    {
      _positionedItems.Clear();
      int x = 0;
      foreach (var menuItem in MenuItems)
      {
        object action;
        if (!menuItem.AdditionalProperties.TryGetValue(Consts.KEY_ITEM_ACTION, out action))
          continue;
        WorkflowAction wfAction = action as WorkflowAction;
        if (wfAction == null)
          continue;

        // intercept the menu item commands, so we can set the item as LastSelectedItem
        // since the menu items are recreated when an sub screen is opened we have to check if the item is already intercepted each time
        if (!(menuItem.Command is MenuItemCommandInterceptor))
        {
          menuItem.Command = new MenuItemCommandInterceptor(this, menuItem);
        }

        // Under "others" all items are places, that do not fit into any other category
        if (CurrentKey == MenuSettings.MENU_NAME_OTHERS)
        {
          bool found = _menuSettings.Settings.MenuItems.Keys.Any(key => _menuSettings.Settings.MenuItems[key].ContainsKey(wfAction.ActionId));
          if (!found)
          {
            GridListItem gridItem = new GridListItem(menuItem)
            {
              GridColumn = x % MenuSettings.DEFAULT_NUM_COLS,
              GridRow = (x / MenuSettings.DEFAULT_NUM_COLS) * MenuSettings.DEFAULT_ROWSPAN_SMALL,
              GridRowSpan = MenuSettings.DEFAULT_ROWSPAN_SMALL,
              GridColumnSpan = MenuSettings.DEFAULT_COLSPAN_SMALL,
            };
            _positionedItems.Add(gridItem);
            x += MenuSettings.DEFAULT_COLSPAN_SMALL;
          }
        }
        else
        {
          GridPosition gridPosition;
          if (Positions.TryGetValue(wfAction.ActionId, out gridPosition))
          {
            GridListItem gridItem = new GridListItem(menuItem)
            {
              GridRow = gridPosition.Row,
              GridColumn = gridPosition.Column,
              GridRowSpan = gridPosition.RowSpan,
              GridColumnSpan = gridPosition.ColumnSpan,
            };
            _positionedItems.Add(gridItem);
          }
        }
      }
      _positionedItems.FireChange();
    }
Beispiel #6
0
    protected void CreatePositionedItems()
    {
      _positionedItems.Clear();
      int x = 0;
      foreach (var menuItem in MenuItems)
      {
        object action;
        if (!menuItem.AdditionalProperties.TryGetValue(Consts.KEY_ITEM_ACTION, out action))
          continue;
        WorkflowAction wfAction = action as WorkflowAction;
        if (wfAction == null)
          continue;

        // Under "others" all items are places, that do not fit into any other category
        if (CurrentKey == MenuSettings.MENU_NAME_OTHERS)
        {
          bool found = IsManuallyPositioned(wfAction);
          if (!found)
          {
            GridListItem gridItem = new GridListItem(menuItem)
            {
              GridColumn = x % MenuSettings.DEFAULT_NUM_COLS,
              GridRow = (x / MenuSettings.DEFAULT_NUM_COLS) * MenuSettings.DEFAULT_ROWSPAN_SMALL,
              GridRowSpan = MenuSettings.DEFAULT_ROWSPAN_SMALL,
              GridColumnSpan = MenuSettings.DEFAULT_COLSPAN_SMALL,
            };
            _positionedItems.Add(gridItem);
            x += MenuSettings.DEFAULT_COLSPAN_SMALL;
          }
        }
        else
        {
          GridPosition gridPosition;
          if (Positions.TryGetValue(wfAction.ActionId, out gridPosition))
          {
            GridListItem gridItem = new GridListItem(menuItem)
            {
              GridRow = gridPosition.Row,
              GridColumn = gridPosition.Column,
              GridRowSpan = gridPosition.RowSpan,
              GridColumnSpan = gridPosition.ColumnSpan,
            };
            _positionedItems.Add(gridItem);
          }
        }
      }
      _positionedItems.FireChange();
    }