Example #1
0
        public AlarmWindow(params object[] options) : base()
        {
            sceneTitle = "Current Alarms";

            var acknowledgeButton = new TouchButton();

            acknowledgeButton.SetSizeRequest(100, 60);
            acknowledgeButton.text                = "Acknowledge Alarms";
            acknowledgeButton.buttonColor         = "compl";
            acknowledgeButton.ButtonReleaseEvent += (o, args) => {
                Alarm.Acknowledge();
                Update();
            };

            tv = new TextView();
            tv.ModifyFont(Pango.FontDescription.FromString("Sans 11"));
            tv.ModifyBase(StateType.Normal, TouchColor.NewGtkColor("grey4"));
            tv.CanFocus = false;

            var sw = new ScrolledWindow();

            sw.SetSizeRequest(720, 340);
            sw.VScrollbar.WidthRequest  = 30;
            sw.HScrollbar.HeightRequest = 30;
            sw.Add(tv);
            Put(sw, 65, 60);
            sw.Show();
            tv.Show();

            if (options.Length >= 2)
            {
                var lastScreen = options[1] as string;
                if (lastScreen != null)
                {
                    var b = new TouchButton();
                    b.SetSizeRequest(100, 60);
                    b.text = "Back\n" + lastScreen;

                    b.ButtonReleaseEvent += (o, args) => {
                        AquaPicGui.AquaPicUserInterface.ChangeScreens(lastScreen, Toplevel, AquaPicGui.AquaPicUserInterface.currentScene);
                    };
                    Put(b, 575, 405);
                    b.Show();

                    Put(acknowledgeButton, 685, 405);
                }
                else
                {
                    Put(acknowledgeButton, 575, 405);
                }
            }
            acknowledgeButton.Show();

            Update();
            Show();
        }
 public ButtonWidget(string name, int row, int column) : base("Button", name, row, column)
 {
     button = new TouchButton();
     button.SetSizeRequest(100, 82);
     button.text                = name;
     button.buttonColor         = Bit.Instance.Check(button.text) ? "pri" : "seca";
     button.ButtonReleaseEvent += OnButtonRelease;
     Put(button, 0, 0);
     button.Show();
 }
        public AnalogOutputWindow(params object[] options) : base()
        {
            card = Driver.AnalogOutput.firstCard;
            if (card.IsNotEmpty())
            {
                sceneTitle = "Analog Output Cards";
            }
            else
            {
                sceneTitle = "No Analog Output Cards Added";
            }

            displays = new AnalogChannelDisplay[4];
            for (int i = 0; i < 4; ++i)
            {
                displays[i] = new AnalogChannelDisplay();
                displays[i].divisionSteps            = 1000;
                displays[i].typeLabel.Visible        = true;
                displays[i].ForceButtonReleaseEvent += OnForceRelease;
                displays[i].ValueChangedEvent       += OnValueChanged;
                Put(displays[i], 70, 90 + (i * 75));
                if (card.IsNotEmpty())
                {
                    displays[i].Show();
                }
                else
                {
                    displays[i].Visible = false;
                }
            }

            settingsButton = new TouchButton();
            settingsButton.SetSizeRequest(30, 30);
            settingsButton.buttonColor         = "grey4";
            settingsButton.text                = Convert.ToChar(0x2699).ToString();
            settingsButton.ButtonReleaseEvent += OnGlobalSettingsRelease;
            Put(settingsButton, 755, 35);
            settingsButton.Show();

            combo = new TouchComboBox(Driver.AnalogOutput.GetAllCardNames());
            combo.comboList.Add("New card...");
            if (card.IsNotEmpty())
            {
                combo.activeText = card;
            }
            combo.WidthRequest       = 200;
            combo.ComboChangedEvent += OnComboChanged;
            Put(combo, 550, 35);
            combo.Show();

            GetCardData();
            Show();
        }
Example #4
0
        public AnalogChannelDisplay()
        {
            SetSizeRequest(710, 50);

            label = new TouchLabel();
            label.WidthRequest = 490;
            Put(label, 5, 0);
            label.Show();

            textBox = new TouchTextBox();
            textBox.WidthRequest      = 175;
            textBox.TextChangedEvent += (sender, args) => {
                try {
                    currentValue = Convert.ToSingle(args.text);
                    ValueChanged();
                } catch {
                    ;
                }
            };
            Put(textBox, 0, 20);
            textBox.Show();

            progressBar = new TouchProgressBar(TouchOrientation.Horizontal);
            progressBar.WidthRequest          = 425;
            progressBar.ProgressChangedEvent += (sender, args) => {
                currentValue = args.currentProgress * divisionSteps;
                ValueChanged();
            };
            Put(progressBar, 185, 20);
            progressBar.Show();

            typeLabel               = new TouchLabel();
            typeLabel.Visible       = false;
            typeLabel.WidthRequest  = 200;
            typeLabel.textAlignment = TouchAlignment.Right;
            Put(typeLabel, 500, 0);

            forceButton = new TouchButton();
            forceButton.SetSizeRequest(85, 30);
            forceButton.buttonColor         = "grey4";
            forceButton.text                = "Force";
            forceButton.ButtonReleaseEvent += OnForceReleased;
            Put(forceButton, 620, 20);
            forceButton.Show();

            Show();
        }
        public SettingsWindow(params object[] options) : base()
        {
            sceneTitle = "Settings";

            if (options.Length >= 1)
            {
                topWindow = options[0] as AquaPicGui;
                if (topWindow != null)
                {
                    if (topWindow.IsTopLevel)
                    {
                        var b = new TouchButton();
                        b.SetSizeRequest(100, 60);
                        b.text = "Unfullscreen";
                        b.ButtonReleaseEvent += (o, args) => {
                            topWindow.ShowDecoration();
#if RPI_BUILD
                            topWindow.Unfullscreen();
#endif
                        };
                        Put(b, 685, 140);
                        b.Show();

                        b = new TouchButton();
                        b.SetSizeRequest(100, 60);
                        b.text = "Back";
                        b.ButtonReleaseEvent += (o, args) => AquaPicGui.AquaPicUserInterface.ChangeScreens("Home");
                        Put(b, 685, 210);
                        b.Show();
                    }
                    else
                    {
                        topWindow = null;
                    }
                }
            }

            var btn = new TouchButton();
            btn.SetSizeRequest(100, 60);
            btn.text = "Close";
            btn.ButtonReleaseEvent += OnCloseButtonRelease;
            Put(btn, 685, 70);
            btn.Show();

            Show();
        }
