public void Display(int page = 0) { page = page > (this.items.Count - 1) / this.maxItems ? 0 : page; Console.Clear(); ColorMessage.Print(@"\y" + this.Title + "\n"); bool pagable = false; postTitleItem?.Print(); int choosableItemsSum = 1 << 0; if (page > 0) { pagable = true; choosableItemsSum += 1 << 8; } if (page < (this.items.Count - 1) / this.maxItems) { pagable = true; choosableItemsSum += 1 << 9; } for (int itemId = page * this.maxItems, option = 1; itemId < this.items.Count && option < this.maxItems + 1; itemId++) { if (items[itemId] is ChoosableItem) { ChoosableItem Item = items[itemId] as ChoosableItem; bool enabled = Item.Callback == null || Item.Callback.Handler(this, itemId); if (enabled) { choosableItemsSum += 1 << option; } Item.Print(enabled, option); } else { items[itemId].Print(); } if (items[itemId].Slot) { option++; } } Console.WriteLine(); if (pagable) { ColorMessage.Print(string.Format(@"{0}8. \y{1}", (choosableItemsSum & 1 << 8) > 0 ? @"\r" : @"\d", backPageName)); ColorMessage.Print(string.Format(@"{0}9. \y{1}", (choosableItemsSum & 1 << 9) > 0 ? @"\r" : @"\d", nextPageName)); } ColorMessage.Print(string.Format(@"\r0. \y{0}", exitName)); this.choseOption(choosableItemsSum); }
public void Print(bool enabled, int number) { ColorMessage.Print(string.Format(@"{0}{1}. \y{2}", enabled ? @"\r" : @"\d", number.ToString(), Text)); PostItem?.Print(); }