/// <summary>
        /// EVENT FUNCTION FOR ACTION POPUP FOR SINGLE SENSOR
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void handleActionPopup(object sender, EventArgs e)
        {
            UIAlertController addDeviceSheet;

            addDeviceSheet = UIAlertController.Create(Util.Strings.Analyzer.DEVICEACTIONS, "", UIAlertControllerStyle.Alert);

            UIPopoverPresentationController presentationPopover = addDeviceSheet.PopoverPresentationController;

            if (presentationPopover != null)
            {
                presentationPopover.SourceView = this.View;
                presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Right;
            }
            if (sensorActions.pressedSensor.isManual.Equals(false))
            {
                addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.Alarms.SELF, UIAlertActionStyle.Default, (action) => {
                    alarmRequestViewer(sensorActions);
                }));
            }
            addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.RENAME, UIAlertActionStyle.Default, (action) => {
                renamePopup();
            }));
            addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.Analyzer.REMOVESENSOR, UIAlertActionStyle.Default, (action) => {
                AnalyserUtilities.RemoveDevice(sensorActions, lowHighSensors, analyzerSensors, ion.currentAnalyzer.sensorList);
                blockerView.Hidden       = true;
                sactionView.aView.Hidden = true;
            }));

            addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.CANCEL, UIAlertActionStyle.Cancel, (action) => { Console.WriteLine("Cancel Action"); blockerView.Hidden = true; }));
            this.View.Window.RootViewController.PresentViewController(addDeviceSheet, true, null);
        }
        /// <summary>
        /// POPUP TO DETERMINE LOW/HIGH AREA ACTIONS
        /// </summary>
        /// <param name="pressedArea">LOCATION OF SENSOR</param>
        public void ShowPopup(UIView pressedArea, lowHighSensor lowHighArea, sensor associatedSensor)
        {
            UIAlertController addDeviceSheet;

            ///LOW/HIGH AREA IS ASSOCIATED WITH A SINGLE SENSOR ALREADY

            addDeviceSheet = UIAlertController.Create(Util.Strings.Analyzer.ADDFROM, "", UIAlertControllerStyle.Alert);

            if (lowHighArea.snapArea.AccessibilityIdentifier == "low" || lowHighArea.snapArea.AccessibilityIdentifier == "high")
            {
                addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.Device.Manager.SELF, UIAlertActionStyle.Default, (action) => {
                    if ((lowHighArea.snapArea.AccessibilityIdentifier == "low" && ion.currentAnalyzer.IsSideFull(ESide.Low)) || (lowHighArea.snapArea.AccessibilityIdentifier == "high" && ion.currentAnalyzer.IsSideFull(ESide.High)))
                    {
                        showFullAlert();
                    }
                    else
                    {
                        Console.WriteLine("Low high pressed");
                        lhOnRequestViewer(lowHighArea);
                    }
                }));

                addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.Analyzer.CREATEMANUAL, UIAlertActionStyle.Default, (action) => {
                    if ((lowHighArea.snapArea.AccessibilityIdentifier == "low" && ion.currentAnalyzer.IsSideFull(ESide.Low)) || (lowHighArea.snapArea.AccessibilityIdentifier == "high" && ion.currentAnalyzer.IsSideFull(ESide.High)))
                    {
                        showFullAlert();
                    }
                    else
                    {
                        //start = new manualEntry();
                        start.pressedView  = pressedArea;
                        start.topLabel     = lowHighArea.LabelTop;
                        start.middleLabel  = lowHighArea.LabelMiddle;
                        start.bottomLabel  = lowHighArea.LabelBottom;
                        start.subviewLabel = lowHighArea.LabelSubview;
                        mentryView.mView.AccessibilityIdentifier = "Pressure";
                        mentryView.setDoneAction();
                        mentryView.isManual     = true;
                        mentryView.mView.Hidden = false;
                    }
                }));
            }
            else
            {
                addDeviceSheet = UIAlertController.Create(lowHighArea.LabelTop.Text + " " + Util.Strings.ACTIONS, "", UIAlertControllerStyle.Alert);
                if (associatedSensor.currentSensor != null && !associatedSensor.currentSensor.device.isConnected)
                {
                    addDeviceSheet.AddAction(UIAlertAction.Create(Strings.Device.RECONNECT.FromResources(), UIAlertActionStyle.Default, (action) => {
                        lowHighSensors.lowArea.connectionSpinner(2);
                    }));
                }

                addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.Analyzer.ADDSUBVIEW, UIAlertActionStyle.Default, (action) => {
                    AnalyserUtilities.subviewOptionChosen(lowHighArea);
                }));

                if (!lowHighArea.isManual)
                {
                    addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.Alarms.SELF, UIAlertActionStyle.Default, (action) => {
                        AnalyserUtilities.alarmRequestViewer(associatedSensor);
                    }));
                }
                addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.Analyzer.REMOVESENSOR, UIAlertActionStyle.Default, (action) => {
                    var attached = AnalyserUtilities.RemoveDevice(associatedSensor, lowHighSensors);
                    Console.WriteLine("attached was: " + attached);
                    if (attached == "low")
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            analyzerSensors.viewList[i].topLabel.BackgroundColor = UIColor.White;
                            analyzerSensors.viewList[i].topLabel.TextColor       = UIColor.Gray;
                        }
                    }
                    else if (attached == "high")
                    {
                        for (int i = 4; i < 8; i++)
                        {
                            analyzerSensors.viewList[i].topLabel.BackgroundColor = UIColor.White;
                            analyzerSensors.viewList[i].topLabel.TextColor       = UIColor.Gray;
                        }
                    }
                }));

                if (associatedSensor.currentSensor != null && associatedSensor.currentSensor.device.isConnected)
                {
                    addDeviceSheet.AddAction(UIAlertAction.Create(Strings.Device.DISCONNECT.FromResources(), UIAlertActionStyle.Default, (action) => {
                        lowHighSensors.lowArea.connectionSpinner(1);
                    }));
                }

                addDeviceSheet.AddAction(UIAlertAction.Create(Util.Strings.RENAME, UIAlertActionStyle.Default, (action) => {
                    AnalyserUtilities.renamePopup(associatedSensor, lowHighArea);
                }));
            }

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

            this.View.Window.RootViewController.PresentViewController(addDeviceSheet, true, null);
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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);
        }
        /// <summary>
        /// CREATE GESTURE RECOGNIZERS FOR DRAG/DROP AND LONG PRESS
        /// </summary>
        void AddSensorGestures(sensor Sensor, UIView mainView)
        {
            ////CREATE OFFSETS TO FOLLOW EACH SUBVIEW AS IT MOVES

            nfloat dx = 0;
            nfloat dy = 0;

            Sensor.panGesture = new UIPanGestureRecognizer(() => {
                if (Sensor.panGesture.State == UIGestureRecognizerState.Began)
                {
                    //View.BringSubviewToFront(Sensor.snapArea);
                    mainView.BringSubviewToFront(Sensor.snapArea);
                }
                if ((Sensor.panGesture.State == UIGestureRecognizerState.Began || Sensor.panGesture.State == UIGestureRecognizerState.Changed) && (Sensor.panGesture.NumberOfTouches == 1))
                {
                    // remove any previosuly applied snap behavior to avoid a flicker that will occur if both the gesture and physics are operating on the view simultaneously
                    if (snap != null)
                    {
                        animator.RemoveBehavior(snap);
                    }

                    //var p0 = Sensor.panGesture.LocationInView (View);
                    var p0 = Sensor.panGesture.LocationInView(mainView);

                    if (dx == 0)
                    {
                        dx = p0.X - Sensor.snapArea.Center.X;
                    }

                    if (dy == 0)
                    {
                        dy = p0.Y - Sensor.snapArea.Center.Y;
                    }

                    // this is where the offsets are applied so that the location of the image follows the point where the image is touched as it is dragged,
                    // otherwise the center of the image would snap to the touch point at the start of the pan gesture

                    var p1 = new CGPoint(p0.X - dx, p0.Y - dy);

                    Sensor.snapArea.Center = p1;
                }
                else if (Sensor.panGesture.State == UIGestureRecognizerState.Ended)
                {
                    //View.SendSubviewToBack(Sensor.snapArea);
                    mainView.SendSubviewToBack(Sensor.snapArea);
                    // reset offsets when dragging ends so that they will be recalculated for next touch and drag that occurs
                    dx = 0;
                    dy = 0;

                    /// CHECK IF SENSOR WAS DROPPED IN LOW OR HIGH SECTION

                    AnalyserUtilities.updateLowHighArea(Sensor.panGesture.LocationInView(mainView), Sensor, lowHighSensors, this, mainView);

                    ////FIGURE OUT WHERE TO SNAP THE SUBVIEW BASED ON IT'S LOCATION AND IDENTIFIER
                    AnalyserUtilities.LHSwapCheck(this, lowHighSensors, Convert.ToInt32(Sensor.snapArea.AccessibilityIdentifier), Sensor.panGesture.LocationInView(mainView), mainView);
                }
                else if (Sensor.panGesture.State == UIGestureRecognizerState.Failed)
                {
                    Console.WriteLine("Touch has failed to be recognized for " + Sensor.snapArea.AccessibilityIdentifier + " area");
                }
            });

            Sensor.holdGesture = new UILongPressGestureRecognizer(() => {
                if (Sensor.holdGesture.State == UIGestureRecognizerState.Began)
                {
                }
            });
        }