コード例 #1
0
        /// <summary>
        /// EVENT FUNCTION FOR MANUAL ENTRY POPUP
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void handleManualPopup(object sender, EventArgs e)
        {
            if (mtextValue.Text.Contains("."))
            {
                var p1    = mtextValue.Text.Split('.');
                var check = p1[1];
                if (check.Length.Equals(0))
                {
                    textValidation.Text   = Util.Strings.Analyzer.VALIDMEASUREMENT;
                    textValidation.Hidden = false;
                    return;
                }
            }
            if (mtextValue.Text.Length <= 0)
            {
                textValidation.Text   = Util.Strings.Analyzer.MISSINGVALUE;
                textValidation.Hidden = false;
                return;
            }
            if (mtextValue.Text.Contains("-") && mtextValue.Text.Length.Equals(1))
            {
                textValidation.Text   = Util.Strings.Analyzer.VALIDMEASUREMENT;
                textValidation.Hidden = false;
                return;
            }
            if (start.addPan == null)
            {
                Console.WriteLine("Pan gesture is null");
            }
            start.pressedSensor.isManual = true;
            start.pressedView.AddGestureRecognizer(start.addPan);
            start.availableView.Hidden        = true;
            start.pressedView.BackgroundColor = UIColor.White;
            start.topLabel.Hidden             = false;
            start.middleLabel.Hidden          = false;
            start.bottomLabel.Hidden          = false;
            start.topLabel.Text = " " + dtypeButton.AccessibilityIdentifier;
            var amount = Convert.ToDecimal(mtextValue.Text);

            if (dtypeButton.AccessibilityIdentifier.Equals("Vaccum"))
            {
                start.middleLabel.Text = ((int)amount).ToString();
            }
            else
            {
                start.middleLabel.Text = amount.ToString("N");
            }
            start.bottomLabel.Text       = mbuttonText.Text;
            start.pressedSensor.isManual = true;
            start.addIcon.Hidden         = true;

            ///CREATE MANUAL MANIFOLDS
            if (dtypeButton.AccessibilityIdentifier.Equals("Pressure"))
            {
                start.pressedSensor.manualSensor = new ManualSensor(ion.manualSensorContainer, ESensorType.Pressure, ion.preferences.units.DefaultUnitFor(ESensorType.Pressure).OfScalar(0.0));
                //start.pressedSensor.manualSensor = new ManualSensor(ESensorType.Pressure, ion.preferences.units.DefaultUnitFor(ESensorType.Pressure).OfScalar(0.0));
            }
            else if (dtypeButton.AccessibilityIdentifier.Equals("Temperature"))
            {
                start.pressedSensor.manualSensor = new ManualSensor(ion.manualSensorContainer, ESensorType.Temperature, ion.preferences.units.DefaultUnitFor(ESensorType.Temperature).OfScalar(0.0));
                //start.pressedSensor.manualSensor = new ManualSensor(ESensorType.Temperature, ion.preferences.units.DefaultUnitFor(ESensorType.Temperature).OfScalar(0.0));
            }
            else
            {
                start.pressedSensor.manualSensor = new ManualSensor(ion.manualSensorContainer, ESensorType.Vacuum, ion.preferences.units.DefaultUnitFor(ESensorType.Vacuum).OfScalar(0.0));
                //start.pressedSensor.manualSensor = new ManualSensor(ESensorType.Vacuum, ion.preferences.units.DefaultUnitFor(ESensorType.Vacuum).OfScalar(0.0));
            }

            ///SET MANUALSENSOR MEASUREMENT AND UNIT TYPE
            start.pressedSensor.manualSensor.unit = AnalyserUtilities.getManualUnit(start.pressedSensor.manualSensor.type, mbuttonText.Text.ToLower());

            ((ManualSensor)start.pressedSensor.manualSensor).SetMeasurement(new Scalar(start.pressedSensor.manualSensor.unit, Convert.ToDouble(mtextValue.Text)));

            textValidation.Hidden      = true;
            mdoneButton.TouchUpInside -= handleManualPopup;
            dtypeButton.SetTitle(Util.Strings.Sensor.Type.PRESSURE, UIControlState.Normal);
            dtypeButton.AccessibilityIdentifier = "Pressure";
            mbuttonText.Text = start.pressures[0];
            mtextValue.Text  = "";
            mView.Hidden     = true;
            mtextValue.ResignFirstResponder();
        }
