public AnalogSensorSettingsDialog(
            GenericAnalogSensorSettings settings,
            GenericAnalogSensorCollection sensorCollection,
            GenericAnalogInputBase analogInputDriver,
            Window parent)
            : base(settings, sensorCollection, analogInputDriver, parent)
        {
            var t = new SettingsTextBox("LPF Factor");

            t.textBox.text              = sensorName.IsNotEmpty() ? settings.lowPassFilterFactor.ToString() : "5";
            t.textBox.TextChangedEvent += (sender, args) => {
                try {
                    var factor = Convert.ToInt32(args.text);

                    if (factor < 0)
                    {
                        MessageBox.Show("Low passs filter factor can't be negative");
                        args.keepText = false;
                        return;
                    }
                } catch {
                    MessageBox.Show("Improper Low passs filter factor format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            DrawSettings();
        }
Esempio n. 2
0
        public TemperatureProbeSettingsDialog(TemperatureProbeSettings settings, Window parent)
            : base(settings.name, settings.name.IsNotEmpty(), parent)
        {
            temperatureProbeName = settings.name;

            var t = new SettingsTextBox("Name");

            t.textBox.text              = temperatureProbeName.IsNotEmpty() ? temperatureProbeName : "Enter name";
            t.textBox.TextChangedEvent += (sender, args) => {
                if (args.text.IsEmpty())
                {
                    args.keepText = false;
                }
                else if (Sensors.TemperatureProbes.GadgetNameExists(args.text))
                {
                    MessageBox.Show("Probe name already exists");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            var c = new SettingsComboBox("Input Channel");

            if (temperatureProbeName.IsNotEmpty())
            {
                var ic = settings.channel;
                c.combo.comboList.Add(string.Format("Current: {0}.i{1}", ic.Group, ic.Individual));
                c.combo.activeIndex = 0;
            }
            c.combo.nonActiveMessage = "Please select channel";
            c.combo.comboList.AddRange(Driver.AnalogInput.GetAllAvaiableChannels());
            AddSetting(c);

            DrawSettings();
        }
Esempio n. 3
0
        public HeaterSettingsDialog(HeaterSettings settings, Window parent)
            : base(settings.name, settings.name.IsNotEmpty(), parent)
        {
            heaterName = settings.name;

            var t = new SettingsTextBox("Name");

            if (heaterName.IsNotEmpty())
            {
                t.textBox.text = heaterName;
            }
            else
            {
                t.textBox.text = "Enter name";
            }
            t.textBox.TextChangedEvent += (sender, args) => {
                if (string.IsNullOrWhiteSpace(args.text))
                {
                    args.keepText = false;
                }
                else if (Devices.Heater.GadgetNameExists(args.text))
                {
                    MessageBox.Show("Heater name already exists");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            var c = new SettingsComboBox("Outlet");

            if (heaterName.IsNotEmpty())
            {
                var ic = settings.channel;
                c.combo.comboList.Add(string.Format("Current: {0}.i{1}", ic.Group, ic.Individual));
                c.combo.activeIndex = 0;
            }
            c.combo.nonActiveMessage = "Please select outlet";
            c.combo.comboList.AddRange(Driver.Power.GetAllAvaiableChannels());
            AddSetting(c);

            c = new SettingsComboBox("Temperature Group");
            if (heaterName.IsNotEmpty())
            {
                c.combo.comboList.Add("Current: " + settings.temperatureGroup);
                c.combo.activeIndex = 0;
            }
            c.combo.nonActiveMessage = "Please select group";
            c.combo.comboList.AddRange(Temperature.GetAllTemperatureGroupNames());
            AddSetting(c);

            DrawSettings();
        }
        public TemperatureGroupSettingsDialog(TemperatureGroupSettings settings, Window parent)
            : base(settings.name + " Temperature", settings.name.IsNotEmpty(), parent)
        {
            groupName = settings.name;

            var t = new SettingsTextBox("Name");

            if (groupName.IsNotEmpty())
            {
                t.textBox.text              = groupName;
                t.textBox.enableTouch       = false;
                t.textBox.TextChangedEvent += (sender, args) => {
                    MessageBox.Show("Can not change temperature group name during runtime");
                    args.keepText = false;
                };
            }
            else
            {
                t.textBox.text              = "Enter name";
                t.textBox.TextChangedEvent += (sender, args) => {
                    if (args.text.IsNotEmpty())
                    {
                        args.keepText = false;
                    }
                    else if (Temperature.TemperatureGroupNameExists(args.text))
                    {
                        MessageBox.Show("Temperature group name already exists");
                        args.keepText = false;
                    }
                };
            }
            AddSetting(t);

            t = new SettingsTextBox("Setpoint");
            if (groupName.IsNotEmpty())
            {
                t.textBox.text = Temperature.GetTemperatureGroupTemperatureSetpoint(groupName).ToString();
            }
            else
            {
                t.textBox.text = "0.0";
            }
            t.textBox.TextChangedEvent += (sender, args) => {
                try {
                    Convert.ToSingle(args.text);
                } catch {
                    MessageBox.Show("Improper floating point number format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            t = new SettingsTextBox("Deadband");
            if (groupName.IsNotEmpty())
            {
                t.textBox.text = Temperature.GetTemperatureGroupTemperatureDeadband(groupName).ToString();
            }
            else
            {
                t.textBox.text = "0.5";
            }
            t.textBox.TextChangedEvent += (sender, args) => {
                try {
                    Convert.ToSingle(args.text);
                } catch {
                    MessageBox.Show("Improper floating point number format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            t = new SettingsTextBox("High Alarm");
            if (groupName.IsNotEmpty())
            {
                t.textBox.text = Temperature.GetTemperatureGroupHighTemperatureAlarmSetpoint(groupName).ToString();
            }
            else
            {
                t.textBox.text = "100.0";
            }
            t.textBox.TextChangedEvent += (sender, args) => {
                try {
                    Convert.ToSingle(args.text);
                } catch {
                    MessageBox.Show("Improper floating point number format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            t = new SettingsTextBox("Low Alarm");
            if (groupName.IsNotEmpty())
            {
                t.textBox.text = Temperature.GetTemperatureGroupLowTemperatureAlarmSetpoint(groupName).ToString();
            }
            else
            {
                t.textBox.text = "0.0";
            }
            t.textBox.TextChangedEvent += (sender, args) => {
                try {
                    Convert.ToSingle(args.text);
                } catch {
                    MessageBox.Show("Improper floating point number format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            DrawSettings();
        }
        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();
        }
        public FixtureSettings(LightingFixtureSettings settings, Window parent)
            : base(settings.name, settings.name.IsNotEmpty(), parent)
        {
            fixtureName = settings.name;

            var t = new SettingsTextBox("Name");

            t.textBox.text              = fixtureName.IsNotEmpty() ? fixtureName : "Enter name";
            t.textBox.TextChangedEvent += (sender, args) => {
                if (args.text.IsEmpty())
                {
                    args.keepText = false;
                }
                else if (Devices.Lighting.GadgetNameExists(args.text))
                {
                    MessageBox.Show("Heater name already exists");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            var c = new SettingsComboBox("Outlet");

            if (fixtureName.IsNotEmpty())
            {
                var ic = settings.channel;
                c.combo.comboList.Add(string.Format("Current: {0}.p{1}", ic.Group, ic.Individual));
                c.combo.activeIndex = 0;
            }
            c.combo.nonActiveMessage = "Select outlet";
            c.combo.comboList.AddRange(Driver.Power.GetAllAvaiableChannels());
            AddSetting(c);

            var s = new SettingsSelectorSwitch("Temp Lockout");

            if (fixtureName.IsNotEmpty())
            {
                s.selectorSwitch.currentSelected = settings.highTempLockout ? 0 : 1;
            }
            AddSetting(s);

            bool isDimming = settings.dimmingChannel.IsNotEmpty();

            s = new SettingsSelectorSwitch("Dimming Fixture", "Yes", "No");
            s.selectorSwitch.currentSelected = isDimming ? 0 : 1;
            showOptional = isDimming;
            s.selectorSwitch.SelectorChangedEvent += (sender, args) => {
                if (args.currentSelectedIndex == 0)
                {
                    showOptional = true;
                }
                else
                {
                    showOptional = false;
                }
            };
            AddSetting(s);

            c = new SettingsComboBox("Dimming Channel");
            if (fixtureName.IsNotEmpty() && isDimming)
            {
                var ic = settings.dimmingChannel;
                c.combo.comboList.Add(string.Format("Current: {0}.q{1}", ic.Group, ic.Individual));
                c.combo.activeIndex = 0;
            }
            c.combo.nonActiveMessage = "Select outlet";
            c.combo.comboList.AddRange(Driver.AnalogOutput.GetAllAvaiableChannels());
            AddOptionalSetting(c);

            DrawSettings();
        }
        public AtoSettings(AutoTopOffGroupSettings settings, Window parent)
            : base(settings.name + " Auto Top Off", 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;
                }
                else if (!AutoTopOff.AtoGroupNameOk(args.text))
                {
                    MessageBox.Show("ATO group name already exists");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            var s = new SettingsSelectorSwitch("Enable");

            if (groupName.IsNotEmpty())
            {
                s.selectorSwitch.currentSelected = settings.enable ? 0 : 1;
            }
            AddSetting(s);

            var c = new SettingsComboBox("Water Group");

            c.combo.nonActiveMessage = "Select Water Level Group";
            var availableGroups = WaterLevel.GetAllWaterLevelGroupNames();

            c.combo.comboList.AddRange(availableGroups);
            if (groupName.IsNotEmpty())
            {
                var index = Array.IndexOf(availableGroups, settings.waterLevelGroupName);
                c.combo.activeIndex = index;
            }
            AddSetting(c);

            t = new SettingsTextBox("Request Bit Name");
            t.textBox.text              = groupName.IsNotEmpty() ? settings.requestBitName : "Enter name";
            t.textBox.TextChangedEvent += (sender, args) => {
                if (args.text.IsEmpty())
                {
                    args.keepText = false;
                }
            };
            AddSetting(t);

            s = new SettingsSelectorSwitch("Use Analog");
            if (groupName.IsNotEmpty())
            {
                s.selectorSwitch.currentSelected = settings.useAnalogSensors ? 0 : 1;
            }
            AddSetting(s);

            t = new SettingsTextBox("Analog Off");
            t.textBox.text              = groupName.IsNotEmpty() ? settings.analogOffSetpoint.ToString() : "0";
            t.textBox.TextChangedEvent += (sender, args) => {
                try {
                    float offStpnt = Convert.ToSingle(args.text);

                    if (offStpnt < 0f)
                    {
                        MessageBox.Show("Analog on setpoint can't be negative");
                        args.keepText = false;
                        return;
                    }
                } catch {
                    MessageBox.Show("Improper analog off setpoint format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            t = new SettingsTextBox("Analog On");
            t.textBox.text              = groupName.IsNotEmpty() ? settings.analogOnSetpoint.ToString() : "0";
            t.textBox.TextChangedEvent += (sender, args) => {
                try {
                    float onStpnt = Convert.ToSingle(args.text);

                    if (onStpnt < 0f)
                    {
                        MessageBox.Show("Analog on setpoint can't be negative");
                        args.keepText = false;
                        return;
                    }
                } catch {
                    MessageBox.Show("Improper analog on setpoint format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            s = new SettingsSelectorSwitch("Use Float Switch");
            if (groupName.IsNotEmpty())
            {
                s.selectorSwitch.currentSelected = settings.useFloatSwitches ? 0 : 1;
            }
            AddSetting(s);

            t = new SettingsTextBox("Max Runtime");
            t.textBox.text = groupName.IsNotEmpty() ?
                             string.Format("{0} mins", settings.maximumRuntime) :
                             "1 min";
            t.textBox.TextChangedEvent += (sender, args) => {
                if (args.text.IsEmpty())
                {
                    args.keepText = false;
                }

                var time = ParseTime(args.text);
                if (time >= 0)
                {
                    args.text = string.Format("{0} mins", time);
                }
                else
                {
                    MessageBox.Show("Improper format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            t = new SettingsTextBox("Cooldown");
            t.textBox.text = groupName.IsNotEmpty() ?
                             string.Format("{0} mins", settings.minimumCooldown) :
                             "10 min";
            t.textBox.TextChangedEvent += (sender, args) => {
                if (args.text.IsEmpty())
                {
                    args.keepText = false;
                }

                var time = ParseTime(args.text);
                if (time >= 0)
                {
                    args.text = string.Format("{0} mins", time);
                }
                else
                {
                    MessageBox.Show("Improper format");
                    args.keepText = false;
                }
            };
            AddSetting(t);

            DrawSettings();
        }
Esempio n. 8
0
        public AddHomeWidgetDialog(Window parent) : base("Add Home Screen Widget", parent, DialogFlags.DestroyWithParent)
        {
            Name           = "AquaPic.Home.Settings.Widget.Add";
            WindowPosition = (WindowPosition)4;
            SetSizeRequest(600, 320);

#if RPI_BUILD
            Decorated = false;

            ExposeEvent += (o, args) => {
                using (var cr = Gdk.CairoHelper.Create(GdkWindow)) {
                    cr.MoveTo(Allocation.Left, Allocation.Top);
                    cr.LineTo(Allocation.Right, Allocation.Top);
                    cr.LineTo(Allocation.Right, Allocation.Bottom);
                    cr.LineTo(Allocation.Left, Allocation.Bottom);
                    cr.ClosePath();
                    cr.LineWidth = 1.8;
                    TouchColor.SetSource(cr, "grey4");
                    cr.Stroke();
                }
            };
#endif

            ModifyBg(StateType.Normal, TouchColor.NewGtkColor("grey0"));

            foreach (Widget w in Children)
            {
                Remove(w);
                w.Dispose();
            }

            fix = new Fixed();
            fix.SetSizeRequest(600, 320);

            addBtn = new TouchButton();
            addBtn.SetSizeRequest(100, 30);
            addBtn.text = "Add";
            addBtn.ButtonReleaseEvent += OnAddButtonReleased;
            fix.Put(addBtn, 495, 285);
            addBtn.Show();

            cancelButton = new TouchButton();
            cancelButton.SetSizeRequest(100, 30);
            cancelButton.text = "Cancel";
            cancelButton.ButtonReleaseEvent += (o, args) => {
                Destroy();
            };
            fix.Put(cancelButton, 385, 285);
            cancelButton.Show();

            var widgetLabel = new TouchLabel();
            widgetLabel.text          = "Home Screen Widgets";
            widgetLabel.textAlignment = TouchAlignment.Right;
            widgetLabel.WidthRequest  = 185;
            fix.Put(widgetLabel, 5, 11);
            widgetLabel.Show();

            nameTextBox         = new SettingsTextBox("Name");
            nameTextBox.Visible = false;
            fix.Put(nameTextBox, 5, 40);

            moduleComboBox = new SettingsComboBox("Module");
            moduleComboBox.combo.nonActiveMessage   = "Please select module";
            moduleComboBox.combo.maxListHeight      = 6;
            moduleComboBox.combo.ComboChangedEvent += OnModuleComboChanged;
            moduleComboBox.Visible             = false;
            moduleComboBox.ButtonReleaseEvent += (o, args) => SwapTypeComboToTop();
            fix.Put(moduleComboBox, 5, 40);

            nameComboBox = new SettingsComboBox("Name");
            nameComboBox.combo.nonActiveMessage   = "Please select name";
            nameComboBox.combo.maxListHeight      = 3;
            nameComboBox.combo.ComboChangedEvent += OnModuleComboChanged;
            nameComboBox.Visible             = false;
            nameComboBox.ButtonReleaseEvent += (o, args) => SwapTypeComboToTop();
            fix.Put(nameComboBox, 5, 40);

            groupComboBox = new SettingsComboBox("Group");
            groupComboBox.combo.nonActiveMessage = "Please select group";
            groupComboBox.combo.maxListHeight    = 3;
            groupComboBox.Visible             = false;
            groupComboBox.ButtonReleaseEvent += (o, args) => SwapTypeComboToTop();
            fix.Put(groupComboBox, 305, 40);

            typeCombo = new TouchComboBox();
            typeCombo.comboList.Add("Line Plot");
            typeCombo.comboList.Add("Curved Bar Plot");
            typeCombo.comboList.Add("Button");
            typeCombo.comboList.Add("Timer");
            typeCombo.comboList.Add("Bar Plot");
            typeCombo.nonActiveMessage   = "Select type";
            typeCombo.WidthRequest       = 400;
            typeCombo.maxListHeight      = 6;
            typeCombo.ComboChangedEvent += OnTypeComboChanged;
            fix.Put(typeCombo, 195, 5);
            typeCombo.Show();

            Add(fix);
            fix.Show();
        }