private void button10_Click(object sender, EventArgs e) { var cont = new DeviceController(); var firstDev = cont.RetrieveDevice(1); var window = new SetDeviceCommunicators(firstDev); window.Show(); }
private void bSave_Click(object sender, EventArgs e) { //Create new model. var model = new Models.Rule() { DeviceId = _device.Id, Device = _device, RuleType = (Models.RuleType) cbRuleType.SelectedItem, ValueType = (Models.ValueType) cbValueType.SelectedItem, Action = null, Alarm = cAlarm.Checked, Constraint = tConstraint.Text, Name = tName.Text }; //Push to Database. var controller = new RuleController(); _rule = controller.CreateRule(model); //Update the global Device object. var devController = new DeviceController(); var index = DeviceController.AllDevices.FindIndex(d => d.Id == _device.Id); var allRules = new List<Rule>(); allRules.AddRange(_device.Rules); allRules.Add(_rule); _device.Rules = allRules; DeviceController.AllDevices[index] = _device; }
private void button2_Click(object sender, EventArgs e) { var controller = new DeviceController(); Device testDev = controller.GetAllDevices().Last(); AddRule ar = new AddRule(testDev); ar.ShowDialog(); }
private void bCommunicator_Click(object sender, EventArgs e) { if (_comm == null) { var devCont = new DeviceController(); var device = devCont.RetrieveDevice(_rule.DeviceId); var ai = new AddCommunicator(device,false); ai.ShowDialog(); _comm = ai._communicator; } else { var cm = new CommunicatorModifier(_comm); cm.ShowDialog(); } }
private void add_cbRule_SelectedIndexChanged(object sender, EventArgs e) { var devController = new DeviceController(); var commController = new CommunicatorController(); _rule = (Models.Rule)add_cbRule.SelectedItem; _rule.Device = devController.RetrieveDevice(_rule.DeviceId); _device = _rule.Device; //add_cbCommunicatorDestination.Items.AddRange(commController.GetAllCommunicators().Where(com=>com.Device.Id==_rule.DeviceId && com.Inbound==false).ToArray()); }
private void modify_bSave_Click(object sender, EventArgs e) { try { //Update the global object with any updates values. _selectedDevice.Name = modify_tDevName.Text; _selectedDevice.Custodian = modify_tCustodian.Text; _selectedDevice.Location = modify_tLocation.Text; _selectedDevice.Enabled = modify_rbTrue.Checked; //Create new Device Controller. var controller = new DeviceController(); //Save the Device. var savedDevice = controller.SaveDevice(_selectedDevice); //If the updated device is null or has been corupted (i.e. wrong device info), error! if (savedDevice == null || savedDevice.Id != _selectedDevice.Id) { MessageBox.Show("There was an error saving the Device...", _selectedDevice.ToString()); } else { //Updated the global variable with a database replica. //(Should not change the object properties). _selectedDevice = savedDevice; //Inform the user DebugOutput.Print("Device was updated successfully. ", _selectedDevice.ToString()); } } catch (Exception ex) { DebugOutput.Print("Could not save data for selected object. ", ex.Message); } }
private void add_bSaveNewDevice_Click(object sender, EventArgs e) { var _controller = new DeviceController(); bool enabled = add_rbTrue.Checked && !add_rbFalse.Checked; _selectedDevice = _controller.GetDeviceObject(Convert.ToInt32(add_tId.Text), add_tName.Text, add_tLocation.Text, add_tCustodian.Text, enabled); var newDevice = _controller.SaveDevice(_selectedDevice); _selectedDevice = newDevice; if (newDevice== null) { MessageBox.Show("There was an error saving the Device..."); } }
private void bModify_Click(object sender, EventArgs e) { //Print output statement as to the event. DebugOutput.Print("Dashboard: Modify Device"); //Populate appropriate objects/fields. modify_lbDeviceList.Items.Clear(); var controller = new DeviceController(); foreach (var dev in controller.GetAllDevices()) { modify_lbDeviceList.Items.Add(dev); } //Bring page to user's view. pTabPanel.SelectedTab = pModifyDevice; }
private void bAddNew_Click(object sender, EventArgs e) { DebugOutput.Print("Dashboard: Add New Device"); var _controller = new DeviceController(); add_tId.Text = (_controller.CurrentMaxId() + 1).ToString(); pTabPanel.SelectedTab = pAddNewDevice; }
private void bStopProcess_Click(object sender, EventArgs e) { //Print output statement as to the event. DebugOutput.Print("Dashboard: Stop Device Process"); //Populate appropriate objects/fields. stop_lbDevice.Items.Clear(); var controller = new DeviceController(); foreach (var dev in controller.GetAllDevices()) { stop_lbDevice.Items.Add(dev); } //Bring page to user's view. pTabPanel.SelectedTab = pStop; }
private void alarm_lbAlarms_SelectedIndexChanged(object sender, EventArgs e) { //Resetting the form. alarm_bRule.Enabled = false; alarm_bDevice.Enabled = false; alarm_tDateTime.Text = ""; alarm_rbTrue.Checked = false; alarm_rbFalse.Checked = false; alarm_tValue.Text = ""; alarm_tDevice.Text = ""; try { var selected = (Alarm) alarm_lbAlarms.SelectedItem; alarm_tDateTime.Text = selected.TimeStamp.ToString(); alarm_rbTrue.Checked = selected.Accepted; alarm_rbFalse.Checked = !selected.Accepted; //Get Value information. if (selected.ValueId > 0) { var controller = new ValueController(); _value = controller.GetValueById(selected.ValueId); selected.Value = _value; alarm_tValue.Text = selected.Value.StringValue; } //Get Rule information. if (selected.RuleId > 0) { var controller = new RuleController(); _rule = controller.RetrieveRuleById(selected.RuleId); alarm_bRule.Enabled = true; } //Get Device information. if (selected.DeviceId > 0) { var controller = new DeviceController(); _selectedDevice = controller.RetrieveDevice(selected.DeviceId); selected.Device = _selectedDevice; alarm_tDevice.Text = _selectedDevice.ToString(); alarm_bDevice.Enabled = true; } } catch { DebugOutput.Print("Attempted to load an alarm and failed..."); } }
private void button1_Click(object sender, EventArgs e) { var cont = new DeviceController(); cont.SaveDevice(localisedDevice); }
private void button7_Click(object sender, EventArgs e) { var controller = new DeviceController(); Device testDev = controller.GetAllDevices().Last(); AddCommunicator ai = new AddCommunicator(testDev,true); ai.ShowDialog(); }