コード例 #2
0
        /// <summary>
        /// EVENT FUNCTION FOR LOW HIGH MANUAL POPUP. ASSOCIATES A SINGLE SENSOR TO THE LOW/HIGH AREA WHEN MAKING A MANUAL LOW/HIGH ENTRY
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void handleManualLHPopup(object sender, EventArgs e)
        {
            if (mtextValue.Text.Contains("."))
            {
                var p1    = mtextValue.Text.Split('.');
                var check = p1[1];
                if (check.Length.Equals(0))
                {
                    mtextValue.Text += "0";
                    return;
                }
            }
            if (mtextValue.Text.Length <= 0)
            {
                textValidation.Text   = Util.Strings.Analyzer.MISSINGVALUE;
                textValidation.Hidden = false;
                return;
            }

            var amount = Convert.ToDecimal(mtextValue.Text);
            var begin  = 0;
            var end    = 4;
            var color  = UIColor.Blue;

            if (start.pressedView.AccessibilityIdentifier == "high")
            {
                begin = 4;
                end   = 8;
                color = UIColor.Red;
            }

            for (int i = begin; i < end; i++)
            {
                if (!analyzerSensors.viewList[i].availableView.Hidden)
                {
                    analyzerSensors.viewList[i].addIcon.Hidden           = true;
                    analyzerSensors.viewList[i].availableView.Hidden     = true;
                    analyzerSensors.viewList[i].snapArea.BackgroundColor = UIColor.White;
                    analyzerSensors.viewList[i].snapArea.AddGestureRecognizer(analyzerSensors.viewList[i].panGesture);
                    analyzerSensors.viewList[i].topLabel.Text            = " " + dtypeButton.AccessibilityIdentifier;
                    analyzerSensors.viewList[i].topLabel.Hidden          = false;
                    analyzerSensors.viewList[i].topLabel.BackgroundColor = color;
                    analyzerSensors.viewList[i].topLabel.TextColor       = UIColor.White;

                    if (mbuttonText.Text == "micron")
                    {
                        analyzerSensors.viewList[i].middleLabel.Text = ((int)amount).ToString();
                    }
                    else
                    {
                        analyzerSensors.viewList[i].middleLabel.Text = amount.ToString("N");
                    }
                    analyzerSensors.viewList[i].middleLabel.Hidden = false;
                    analyzerSensors.viewList[i].bottomLabel.Text   = mbuttonText.Text;
                    analyzerSensors.viewList[i].bottomLabel.Hidden = false;
                    analyzerSensors.viewList[i].isManual           = true;

                    if (dtypeButton.AccessibilityIdentifier.Equals("Pressure"))
                    {
                        analyzerSensors.viewList[i].manualSensor = new ManualSensor(ion.manualSensorContainer, ESensorType.Pressure, ion.preferences.units.DefaultUnitFor(ESensorType.Pressure).OfScalar(0.0));
                        //analyzerSensors.viewList[i].manualSensor = new ManualSensor(ESensorType.Pressure, ion.preferences.units.DefaultUnitFor(ESensorType.Pressure).OfScalar(0.0));
                    }
                    else if (dtypeButton.AccessibilityIdentifier.Equals("Temperature"))
                    {
                        analyzerSensors.viewList[i].manualSensor = new ManualSensor(ion.manualSensorContainer, ESensorType.Temperature, ion.preferences.units.DefaultUnitFor(ESensorType.Temperature).OfScalar(0.0));
                        //analyzerSensors.viewList[i].manualSensor = new ManualSensor(ESensorType.Temperature, ion.preferences.units.DefaultUnitFor(ESensorType.Temperature).OfScalar(0.0));
                    }
                    else
                    {
                        analyzerSensors.viewList[i].manualSensor = new ManualSensor(ion.manualSensorContainer, ESensorType.Vacuum, ion.preferences.units.DefaultUnitFor(ESensorType.Vacuum).OfScalar(0.0));
                        //analyzerSensors.viewList[i].manualSensor = new ManualSensor(ESensorType.Vacuum, ion.preferences.units.DefaultUnitFor(ESensorType.Vacuum).OfScalar(0.0));
                    }
                    analyzerSensors.viewList[i].manualSensor.name = analyzerSensors.viewList[i].topLabel.Text;
                    analyzerSensors.viewList[i].manualSensor.unit = AnalyserUtilities.getManualUnit(analyzerSensors.viewList[i].manualSensor.type, mbuttonText.Text.ToLower());
                    ((ManualSensor)analyzerSensors.viewList[i].manualSensor).SetMeasurement(new Scalar(analyzerSensors.viewList[i].manualSensor.unit, Convert.ToDouble(mtextValue.Text)));

                    Console.WriteLine("Handlemanuallhpopup about to low high associate");
                    if (begin == 4)
                    {
                        /////ASSOCIATE HIGH AREA TO MANUALLY CREATED SENSOR
                        lowHighSensors.highArea.manualSensor = analyzerSensors.viewList[i].manualSensor;
                        lowHighSensors.highArea.manualGType  = analyzerSensors.viewList[i].manualSensor.type.ToString();
                        lowHighSensors.highArea.isManual     = true;
                        ion.currentAnalyzer.SetManifold(Core.Content.Analyzer.ESide.High, lowHighSensors.highArea.manualSensor);

                        ///////////////////// change the high manifold to be based on moved location instead of created position
                        Console.WriteLine("addLHDeviceSensor already on analyzer Should change highAccessibility to " + i + " instead of " + analyzerSensors.viewList[i].snapArea.AccessibilityIdentifier);
                        lowHighSensors.highArea.snapArea.AccessibilityIdentifier = i.ToString();
                        ion.currentAnalyzer.highAccessibility = i.ToString();
                        /////////////////////
                        lowHighSensors.highArea.setLHUI();
                    }
                    else
                    {
                        /////ASSOCIATE LOW AREA TO MANUALLY CREATED SENSOR
                        lowHighSensors.lowArea.manualSensor = analyzerSensors.viewList[i].manualSensor;
                        lowHighSensors.lowArea.manualGType  = analyzerSensors.viewList[i].manualSensor.type.ToString();
                        lowHighSensors.lowArea.isManual     = true;
                        ion.currentAnalyzer.SetManifold(Core.Content.Analyzer.ESide.Low, lowHighSensors.highArea.manualSensor);

                        ///////////////////// change the low manifold to be based on moved location instead of created position
                        Console.WriteLine("handleManualLHPopup Should change lowAccessibility to " + i + " instead of " + analyzerSensors.viewList[i].snapArea.AccessibilityIdentifier);
                        lowHighSensors.lowArea.snapArea.AccessibilityIdentifier = i.ToString();
                        ion.currentAnalyzer.lowAccessibility = i.ToString();
                        /////////////////////
                        lowHighSensors.lowArea.setLHUI();
                    }

                    break;
                }
            }

            mdoneButton.TouchUpInside -= handleManualLHPopup;
            dtypeButton.SetTitle(Util.Strings.Sensor.Type.PRESSURE, UIControlState.Normal);
            dtypeButton.AccessibilityIdentifier = "Pressure";
            mtextValue.Text  = "";
            mbuttonText.Text = start.pressures[0];
            mView.Hidden     = true;
            mtextValue.ResignFirstResponder();
        }
