Beispiel #1
0
        protected void Update()
        {
            List <AlarmData> alarming = Alarm.GetAllAlarming();
            TextBuffer       tb       = tv.Buffer;

            tb.Text = string.Empty;

            foreach (var a in alarming)
            {
                var tag = new TextTag(null);
                if (a.acknowledged)
                {
                    tag.ForegroundGdk = TouchColor.NewGtkColor("seca");
                }
                else
                {
                    tag.ForegroundGdk = TouchColor.NewGtkColor("compl");
                }
                TextTagTable ttt = tb.TagTable;
                ttt.Add(tag);

                var ti = tb.EndIter;
                tb.InsertWithTags(ref ti, string.Format("{0:MM/dd hh:mm:ss}: {1}\n", a.postTime, a.name), tag);
            }
        }
Beispiel #2
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();
        }
Beispiel #3
0
        protected void OnExpose(object sender, ExposeEventArgs args)
        {
            if (!init)
            {
                if (calState == CalibrationState.ZeroActual)
                {
                    TextBuffer tb = tv.Buffer;
                    if (zeroActualInstructions.IsNotEmpty())
                    {
                        tb.Text = zeroValueInstructions;
                    }
                    else
                    {
                        tb.Text = "Please enter the zero actual value.\n" +
                                  "Once the zero actual value is entered press the zero button.\n\n";
                    }

                    var tag = new TextTag(null);
                    tag.ForegroundGdk = TouchColor.NewGtkColor("seca");
                    tb.TagTable.Add(tag);

                    var ti = tb.EndIter;
                    tb.InsertWithTags(ref ti, string.Format("Previous zero actual: {0:F2}", calArgs.zeroActual), tag);
                }
                else if (calState == CalibrationState.ZeroValue)
                {
                    TextBuffer tb = tv.Buffer;
                    if (!string.IsNullOrWhiteSpace(zeroValueInstructions))
                    {
                        tb.Text = zeroValueInstructions;
                    }
                    else
                    {
                        tb.Text = "Place the instrument in its zero state.\n" +
                                  "Once value has settled, press the zero button.\n\n";
                    }

                    var tag = new TextTag(null);
                    tag.ForegroundGdk = TouchColor.NewGtkColor("seca");
                    tb.TagTable.Add(tag);

                    var ti = tb.EndIter;
                    tb.InsertWithTags(ref ti, string.Format("Previous zero value: {0:F2}", calArgs.zeroValue), tag);
                }
                tv.QueueDraw();
                init = true;
            }
        }
Beispiel #4
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();
        }
Beispiel #5
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();
        }
        protected AquaPicGui() : base(WindowType.Toplevel)
        {
            Name           = "AquaPicGUI";
            Title          = "AquaPic Controller Version 0";
            WindowPosition = WindowPosition.Center;
            SetSizeRequest(800, 480);
            Resizable = false;
            AllowGrow = false;

            DeleteEvent += (o, args) => {
                Application.Quit();
                args.RetVal = true;
            };

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

#if RPI_BUILD
            this.Decorated = false;
            this.Fullscreen();
#endif

            GLib.ExceptionManager.UnhandledException += (args) => {
                Exception ex = args.ExceptionObject as Exception;
                Logger.AddError(ex.ToString());
                args.ExitApplication = false;
            };

            ChangeSceneEvent += ScreenChange;

            scenes = new Dictionary <string, SceneData> {
                { "Power", new SceneData("Power", true, (options) => { return(new PowerWindow(options)); }) },
                { "Lighting", new SceneData("Lighting", true, (options) => { return(new LightingWindow(options)); }) },
                { "Temperature", new SceneData("Temperature", true, (options) => { return(new TemperatureWindow(options)); }) },
                { "Water Level", new SceneData("Water Level", true, (options) => { return(new WaterLevelWindow(options)); }) },
                { "Sensors", new SceneData("Sensors", true, (options) => { return(new SensorsWindow(options)); }) },
                { "Chemistry", new SceneData("Chemistry", true, (options) => { return(new ChemistryWindow(options)); }) },
                { "Analog Output", new SceneData("Analog Output", true, (options) => { return(new AnalogOutputWindow(options)); }) },
                { "Analog Input", new SceneData("Analog Input", true, (options) => { return(new AnalogInputWindow(options)); }) },
                { "Digital Input", new SceneData("Digital Input", true, (options) => { return(new DigitalInputWindow(options)); }) },
                { "pH/ORP", new SceneData("pH/ORP", true, (options) => { return(new PhOrpWindow(options)); }) },
                { "Serial Bus", new SceneData("Serial Bus", true, (options) => { return(new SerialBusWindow(options)); }) },
                { "Alarms", new SceneData("Alarms", true, (options) => { return(new AlarmWindow(options)); }) },
                { "Logger", new SceneData("Logger", true, (options) => { return(new LoggerWindow(options)); }) },
                { "Settings", new SceneData("Settings", true, (options) => { return(new SettingsWindow(options)); }) },
                { "Menu", new SceneData("Menu", false, (options) => { return(new MenuWindow(options)); }) },
                { "Home", new SceneData("Home", true, (options) => { return(new HomeWindow(options)); }) }
            };

            currentScene = "Home";

            f = new Fixed();
            f.SetSizeRequest(800, 480);

            current = scenes[currentScene].CreateInstance();
            f.Put(current, 0, 0);
            current.Show();

            side = new MySideBar(scenes, currentScene);
            f.Put(side, 0, 20);
            side.Show();

            notification = new MyNotificationBar();
            f.Put(notification, 0, 0);
            notification.Show();

            Add(f);
            f.Show();

            Show();
        }
