/// <summary> /// Initializer for a new Wizard. /// </summary> public AddSensorWizard(SensorListItem sli) { InitializeComponent(); //SensorListItem sli = (SensorListItem)sender; Sensor selSens = sli.getSensor(); EditSensor editSens = new EditSensor(selSens); editSens.Location = new System.Drawing.Point(0, 0); this.Controls.Clear(); this.Controls.Add(editSens); editSens.VisibleChanged += new System.EventHandler(this.proceed); //DataColumn type = new DataColumn(); //DataColumn name = new DataColumn(); //DataColumn sensor = new DataColumn(); //type.DataType = Type.GetType("CarSens.Sensors.SensorType"); //sensor.DataType = Type.GetType("CarSens.Sensors.Sensor"); //DataTable termo = new DataTable("Thermo"); //termo.Columns.Add(type); //termo.Columns.Add(name); //termo.Columns.Add(sensor); //therms = new SensorListThermo(termo); //System.IO.MemoryStream stream = new System.IO.MemoryStream(); //termo.WriteXmlSchema(stream, true); //DataTable gps = new DataTable(); //stream.Position = 0; //gps.ReadXmlSchema(stream); //gps.TableName = "GPS"; //gpss = new SensorListGPS(gps); //DataTable volts = new DataTable(); //stream.Position = 0; //volts.ReadXmlSchema(stream); //volts.TableName = "VOLTS"; //voltslist = new SensorListVolt(volts); //timer1.Interval = 40; //timer1.Enabled = true; //updateSensors.Interval = 4000; //updateSensors.Enabled = true; }
/// <summary> /// Starts the Wizard. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void startWizard(object sender, EventArgs e) { if (sender.GetType() == Type.GetType("CarSens.Components.SensorListItem")) { SensorListItem sli = (SensorListItem)sender; Sensor selSens = sli.getSensor(); EditSensor editSens = new EditSensor(selSens); editSens.Location = new System.Drawing.Point(0, 0); this.Controls.Clear(); this.Controls.Add(editSens); editSens.VisibleChanged += new System.EventHandler(this.proceed); } }
/// <summary> /// Updates the Sensor list. /// </summary> private void updateSensorList() { int top = 0; int newItems = 0; foreach (DataTable lists in set.Tables) { foreach (DataRow row in lists.Rows) { Sensor[] senses = SensorManager.getAllSensors(); Sensor sens = (Sensor)row.ItemArray[2]; Boolean inList = false; foreach (Sensor sin in senses) { if (sin.getIdentifier().Equals(sens.getIdentifier())) { inList = true; } } if (!inList) { SensorListItem listItem = new SensorListItem(sens); listItem.Click += new System.EventHandler(this.startWizard); listItem.Location = new System.Drawing.Point(0, top); top += listItem.Size.Height + 10; this.panel2.Controls.Add(listItem); newItems++; } } } if (newItems == 0) { Label nothing = new Label(); nothing.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); nothing.ForeColor = Color.White; nothing.Text = "No unassigned Sensors found"; nothing.Width = 250; nothing.Location = new System.Drawing.Point(0, top); this.Controls.Add(nothing); } }
private void SensorListItemCLick(object sender, MouseButtonEventArgs e) { SensorListItem slItem = (SensorListItem)sender; mainWindow.OpenWindow(new SensorEditDialog(slItem.getSensor(), this.mainWindow)); }
/// <summary> /// Updates the List. /// </summary> private void updateSensorList() { double top = 0; foreach (DataTable table in set.Tables) { foreach (DataRow row in table.Rows) { Sensor[] senses = SensorManager.getAllSensors(); Sensor sens = (Sensor)row.ItemArray[2]; Boolean inList = false; SensorStatus status = SensorStatus.AVAILABLE; //Check if Sensor is in CurrentlyConnectedList foreach (Sensor sin in senses) { if (sin.getIdentifier().Equals(sens.getIdentifier())) { inList = true; break; } } if (!inList) { status = SensorStatus.AVAILABLE; } else { DataRow found = assigned.Rows.Find(sens.getIdentifier()); object[] array = found.ItemArray; array[1] = true; found.ItemArray = array; sens = (Sensor)array[2]; status = SensorStatus.CONNECTED; } SensorListItem listItem = new SensorListItem(sens); //listItem.setStatus(status); //listItem.Location = new System.Drawing.Point(0, top); top += listItem.Height + 10; listItem.MouseLeftButtonUp += new MouseButtonEventHandler(SensorListItemCLick); //listItem.MouseClick += new MouseEventHandler(ClickListItem); this.Panel.Children.Add(listItem); } } foreach (DataRow row in assigned.Rows) { if (!(Boolean)row.ItemArray[1]) { Sensor sens = (Sensor)row.ItemArray[2]; SensorListItem listItem = new SensorListItem(sens); listItem.MouseLeftButtonUp += new MouseButtonEventHandler(SensorListItemCLick); //listItem.Location = new System.Drawing.Point(0, top); top += listItem.Height + 10; Panel.Children.Add(listItem); //listItem.setStatus(SensorStatus.CONNECTED); } } if (Panel.Children.Count == 0) { SensorMock mock = new SensorMock(); mock.setName("No Sensors found"); mock.setDeviceIdentifier(""); Panel.Children.Add(new SensorListItem(mock)); } }