public SellRuleWindow(SellRule s) : this() { txtRuleName.Text = s.Name; nudMinIlvl.Value = s.MinIlvl; SelectValue(s.ItemType, cboItemTypes); PopulateCriterias(s); }
private void PopulateCriterias(SellRule s) { SelectValue(s.Criterias[0].StatID, cboStat1); nudStat1.Value = s.Criterias[0].MinAmount; for (int i = 1; i < s.Criterias.Length; i++) { AddLine(null, new EventArgs()); ComboBox lastCbo = (ComboBox)pnlRuleDef.Controls.Find(STAT_CBO_NAME + (i + 1), true)[0]; NumericUpDown lastNud = (NumericUpDown)pnlRuleDef.Controls.Find(STAT_NUD_NAME + (i + 1), true)[0]; SelectValue(s.Criterias[i].StatID, lastCbo); lastNud.Value = s.Criterias[i].MinAmount; } }
private void btnConfirm_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(txtRuleName.Text)) { MessageBox.Show(this, "Please enter a rule name.", "Incorrect rule name", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } SellRule s = new SellRule(); s.Name = txtRuleName.Text; s.MinIlvl = (int)nudMinIlvl.Value; s.ItemType = ((ComboBoxItem)cboItemTypes.SelectedItem).Value; s.Criterias = GetCriterias(); SellRule = s; this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }