private void generateSlot() { if (!itemBinder.name.Equals("air")) { if (itemBinder.stackNumber > 1) { TextBoxInt countBox = new TextBoxInt(itemBinder.count, 1, itemBinder.stackNumber); labeledCountBox = new LabeledBox("Count", countBox); Controls.Add(labeledCountBox); } if (itemBinder.hasQuality) { int degradation = itemBinder.getDegradation(); degradationBox = new TextBoxDegradation(itemBinder.useTimes, 1, degradation, itemBinder); labeledDegradationBox = new LabeledBox("Durability", degradationBox); qualityBox = new TextBoxQuality(itemBinder.quality, 0, DataItem.MAX_QUALITY, degradationBox); labeledQualityBox = new LabeledBox("Quality", qualityBox); if (itemBinder.parts.Length > 0) { qualityBox.Enabled = false; degradationBox.Enabled = false; if (itemBinder.hasAllParts()) { degradationBox.Text = ""; } else { qualityBox.Text = 0.ToString(); degradationBox.Text = 0.ToString(); } } Controls.Add(labeledQualityBox); Controls.Add(labeledDegradationBox); if (itemBinder.magazineSize > 0) { TextBoxInt magazineBox = new TextBoxInt(itemBinder.meta, 0, itemBinder.magazineSize); labeledMagazineBox = new LabeledBox("Magazine", magazineBox); Controls.Add(labeledMagazineBox); } if (itemBinder.magazineItems != null && itemBinder.magazineItems.Length > 1) { magazineItems = new ComboBox(); magazineItems.DropDownStyle = ComboBoxStyle.DropDownList; magazineItems.DataSource = new string[] { itemBinder.magazineItems[itemBinder.selectedAmmoTypeIndex.get()] }; EventHandler handler = null; handler = (sender, e) => populateComboBox(sender, e, itemBinder.magazineItems, itemBinder.magazineItems[itemBinder.selectedAmmoTypeIndex.get()], handler); magazineItems.DropDown += handler; magazineItems.DropDownClosed += (sender, e) => { itemBinder.itemValue.selectedAmmoTypeIndex.set((byte)magazineItems.SelectedIndex); }; labeledMagazineComboBox = new LabeledBox("Selected ammo", magazineItems); Controls.Add(labeledMagazineComboBox); } if (itemBinder.itemValue.parts.Length > 0) { parts = new Button(); parts.Text = "Parts"; parts.Click += (sender, e) => { new WindowParts(itemBinder, this); }; Controls.Add(parts); } } } }
public TextBoxQuality(Value<int> value, int min, int max, TextBoxDegradation textBoxDegradation) : base(value, min, max) { this.textBoxDegradation = textBoxDegradation; }