Exemple #1
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;
            }
        }
Exemple #2
0
        protected void OnActionButtonReleaseEvent(object sender, ButtonReleaseEventArgs args)
        {
            switch (calState)
            {
            case CalibrationState.ZeroActual:
                if (valTb.text == "Enter Actual")
                {
                    MessageBox.Show("Please enter the zero actual value");
                }
                else
                {
                    calArgs.zeroActual = Convert.ToDouble(valTb.text);
                    MoveToNextState();
                }

                break;

            case CalibrationState.ZeroValue:
                if (!forced)
                {
                    calArgs.zeroValue = GetCalibrationValue();
                }
                else
                {
                    calArgs.zeroValue = Convert.ToDouble(valTb.text);
                }

                MoveToNextState();
                break;

            case CalibrationState.FullScaleActual:
                if (valTb.text == "Enter Actual")
                {
                    MessageBox.Show("Please enter the full scale actual value");
                }
                else
                {
                    calArgs.fullScaleActual = Convert.ToDouble(valTb.text);
                    MoveToNextState();
                }

                break;

            case CalibrationState.FullScaleValue:
                if (!forced)
                {
                    calArgs.fullScaleValue = GetCalibrationValue();
                }
                else
                {
                    calArgs.fullScaleValue = Convert.ToDouble(valTb.text);
                }

                CalibrationCompleteEvent?.Invoke(calArgs);

                Destroy();
                break;

            default:
                break;
            }
        }