Example #6
0
        public MenuWindow(params object[] options) : base()
        {
            sceneTitle = "Menu";

            List <string> screenNames = new List <string> ();

            foreach (var screen in AquaPicGui.AquaPicUserInterface.scenes.Keys)
            {
                screenNames.Add(screen);
            }

            screenNames.Sort();

            int x = 60;
            int y = 80;

            foreach (var name in screenNames)
            {
                SceneData screen = AquaPicGui.AquaPicUserInterface.scenes[name];
                if (screen.showInMenu)
                {
                    var b = new TouchButton();
                    b.SetSizeRequest(220, 50);
                    b.text                = screen.name;
                    b.textColor           = "black";
                    b.ButtonReleaseEvent += OnButtonClick;
                    Put(b, x, y);

                    x += 230;
                    if (x >= 690)
                    {
                        x  = 60;
                        y += 60;
                    }
                }
            }

            ShowAll();
        }
        public DigitalDisplay()
        {
            SetSizeRequest(120, 140);

            label = new TouchLabel();
            label.WidthRequest        = 120;
            label.textAlignment       = TouchAlignment.Center;
            label.textRender.textWrap = TouchTextWrap.Shrink;
            label.textColor           = "grey3";
            Put(label, 0, 35);

            textBox               = new TouchLabel();
            textBox.text          = "Open";
            textBox.textColor     = "seca";
            textBox.textAlignment = TouchAlignment.Center;
            textBox.textSize      = 20;
            textBox.SetSizeRequest(120, 30);
            Put(textBox, 0, 0);

            button                     = new TouchButton();
            button.text                = "Force";
            button.buttonColor         = "grey3";
            button.ButtonReleaseEvent += OnForceReleased;
            button.SetSizeRequest(120, 30);
            Put(button, 0, 55);

            selector = new TouchSelectorSwitch(2);
            selector.SetSizeRequest(120, 30);
            selector.sliderSize            = MySliderSize.Large;
            selector.textOptions[0]        = "Open";
            selector.textOptions[1]        = "Closed";
            selector.sliderColorOptions[0] = "grey2";
            selector.sliderColorOptions[1] = "pri";
            selector.SelectorChangedEvent += OnSelectorChange;
            selector.Visible = false;
            Put(selector, 0, 90);

            Show();
        }
Example #8
0
        public LoggerWindow(params object[] options) : base()
        {
            sceneTitle = "Logger";

            TextTagTable ttt = new TextTagTable();

            buffer = new TextBuffer(ttt);

            var tag = new TextTag("DateTimeTag");

            tag.ForegroundGdk = TouchColor.NewGtkColor("seca");
            buffer.TagTable.Add(tag);

            tag = new TextTag("InfoTag");
            tag.ForegroundGdk = TouchColor.NewGtkColor("pri");
            buffer.TagTable.Add(tag);

            tag = new TextTag("WarningTag");
            tag.ForegroundGdk = TouchColor.NewGtkColor("secb");
            buffer.TagTable.Add(tag);

            tag = new TextTag("ErrorTag");
            tag.ForegroundGdk = TouchColor.NewGtkColor("compl");
            buffer.TagTable.Add(tag);

            foreach (var log in Logger.logs)
            {
                AddLogToBuffer(log);
            }

            tv = new TextView(buffer);
            tv.ModifyFont(Pango.FontDescription.FromString("Sans 11"));
            tv.ModifyBase(StateType.Normal, TouchColor.NewGtkColor("grey4"));
            tv.ModifyText(StateType.Normal, TouchColor.NewGtkColor("black"));
            tv.CanFocus = false;
            tv.Editable = false;

            ScrolledWindow sw = new ScrolledWindow();

            sw.SetSizeRequest(720, 340);
            sw.VScrollbar.WidthRequest  = 30;
            sw.HScrollbar.HeightRequest = 30;
            sw.Add(tv);
            Put(sw, 65, 60);
            sw.Show();
            tv.Show();

            var b = new TouchButton();

            b.SetSizeRequest(100, 60);
            b.text = "Clear Logger";
            b.ButtonReleaseEvent += OnClearButtonRelease;
            Put(b, 685, 405);

            b = new TouchButton();
            b.SetSizeRequest(100, 60);
            b.text = "Save Logger";
            b.ButtonReleaseEvent += (o, args) => SaveEvents();
            Put(b, 575, 405);

            Logger.EventAddedEvent += OnEventAdded;
            Show();
        }
        public DigitalInputWindow(params object[] options) : base()
        {
            card = Driver.DigitalInput.firstCard;
            if (card.IsNotEmpty())
            {
                sceneTitle = "Digital Inputs Cards";
            }
            else
            {
                sceneTitle = "No Digital Input Cards Added";
            }

            displays = new DigitalDisplay[6];

            for (int i = 0; i < 6; ++i)
            {
                displays[i] = new DigitalDisplay();
                displays[i].ForceButtonReleaseEvent   += OnForceRelease;
                displays[i].StateSelectedChangedEvent += OnSelectorChanged;
                int x, y;
                if (i < 3)
                {
                    x = (i * 150) + 175;
                    y = 125;
                }
                else
                {
                    x = ((i - 3) * 150) + 175;
                    y = 275;
                }
                Put(displays[i], x, y);
                if (card.IsNotEmpty())
                {
                    displays[i].Show();
                }
                else
                {
                    displays[i].Visible = false;
                }
            }

            settingsButton = new TouchButton();
            settingsButton.SetSizeRequest(30, 30);
            settingsButton.buttonColor         = "grey4";
            settingsButton.text                = Convert.ToChar(0x2699).ToString();
            settingsButton.ButtonReleaseEvent += OnGlobalSettingsRelease;
            Put(settingsButton, 755, 35);
            settingsButton.Show();

            combo = new TouchComboBox(Driver.DigitalInput.GetAllCardNames());
            combo.comboList.Add("New card...");
            if (card.IsNotEmpty())
            {
                combo.activeText = card;
            }
            combo.WidthRequest       = 200;
            combo.ComboChangedEvent += OnComboChanged;
            Put(combo, 550, 35);
            combo.Show();

            GetCardData();
            Show();
        }
