public ScreenMenuCategory AddCategory(string categoryName)
        {
            var result = new ScreenMenuCategory(categoryName);

            Categories.Add(result);
            return(result);
        }
示例#2
0
 public IEnumerable<string> GetScreenMenuCategories(ScreenMenuCategory category, string parentTag)
 {
     return category.ScreenMenuItems.Where(x => !string.IsNullOrEmpty(x.SubMenuTag))
         .Select(x => x.SubMenuTag)
         .Distinct()
         .Where(x => string.IsNullOrEmpty(parentTag) || (x.StartsWith(parentTag) && x != parentTag))
         .Select(x => Regex.Replace(x, "^" + parentTag + ",", ""))
         .Where(x => !x.Contains(","))
         .Select(x => !string.IsNullOrEmpty(parentTag) ? parentTag + "," + x : x);
 }
        public void AddItemsToCategory(string category, List <MenuItem> menuItems)
        {
            ScreenMenuCategory menuCategory = Categories.Single(x => x.Name == category);

            Debug.Assert(menuCategory != null);
            foreach (var menuItem in menuItems)
            {
                menuCategory.AddMenuItem(menuItem);
            }
        }
示例#4
0
        public ScreenMenuItemButton(ScreenMenuItem screenMenuItem, ICommand command, ScreenMenuCategory category)
        {
            _screenMenuItem = screenMenuItem;
            _command = command;
            _category = category;

            var color = screenMenuItem.ButtonColor;

            if (string.IsNullOrEmpty(color))
                color = category != null ? category.ButtonColor : "Green";

            ButtonColor = color;
        }
示例#5
0
        public IEnumerable<ScreenMenuItem> GetScreenMenuItems(ScreenMenuCategory category, int currentPageNo, string tag)
        {
            var items = category.ScreenMenuItems
                .Where(x => x.SubMenuTag == tag || (string.IsNullOrEmpty(tag) && string.IsNullOrEmpty(x.SubMenuTag)));

            if (category.PageCount > 1)
            {
                items = items
                    .Skip(category.ItemCountPerPage * currentPageNo)
                    .Take(category.ItemCountPerPage);
            }

            return items.OrderBy(x => x.SortOrder);
        }
        private void UpdateMenuButtons(ScreenMenuCategory category)
        {
            MenuItems = CreateMenuButtons(category, CurrentPageNo, CurrentTag ?? "");

            SubCategories.Clear();
            SubCategories.AddRange(
                category.GetScreenMenuCategories(CurrentTag)
                .Select(x => new ScreenSubCategoryButton(x, SubCategoryCommand, category.MainButtonColor, category.MainFontSize, category.SubButtonHeight)));

            if (!string.IsNullOrEmpty(CurrentTag))
            {
                var backButton = new ScreenSubCategoryButton(CurrentTag.Replace(CurrentTag.Split(',').Last(), "").Trim(new[] { ',', ' ' }), SubCategoryCommand, "Gainsboro", category.MainFontSize, category.SubButtonHeight, true);
                SubCategories.Add(backButton);
            }

            if (Categories != null && MenuItems.Count == 0)
            {
                if (category.NumeratorType == 2 && SubCategories.Count == 0)
                    InteractionService.ShowKeyboard();

                MenuItems.Clear();

                if (category.MaxItems > 0)
                {
                    IEnumerable<ScreenMenuItem> sitems = category.ScreenMenuItems.OrderBy(x => x.SortOrder);
                    if (SubCategories.Count == 0)
                    {
                        sitems = Categories.Select(x => x.Category).SelectMany(x => x.ScreenMenuItems);
                    }
                    var items = sitems.Select(x => new ScreenMenuItemButton(x, MenuItemCommand, SelectedCategory));
                    MenuItems.AddRange(items.Take(category.MaxItems));
                }
            }

            RaisePropertyChanged(() => MenuItems);
            RaisePropertyChanged(() => IsPageNumberNavigatorVisible);
            RaisePropertyChanged(() => MenuItemsVerticalAlignment);
        }
        private void OnCategoryCommandExecute(ScreenMenuCategory category)
        {
            CurrentPageNo = 0;
            CurrentTag = "";
            UpdateMenuButtons(category);
            if (IsQuickNumeratorVisible)
            {
                QuickNumeratorValues = string.IsNullOrEmpty(category.NumeratorValues) ? new[] { "1", "2", "3", "4", "5" } : category.NumeratorValues.Split(',');
                NumeratorValue = QuickNumeratorValues[0];
            }
            else NumeratorValue = "";

            AlphaButtonValues = string.IsNullOrEmpty(category.AlphaButtonValues) ? new string[0] : category.AlphaButtonValues.Split(',');

            RaisePropertyChanged(() => IsQuickNumeratorVisible);
            RaisePropertyChanged(() => IsNumeratorVisible);
            RaisePropertyChanged(() => QuickNumeratorValues);
            RaisePropertyChanged(() => AlphaButtonValues);
            RaisePropertyChanged(() => MenuItemsVerticalAlignment);
            RaisePropertyChanged(() => IsSelectedItemsVisible);
        }
        private ObservableCollection<ScreenMenuItemButton> CreateMenuButtons(ScreenMenuCategory category, int pageNo, string tag)
        {
            SelectedCategory = category;

            var screenMenuItems = category.GetScreenMenuItems(pageNo, tag);
            var result = new ObservableCollection<ScreenMenuItemButton>();
            var items = screenMenuItems.Select(x => new ScreenMenuItemButton(x, MenuItemCommand, category));
            result.AddRange(items);
            return result;
        }
 public ScreenMenuCategoryViewModel(ScreenMenuCategory model)
 {
     Model = model;
 }