Beispiel #7
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);
        }
Beispiel #8
0
        protected void MoveToNextState()
        {
            TextBuffer tb;
            TextTag    tag;
            TextIter   ti;

            switch (calState)
            {
            case CalibrationState.ZeroActual:
                if (!forced)
                {
                    valTb.enableTouch       = false;
                    valTb.backgroundColor   = "grey1";
                    valTb.TextChangedEvent -= OnValueTextBoxTextChanged;
                }
                valTb.text = GetCalibrationValue().ToString("F2");
                valTb.QueueDraw();

                actionBtn.text = "Zero Value";
                actionBtn.QueueDraw();

                tb = tv.Buffer;
                if (!string.IsNullOrWhiteSpace(zeroValueInstructions))
                {
                    tb.Text = zeroValueInstructions;
                }
                else
                {
                    tb.Text = "Place the instrument in its zero state.\n" +
                              "Once value has settled, press the button.\n\n";
                }

                tag = new TextTag(null);
                tag.ForegroundGdk = TouchColor.NewGtkColor("seca");
                tb.TagTable.Add(tag);

                ti = tb.EndIter;
                tb.InsertWithTags(ref ti, string.Format("Previous zero value: {0:F2}", calArgs.zeroValue), tag);

                tv.QueueDraw();

                calState = CalibrationState.ZeroValue;

                break;

            case CalibrationState.ZeroValue:
                if (!forced)
                {
                    valTb.enableTouch       = true;
                    valTb.backgroundColor   = "grey1";
                    valTb.TextChangedEvent += OnValueTextBoxTextChanged;
                }
                valTb.text = "Enter Actual";
                valTb.QueueDraw();

                actionBtn.text = "Full Scale Actual";
                actionBtn.QueueDraw();

                tb = tv.Buffer;
                if (!string.IsNullOrWhiteSpace(fullScaleActualInstructions))
                {
                    tb.Text = fullScaleActualInstructions;
                }
                else
                {
                    tb.Text = "Please enter the full scale actual value.\n" +
                              "Once the full scale value is entered press the button.\n\n";
                }

                tag = new TextTag(null);
                tag.ForegroundGdk = TouchColor.NewGtkColor("seca");
                tb.TagTable.Add(tag);

                ti = tb.EndIter;
                tb.InsertWithTags(ref ti, string.Format("Previous full scale actual: {0:F2}", calArgs.fullScaleActual), tag);

                tv.QueueDraw();

                calState = CalibrationState.FullScaleActual;
                break;

            case CalibrationState.FullScaleActual:
                if (!forced)
                {
                    valTb.enableTouch       = false;
                    valTb.backgroundColor   = "grey1";
                    valTb.TextChangedEvent -= OnValueTextBoxTextChanged;
                }

                valTb.text = GetCalibrationValue().ToString("F2");
                valTb.QueueDraw();

                actionBtn.text = "Full Scale Value";
                actionBtn.QueueDraw();

                tb = tv.Buffer;
                if (!string.IsNullOrWhiteSpace(fullScaleValueInstructions))
                {
                    tb.Text = fullScaleValueInstructions;
                }
                else
                {
                    tb.Text = "Please the instrument in its full scale state.\n" +
                              "Once value has settled, press the button.\n\n";
                }

                tag = new TextTag(null);
                tag.ForegroundGdk = TouchColor.NewGtkColor("seca");
                tb.TagTable.Add(tag);

                ti = tb.EndIter;
                tb.InsertWithTags(ref ti, string.Format("Previous full scale value: {0:F2}", calArgs.fullScaleValue), tag);

                tv.QueueDraw();

                calState = CalibrationState.FullScaleValue;
                break;

            case CalibrationState.FullScaleValue:
                CalibrationCompleteEvent?.Invoke(calArgs);

                Destroy();
                break;

            default:
                break;
            }
        }