private void MeterBoard32Form_Load(object sender, EventArgs e) { // Set up Meter list view meterList = new TypedObjectListView <Meter>(objectListView1); meterList.GetColumn(0).AspectGetter = delegate(Meter x) { return(x.MeterId); }; meterList.GetColumn(1).AspectGetter = delegate(Meter x) { return(x.PrimaryAddress); }; meterList.GetColumn(2).AspectGetter = delegate(Meter x) { return(x.MeterType); }; meterList.GetColumn(3).AspectGetter = delegate(Meter x) { return(x.ManufacturerId); }; meterList.GetColumn(4).AspectGetter = delegate(Meter x) { return(x.dataRecords.Count); }; meterList.GetColumn(5).AspectGetter = delegate(Meter x) { return("Delete"); }; meterList.GetColumn(6).AspectGetter = delegate(Meter x) { return("Modify"); }; meterList.ListView.ButtonClick += delegate(object sender2, CellClickEventArgs e2) { Meter meter = (Meter)e2.Model; if (e2.ColumnIndex == 5) { meters.Remove(meter); objectListView1.RemoveObject(meter); } else if (e2.ColumnIndex == 6) { MeterForm meterForm = new MeterForm(ref meter); if (meterForm.ShowDialog(this).Equals(DialogResult.OK)) { objectListView1.UpdateObject(meter); } } objectListView1.RefreshObject(e2.Model); }; // Set up console component consoleControl.WriteOutput("Welcome to MeterBoard32 Configuration Tool console!\r", Color.White); consoleTextBox.ReadOnly = true; }
/// <summary> /// Event handler for the "Add Meter" button /// Provides the user with a means of adding a new meter to the current configuration /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddMeter_Click(object sender, EventArgs e) { MeterForm meterForm = new MeterForm(); if (meterForm.ShowDialog(this).Equals(DialogResult.OK)) { meters.Add(meterForm.resultMeter); ShowInfo(string.Format("Added meter {0} to current configuration", meterForm.resultMeter.MeterId)); updateGUI(); } }