public WaterLevelWindow(params object[] options) { sceneTitle = "Water Level"; ExposeEvent += OnExpose; /******************************************************************************************************/ /* Water Level Groups */ /******************************************************************************************************/ groupName = WaterLevel.firstWaterLevelGroup; if (options.Length >= 3) { var requestedGroup = options[2] as string; if (requestedGroup != null) { if (WaterLevel.WaterLevelGroupNameExists(requestedGroup)) { groupName = requestedGroup; } } } var label = new TouchLabel(); label.text = "Groups"; label.WidthRequest = 118; label.textColor = "seca"; label.textSize = 12; label.textAlignment = TouchAlignment.Left; Put(label, 37, 80); label.Show(); label = new TouchLabel(); label.WidthRequest = 329; label.text = "Level"; label.textColor = "grey3"; label.textAlignment = TouchAlignment.Center; Put(label, 60, 155); label.Show(); levelLabel = new TouchLabel(); levelLabel.WidthRequest = 329; levelLabel.textSize = 20; levelLabel.textAlignment = TouchAlignment.Center; levelLabel.textRender.unitOfMeasurement = UnitsOfMeasurement.Inches; Put(levelLabel, 60, 120); levelLabel.Show(); var globalSettingsBtn = new TouchButton(); globalSettingsBtn.text = "\u2699"; globalSettingsBtn.SetSizeRequest(30, 30); globalSettingsBtn.buttonColor = "pri"; globalSettingsBtn.ButtonReleaseEvent += OnGroupSettingsButtonReleaseEvent; Put(globalSettingsBtn, 358, 77); globalSettingsBtn.Show(); /******************************************************************************************************/ /* ATO Groups */ /******************************************************************************************************/ atoGroupName = AutoTopOff.firstAtoGroup; label = new TouchLabel(); label.text = "ATO"; label.textColor = "seca"; label.textSize = 12; Put(label, 37, 280); label.Show(); atoStateTextBox = new TouchLabel(); atoStateTextBox.WidthRequest = 329; atoStateTextBox.textSize = 20; atoStateTextBox.textAlignment = TouchAlignment.Center; Put(atoStateTextBox, 60, 320); atoStateTextBox.Show(); var atoSettingsBtn = new TouchButton(); atoSettingsBtn.text = "\u2699"; atoSettingsBtn.SetSizeRequest(30, 30); atoSettingsBtn.buttonColor = "pri"; atoSettingsBtn.ButtonReleaseEvent += OnAtoSettingsButtonReleaseEvent; Put(atoSettingsBtn, 358, 277); atoSettingsBtn.Show(); atoClearFailBtn = new TouchButton(); atoClearFailBtn.SetSizeRequest(100, 60); atoClearFailBtn.text = "Reset ATO"; atoClearFailBtn.buttonColor = "compl"; atoClearFailBtn.ButtonReleaseEvent += (o, args) => { if (atoGroupName.IsNotEmpty()) { if (AutoTopOff.GetAtoGroupState(atoGroupName) == AutoTopOffState.Cooldown) { AutoTopOff.ResetCooldownTime(atoGroupName); } else { if (!AutoTopOff.ClearAtoAlarm(atoGroupName)) { MessageBox.Show("Please acknowledge alarms first"); } } } }; Put(atoClearFailBtn, 70, 405); /**************************************************************************************************************/ /* Analog water sensor */ /**************************************************************************************************************/ analogSensorWidget = new WaterLevelSensorWidget(); Put(analogSensorWidget, 415, 77); analogSensorWidget.Show(); analogSensorWidget.sensorCombo.comboList.Clear(); if (groupName.IsNotEmpty()) { var groupsWaterLevelSensors = WaterLevel.GetAllWaterLevelSensorsForWaterLevelGroup(groupName); analogSensorWidget.sensorCombo.comboList.AddRange(groupsWaterLevelSensors); if (groupsWaterLevelSensors.Length > 0) { analogSensorWidget.sensorName = groupsWaterLevelSensors[0]; } else { analogSensorWidget.sensorName = string.Empty; } } analogSensorWidget.sensorCombo.comboList.Add("New level sensor..."); analogSensorWidget.sensorCombo.activeIndex = 0; analogSensorWidget.sensorCombo.QueueDraw(); /**************************************************************************************************************/ /* Float Switches */ /**************************************************************************************************************/ label = new TouchLabel(); label.text = "Probes"; label.textColor = "seca"; label.textSize = 12; Put(label, 415, 280); label.Show(); switchStateLabel = new TouchLabel(); switchStateLabel.text = "Current Switch State"; switchStateLabel.textAlignment = TouchAlignment.Center; switchStateLabel.textColor = "grey3"; switchStateLabel.WidthRequest = 370; Put(switchStateLabel, 415, 355); switchStateTextBox = new TouchLabel(); switchStateTextBox.WidthRequest = 370; switchStateTextBox.textSize = 20; switchStateTextBox.textAlignment = TouchAlignment.Center; Put(switchStateTextBox, 415, 320); switchStateTextBox.Show(); //Type switchTypeLabel = new TouchLabel(); switchTypeLabel.WidthRequest = 370; switchTypeLabel.textAlignment = TouchAlignment.Center; switchTypeLabel.textColor = "grey3"; Put(switchTypeLabel, 415, 370); switchTypeLabel.Show(); var switchSetupBtn = new TouchButton(); switchSetupBtn.text = "\u2699"; switchSetupBtn.SetSizeRequest(30, 30); switchSetupBtn.buttonColor = "pri"; switchSetupBtn.ButtonReleaseEvent += OnFloatSwitchSettingsButtonReleaseEvent; Put(switchSetupBtn, 755, 277); switchSetupBtn.Show(); groupCombo = new TouchComboBox(WaterLevel.GetAllWaterLevelGroupNames()); if (groupName.IsNotEmpty()) { groupCombo.activeText = groupName; } else { groupCombo.activeIndex = 0; } groupCombo.WidthRequest = 200; groupCombo.comboList.Add("New group..."); groupCombo.ComboChangedEvent += OnGroupComboChanged; Put(groupCombo, 153, 77); groupCombo.Show(); atoGroupCombo = new TouchComboBox(AutoTopOff.GetAllAtoGroupNames()); if (atoGroupName.IsNotEmpty()) { atoGroupCombo.activeText = atoGroupName; } else { atoGroupCombo.activeIndex = 0; } atoGroupCombo.WidthRequest = 200; atoGroupCombo.comboList.Add("New ATO..."); atoGroupCombo.ComboChangedEvent += OnAtoGroupComboChanged; Put(atoGroupCombo, 153, 277); atoGroupCombo.Show(); switchCombo = new TouchComboBox(); switchCombo.WidthRequest = 200; if (groupName.IsNotEmpty()) { var groupsFloatSwitches = WaterLevel.GetAllFloatSwitchesForWaterLevelGroup(groupName); switchCombo.comboList.AddRange(groupsFloatSwitches); if (groupsFloatSwitches.Length > 0) { switchName = groupsFloatSwitches[0]; } else { switchName = string.Empty; } } switchCombo.comboList.Add("New switch..."); switchCombo.activeIndex = 0; switchCombo.ComboChangedEvent += OnSwitchComboChanged; Put(switchCombo, 550, 277); switchCombo.Show(); GetGroupData(); GetAtoGroupData(); analogSensorWidget.GetSensorData(); GetSwitchData(); Show(); }
public WaterGroupSettings(WaterLevelGroupSettings settings, Window parent) : base(settings.name + " Water", settings.name.IsNotEmpty(), parent) { groupName = settings.name; var t = new SettingsTextBox("Name"); t.textBox.text = groupName.IsNotEmpty() ? groupName : "Enter name"; t.textBox.TextChangedEvent += (sender, args) => { if (args.text.IsEmpty()) { args.keepText = false; } if (WaterLevel.WaterLevelGroupNameExists(args.text)) { MessageBox.Show("Water level group name already exists"); args.keepText = false; } }; AddSetting(t); var b = new SettingsBlank("blank1"); AddSetting(b); var s = new SettingsSelectorSwitch("Enable High Alarm"); s.selectorSwitch.currentSelected = 1; if (groupName.IsNotEmpty()) { s.selectorSwitch.currentSelected = settings.enableHighAnalogAlarm ? 0 : 1; } AddSetting(s); t = new SettingsTextBox("High Alarm"); t.textBox.text = groupName.IsNotEmpty() ? settings.highAnalogAlarmSetpoint.ToString() : "0"; t.textBox.TextChangedEvent += (sender, args) => { try { float highAlarmStpnt = Convert.ToSingle(args.text); if (highAlarmStpnt < 0f) { MessageBox.Show("High alarm setpoint can't be negative"); args.keepText = false; return; } } catch { MessageBox.Show("Improper high alarm setpoint format"); args.keepText = false; } }; AddSetting(t); s = new SettingsSelectorSwitch("Enable Low Alarm"); s.selectorSwitch.currentSelected = 1; if (groupName.IsNotEmpty()) { s.selectorSwitch.currentSelected = settings.enableLowAnalogAlarm ? 0 : 1; } AddSetting(s); t = new SettingsTextBox("Low Alarm"); t.textBox.text = groupName.IsNotEmpty() ? settings.lowAnalogAlarmSetpoint.ToString() : "0"; t.textBox.TextChangedEvent += (sender, args) => { try { float lowAlarmStpnt = Convert.ToSingle(args.text); if (lowAlarmStpnt < 0f) { MessageBox.Show("Low alarm setpoint can't be negative"); args.keepText = false; return; } } catch { MessageBox.Show("Improper low alarm setpoint format"); args.keepText = false; } }; AddSetting(t); DrawSettings(); }