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); } }
protected virtual void OnExpose(object sender, ExposeEventArgs args) { using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { TouchColor.SetSource(cr, "grey3", 0.75); double midY = 272.5; for (int i = 0; i < 3; ++i) { cr.MoveTo(60 + (i * 185), midY); cr.LineTo(220 + (i * 185), midY); cr.ClosePath(); cr.Stroke(); cr.MoveTo(232.5 + (i * 185), 115); cr.LineTo(232.5 + (i * 185), 425); cr.ClosePath(); cr.Stroke(); } cr.MoveTo(615, midY); cr.LineTo(775, midY); cr.ClosePath(); cr.Stroke(); } }
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(); }
protected void OnTouchAreaExpose(object obj, ExposeEventArgs args) { if (selected) { using (Context cr = CairoHelper.Create(GdkWindow)) { cr.Rectangle(Allocation.Left, Allocation.Top, Allocation.Width, Allocation.Height); TouchColor.SetSource(cr, "grey0", 0.5); cr.Fill(); } } }
public TimerTab(int position) { SetSizeRequest(130, 30); VisibleWindow = false; ExposeEvent += OnEventBoxExpose; color = "grey3"; text = string.Empty; selected = false; this.position = position; }
protected override void OnExpose(object sender, ExposeEventArgs args) { using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { cr.Rectangle(Allocation.Left, Allocation.Top, Allocation.Width, Allocation.Height); color.SetSource(cr); cr.Fill(); cr.MoveTo(Allocation.Left, Allocation.Top); cr.LineTo(Allocation.Right + 1, Allocation.Top); TouchColor.SetSource(cr, "grey2", 1.0); cr.LineWidth = 2.0; cr.Stroke(); } }
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; } }
protected void onExpose(object sender, ExposeEventArgs args) { var area = sender as EventBox; using (Context cr = Gdk.CairoHelper.Create(area.GdkWindow)) { int width = Allocation.Width; cr.MoveTo(0, 0); cr.LineTo(width, 0); cr.LineTo(width, 17); cr.LineTo(0, 17); cr.MoveTo(0, 0); cr.ClosePath(); cr.SetSourceRGB(0.15, 0.15, 0.15); cr.Fill(); cr.MoveTo(0, 17); cr.LineTo(width, 17); cr.LineTo(width, 19); cr.LineTo(0, 19); cr.LineTo(0, 17); cr.ClosePath(); using (var pat = new LinearGradient(0, 19, width, 19)) { pat.AddColorStop(0.0, TouchColor.NewCairoColor("grey2", 0.35)); pat.AddColorStop(0.5, TouchColor.NewCairoColor("pri")); pat.AddColorStop(1.0, TouchColor.NewCairoColor("grey2", 0.35)); cr.SetSource(pat); cr.Fill(); } TouchText textRender = new TouchText(DateTime.Now.ToLongTimeString()); textRender.alignment = TouchAlignment.Right; textRender.Render(this, width - 120, 0, 120, 19); textRender.text = alarmName; if (alarmName == "No Alarms") { textRender.font.color = "white"; } else { textRender.font.color = "compl"; } textRender.alignment = TouchAlignment.Left; textRender.Render(this, 0, 0, 500, 19); } }
protected void OnEventBoxExpose(object sender, ExposeEventArgs args) { EventBox eb = sender as EventBox; using (Context cr = Gdk.CairoHelper.Create(eb.GdkWindow)) { int height = Allocation.Height; int width = Allocation.Width; int top = Allocation.Top; int left = Allocation.Left; int radius = 4; if (!selected) { width -= 25; left += position * 13; top += 7; height -= 7; } cr.MoveTo(left, top + radius); cr.Arc(left + radius, top + radius, radius, Math.PI, -Math.PI / 2); cr.LineTo(left + width - radius, top); cr.Arc(left + width - radius, top + radius, radius, -Math.PI / 2, 0); cr.LineTo(left + width, top + height); cr.LineTo(left, top + height); cr.ClosePath(); if (selected) { color = "grey2"; color.A = 1.0f; } else { color = "grey4"; color.A = 0.1f; } color.SetSource(cr); cr.Fill(); TouchText render = new TouchText(text); render.alignment = TouchAlignment.Center; render.font.color = "white"; render.Render(this, left, top, width, height); } }
protected void OnExpose(object sender, ExposeEventArgs args) { using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { TouchColor.SetSource(cr, "grey3", 0.75); cr.LineWidth = 3; cr.MoveTo(402.5, 70); cr.LineTo(402.5, 460); cr.ClosePath(); cr.Stroke(); cr.MoveTo(417.5, 267.5); cr.LineTo(780, 267.5); cr.ClosePath(); cr.Stroke(); } }
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(); }
protected void onExpose(object sender, ExposeEventArgs args) { using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { int left = Allocation.Left; int right = Allocation.Right; int top = Allocation.Top; int bottom = Allocation.Bottom; int width = Allocation.Width; int height = Allocation.Height; double originY = top + (height / 2d); double originX = -850.105; double radius = 1075.105; if (expanded) { cr.Rectangle(left, top, width, height); TouchColor.SetSource(cr, "grey0", 0.80); cr.Fill(); cr.MoveTo(left, top); cr.LineTo(200, top); cr.Arc(originX, originY, radius, (192.41466).ToRadians(), (167.58534).ToRadians()); cr.LineTo(200, top + height); cr.LineTo(left, top + height); cr.LineTo(left, top); cr.ClosePath(); TouchColor.SetSource(cr, "grey3", 0.80); cr.Fill(); var currentWindowTop = (height / 2) - 30 + top; TouchGlobal.DrawRoundedRectangle(cr, left - 50, currentWindowTop, 300, 60, 20); var color = new TouchColor("grey3"); var outlineColor = new TouchColor(color); outlineColor.ModifyColor(0.5); var highlightColor = new TouchColor(color); highlightColor.ModifyColor(1.1); var lowlightColor = new TouchColor(color); lowlightColor.ModifyColor(0.75); using (var grad = new LinearGradient(left, currentWindowTop, left, currentWindowTop + 60)) { grad.AddColorStop(0, highlightColor.ToCairoColor()); grad.AddColorStop(0.15, color.ToCairoColor()); grad.AddColorStop(0.85, lowlightColor.ToCairoColor()); cr.SetSource(grad); cr.FillPreserve(); } outlineColor.SetSource(cr); cr.LineWidth = 1; cr.Stroke(); // Menu Button cr.MoveTo(right + 5, top); cr.LineTo(right - 120, top); cr.LineTo(right - 120, top + 20); cr.ArcNegative(right - 100, top + 20, 20, 0, Math.PI / 2); cr.LineTo(right + 5, top + 40); cr.ClosePath(); color = new TouchColor("grey4", 0.8); highlightColor = new TouchColor(color); highlightColor.ModifyColor(1.3); lowlightColor = new TouchColor(color); lowlightColor.ModifyColor(0.75); using (var grad = new LinearGradient(right - 120, top, right - 120, top + 40)) { grad.AddColorStop(0, highlightColor.ToCairoColor()); grad.AddColorStop(0.2, color.ToCairoColor()); grad.AddColorStop(0.85, lowlightColor.ToCairoColor()); cr.SetSource(grad); cr.Fill(); } // Home Button cr.MoveTo(right + 5, bottom + 5); cr.LineTo(right - 120, bottom + 5); cr.LineTo(right - 120, bottom - 20); cr.Arc(right - 100, bottom - 20, 20, 0, -Math.PI / 2); cr.LineTo(right + 5, bottom - 40); cr.ClosePath(); using (var grad = new LinearGradient(right - 165, bottom - 40, right - 165, bottom)) { grad.AddColorStop(0, highlightColor.ToCairoColor()); grad.AddColorStop(0.2, color.ToCairoColor()); grad.AddColorStop(0.85, lowlightColor.ToCairoColor()); cr.SetSource(grad); cr.Fill(); } var t = new TouchText(windows[highlighedScreenIndex]); t.font.color = "pri"; t.alignment = TouchAlignment.Right; if (clicked) { t.font.size = 18; double radians = (180 + (offset * 2.75881)).ToRadians(); double textWidth = 210 - CalcX(radius, radians); t.Render(this, left, (height / 2) - 25 + top - (offset * 50.0).ToInt(), textWidth.ToInt(), 50); } else { t.font.size = 20; t.Render(this, left, (height / 2) - 25 + top, 245, 50); } t.font.color = "black"; for (int i = 0; i < 4; ++i) { int drawIndex = highlighedScreenIndex + 1 + i; if (drawIndex >= windows.Length) { drawIndex -= windows.Length; } double radians = (177.24119 - (i * 2.75881) + (offset * 2.75881)).ToRadians(); double textWidth = 210 - CalcX(radius, radians); t.text = windows[drawIndex]; t.font.size = 16 - (i * 0.75).ToInt(); int textY = (height / 2) + top + 25 + (i * 50) - (offset * 50.0).ToInt(); t.Render( this, left, textY, textWidth.ToInt(), 50); drawIndex = highlighedScreenIndex - 1 - i; if (drawIndex < 0) { drawIndex = windows.Length + drawIndex; //adding drawIndex because its negative } t.text = windows[drawIndex]; textY = (height / 2) + top - 75 - (i * 50) - (offset * 50.0).ToInt(); t.Render( this, left, textY, textWidth.ToInt(), 50); } // Menu Text t.text = "Menu"; t.font.size = 18; t.alignment = TouchAlignment.Right; t.Render(this, right - 120, top, 115, 40); // Home Text t.text = "Home"; t.Render(this, right - 120, bottom - 40, 115, 40); } else { cr.Arc(originX - 208, originY, radius, 0, 2 * Math.PI); cr.ClosePath(); TouchColor.SetSource(cr, "grey3", 0.75); cr.LineWidth = 0.75; cr.StrokePreserve(); TouchColor.SetSource(cr, "grey2", 0.25); cr.Fill(); var topEdge = (height / 2) - 30 + top; TouchGlobal.DrawRoundedRectangle(cr, left - 30, topEdge, 55, 60, 25); var color = new TouchColor("grey3"); var outlineColor = new TouchColor(color); outlineColor.ModifyColor(0.5); var highlightColor = new TouchColor(color); highlightColor.ModifyColor(1.1); var lowlightColor = new TouchColor(color); lowlightColor.ModifyColor(0.75); using (var grad = new LinearGradient(left, topEdge, left, topEdge + 60)) { grad.AddColorStop(0, highlightColor.ToCairoColor()); grad.AddColorStop(0.15, color.ToCairoColor()); grad.AddColorStop(0.85, lowlightColor.ToCairoColor()); cr.SetSource(grad); cr.FillPreserve(); } outlineColor.SetSource(cr); cr.LineWidth = 1; cr.Stroke(); } } }
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(); }
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); }
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; } }