Example #10
0
        public LightingWindow(params object[] options) : base(false)
        {
            sceneTitle = "Lighting";

            fixtureName = Devices.Lighting.defaultGadget;
            if (fixtureName.IsNotEmpty())
            {
                dimmingIsManual = false;
            }

            if (options.Length >= 3)
            {
                string requestedFixture = options[2] as string;
                if (requestedFixture != null)
                {
                    if (Devices.Lighting.CheckGadgetKeyNoThrow(requestedFixture))
                    {
                        fixtureName = requestedFixture;
                    }
                }
            }

            outletSelectorSwitch = new TouchSelectorSwitch(3);
            outletSelectorSwitch.WidthRequest                = 180;
            outletSelectorSwitch.sliderColorOptions[1]       = "pri";
            outletSelectorSwitch.selectedTextColorOptions[1] = "black";
            outletSelectorSwitch.sliderColorOptions[2]       = "seca";
            outletSelectorSwitch.textOptions           = new string[] { "Off", "Auto", "On" };
            outletSelectorSwitch.SelectorChangedEvent += OnOutletControlSelectorChanged;
            Put(outletSelectorSwitch, 605, 77);
            outletSelectorSwitch.Show();

            outletStateLabel = new TouchLabel();
            outletStateLabel.textAlignment = TouchAlignment.Center;
            outletStateLabel.WidthRequest  = 180;
            outletStateLabel.textSize      = 14;
            Put(outletStateLabel, 605, 110);
            outletStateLabel.Show();

            dimmingHeader = new TouchLabel();
            dimmingHeader.textAlignment = TouchAlignment.Center;
            dimmingHeader.WidthRequest  = 180;
            dimmingHeader.text          = "Dimming Control";
            Put(dimmingHeader, 605, 148);
            dimmingHeader.Show();

            modeSelector = new TouchSelectorSwitch();
            modeSelector.SetSizeRequest(140, 30);
            modeSelector.sliderColorOptions[1]       = "pri";
            modeSelector.selectedTextColorOptions[1] = "black";
            modeSelector.textOptions           = new string[] { "Manual", "Auto" };
            modeSelector.SelectorChangedEvent += OnDimmingModeSelectorChanged;
            Put(modeSelector, 605, 173);
            modeSelector.Show();

            dimmingProgressBar = new TouchLayeredProgressBar();
            dimmingProgressBar.colorProgress          = "seca";
            dimmingProgressBar.colorProgressSecondary = "pri";
            dimmingProgressBar.drawPrimaryWhenEqual   = false;
            dimmingProgressBar.ProgressChangedEvent  += OnProgressChanged;
            dimmingProgressBar.ProgressChangingEvent += OnProgressChanging;
            dimmingProgressBar.HeightRequest          = 280;
            Put(dimmingProgressBar, 755, 173);
            dimmingProgressBar.Show();

            actualTextBox = new TouchLabel();
            actualTextBox.WidthRequest  = 140;
            actualTextBox.textSize      = 20;
            actualTextBox.textColor     = "pri";
            actualTextBox.textAlignment = TouchAlignment.Center;
            actualTextBox.textRender.unitOfMeasurement = UnitsOfMeasurement.Percentage;
            Put(actualTextBox, 605, 209);
            actualTextBox.Show();

            actualLabel = new TouchLabel();
            actualLabel.WidthRequest  = 140;
            actualLabel.text          = "Current";
            actualLabel.textColor     = "grey3";
            actualLabel.textAlignment = TouchAlignment.Center;
            Put(actualLabel, 605, 244);
            actualLabel.Show();

            requestedLabel = new TouchLabel();
            requestedLabel.WidthRequest  = 140;
            requestedLabel.textSize      = 20;
            requestedLabel.textColor     = "seca";
            requestedLabel.textAlignment = TouchAlignment.Center;
            requestedLabel.textRender.unitOfMeasurement = UnitsOfMeasurement.Percentage;
            Put(requestedLabel, 605, 272);
            requestedLabel.Show();

            requestedTextBox                   = new TouchTextBox();
            requestedTextBox.enableTouch       = true;
            requestedTextBox.TextChangedEvent += (sender, args) => {
                try {
                    float newLevel = Convert.ToSingle(args.text);
                    if (newLevel < 0.0f)
                    {
                        newLevel = 0.0f;
                    }
                    if (newLevel > 100.0f)
                    {
                        newLevel = 100.0f;
                    }
                    Devices.Lighting.SetDimmingLevel(fixtureName, newLevel);
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    args.keepText = false;
                }
            };
            requestedTextBox.SetSizeRequest(110, 36);
            requestedTextBox.textSize      = 20;
            requestedTextBox.textColor     = "seca";
            requestedTextBox.textAlignment = TouchAlignment.Center;
            requestedTextBox.textRender.unitOfMeasurement = UnitsOfMeasurement.Percentage;
            requestedTextBox.Visible = false;
            Put(requestedTextBox, 620, 272);
            requestedTextBox.Show();

            requestedTextLabel = new TouchLabel();
            requestedTextLabel.WidthRequest  = 140;
            requestedTextLabel.text          = "Requested";
            requestedTextLabel.textColor     = "grey3";
            requestedTextLabel.textAlignment = TouchAlignment.Center;
            Put(requestedTextLabel, 605, 307);
            requestedTextLabel.Show();

            autoTextBox = new TouchLabel();
            autoTextBox.WidthRequest  = 140;
            autoTextBox.Visible       = false;
            autoTextBox.textSize      = 20;
            autoTextBox.textColor     = "grey4";
            autoTextBox.textAlignment = TouchAlignment.Center;
            autoTextBox.textRender.unitOfMeasurement = UnitsOfMeasurement.Percentage;
            Put(autoTextBox, 605, 335);
            autoTextBox.Show();

            autoLabel = new TouchLabel();
            autoLabel.WidthRequest  = 140;
            autoLabel.Visible       = false;
            autoLabel.text          = "Auto";
            autoLabel.textColor     = "grey3";
            autoLabel.textAlignment = TouchAlignment.Center;
            Put(autoLabel, 605, 370);
            autoLabel.Show();

            fixtureSettingBtn      = new TouchButton();
            fixtureSettingBtn.text = Convert.ToChar(0x2699).ToString();
            fixtureSettingBtn.SetSizeRequest(30, 30);
            fixtureSettingBtn.buttonColor         = "pri";
            fixtureSettingBtn.ButtonReleaseEvent += OnFixtureSettingsButtonReleased;
            Put(fixtureSettingBtn, 755, 35);
            fixtureSettingBtn.Show();

            lightingStateWidget = new LightingStateWidget();
            Put(lightingStateWidget, 55, 77);
            lightingStateWidget.Show();

            combo = new TouchComboBox(Devices.Lighting.GetAllGadgetNames());
            combo.comboList.Add("New fixture...");
            combo.activeIndex        = 0;
            combo.WidthRequest       = 250;
            combo.ComboChangedEvent += OnComboChanged;
            Put(combo, 500, 35);
            combo.Show();

            if (fixtureName.IsNotEmpty())
            {
                combo.activeText = fixtureName;
            }
            else
            {
                combo.activeIndex = 0;
            }

            outletSubscriber = new OutputChannelValueSubscriber(OnValueChanged);

            GetFixtureData();
            lightingStateWidget.SetStates(fixtureName);
            Show();
        }
