예제 #1
0
        protected void OnComboChanged(object sender, ComboBoxChangedEventArgs e)
        {
            if (e.activeText == "New fixture...")
            {
                var parent = Toplevel as Window;
                var s      = new FixtureSettings(new LightingFixtureSettings(), parent);
                s.Run();
                var newFixtureName = s.fixtureName;
                var outcome        = s.outcome;

                if (outcome == TouchSettingsOutcome.Added)
                {
                    combo.comboList.Insert(combo.comboList.Count - 1, newFixtureName);
                    combo.activeText = newFixtureName;
                    fixtureName      = newFixtureName;
                }
                else
                {
                    combo.activeText = fixtureName;
                }
            }
            else
            {
                fixtureName = e.activeText;
            }

            GetFixtureData();
            lightingStateWidget.SetStates(fixtureName);
            lightingStateWidget.QueueDraw();
            combo.QueueDraw();
        }
예제 #2
0
        protected void OnGroupComboChanged(object sender, ComboBoxChangedEventArgs e)
        {
            if (e.activeText == "New group...")
            {
                CallTemperatureGroupSettingsDialog(true);
            }
            else
            {
                groupName = e.activeText;

                probeWidget.sensorCombo.comboList.Clear();
                if (groupName.IsNotEmpty())
                {
                    var groupsTemperatureProbes = Temperature.GetAllTemperatureProbesForTemperatureGroup(groupName);
                    probeWidget.sensorCombo.comboList.AddRange(groupsTemperatureProbes);
                    if (groupsTemperatureProbes.Length > 0)
                    {
                        probeWidget.sensorName = groupsTemperatureProbes[0];
                    }
                    else
                    {
                        probeWidget.sensorName = string.Empty;
                    }
                }
                probeWidget.sensorCombo.comboList.Add("New level sensor...");
                probeWidget.sensorCombo.activeIndex = 0;
                probeWidget.sensorCombo.QueueDraw();

                heaterCombo.comboList.Clear();
                if (groupName.IsNotEmpty())
                {
                    var heaterNames = Devices.Heater.GetAllHeatersForTemperatureGroup(groupName);
                    if (heaterNames.Length > 0)
                    {
                        heaterCombo.comboList.AddRange(heaterNames);
                        heaterName = heaterNames[0];
                    }
                    else
                    {
                        heaterName = string.Empty;
                    }
                }
                heaterCombo.comboList.Add("New heater...");
                heaterCombo.activeIndex = 0;
                heaterCombo.QueueDraw();
            }

            groupCombo.QueueDraw();
            GetGroupData();
            probeWidget.GetSensorData();
        }
        protected void GetSwitchData()
        {
            if (switchName.IsNotEmpty())
            {
                var  floatSwitch = (FloatSwitch)Sensors.FloatSwitches.GetGadget(switchName);
                bool state       = floatSwitch.activated;

                if (state)
                {
                    switchStateTextBox.text      = "Activated";
                    switchStateTextBox.textColor = "pri";
                }
                else
                {
                    switchStateTextBox.text      = "Normal";
                    switchStateTextBox.textColor = "seca";
                }

                switchStateLabel.Visible = true;
                switchTypeLabel.Visible  = true;

                SwitchType type = floatSwitch.switchType;
                switchTypeLabel.text = Utils.GetDescription(type);
            }
            else
            {
                switchStateLabel.Visible     = false;
                switchTypeLabel.Visible      = false;
                switchStateTextBox.text      = "Switch not available";
                switchStateTextBox.textColor = "white";
            }

            switchCombo.Visible = false;
            switchCombo.Visible = true;

            switchCombo.QueueDraw();
            switchTypeLabel.QueueDraw();
            switchStateTextBox.QueueDraw();
        }
        protected void OnAtoSettingsButtonReleaseEvent(object sender, ButtonReleaseEventArgs args)
        {
            var parent = Toplevel as Window;
            var s      = new AtoSettings(AutoTopOff.GetAutoTopOffGroupSettings(atoGroupName), parent);

            s.Run();
            var newAtoGroupName = s.groupName;
            var outcome         = s.outcome;

            if ((outcome == TouchSettingsOutcome.Modified) && (newAtoGroupName != groupName))
            {
                var index = atoGroupCombo.comboList.IndexOf(groupName);
                atoGroupCombo.comboList[index] = newAtoGroupName;
                atoGroupName = newAtoGroupName;
            }
            else if (outcome == TouchSettingsOutcome.Added)
            {
                atoGroupCombo.comboList.Insert(atoGroupCombo.comboList.Count - 1, newAtoGroupName);
                atoGroupCombo.activeText = newAtoGroupName;
                atoGroupName             = newAtoGroupName;
            }
            else if (outcome == TouchSettingsOutcome.Deleted)
            {
                atoGroupCombo.comboList.Remove(atoGroupName);
                atoGroupName = AutoTopOff.firstAtoGroup;
                if (atoGroupName.IsNotEmpty())
                {
                    atoGroupCombo.activeText = atoGroupName;
                }
                else
                {
                    atoGroupCombo.activeIndex = -1;
                }
            }

            atoGroupCombo.QueueDraw();
            GetAtoGroupData();
        }
        protected void CallWaterLevelGroupSettingsDialog(bool forceNew = false)
        {
            WaterLevelGroupSettings settings;

            if (groupName.IsNotEmpty() && !forceNew)
            {
                settings = WaterLevel.GetWaterLevelGroupSettings(groupName);
            }
            else
            {
                settings = new WaterLevelGroupSettings();
            }

            var parent = Toplevel as Window;
            var s      = new WaterGroupSettings(WaterLevel.GetWaterLevelGroupSettings(groupName), parent);

            s.Run();
            var newGroupName = s.groupName;
            var outcome      = s.outcome;

            if ((outcome == TouchSettingsOutcome.Modified) && (newGroupName != groupName))
            {
                var index = groupCombo.comboList.IndexOf(groupName);
                groupCombo.comboList[index] = newGroupName;
                groupCombo.activeText       = newGroupName;
            }
            else if (outcome == TouchSettingsOutcome.Added)
            {
                groupName = newGroupName;
                groupCombo.comboList.Insert(groupCombo.comboList.Count - 1, groupName);
                groupCombo.activeText = groupName;

                analogSensorWidget.sensorCombo.comboList.Clear();
                analogSensorWidget.sensorCombo.comboList.Add("New level sensor...");
                analogSensorWidget.sensorCombo.activeIndex = 0;
                analogSensorWidget.sensorCombo.QueueDraw();
                analogSensorWidget.sensorName = string.Empty;

                switchCombo.comboList.Clear();
                switchCombo.comboList.Add("New switch...");
                switchCombo.activeIndex = 0;
                switchCombo.QueueDraw();
                switchName = string.Empty;
            }
            else if (outcome == TouchSettingsOutcome.Deleted)
            {
                groupCombo.comboList.Remove(groupName);
                groupName             = WaterLevel.firstWaterLevelGroup;
                groupCombo.activeText = groupName;

                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();

                switchCombo.comboList.Clear();
                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.QueueDraw();
            }

            groupCombo.QueueDraw();
            GetGroupData();
            analogSensorWidget.GetSensorData();
            GetSwitchData();
        }