void Iterate(ref int xpos, ref int ypos, CategoryAction catAction, ItemAction action) { foreach (Category category in this.categories) { if (!category.IsVisible) { continue; } xpos = 0; if (this.showCategories) { layout.SetText(category.Text); int x, y; layout.GetPixelSize(out x, out y); y += CategoryTopBottomPadding * 2; if (catAction != null) { catAction(category, new Size(this.Allocation.Width, y)); } ypos += y; } if (category.IsExpanded || category.AnimatingExpand || !this.showCategories) { IterateItems(category, ref xpos, ref ypos, action); } } }
public IHttpActionResult Create(CategoryAction categoryAction) { string token = Request.Headers.GetValues("token").First().ToString(); User user = _context.Users.FirstOrDefault(u => u.Token == token); if (_context.Categories.Any(c => c.Name == categoryAction.Name && c.UserId == user.Id)) { ModelState.AddModelError("name", "Bu adda kateqoriyaniz artıq var"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Category category = new Category { UserId = user.Id, Name = categoryAction.Name }; _context.Categories.Add(category); _context.SaveChanges(); return(Ok()); }
void Iterate(bool startAtPage, ref int ypos, CategoryAction catAction, ItemAction action) { int curItem = 0; if (InCategoryMode) { foreach (Category category in this.categories) { if (category.CompletionCategory != null) { if (!startAtPage || curItem >= page) { if (catAction != null) { catAction(category, ypos); } ypos += rowHeight; } curItem++; } bool result = IterateItems(category, startAtPage, ref ypos, ref curItem, action); if (!result) { break; } } } else { int startItem = 0; if (startAtPage) { startItem = curItem = page; } if (action != null) { for (int item = startItem; item < filteredItems.Count; item++) { bool result = action(null, item, ypos); if (!result) { break; } ypos += rowHeight; curItem++; } } else { int itemCount = (filteredItems.Count - startItem); ypos += rowHeight * itemCount; curItem += itemCount; } } }
public Action(string id, InputType type, string key, CategoryAction category, string name) { this.axisAble = true; this.keyAble = true; this.id = id; this.category = category; this.name = name; this.keys = new List <ActionKey> { new ActionKey(type, key) }; }
void Iterate(bool startAtPage, ref int ypos, CategoryAction catAction, ItemAction action) { int curItem = 0; if (InCategoryMode) { foreach (CategorizedCompletionItems category in this.categories) { var nextYPos = ypos + rowHeight; // if (!startAtPage || nextYPos >= vadj.Value) { if (catAction != null) { catAction(category, ypos); } // } ypos = nextYPos; curItem++; bool result = IterateItems(category, startAtPage, ref ypos, ref curItem, action); if (!result) { break; } } } else { int startItem = 0; if (startAtPage) { startItem = curItem = Math.Max(0, (int)(ypos / rowHeight)); } if (action != null) { for (int item = startItem; item < filteredItems.Count; item++) { bool result = action(null, filteredItems[item], curItem, ypos); if (!result) { break; } ypos += rowHeight; curItem++; } } else { int itemCount = (filteredItems.Count - startItem); ypos += rowHeight * itemCount; curItem += itemCount; } } }
public static void GetCategory(DropDownList drpCategory, bool isSearchEngine) { drpCategory.DataSource = CategoryAction.GetCategory(); drpCategory.DataValueField = "CategoryId"; drpCategory.DataTextField = "Description"; if (isSearchEngine) { ListItem listItem = new ListItem(); drpCategory.Items.RemoveAt(0); listItem.Text = "All Categories"; listItem.Value = ""; drpCategory.Items.Insert(0, listItem); } drpCategory.DataBind(); }
public IHttpActionResult Edit(int id, CategoryAction categoryAction) { string token = Request.Headers.GetValues("token").First().ToString(); User user = _context.Users.FirstOrDefault(u => u.Token == token); Category category = _context.Categories.FirstOrDefault(c => c.UserId == user.Id && c.Id == id); if (category == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } category.Name = categoryAction.Name; _context.SaveChanges(); return(Ok()); }
void Iterate (bool startAtPage, ref int ypos, CategoryAction catAction, ItemAction action) { int curItem = 0; if (InCategoryMode) { foreach (Category category in this.categories) { var nextYPos = ypos + rowHeight; // if (!startAtPage || nextYPos >= vadj.Value) { if (catAction != null) catAction (category, ypos); // } ypos = nextYPos; curItem++; bool result = IterateItems (category, startAtPage,ref ypos, ref curItem, action); if (!result) break; } } else { int startItem = 0; if (startAtPage) startItem = curItem = Math.Max (0, (int)(ypos / rowHeight)); if (action != null) { for (int item = startItem; item < filteredItems.Count; item++) { bool result = action (null, filteredItems[item], curItem, ypos); if (!result) break; ypos += rowHeight; curItem++; } } else { int itemCount = (filteredItems.Count - startItem); ypos += rowHeight * itemCount; curItem += itemCount; } } }
void Iterate (bool startAtPage, ref int ypos, CategoryAction catAction, ItemAction action) { int curItem = 0; if (InCategoryMode) { foreach (Category category in this.categories) { if (category.CompletionCategory != null) { if (!startAtPage || curItem >= page) { if (catAction != null) catAction (category, ypos); ypos += rowHeight; } curItem++; } bool result = IterateItems (category, startAtPage,ref ypos, ref curItem, action); if (!result) break; } } else { int startItem = 0; if (startAtPage) startItem = curItem = page; if (action != null) { for (int item = startItem; item < filteredItems.Count; item++) { bool result = action (null, filteredItems[item], curItem, ypos); if (!result) break; ypos += rowHeight; curItem++; } } else { int itemCount = (filteredItems.Count - startItem); ypos += rowHeight * itemCount; curItem += itemCount; } } }
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; } } } }