Example #11
0
        public CalibrationDialog(
            string name,
            Window parent,
            GetCalibrationValueHandler GetCalibrationValue,
            CalibrationState startingState = CalibrationState.ZeroValue)
            : base(name + " Calibration", parent, DialogFlags.DestroyWithParent)
        {
            Name           = "AquaPic.Calibration." + name;
            WindowPosition = (WindowPosition)4;
            SetSizeRequest(600, 300);
#if RPI_BUILD
            Decorated = false;

            ExposeEvent += (o, args) => {
                using (Context 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 (var w in Children)
            {
                Remove(w);
                w.Destroy();
            }

            ExposeEvent += OnExpose;

            this.GetCalibrationValue = GetCalibrationValue;
            if ((startingState == CalibrationState.ZeroActual) || (startingState == CalibrationState.ZeroValue))
            {
                calState = startingState;
            }
            else
            {
                calState = CalibrationState.ZeroValue;
            }
            calArgs = new CalibrationArguments();
            forced  = false;
            init    = false;

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

            tv = new TextView();
            tv.ModifyFont(Pango.FontDescription.FromString("Sans 11"));
            tv.ModifyBase(StateType.Normal, TouchColor.NewGtkColor("grey4"));
            tv.ModifyText(StateType.Normal, TouchColor.NewGtkColor("black"));
            tv.CanFocus = false;
            tv.Editable = false;

            ScrolledWindow sw = new ScrolledWindow();
            sw.SetSizeRequest(580, 225);
            sw.Add(tv);
            tv.Show();
            fix.Put(sw, 10, 25);
            sw.Show();

            var l = new TouchLabel();
            l.text          = name;
            l.WidthRequest  = 600;
            l.textAlignment = TouchAlignment.Center;
            fix.Put(l, 0, 3);
            l.Show();

            valTb = new TouchTextBox();
            valTb.SetSizeRequest(110, 30);
            valTb.textAlignment   = TouchAlignment.Center;
            valTb.backgroundColor = "grey1";
            if (calState == CalibrationState.ZeroActual)
            {
                valTb.text              = "Enter Actual";
                valTb.enableTouch       = true;
                valTb.backgroundColor   = "grey4";
                valTb.TextChangedEvent += OnValueTextBoxTextChanged;
            }
            else
            {
                valTb.text = GetCalibrationValue().ToString("F2");
            }
            fix.Put(valTb, 10, 260);
            valTb.Show();

            actionBtn = new TouchButton();
            actionBtn.SetSizeRequest(150, 30);
            if (calState == CalibrationState.ZeroActual)
            {
                actionBtn.text = "Zero Actual";
            }
            else
            {
                actionBtn.text = "Zero Value";
            }
            actionBtn.ButtonReleaseEvent += OnActionButtonReleaseEvent;
            fix.Put(actionBtn, 440, 260);
            actionBtn.Show();

            var cancelBtn = new TouchButton();
            cancelBtn.SetSizeRequest(100, 30);
            cancelBtn.text                = "Cancel";
            cancelBtn.buttonColor         = "compl";
            cancelBtn.ButtonReleaseEvent += (o, args) => Destroy();
            fix.Put(cancelBtn, 335, 260);
            cancelBtn.Show();

            skipBtn = new TouchButton();
            skipBtn.SetSizeRequest(100, 30);
            skipBtn.text                = "Skip";
            skipBtn.buttonColor         = "seca";
            skipBtn.ButtonReleaseEvent += OnSkipButtonReleaseEvent;
            fix.Put(skipBtn, 230, 260);
            skipBtn.Show();

            var forceBtn = new TouchButton();
            forceBtn.SetSizeRequest(100, 30);
            forceBtn.text                = "Force";
            forceBtn.buttonColor         = "grey3";
            forceBtn.ButtonReleaseEvent += OnForceButtonReleaseEvent;
            fix.Put(forceBtn, 125, 260);
            forceBtn.Show();

            Add(fix);
            fix.Show();

            timerId = GLib.Timeout.Add(1000, OnUpdateTimer);
        }
Example #12
0
        public ChemistryWindow(params object[] options) : base(false)
        {
            sceneTitle = "Chemistry";

            string path = System.IO.Path.Combine(Utils.AquaPicEnvironment, "TestProcedures");

            var d = new DirectoryInfo(path);

            FileInfo[] files = d.GetFiles("*.json");

            testIdx = -1;
            tests   = new List <TestProcedure> ();
            foreach (var file in files)
            {
                try {
                    tests.Add(new TestProcedure(file.FullName));
                } catch (Exception ex) {
                    Logger.AddError(ex.ToString());
                }
            }

            timerProgress = new TouchCurvedProgressBar(
                new TouchColor("grey3"),
                new TouchColor("pri"),
                100.0f);
            timerProgress.SetSizeRequest(250, 175);
            timerProgress.curveStyle = CurveStyle.ThreeQuarterCurve;
            Put(timerProgress, 275, 100);
            timerProgress.Visible = false;

            timerLabel = new TouchLabel();
            timerLabel.WidthRequest  = 200;
            timerLabel.textAlignment = TouchAlignment.Center;
            timerLabel.textSize      = 20;
            Put(timerLabel, 300, 240);
            timerLabel.Visible = false;

            stepButton = new TouchButton();
            stepButton.SetSizeRequest(200, 50);
            stepButton.buttonColor         = "grey2";
            stepButton.text                = "N/A";
            stepButton.ButtonReleaseEvent += OnStepButtonReleased;
            Put(stepButton, 300, 365);
            stepButton.Show();

            resetBtn = new TouchButton();
            resetBtn.SetSizeRequest(200, 50);
            resetBtn.text = "Restart";
            resetBtn.ButtonReleaseEvent += OnResetButtonReleased;
            Put(resetBtn, 510, 365);
            resetBtn.Visible = false;

            skipBtn = new TouchButton();
            skipBtn.SetSizeRequest(200, 50);
            skipBtn.text                = "Skip";
            skipBtn.buttonColor         = "seca";
            skipBtn.ButtonReleaseEvent += OnSkipButtonReleased;
            Put(skipBtn, 90, 365);
            skipBtn.Visible = false;

            nameLabel = new TouchLabel();
            nameLabel.WidthRequest  = 700;
            nameLabel.textSize      = 14;
            nameLabel.textColor     = "seca";
            nameLabel.textAlignment = TouchAlignment.Center;
            Put(nameLabel, 50, 65);
            nameLabel.Show();

            stepLabel = new TouchTextBox();
            stepLabel.SetSizeRequest(620, 75);
            stepLabel.textAlignment = TouchAlignment.Center;
            stepLabel.text          = "Please select a test procedure";
            Put(stepLabel, 90, 280);
            stepLabel.Show();

            actionLabel = new TouchLabel();
            actionLabel.WidthRequest  = 200;
            actionLabel.textAlignment = TouchAlignment.Right;
            Put(actionLabel, 510, 420);
            actionLabel.Show();

            combo = new TouchComboBox();
            foreach (var test in tests)
            {
                combo.comboList.Add(test.name);
            }
            combo.nonActiveMessage   = "Select test";
            combo.WidthRequest       = 235;
            combo.ComboChangedEvent += OnComboChanged;
            Put(combo, 550, 35);
            combo.Show();

            CanFocus       = true;
            KeyPressEvent += EntryKeyPressEvent;

            ExposeEvent += (o, args) => {
                GrabFocus();
            };

            Show();
        }
        public EditPluginWindow(params object[] options) : base()
        {
            var box = new MyBox(780, 395);

            Put(box, 10, 30);

            var backButton = new TouchButton();

            backButton.text = "back";
            backButton.SetSizeRequest(100, 40);
            backButton.ButtonReleaseEvent += (o, args) => GuiGlobal.ChangeScreens("Plugins");
            Put(backButton, 15, 380);

            var label = new TouchLabel();

            label.textSize      = 13;
            label.WidthRequest  = 780;
            label.textAlignment = MyAlignment.Center;

            tv = new TextView();
            tv.ModifyFont(Pango.FontDescription.FromString("Sans 11"));
            tv.ModifyText(StateType.Normal, MyColor.NewGtkColor("black"));
            tv.ModifyBase(StateType.Normal, MyColor.NewGtkColor("grey4"));
            tv.CanFocus = false;

            ScrolledWindow sw = new ScrolledWindow();

            sw.SetSizeRequest(770, 315);
            sw.Add(tv);
            Put(sw, 15, 60);

            BaseScript script = null;

            foreach (var opt in options)
            {
                script = opt as BaseScript;

                if (script != null)
                {
                    label.text      = script.name;
                    label.textColor = "pri";

                    DisplayErrors(script);

                    var b = new TouchButton();
                    b.SetSizeRequest(100, 40);
                    b.text = "Recompile and Load";
                    b.ButtonReleaseEvent += (o, args) => {
                        if (script.errors.Count != 0)
                        {
                            script.CompileAndLoad();
                            if (script.flags.HasFlag(ScriptFlags.Initializer))
                            {
                                script.RunInitialize();
                            }
                            DisplayErrors(script);
                            tv.QueueDraw();
                        }
                        else
                        {
                            MessageBox.Show("Script is already running.\nCannot recomile and load");
                        }
                    };
                    Put(b, 685, 380);

                    break;
                }
            }

            if (script == null)
            {
                label.text      = "No Plugin Selected";
                label.textColor = "secb";

                backButton.text = "Select Plugin";
            }

            Put(label, 10, 35);

            ShowAll();
        }
        public AnalogSensorWidget(
            string sensorTypeLabel,
            GenericAnalogSensorCollection sensorCollection,
            GenericAnalogInputBase analogInputDriver,
            Type settingsType
            )
        {
            this.sensorCollection  = sensorCollection;
            this.analogInputDriver = analogInputDriver;
            if (!settingsType.TypeIs(typeof(GenericAnalogSensorSettings)))
            {
                throw new ArgumentException("The settings type must derive GenericAnalogSensorSettings", nameof(settingsType));
            }
            this.settingsType = settingsType;

            SetSizeRequest(370, 188);

            var label = new TouchLabel();

            label.text      = sensorTypeLabel;
            label.textColor = "seca";
            label.textSize  = 12;
            Put(label, 0, 3);
            label.Show();

            var sensorSettingsButton = new TouchButton();

            sensorSettingsButton.text = "\u2699";
            sensorSettingsButton.SetSizeRequest(30, 30);
            sensorSettingsButton.buttonColor         = "pri";
            sensorSettingsButton.ButtonReleaseEvent += OnSensorSettingsButtonReleaseEvent;
            Put(sensorSettingsButton, 340, 0);
            sensorSettingsButton.Show();

            var b = new TouchButton();

            b.text = "Calibrate";
            b.SetSizeRequest(100, 60);
            b.ButtonReleaseEvent += OnCalibrationButtonReleaseEvent;
            Put(b, 0, 118);
            b.Show();

            sensorLabel               = new TouchLabel();
            sensorLabel.text          = sensorTypeLabel;
            sensorLabel.textAlignment = TouchAlignment.Center;
            sensorLabel.textColor     = "grey3";
            sensorLabel.WidthRequest  = 370;
            Put(sensorLabel, 0, 78);
            sensorLabel.Show();

            sensorStateTextbox = new TouchLabel();
            sensorStateTextbox.WidthRequest  = 370;
            sensorStateTextbox.textSize      = 20;
            sensorStateTextbox.textAlignment = TouchAlignment.Center;
            sensorStateTextbox.textRender.unitOfMeasurement = UnitsOfMeasurement.None;
            Put(sensorStateTextbox, 0, 43);
            sensorStateTextbox.Show();

            sensorCombo = new TouchComboBox();
            sensorCombo.WidthRequest = 200;
            var allSensors = sensorCollection.GetAllGadgetNames();

            if (allSensors.Length > 0)
            {
                sensorCombo.comboList.AddRange(allSensors);
                sensorName = allSensors[0];
            }
            else
            {
                sensorName = string.Empty;
            }
            sensorCombo.comboList.Add("New sensor...");
            sensorCombo.activeIndex        = 0;
            sensorCombo.ComboChangedEvent += OnSensorComboChanged;
            Put(sensorCombo, 135, 0);
            sensorCombo.Show();

            GetSensorData();

            Show();
        }
Example #15
0
        public SerialBusWindow(params object[] options) : base()
        {
            sceneTitle = "AquaPic Bus";

            var l = new TouchLabel();

            l.text          = "Name";
            l.textAlignment = TouchAlignment.Center;
            l.WidthRequest  = 235;
            Put(l, 60, 121);
            l.Show();

            l               = new TouchLabel();
            l.text          = "Address";
            l.textAlignment = TouchAlignment.Center;
            l.WidthRequest  = 75;
            Put(l, 303, 121);
            l.Show();

            l               = new TouchLabel();
            l.text          = "Status";
            l.textAlignment = TouchAlignment.Center;
            l.WidthRequest  = 295;
            Put(l, 380, 121);
            l.Show();

            l               = new TouchLabel();
            l.text          = "Response Time";
            l.textAlignment = TouchAlignment.Right;
            l.WidthRequest  = 170;
            Put(l, 605, 121);
            l.Show();

            slaves = new SerialBusSlaveWidget[AquaPicBus.slaveCount];
            string[] names     = AquaPicBus.slaveNames;
            int[]    addresses = AquaPicBus.slaveAdresses;

            for (int i = 0; i < slaves.Length; ++i)
            {
                slaves[i]         = new SerialBusSlaveWidget();
                slaves[i].name    = names[i];
                slaves[i].address = addresses[i];
                Put(slaves[i], 65, (i * 35) + 143);
                slaves[i].Show();
            }

            if (AquaPicBus.slaveCount == 0)
            {
                var blankWidget = new SerialBusSlaveWidget();
                Put(blankWidget, 65, 143);
                blankWidget.Show();
            }

            var b = new TouchButton();

            b.SetSizeRequest(100, 30);
            b.text = "Open";
            if (AquaPicBus.isOpen)
            {
                b.buttonColor = "grey3";
            }
            else
            {
                b.ButtonReleaseEvent += OnOpenButtonRelease;
            }
            Put(b, 685, 70);
            b.Show();

            c = new TouchComboBox();
            if (!AquaPicBus.isOpen)
            {
                string[] portNames = SerialPort.GetPortNames();
                if (Utils.ExecutingOperatingSystem == Platform.Linux)
                {
                    var sortedPortNames = new List <string> ();
                    foreach (var name in portNames)
                    {
                        if (name.Contains("USB"))
                        {
                            sortedPortNames.Add(name);
                        }
                    }
                    portNames = sortedPortNames.ToArray();
                }
                c.comboList.AddRange(portNames);
                c.nonActiveMessage = "Select Port";
            }
            else
            {
                c.comboList.Add(AquaPicBus.portName);
                c.activeText = AquaPicBus.portName;
            }
            c.WidthRequest = 300;
            Put(c, 380, 70);
            c.Show();

            GetSlaveData();
            Show();
        }
Example #16
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();
        }
Example #17
0
        public DeluxeTimerWidget(string name, int row, int column) : base("Timer", name, row, column)
        {
            timerIndex = 0;

            SetSizeRequest(310, 169);

            timers = new IntervalTimer[3];
            for (int i = 0; i < timers.Length; ++i)
            {
                timers[i] = IntervalTimer.GetTimer("Timer " + name + " " + (i + 1).ToString());
                timers[i].TimerInterumEvent += OnTimerInterum;
                timers[i].TimerElapsedEvent += OnTimerElapsed;
                timers[i].TimerStartEvent   += OnTimerStartStop;
                timers[i].TimerStopEvent    += OnTimerStartStop;
            }

            var box2 = new TimerBackground(310, 139);

            box2.color        = "grey4";
            box2.transparency = 0.1f;
            Put(box2, 0, 30);

            tabs = new TimerTab[3];
            for (int i = 2; i >= 0; --i)
            {
                tabs[i]      = new TimerTab(i);
                tabs[i].text = "Timer " + (i + 1).ToString();
                tabs[i].ButtonReleaseEvent += OnTabButtonRelease;
                Put(tabs[i], 90 * i, 0);
                tabs[i].Show();
            }

            tabs[0].selected = true;

            var minuteLabel = new TouchLabel();

            minuteLabel.text      = "Minutes";
            minuteLabel.textColor = "grey3";
            Put(minuteLabel, 5, 37);
            minuteLabel.Show();

            minutes = new TouchTextBox();
            minutes.SetSizeRequest(99, 51);
            minutes.enableTouch       = true;
            minutes.textSize          = 16;
            minutes.textAlignment     = TouchAlignment.Center;
            minutes.TextChangedEvent += (sender, args) => {
                try {
                    uint time = Convert.ToUInt32(args.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    UpdateTime(time);
                } catch {
                    args.keepText = false;
                }
            };
            Put(minutes, 3, 57);

            minUpDown = new TouchUpDownButtons();
            minUpDown.up.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = (Convert.ToUInt32(minutes.text) + 1) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    UpdateTime(time);
                }
            };
            minUpDown.down.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    if (minutes.text != "0")
                    {
                        uint time = (Convert.ToUInt32(minutes.text) - 1) * 60;
                        time += Convert.ToUInt32(seconds.text);
                        UpdateTime(time);
                    }
                }
            };
            Put(minUpDown, 3, 113);
            minUpDown.Show();

            var secondsLabel = new TouchLabel();

            secondsLabel.text      = "Seconds";
            secondsLabel.textColor = "grey3";
            Put(secondsLabel, 108, 37);
            secondsLabel.Show();

            seconds = new TouchTextBox();
            seconds.SetSizeRequest(98, 51);
            seconds.enableTouch       = true;
            seconds.textAlignment     = TouchAlignment.Center;
            seconds.textSize          = 16;
            seconds.TextChangedEvent += (sender, args) => {
                try {
                    uint time = Convert.ToUInt32(args.text);

                    if (time < 60)
                    {
                        time += Convert.ToUInt32(minutes.text) * 60;
                    }

                    UpdateTime(time);
                } catch {
                    args.keepText = false;
                }
            };
            Put(seconds, 106, 57);

            secUpDown = new TouchUpDownButtons();
            secUpDown.up.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = Convert.ToUInt32(minutes.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    ++time;
                    UpdateTime(time);
                }
            };
            secUpDown.down.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = Convert.ToUInt32(minutes.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    if (time != 0)
                    {
                        --time;
                        UpdateTime(time);
                    }
                }
            };
            Put(secUpDown, 106, 113);
            secUpDown.Show();

            startStopButton = new TouchButton();
            startStopButton.SetSizeRequest(98, 51);
            startStopButton.ButtonReleaseEvent += OnStartStopButtonRelease;
            Put(startStopButton, 209, 57);
            startStopButton.Show();

            resetButton = new TouchButton();
            resetButton.SetSizeRequest(98, 51);
            resetButton.text = "Reset";
            resetButton.ButtonReleaseEvent += OnResetButtonRelease;
            Put(resetButton, 209, 113);
            resetButton.Show();

            if (timers[timerIndex].enabled)
            {
                UpdateTime(timers[timerIndex].secondsRemaining, false);
            }
            else
            {
                UpdateTime(timers[timerIndex].totalSeconds, false);
            }
        }
        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();
        }
