protected async Task Select(CatDisplay catDisplay, Category selCategory, ChildCategory childCategory = null) { Debug.Write("Select " + catDisplay?.Title ?? "null"); if (selCategory == null) { Debug.Write("Category is null"); } if (lastSelect != null) { lastSelect.Image = lastImageState; } lastSelect = catDisplay; lastImageState = catDisplay?.Image ?? CatSelectImage.none; LastSelectedCategory = selCategory; if (selCategory != null) { LastSelectedCategory.SelectedChildCategory = childCategory; } catDisplay.Image = CatSelectImage.selected; var navigationParams = new NavigationParameters(); navigationParams.Add("SelectedCategory", selCategory); await _navigationService.GoBackAsync(navigationParams); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { CatSelectImage image = value == null ? CatSelectImage.none : (CatSelectImage)value; if (image == CatSelectImage.none) { return(false); } return(true); }
protected void SetButton(byte buttonNo, string title, bool isVisible, CatSelectImage image = CatSelectImage.none, object category = null) { if (buttonNo < 1 && buttonNo > 3) { return; } var button = ButtonList[buttonNo - 1]; button.Title = title; button.IsVisible = isVisible; button.Image = image; button.Category = category; OnPropertyChanged("ButtonListViewHeight"); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { CatSelectImage image = value == null ? CatSelectImage.none : (CatSelectImage)value; switch (image) { case CatSelectImage.arrowDeeper: return("inside_category.png"); case CatSelectImage.selected: return("selected_category.png"); case CatSelectImage.arrowUp: return("up_category.png"); case CatSelectImage.none: return(null); } return(null); }
protected async Task DisplayCategoryAsync(object categoryToShow) { CategoryAction.Clear(); // displaying main category if (categoryToShow == null) { Debug.Write("Displaing categoryToShow is null"); int AllViews = 0; SetButton(1, Category.TitleForNull, true); SetButton(2, String.Empty, false); SetButton(3, String.Empty, false); var categoryList = await _rzeszowiakRepository.GetMasterCategoryListAsync(); foreach (var item in categoryList) { AllViews += item.Views; } CategoryAction.Add(new CatDisplay { Title = Category.TitleForNull, Views = AllViews, Image = LastSelectedCategory == null ? CatSelectImage.selected : CatSelectImage.none, CategoryObj = null, }); foreach (var category in categoryList) { CategoryAction.Add( new CatDisplay { Title = category.Title, Views = category.Views, Image = CatSelectImage.arrowDeeper, CategoryObj = category, }); } } // display category if (categoryToShow != null && categoryToShow.GetType() == typeof(MasterCategory)) { Debug.Write("Displaing categoryToShow is MasterCategory"); var master = categoryToShow as MasterCategory; SetButton(1, Category.TitleForNull, true, CatSelectImage.arrowUp, master); SetButton(2, master.Title, true, CatSelectImage.none, master); SetButton(3, String.Empty, false); var categoryList = await _rzeszowiakRepository.GetCategoryListAsync(); foreach (var category in categoryList) { if (master == category.Master) { var catDisplay = new CatDisplay { Title = category.Title, Views = category.Views, Image = (LastSelectedCategory == category) && (category.SelectedChildCategory == null) && ((category.ChildCategory?.Count ?? 0) == 0) ? CatSelectImage.selected : ((category.ChildCategory?.Count ?? 0) > 0 ? CatSelectImage.arrowDeeper : CatSelectImage.none), CategoryObj = category, }; CategoryAction.Add(catDisplay); if (catDisplay.Image == CatSelectImage.selected) { lastSelect = catDisplay; lastImageState = (category.ChildCategory?.Count ?? 0) > 0 ? CatSelectImage.arrowDeeper : CatSelectImage.none; } } } } //display childCategory if (categoryToShow != null && categoryToShow?.GetType() == typeof(Category)) { Debug.Write("Displaing categoryToShow is Category"); var category = categoryToShow as Category; SetButton(1, Category.TitleForNull, true, CatSelectImage.arrowUp, category.Master); SetButton(2, category.Master.Title, true, CatSelectImage.arrowUp, category.Master); SetButton(3, category.Title, true, CatSelectImage.none, category); var catDisplay = new CatDisplay { Title = $"Wszystkie w {category.Title}", Views = category.Views, Image = ((LastSelectedCategory) == category) && (LastSelectedCategory?.SelectedChildCategory == null) ? CatSelectImage.selected : CatSelectImage.none, CategoryObj = category, }; CategoryAction.Add(catDisplay); if (catDisplay.Image == CatSelectImage.selected) { lastSelect = catDisplay; lastImageState = CatSelectImage.none; } foreach (var child in category.ChildCategory) { Debug.Write("End Displaing categoryToShow is MasterCategory"); catDisplay = new CatDisplay { Title = child.Title, Views = child.Views, Image = (LastSelectedCategory == category && LastSelectedCategory?.SelectedChildCategory == child) ? CatSelectImage.selected : CatSelectImage.none, CategoryObj = child, }; CategoryAction.Add(catDisplay); if (catDisplay.Image == CatSelectImage.selected) { lastSelect = catDisplay; lastImageState = CatSelectImage.none; } } } }