コード例 #3
0
        public void makeEvents(lowHighSensor lhSensor, CGRect tableRect)
        {
            cellHeader = new UILabel(new CGRect(0, 0, 1.006 * tableRect.Width, .5 * lhSensor.cellHeight));
            cellButton = new UIButton(new CGRect(0, .5 * lhSensor.cellHeight, tableRect.Width, .5 * lhSensor.cellHeight));

            cellHeader.Text                      = "ALT";
            cellHeader.TextColor                 = UIColor.White;
            cellHeader.BackgroundColor           = UIColor.Black;
            cellHeader.Font                      = UIFont.FromName("Helvetica-Bold", 21f);
            cellHeader.TextAlignment             = UITextAlignment.Center;
            cellHeader.AdjustsFontSizeToFitWidth = true;

            cellReading = lhSensor.altReading;
            cellReading.AdjustsFontSizeToFitWidth = true;
            cellReading.TextAlignment             = UITextAlignment.Right;

            cellButton.BackgroundColor   = UIColor.Clear;
            cellButton.Layer.BorderColor = UIColor.Black.CGColor;

            if (lhSensor.isManual)
            {
                if (lhSensor.currentSensor.type == ESensorType.Pressure)
                {
                    manSensor = new ManualSensor(AppState.context.manualSensorContainer, ESensorType.Pressure, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Pressure).OfScalar(0.0));
                    //manSensor = new ManualSensor(ESensorType.Pressure, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Pressure).OfScalar(0.0));
                    manSensor.unit = AnalyserUtilities.getManualUnit(ESensorType.Pressure, lhSensor.LabelBottom.Text.ToLower());
                    ((ManualSensor)manSensor).SetMeasurement(manSensor.unit.OfScalar(Convert.ToDouble(lhSensor.LabelMiddle.Text)));
                    lhSensor.alt = new AlternateUnitSensorProperty(manSensor);
                }
                else if (lhSensor.currentSensor.type == ESensorType.Temperature)
                {
                    manSensor = new ManualSensor(AppState.context.manualSensorContainer, ESensorType.Temperature, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Temperature).OfScalar(0.0));
                    //manSensor = new ManualSensor(ESensorType.Temperature, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Temperature).OfScalar(0.0));
                    manSensor.unit = AnalyserUtilities.getManualUnit(ESensorType.Temperature, lhSensor.LabelBottom.Text.ToLower());
                    ((ManualSensor)manSensor).SetMeasurement(manSensor.unit.OfScalar(Convert.ToDouble(lhSensor.LabelMiddle.Text)));
                    lhSensor.alt = new AlternateUnitSensorProperty(manSensor);
                }
                else if (lhSensor.currentSensor.type == ESensorType.Vacuum)
                {
                    manSensor = new ManualSensor(AppState.context.manualSensorContainer, ESensorType.Vacuum, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Vacuum).OfScalar(0.0));
                    //manSensor = new ManualSensor(ESensorType.Vacuum, AppState.context.preferences.units.DefaultUnitFor(ESensorType.Vacuum).OfScalar(0.0));
                    manSensor.unit = AnalyserUtilities.getManualUnit(ESensorType.Vacuum, lhSensor.LabelBottom.Text.ToLower());
                    ((ManualSensor)manSensor).SetMeasurement(manSensor.unit.OfScalar(Convert.ToDouble(lhSensor.LabelMiddle.Text)));
                    lhSensor.alt = new AlternateUnitSensorProperty(manSensor);
                }
                if (lhSensor.altUnit != null)
                {
                    lhSensor.alt.unit = lhSensor.altUnit;
                }
                else
                {
                    lhSensor.alt.unit = manSensor.unit;
                }
                cellReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true);
            }
            else
            {
                lhSensor.alt = new AlternateUnitSensorProperty(lhSensor.currentSensor as Sensor);
                if (lhSensor.altUnit != null)
                {
                    lhSensor.alt.unit = lhSensor.altUnit;
                }
                else
                {
                    if (lhSensor.currentSensor.type == ESensorType.Pressure)
                    {
                        lhSensor.alt.unit = AnalyserUtilities.getManualUnit(lhSensor.currentSensor.type, lhSensor.altUnits[0].Replace("/", "").ToLower());
                    }
                    else if (lhSensor.currentSensor.type == ESensorType.Temperature)
                    {
                        lhSensor.alt.unit = AnalyserUtilities.getManualUnit(lhSensor.currentSensor.type, lhSensor.tempUnits[0].Replace("/", "").ToLower());
                    }
                    else if (lhSensor.currentSensor.type == ESensorType.Vacuum)
                    {
                        lhSensor.alt.unit = AnalyserUtilities.getManualUnit(lhSensor.currentSensor.type, lhSensor.vacUnits[0].Replace("/", "").ToLower());
                    }
                }
            }
            cellButton.TouchUpInside += delegate {
                var window = UIApplication.SharedApplication.KeyWindow;
                var vc     = window.RootViewController;
                while (vc.PresentedViewController != null)
                {
                    vc = vc.PresentedViewController;
                }

                UIAlertController altUnit = UIAlertController.Create(Util.Strings.Analyzer.CHOOSEUNIT, "", UIAlertControllerStyle.Alert);

                if (lhSensor.alt.sensor.type == ESensorType.Pressure)
                {
                    foreach (String unit in lhSensor.altUnits)
                    {
                        altUnit.AddAction(UIAlertAction.Create(unit, UIAlertActionStyle.Default, (action) => {
                            if (lhSensor.isManual)
                            {
                                lhSensor.altUnit         = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.alt.unit        = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true);
                            }
                            else
                            {
                                lhSensor.altUnit         = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.alt.unit        = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true);
                            }
                        }));
                    }
                }
                else if (lhSensor.alt.sensor.type == ESensorType.Temperature)
                {
                    foreach (String unit in lhSensor.tempUnits)
                    {
                        altUnit.AddAction(UIAlertAction.Create(unit, UIAlertActionStyle.Default, (action) => {
                            if (lhSensor.isManual)
                            {
                                lhSensor.altUnit         = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.alt.unit        = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true);
                            }
                            else
                            {
                                lhSensor.altUnit         = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.alt.unit        = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true);
                            }
                        }));
                    }
                }
                else if (lhSensor.alt.sensor.type == ESensorType.Vacuum)
                {
                    foreach (String unit in lhSensor.vacUnits)
                    {
                        altUnit.AddAction(UIAlertAction.Create(unit, UIAlertActionStyle.Default, (action) => {
                            if (lhSensor.isManual)
                            {
                                lhSensor.altUnit         = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.alt.unit        = UnitLookup.GetUnit(lhSensor.alt.sensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true);
                            }
                            else
                            {
                                lhSensor.altUnit         = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.alt.unit        = UnitLookup.GetUnit(lhSensor.currentSensor.type, unit.Replace("/", "").ToLower());
                                lhSensor.altReading.Text = SensorUtils.ToFormattedString(lhSensor.alt.modifiedMeasurement, true);
                            }
                        }));
                    }
                }

                altUnit.AddAction(UIAlertAction.Create(Util.Strings.CANCEL, UIAlertActionStyle.Cancel, (action) => {}));

                vc.PresentViewController(altUnit, true, null);
            };

            this.AddSubview(cellHeader);
            this.AddSubview(cellButton);
            this.AddSubview(cellReading);
        }