示例#10
0
 private void UpdateMenuButtons(ScreenMenuCategory category)
 {
     SelectedCategory = category;
     CreateMenuItemButtons(MenuItems, category, CurrentPageNo, CurrentTag);
 }
示例#11
0
 private void OnCategorySelected(ScreenMenuCategory obj)
 {
     UpdateMenuButtons(obj);
 }
示例#12
0
 private void CreateMenuItemButtons(ObservableCollection<ScreenMenuItemButton> itemButtons,
     ScreenMenuCategory category, int pageNo, string tag)
 {
     itemButtons.Clear();
     if (category == null) return;
     itemButtons.AddRange(AppServices.DataAccessService.GetMenuItems(category, pageNo, tag)
         .Select(x => new ScreenMenuItemButton(x, MenuItemSelectionCommand, category)));
 }
示例#13
0
 public ScreenMenuCategory AddCategory(string categoryName)
 {
     var result = new ScreenMenuCategory(categoryName);
     Categories.Add(result);
     return result;
 }
 private string GetCategorySubButtonColor(string name, ScreenMenuCategory category)
 {
     if (string.IsNullOrEmpty(category.SubButtonColorDef) || !category.SubButtonColorDef.Contains(name + "=")) return category.MainButtonColor;
     return category.SubButtonColorDef;
 }
        private ObservableCollection<ScreenMenuItemButton> CreateMenuButtons(ScreenMenuCategory category, int pageNo, string tag)
        {
            SelectedCategory = category;

            var screenMenuItems = AppServices.DataAccessService.GetMenuItems(category, pageNo, tag);
            var result = new ObservableCollection<ScreenMenuItemButton>();
            var items = screenMenuItems.Select(x => new ScreenMenuItemButton(x, MenuItemCommand, category));
            if (category.SortType == 1) items = items.OrderByDescending(x => x.UsageCount);
            result.AddRange(items);
            return result;
        }
示例#16
0
 public ScreenCategoryButton(ScreenMenuCategory category, ICommand command)
 {
     _category = category;
     ButtonCommand = command;
 }