Example #19
0
        public TemperatureWindow(params object[] options)
        {
            sceneTitle = "Temperature";

            ExposeEvent += OnExpose;

            /******************************************************************************************************/
            /* Temperature Groups                                                                                 */
            /******************************************************************************************************/
            groupName = Temperature.defaultTemperatureGroup;

            if (options.Length >= 3)
            {
                var requestedGroup = options[2] as string;
                if (requestedGroup != null)
                {
                    if (Temperature.TemperatureGroupNameExists(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, 30, 80);
            label.Show();

            var tempLabel = new TouchLabel();

            tempLabel.WidthRequest  = 329;
            tempLabel.text          = "Temperature";
            tempLabel.textColor     = "grey3";
            tempLabel.textAlignment = TouchAlignment.Center;
            Put(tempLabel, 60, 185);
            tempLabel.Show();

            tempTextBox = new TouchLabel();
            tempTextBox.SetSizeRequest(329, 50);
            tempTextBox.textSize      = 36;
            tempTextBox.textAlignment = TouchAlignment.Center;
            tempTextBox.textRender.unitOfMeasurement = UnitsOfMeasurement.Degrees;
            Put(tempTextBox, 60, 130);
            tempTextBox.Show();

            var setpointlabel = new TouchLabel();

            setpointlabel.WidthRequest  = 116;
            setpointlabel.text          = "Setpoint";
            setpointlabel.textColor     = "grey3";
            setpointlabel.textAlignment = TouchAlignment.Center;
            Put(setpointlabel, 108, 260);
            setpointlabel.Show();

            tempSetpoint = new TouchLabel();
            tempSetpoint.SetSizeRequest(116, 30);
            tempSetpoint.textSize      = 20;
            tempSetpoint.textAlignment = TouchAlignment.Center;
            tempSetpoint.textRender.unitOfMeasurement = UnitsOfMeasurement.Degrees;
            Put(tempSetpoint, 108, 225);
            tempSetpoint.Show();

            var tempDeadbandLabel = new TouchLabel();

            tempDeadbandLabel.WidthRequest  = 116;
            tempDeadbandLabel.text          = "Deadband";
            tempDeadbandLabel.textColor     = "grey3";
            tempDeadbandLabel.textAlignment = TouchAlignment.Center;
            Put(tempDeadbandLabel, 224, 260);
            tempDeadbandLabel.Show();

            tempDeadband = new TouchLabel();
            tempDeadband.SetSizeRequest(116, 30);
            tempDeadband.textSize      = 20;
            tempDeadband.textAlignment = TouchAlignment.Center;
            tempDeadband.textRender.unitOfMeasurement = UnitsOfMeasurement.Degrees;
            Put(tempDeadband, 224, 225);
            tempDeadband.Show();

            var globalSettingsBtn = new TouchButton();

            globalSettingsBtn.text = Convert.ToChar(0x2699).ToString();
            globalSettingsBtn.SetSizeRequest(30, 30);
            globalSettingsBtn.buttonColor         = "pri";
            globalSettingsBtn.ButtonReleaseEvent += OnTemperatureGroupSettingsButtonReleaseEvent;
            Put(globalSettingsBtn, 358, 77);
            globalSettingsBtn.Show();

            /******************************************************************************************************/
            /* Heaters                                                                                            */
            /******************************************************************************************************/
            label           = new TouchLabel();
            label.text      = "Heaters";
            label.textColor = "seca";
            label.textSize  = 12;
            Put(label, 415, 80);
            label.Show();

            heaterLabel = new TouchLabel();
            heaterLabel.textAlignment = TouchAlignment.Center;
            heaterLabel.WidthRequest  = 370;
            heaterLabel.textColor     = "secb";
            heaterLabel.textSize      = 20;
            Put(heaterLabel, 415, 120);
            heaterLabel.Show();

            var heaterSetupBtn = new TouchButton();

            heaterSetupBtn.text = Convert.ToChar(0x2699).ToString();
            heaterSetupBtn.SetSizeRequest(30, 30);
            heaterSetupBtn.buttonColor         = "pri";
            heaterSetupBtn.ButtonReleaseEvent += OnHeaterSettingsButtonReleaseEvent;
            Put(heaterSetupBtn, 755, 77);
            heaterSetupBtn.Show();

            /******************************************************************************************************/
            /* Temperature Probes                                                                                 */
            /******************************************************************************************************/
            probeWidget = new TemperatureProbeWidget();
            Put(probeWidget, 415, 277);
            probeWidget.Show();

            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 = new TouchComboBox();
            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.WidthRequest = 200;
            heaterCombo.comboList.Add("New heater...");
            heaterCombo.ComboChangedEvent += OnHeaterComboChanged;
            Put(heaterCombo, 550, 77);
            heaterCombo.Show();

            if (heaterName.IsNotEmpty())
            {
                heaterCombo.activeText = heaterName;
            }
            else
            {
                heaterCombo.activeIndex = 0;
            }

            groupCombo = new TouchComboBox(Temperature.GetAllTemperatureGroupNames());
            groupCombo.WidthRequest = 200;
            groupCombo.comboList.Add("New group...");
            groupCombo.ComboChangedEvent += OnGroupComboChanged;
            Put(groupCombo, 153, 77);
            groupCombo.Show();

            if (groupName.IsNotEmpty())
            {
                groupCombo.activeText = groupName;
            }
            else
            {
                groupCombo.activeIndex = 0;
            }

            GetHeaterData();
            probeWidget.GetSensorData();
            GetGroupData();

            Show();
        }
        public LightingStateWidget()
        {
            SetSizeRequest(540, 380);

            lightingStateDisplay = new LightingStateDisplay();
            lightingStateDisplay.SetSizeRequest(540, 380);
            lightingStateDisplay.LightingStateSelectionChanged += (obj, args) => {
                if (args.stateSelected)
                {
                    adjustDimmingTogetherSelector.Visible = true;
                    adjustDimmingTogetherLabel.Visible    = true;
                    deleteStateButton.Visible             = true;
                }
                else
                {
                    adjustDimmingTogetherSelector.Visible = false;
                    adjustDimmingTogetherLabel.Visible    = false;
                    deleteStateButton.Visible             = false;
                }
            };
            lightingStateDisplay.LightingStateInfoChanged += (obj, hasChanged) => {
                if (hasChanged)
                {
                    acceptChangesButton.buttonColor = "pri";
                    undoChangesButton.buttonColor   = "pri";
                }
                else
                {
                    acceptChangesButton.buttonColor = "grey1";
                    undoChangesButton.buttonColor   = "grey1";
                }
                acceptChangesButton.QueueDraw();
                undoChangesButton.QueueDraw();
            };
            Put(lightingStateDisplay, 0, 0);
            lightingStateDisplay.Show();

            adjustDimmingTogetherSelector = new TouchSelectorSwitch();
            adjustDimmingTogetherSelector.SetSizeRequest(180, 30);
            adjustDimmingTogetherSelector.sliderSize                  = MySliderSize.Large;
            adjustDimmingTogetherSelector.textOptions[0]              = "Separate";
            adjustDimmingTogetherSelector.textOptions[1]              = "Together";
            adjustDimmingTogetherSelector.sliderColorOptions[1]       = "pri";
            adjustDimmingTogetherSelector.selectedTextColorOptions[1] = "black";
            adjustDimmingTogetherSelector.currentSelected             = 1;
            adjustDimmingTogetherSelector.SelectorChangedEvent       += (obj, args) => {
                lightingStateDisplay.adjustDimmingTogether = args.currentSelectedIndex == 1;
            };
            Put(adjustDimmingTogetherSelector, 0, 350);

            adjustDimmingTogetherLabel               = new TouchLabel();
            adjustDimmingTogetherLabel.text          = "Adjust Dimming";
            adjustDimmingTogetherLabel.WidthRequest  = 180;
            adjustDimmingTogetherLabel.textAlignment = TouchAlignment.Center;
            Put(adjustDimmingTogetherLabel, 0, 328);

            acceptChangesButton             = new TouchButton();
            acceptChangesButton.text        = "Accept";
            acceptChangesButton.buttonColor = "grey1";
            acceptChangesButton.SetSizeRequest(80, 40);
            acceptChangesButton.ButtonReleaseEvent += (obj, args) => {
                if (lightingStateDisplay.hasStateInfoChanged)
                {
                    var parent = Toplevel as Window;
                    var ms     = new TouchDialog("Do you want to make the changes permanent", parent, new string[] { "Yes", "No", "Cancel" });
                    ms.Response += (o, a) => {
                        if (a.ResponseId != ResponseType.Cancel)
                        {
                            var makeChangePermanant = a.ResponseId == ResponseType.Yes;

                            Devices.Lighting.SetLightingFixtureLightingStates(
                                fixtureName,
                                lightingStateDisplay.lightingStates,
                                !makeChangePermanant);

                            lightingStateDisplay.selectedState       = -1;
                            lightingStateDisplay.hasStateInfoChanged = false;
                            lightingStateDisplay.QueueDraw();
                        }
                    };

                    ms.Run();
                    ms.Destroy();
                }
            };
            Put(acceptChangesButton, 460, 340);
            acceptChangesButton.Show();

            undoChangesButton             = new TouchButton();
            undoChangesButton.text        = "Undo";
            undoChangesButton.buttonColor = "grey1";
            undoChangesButton.SetSizeRequest(80, 40);
            undoChangesButton.ButtonReleaseEvent += (obj, args) => {
                if (lightingStateDisplay.hasStateInfoChanged)
                {
                    SetStates(fixtureName);
                }
            };
            Put(undoChangesButton, 370, 340);
            undoChangesButton.Show();

            deleteStateButton      = new TouchButton();
            deleteStateButton.text = "Delete";
            deleteStateButton.SetSizeRequest(80, 40);
            deleteStateButton.buttonColor         = "compl";
            deleteStateButton.textColor           = "white";
            deleteStateButton.ButtonReleaseEvent += (obj, args) => {
                var parent = Toplevel as Window;
                var ms     = new TouchDialog("Are you sure you want to delete the state", parent);
                ms.Response += (o, a) => {
                    if (a.ResponseId == ResponseType.Yes)
                    {
                        lightingStateDisplay.RemoveSelectedState();
                    }
                };

                ms.Run();
                ms.Destroy();
            };
            Put(deleteStateButton, 280, 340);

            Show();
        }
Example #21
0
        public PowerWindow(params object[] options) : base()
        {
            powerStripName = power.firstCard;
            if (powerStripName.IsNotEmpty())
            {
                sceneTitle = "Power Strip";
            }
            else
            {
                sceneTitle = "No Power Strips Added";
            }

            graphics = new PowerWindowGraphics();
            Put(graphics, 50, 80);
            if (powerStripName.IsNotEmpty())
            {
                graphics.Show();
            }
            else
            {
                graphics.Visible = false;
            }

            int x, y;

            selectors = new PowerOutletSlider[8];
            for (int i = 0; i < 8; ++i)
            {
                selectors[i] = new PowerOutletSlider(i);
                selectors[i].ss.SelectorChangedEvent += OnSelectorChanged;

                if ((i % 2) == 0)   // even numbers top row
                {
                    x = ((i - (i / 2)) * 185) + 50;
                    y = 85;
                }
                else
                {
                    x = (((i - (i / 2)) - 1) * 185) + 50;
                    y = 275;
                }
                Put(selectors[i], x, y);

                if (powerStripName.IsNotEmpty())
                {
                    selectors[i].Show();
                    var ic = IndividualControl.Empty;
                    ic.Group      = powerStripName;
                    ic.Individual = i;
                    selectors[i].Subscribe(ic);
                }
                else
                {
                    selectors[i].Visible = false;
                }
            }

            settingsButton = new TouchButton();
            settingsButton.SetSizeRequest(30, 30);
            settingsButton.buttonColor         = "pri";
            settingsButton.text                = Convert.ToChar(0x2699).ToString();
            settingsButton.ButtonReleaseEvent += OnSettingsRelease;
            Put(settingsButton, 755, 35);
            settingsButton.Show();

            combo = new TouchComboBox(power.GetAllCardNames());
            combo.comboList.Add("New power strip...");
            combo.activeText         = powerStripName;
            combo.WidthRequest       = 200;
            combo.ComboChangedEvent += OnComboChanged;
            Put(combo, 550, 35);
            combo.Show();

            GetPowerData();

            Show();
        }
        public HomeWindow(params object[] options)
        {
            showTitle = false;

            widgets   = new List <HomeWidget> ();
            tileBoard = new TileBoard(5, 7);

            emptySpaceGraphicalBox = new TouchGraphicalBox();
            emptySpaceGraphicalBox.SetSizeRequest(800, 480);
            emptySpaceGraphicalBox.color.A             = 0;
            emptySpaceGraphicalBox.ButtonPressEvent   += OnEmptySpaceEventBoxButtonPressed;
            emptySpaceGraphicalBox.ButtonReleaseEvent += OnEmptySpaceEventBoxButtonReleased;
            Put(emptySpaceGraphicalBox, 0, 0);
            emptySpaceGraphicalBox.Show();

            var path = System.IO.Path.Combine(Utils.AquaPicSettings, "mainScreen.json");

            if (File.Exists(path))
            {
                using (StreamReader reader = File.OpenText(path)) {
                    var ja = (JArray)JToken.ReadFrom(new JsonTextReader(reader));

                    foreach (var jt in ja)
                    {
                        var jo = jt as JObject;

                        var name = (string)jo["name"];
                        var type = (string)jo["type"];

                        var group = string.Empty;
                        if (jo.ContainsKey("group"))
                        {
                            group = (string)jo["group"];
                        }

                        var column = -1;
                        var row    = -1;
                        try {
                            column = Convert.ToInt32(jo["column"]);
                            row    = Convert.ToInt32(jo["row"]);
                        } catch {
                            Logger.AddWarning(string.Format("Invalid row or column for {0}", name));
                            continue;
                        }

                        var widget = HomeWindowWidgets.GetNewHomeWidget(type, name, group, row, column);

                        if (widget != null)
                        {
                            Put(widget, widget.x, widget.y);
                            widget.Show();
                            widgets.Add(widget);
                            tileBoard.OccupyTiles(widget);
                            widget.WidgetSelectedEvent         += OnWidgetSelected;
                            widget.WidgetUnselectedEvent       += OnWidgetUnselected;
                            widget.RequestNewTileLocationEvent += OnRequestNewTileLocation;
                        }
                    }
                }
            }
            else
            {
                Logger.Add("Home screen file did not exist, created new home screen file");
                var file = File.Create(path);
                file.Close();
                var ja = new JArray();
                File.WriteAllText(path, ja.ToString());
            }

            trashButton = new TouchButton();
            trashButton.SetSizeRequest(40, 40);
            trashButton.text        = "Trash";
            trashButton.buttonColor = "compl";
            trashButton.buttonColor.ModifyColor(0.75);
            trashButton.Visible = false;
            Put(trashButton, 755, 435);

            Update();
            Show();
        }