Ejemplo n.º 1
0
        private void listBoxReagents_SelectedIndexChanged(object sender, EventArgs e)
        {
            ThingReagent thing = (ThingReagent)listBoxReagents.SelectedValue;

            textBoxReagent.Text  = thing.TypeName;
            textBoxQuantity.Text = thing.Quantity.ToString();
            // this causes a change event to light the save/cancel buttons, lets undo that...
            buttonSave.Enabled   = false;
            buttonCancel.Enabled = false;
        }
Ejemplo n.º 2
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     // if we've got it do it....
     if (listBoxReagents.SelectedIndex >= 0)
     {
         ThingReagent thing = (ThingReagent)listBoxReagents.SelectedValue;
         thing.XML.Remove();
         listBoxReagents.DataSource = machine.GetReagents();
     }
 }
Ejemplo n.º 3
0
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            // reset values
            ThingReagent thing = (ThingReagent)listBoxReagents.SelectedValue;

            textBoxReagent.Text  = thing.TypeName;
            textBoxQuantity.Text = thing.Quantity.ToString();
            buttonSave.Enabled   = false;
            buttonCancel.Enabled = false;
        }
Ejemplo n.º 4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            ThingReagent thing = (ThingReagent)listBoxReagents.SelectedValue;

            thing.TypeName = textBoxReagent.Text;
            // this will throw an exception on garbage
            thing.Quantity = Single.Parse(textBoxQuantity.Text);
            thing.Save();
            buttonSave.Enabled   = false;
            buttonCancel.Enabled = false;
            // refresh list item information.....
            listBoxReagents.DataSource = machine.GetReagents();
        }
Ejemplo n.º 5
0
        public List <ThingReagent> GetReagents()
        {
            List <ThingReagent> outList = new List <ThingReagent>();

            var reagents = from i in XML.Element("Reagents").Elements("Reagent")
                           select i;

            foreach (XElement i in reagents)
            {
                ThingReagent thingReagent = new ThingReagent(i);
                outList.Add(thingReagent);
            }

            return(outList);
        }