public void SetPage(int page) { if (CatalogItems != null) { for (int i = 0; i < CatalogItems.Length; i++) { this.Remove(CatalogItems[i]); } } int index = page * PageSize; CatalogItems = new UICatalogItem[Math.Min(PageSize, Math.Max(Selected.Count - index, 0))]; int halfPage = PageSize / 2; for (int i = 0; i < CatalogItems.Length; i++) { var elem = new UICatalogItem(false); elem.Index = index; elem.Info = Selected[index++]; elem.Icon = (elem.Info.Special != null)?elem.Info.Special.Res.GetIcon(elem.Info.Special.ResID):GetObjIcon(elem.Info.GUID); elem.Tooltip = "$" + elem.Info.Price.ToString(); elem.X = (i % halfPage) * 45 + 2; elem.Y = (i / halfPage) * 45 + 2; elem.OnMouseEvent += new ButtonClickDelegate(InnerSelect); elem.SetDisabled(elem.Info.Price > Budget); CatalogItems[i] = elem; this.Add(elem); } Page = page; }
public void SetPage(int page) { if (CatalogItems != null) { for (int i = 0; i < CatalogItems.Length; i++) { Remove(CatalogItems[i]); } } int index = page * PageSize; if (Selected == null) { return; } CatalogItems = new UICatalogItem[Math.Min(PageSize, Math.Max(Selected.Count - index, 0))]; int halfPage = PageSize / 2; for (int i = 0; i < CatalogItems.Length; i++) { var sel = Selected[index++]; var elem = new UICatalogItem(false); if (sel.Item.GUID == uint.MaxValue) { elem.Visible = false; } elem.Index = index - 1; elem.Info = sel; elem.Info.CalcPrice = (int)elem.Info.Item.Price; if (elem.Info.Item.GUID != 0) { var price = (int)elem.Info.Item.Price; var dcPercent = VMBuildableAreaInfo.GetDiscountFor(elem.Info.Item, ActiveVM); var finalPrice = price * (100 - dcPercent) / 100; elem.Info.CalcPrice = finalPrice; } elem.Icon = (elem.Info.Special?.Res != null)?elem.Info.Special.Res.GetIcon(elem.Info.Special.ResID):GetObjIcon(elem.Info.Item.GUID); elem.Tooltip = (elem.Info.CalcPrice > 0)?("$" + elem.Info.CalcPrice.ToString()):null; elem.X = i % halfPage * 45 + 2; elem.Y = i / halfPage * 45 + 2; elem.OnMouseEvent += new ButtonClickDelegate(InnerSelect); elem.SetDisabled(elem.Info.CalcPrice > Budget); CatalogItems[i] = elem; Add(elem); } Page = page; }