public SensorsWindow(params object[] options)
        {
            sceneTitle   = "Sensors";
            ExposeEvent += OnExpose;

            topWidget = new PhProbeWidget();
            Put(topWidget, 415, 77);
            topWidget.Show();

            bottomWidget = new WaterLevelSensorWidget();
            Put(bottomWidget, 415, 277);
            bottomWidget.Show();

            topCombo = new TouchComboBox(analogSensorNames);
            topCombo.WidthRequest       = 235;
            topCombo.activeText         = analogSensorNames[2];
            topCombo.ComboChangedEvent += OnComboChange;
            Put(topCombo, 153, 77);
            topCombo.Show();

            bottomCombo = new TouchComboBox(analogSensorNames);
            bottomCombo.WidthRequest       = 235;
            bottomCombo.activeText         = analogSensorNames[0];
            bottomCombo.ComboChangedEvent += OnComboChange;
            Put(bottomCombo, 153, 277);
            bottomCombo.Show();

            topWidget.GetSensorData();
            bottomWidget.GetSensorData();

            Show();
        }
 protected void OnComboChange(object sender, ComboBoxChangedEventArgs args)
 {
     if (topCombo.Equals(sender))
     {
         topWidget.Destroy();
         topWidget = AnalogSensorWidgetCreater(args.activeText);
         Put(topWidget, 415, 77);
         topWidget.Show();
         topWidget.GetSensorData();
     }
     else
     {
         bottomWidget.Destroy();
         bottomWidget = AnalogSensorWidgetCreater(args.activeText);
         Put(bottomWidget, 415, 277);
         bottomWidget.Show();
         bottomWidget.GetSensorData();
     }
 }
        protected AnalogSensorWidget AnalogSensorWidgetCreater(string name)
        {
            AnalogSensorWidget widget = null;

            switch (name)
            {
            case "Water Level Sensor":
                widget = new WaterLevelSensorWidget();
                break;

            case "Temperature Probe":
                widget = new TemperatureProbeWidget();
                break;

            case "pH Probe":
                widget = new PhProbeWidget();
                break;
            }

            return(widget);
        }
        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();
        }