/// <summary> /// Moves up within the current menu. /// </summary> public void MoveUp() { MenuEntityModel.MoveUp(); if (MovedUp != null) { MovedUp(this, EventArgs.Empty); } }
/// <summary> /// Moves down within the current menu. /// </summary> public void MoveDown() { MenuEntityModel.MoveDown(); if (MovedDown != null) { MovedDown(this, EventArgs.Empty); } }
/// <summary> /// Binds the items. Gets 12 menu items from the main menuitem list. /// </summary> public void BindItems() { // use the same 12 items for binding to prevent memory leak if (VisibleMenuItemModels.Count == 0) { // create 12 menu items for (int i = 0; i < MenuEntity.MaxMenuLabels; i++) { VisibleMenuItemModels.Add(new MenuItemModel() { IsVisible = false, RelayCommand = new RelayCommand(() => { }) }); } } else { for (int i = 0; i < MenuEntity.MaxMenuLabels; i++) { // hide them all before we bind VisibleMenuItemModels[i].IsVisible = false; } } if (MenuEntityModel != null) { int index = 0; foreach (var menuItem in MenuEntityModel.GetVisibleMenuItems()) { VisibleMenuItemModels[index].IsVisible = true; VisibleMenuItemModels[index].DisplayText = menuItem.DisplayText.Length > 80 ? (menuItem.DisplayText.Substring(0, 79) + "..") : menuItem.DisplayText; VisibleMenuItemModels[index].IsSelected = menuItem.IsSelected; VisibleMenuItemModels[index].ParentSelected = menuItem.ParentSelected; VisibleMenuItemModels[index].RelayCommand.action = menuItem.RelayCommand.action; VisibleMenuItemModels[index].FilePath = menuItem.FilePath; index++; } } //VisibleMenuItemModels.Clear(); //if (MenuEntityModel != null) //{ // MenuEntityModel.GetVisibleMenuItems().ForEach(m => VisibleMenuItemModels.Add(m)); //} }