/// <summary> /// Called to inflate the device manager viewcontroller and allow BT connections for single sensors /// </summary> private void lhOnRequestViewer(lowHighSensor area) { var sb = InflateViewController <DeviceGridViewController>(VC_DEVICE_GRID); sb.fromAnalyzerLH = true; sb.onSensorReturnDelegate = (GaugeDeviceSensor sensor) => { if (sensor.type == ESensorType.Temperature) { UIAlertController tempAlert = UIAlertController.Create(Util.Strings.Analyzer.SETUP, Util.Strings.Analyzer.SETUPPRESSURE, UIAlertControllerStyle.Alert); tempAlert.AddAction(UIAlertAction.Create(Util.Strings.OK, UIAlertActionStyle.Cancel, null)); this.PresentViewController(tempAlert, true, null); } else { addLHDeviceSensor(area, sensor); if (area.location == "low") { lowHighSensors.lowArea.subviewTable.Source = new AnalyzerTableSource(ion.currentAnalyzer.lowSideSensor, lowHighSensors.lowArea); } else { lowHighSensors.highArea.subviewTable.Source = new AnalyzerTableSource(ion.currentAnalyzer.highSideSensor, lowHighSensors.highArea); } } }; NavigationController.PushViewController(sb, true); }
public void makeEvents(lowHighSensor lhSensor, CGRect tableRect) { //UILabel cellHeader = new UILabel(new CGRect(0,0,150, 30)); cellHeader = new UILabel(new CGRect(0, 0, 1.006 * lhSensor.snapArea.Bounds.Width, .5 * lhSensor.cellHeight)); //UILabel cellReading = new UILabel(new CGRect(30,30,121,30)); //cellReading = new UILabel(new CGRect(.201 * tableRect.Width, .5 * lhSensor.cellHeight , .812 * tableRect.Width, .5 * lhSensor.cellHeight )); //UIButton cellButton = new UIButton(new CGRect(0,30,30,30)); cellButton = new UIButton(new CGRect(0, .5 * lhSensor.cellHeight, .201 * tableRect.Width, .5 * lhSensor.cellHeight)); cellHeader.Text = "MIN"; cellHeader.TextColor = UIColor.White; cellHeader.BackgroundColor = UIColor.Black; cellHeader.Font = UIFont.FromName("Helvetica-Bold", 21f); cellHeader.TextAlignment = UITextAlignment.Center; cellHeader.AdjustsFontSizeToFitWidth = true; cellReading = lhSensor.minReading; if (lhSensor.minType.Equals("hold") && lhSensor.currentSensor != null) { lhSensor.min = lhSensor.currentSensor.measurement.amount; lhSensor.minType = lhSensor.LabelBottom.Text; } if (lhSensor.isManual) { var amount = Convert.ToDecimal(lhSensor.LabelMiddle.Text); cellReading.Text = amount.ToString("N") + " " + lhSensor.LabelBottom.Text + " "; } else { cellReading.Text = lhSensor.min.ToString("N") + " " + lhSensor.minType + " "; } cellReading.TextAlignment = UITextAlignment.Right; cellReading.Font = UIFont.FromName("Helvetica", 18f); cellReading.AdjustsFontSizeToFitWidth = true; cellReading.Layer.BorderColor = UIColor.Black.CGColor; cellButton.SetImage(UIImage.FromBundle("ic_refresh"), UIControlState.Normal); cellButton.Layer.BorderColor = UIColor.Black.CGColor; cellButton.Layer.BorderWidth = 1f; cellButton.TouchUpInside += delegate { lhSensor.min = Convert.ToDouble(lhSensor.LabelMiddle.Text); lhSensor.minType = lhSensor.LabelBottom.Text; cellReading.Text = lhSensor.min.ToString("N") + " " + lhSensor.minType + " "; }; this.AddSubview(cellHeader); this.AddSubview(cellReading); this.AddSubview(cellButton); }
public void makeEvents(lowHighSensor lhSensor, CGRect tableRect) { cellHeader = new UILabel(new CGRect(0, 0, 1.006 * tableRect.Width, .5 * lhSensor.cellHeight)); cellReading = new UILabel(new CGRect(.2 * tableRect.Width, .5 * lhSensor.cellHeight, .79 * tableRect.Width, .5 * lhSensor.cellHeight)); cellButton = new UIButton(new CGRect(0, .5 * lhSensor.cellHeight, .2 * tableRect.Width, .5 * lhSensor.cellHeight)); cellHeader.Text = Util.Strings.Analyzer.HOLD.ToUpper(); cellHeader.TextColor = UIColor.White; cellHeader.BackgroundColor = UIColor.Black; cellHeader.Font = UIFont.FromName("Helvetica-Bold", 21f); cellHeader.TextAlignment = UITextAlignment.Center; cellHeader.AdjustsFontSizeToFitWidth = true; if (lhSensor.holdType != "hold") { cellReading.Text = lhSensor.holdValue.ToString("N") + " " + lhSensor.holdType + " "; } else { cellReading.Text = lhSensor.holdValue.ToString("N"); } cellReading.TextAlignment = UITextAlignment.Right; cellReading.Font = UIFont.FromName("Helvetica", 18f); cellReading.AdjustsFontSizeToFitWidth = true; cellReading.Layer.BorderColor = UIColor.Black.CGColor; cellButton.SetImage(UIImage.FromBundle("ic_refresh"), UIControlState.Normal); cellButton.Layer.BorderColor = UIColor.Black.CGColor; cellButton.Layer.BorderWidth = 1f; cellButton.TouchUpInside += delegate { if (lhSensor.isManual) { lhSensor.holdValue = Convert.ToDouble(lhSensor.LabelMiddle.Text); lhSensor.holdType = lhSensor.LabelBottom.Text; cellReading.Text = lhSensor.LabelMiddle.Text + " " + lhSensor.LabelBottom.Text + " "; } else { lhSensor.holdValue = Convert.ToDouble(lhSensor.LabelMiddle.Text); lhSensor.holdType = lhSensor.LabelBottom.Text; cellReading.Text = lhSensor.holdValue.ToString("N") + " " + lhSensor.holdType + " "; } }; this.AddSubview(cellHeader); this.AddSubview(cellReading); this.AddSubview(cellButton); }
public void makeEvents(lowHighSensor lhSensor, CGRect tableRect) { cellHeader = new UILabel(new CGRect(0, 0, 1.006 * tableRect.Width, .5 * lhSensor.cellHeight)); secondaryReading = new UILabel(new CGRect(0, .5 * lhSensor.cellHeight, tableRect.Width, .5 * lhSensor.cellHeight)); if (lhSensor.currentSensor != null && lhSensor.currentSensor.type == ESensorType.Temperature) { cellHeader.Text = Util.Strings.LINKED + " PRESS"; } else if (lhSensor.currentSensor != null) { cellHeader.Text = Util.Strings.LINKED + " TEMP"; } else if (lhSensor.manualSensor != null && lhSensor.manualSensor.type == ESensorType.Pressure) { cellHeader.Text = Util.Strings.LINKED + " TEMP"; } else { cellHeader.Text = Util.Strings.LINKED + " PRESS"; } cellHeader.TextColor = UIColor.White; cellHeader.BackgroundColor = UIColor.Black; cellHeader.Font = UIFont.FromName("Helvetica-Bold", 21f); cellHeader.TextAlignment = UITextAlignment.Center; cellHeader.AdjustsFontSizeToFitWidth = true; secondaryReading = lhSensor.secondaryReading; secondaryReading.AdjustsFontSizeToFitWidth = true; secondaryReading.TextAlignment = UITextAlignment.Center; if (lhSensor.currentSensor != null && lhSensor.currentSensor.linkedSensor != null) { secondaryReading.Text = lhSensor.currentSensor.linkedSensor.measurement.amount.ToString("N") + " " + lhSensor.currentSensor.linkedSensor.unit; } else if (lhSensor.manualSensor != null && lhSensor.manualSensor.linkedSensor != null) { secondaryReading.Text = lhSensor.manualSensor.linkedSensor.measurement.amount.ToString("N") + " " + lhSensor.manualSensor.linkedSensor.unit; } else { secondaryReading.Text = Util.Strings.Device.NOTLINKED; } this.AddSubview(cellHeader); this.AddSubview(secondaryReading); }
public void makeEvents(lowHighSensor lhSensor, CGRect tableRect) { cellHeader = new UILabel(new CGRect(0, 0, 1.006 * tableRect.Width, .5 * lhSensor.cellHeight)); fluidType = new UILabel(new CGRect(0, .5 * lhSensor.cellHeight, .5 * tableRect.Width, .5 * lhSensor.cellHeight)); cellHeader = lhSensor.ptFluidState; cellHeader.TextColor = UIColor.White; cellHeader.BackgroundColor = UIColor.Black; cellHeader.Font = UIFont.FromName("Helvetica-Bold", 21f); cellHeader.TextAlignment = UITextAlignment.Center; cellHeader.AdjustsFontSizeToFitWidth = true; fluidType = lhSensor.ptFluidType; fluidType.Text = ion.fluidManager.lastUsedFluid.name; fluidType.BackgroundColor = CGExtensions.FromARGB8888(lhSensor.ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); fluidType.TextAlignment = UITextAlignment.Center; fluidType.Font = UIFont.FromName("Helvetica", 18f); fluidType.AdjustsFontSizeToFitWidth = true; fluidType.Layer.BorderColor = UIColor.Black.CGColor; fluidType.Layer.BorderWidth = 1f; tempReading = lhSensor.ptReading; tempReading.AdjustsFontSizeToFitWidth = true; tempReading.TextAlignment = UITextAlignment.Center; tempReading.Layer.BorderColor = UIColor.Black.CGColor; tempReading.Layer.BorderWidth = 1f; this.AddSubview(cellHeader); this.AddSubview(lhSensor.ptFluidType); this.AddSubview(lhSensor.ptReading); this.AddSubview(lhSensor.changePTFluid); }
public AnalyzerTableSource(Sensor sensor, lowHighSensor lhSensor) { sourceSensor = sensor; tableSensors = lhSensor; }
public LowHighArea(UIView mainView, AnalyzerViewController ViewController, sensorGroup analyzerSensors) { lowArea = new lowHighSensor(new CGRect(.028 * mainView.Bounds.Width, .45 * mainView.Bounds.Height, .465 * mainView.Bounds.Width, .202 * mainView.Bounds.Height), new CGRect(.028 * mainView.Bounds.Width, .652 * mainView.Bounds.Height, .465 * mainView.Bounds.Width, .25 * mainView.Bounds.Height), ViewController, analyzerSensors.viewList); lowArea.location = "low"; lowArea.undefinedText = Strings.Analyzer.LOWUNDEFINED; lowArea.Connection.Image = UIImage.FromBundle("ic_bluetooth_disconnected"); lowArea.LabelSubview.BackgroundColor = UIColor.Blue; lowArea.snapArea.BackgroundColor = UIColor.White; lowArea.snapArea.Alpha = 1f; lowArea.snapArea.UserInteractionEnabled = true; lowArea.snapArea.AccessibilityIdentifier = "low"; lowArea.snapArea.Layer.CornerRadius = 5; lowArea.LabelTop.AdjustsFontSizeToFitWidth = true; lowArea.LabelTop.Text = ""; lowArea.LabelTop.Layer.CornerRadius = 5; lowArea.LabelTop.ClipsToBounds = true; lowArea.LabelMiddle.AdjustsFontSizeToFitWidth = true; lowArea.LabelMiddle.Text = Util.Strings.Analyzer.LOWUNDEFINED; lowArea.LabelMiddle.TextAlignment = UITextAlignment.Right; lowArea.LabelBottom.AdjustsFontSizeToFitWidth = true; lowArea.LabelBottom.Text = ""; lowArea.LabelBottom.TextAlignment = UITextAlignment.Right; lowArea.LabelBottom.BackgroundColor = UIColor.Clear; lowArea.LabelSubview.AdjustsFontSizeToFitWidth = true; lowArea.LabelSubview.Text = ""; lowArea.LabelSubview.TextColor = UIColor.White; lowArea.LabelSubview.ClipsToBounds = true; lowArea.subviewTable.BackgroundColor = UIColor.Clear; lowArea.subviewTable.SeparatorStyle = UITableViewCellSeparatorStyle.None; lowArea.subviewTable.Hidden = true; lowArea.subviewTable.Source = null; lowArea.subviewHide.BackgroundColor = UIColor.Blue; lowArea.subviewHide.SetImage(null, UIControlState.Normal); lowArea.subviewHide.Hidden = true; lowArea.Connection.Image = UIImage.FromBundle("ic_bluetooth_connected"); lowArea.Connection.BackgroundColor = UIColor.Clear; lowArea.Connection.Hidden = true; lowArea.connectionColor.Layer.CornerRadius = 5; lowArea.connectionColor.Layer.BorderColor = UIColor.Black.CGColor; lowArea.connectionColor.Layer.BorderWidth = 1f; lowArea.connectionColor.Hidden = true; lowArea.subviewDivider.BackgroundColor = UIColor.Black; lowArea.headingDivider.Hidden = true; lowArea.headingDivider.BackgroundColor = UIColor.Black; lowArea.snapArea.AddSubview(lowArea.LabelTop); lowArea.snapArea.AddSubview(lowArea.LabelMiddle); lowArea.snapArea.AddSubview(lowArea.LabelBottom); lowArea.snapArea.AddSubview(lowArea.LabelSubview); lowArea.snapArea.AddSubview(lowArea.DeviceImage); lowArea.snapArea.AddSubview(lowArea.Connection); lowArea.snapArea.AddSubview(lowArea.subviewDivider); lowArea.snapArea.AddSubview(lowArea.headingDivider); lowArea.snapArea.AddSubview(lowArea.subviewHide); lowArea.snapArea.BringSubviewToFront(lowArea.headingDivider); lowArea.snapArea.AddSubview(lowArea.connectionColor); lowArea.snapArea.BringSubviewToFront(lowArea.Connection); lowArea.snapArea.AddSubview(lowArea.conDisButton); lowArea.snapArea.BringSubviewToFront(lowArea.conDisButton); lowArea.snapArea.BringSubviewToFront(lowArea.subviewDivider); highArea = new lowHighSensor(new CGRect(.507 * mainView.Bounds.Width, .45 * mainView.Bounds.Height, .465 * mainView.Bounds.Width, .202 * mainView.Bounds.Height), new CGRect(.507 * mainView.Bounds.Width, .652 * mainView.Bounds.Height, .465 * mainView.Bounds.Width, .25 * mainView.Bounds.Height), ViewController, analyzerSensors.viewList); highArea.location = "high"; highArea.undefinedText = Strings.Analyzer.HIGHUNDEFINED; highArea.Connection.Image = UIImage.FromBundle("ic_bluetooth_disconnected"); highArea.LabelSubview.BackgroundColor = UIColor.Red; highArea.snapArea.BackgroundColor = UIColor.White; highArea.snapArea.Alpha = 1f; highArea.snapArea.UserInteractionEnabled = true; highArea.snapArea.AccessibilityIdentifier = "high"; highArea.snapArea.Layer.CornerRadius = 5; highArea.LabelTop.AdjustsFontSizeToFitWidth = true; highArea.LabelTop.Text = ""; highArea.LabelTop.Layer.CornerRadius = 5; highArea.LabelTop.ClipsToBounds = true; highArea.LabelMiddle.AdjustsFontSizeToFitWidth = true; highArea.LabelMiddle.Text = Util.Strings.Analyzer.HIGHUNDEFINED; highArea.LabelMiddle.TextAlignment = UITextAlignment.Right; highArea.LabelBottom.AdjustsFontSizeToFitWidth = true; highArea.LabelBottom.Text = ""; highArea.LabelBottom.TextAlignment = UITextAlignment.Right; highArea.LabelSubview.AdjustsFontSizeToFitWidth = true; highArea.LabelSubview.Text = ""; highArea.LabelSubview.TextColor = UIColor.White; highArea.LabelSubview.ClipsToBounds = true; highArea.subviewTable.BackgroundColor = UIColor.Clear; highArea.subviewTable.SeparatorStyle = UITableViewCellSeparatorStyle.None; highArea.subviewTable.Hidden = true; highArea.subviewTable.Source = null; highArea.subviewHide.BackgroundColor = UIColor.Red; highArea.subviewHide.SetImage(null, UIControlState.Normal); highArea.subviewHide.Hidden = true; highArea.Connection.Image = UIImage.FromBundle("ic_bluetooth_connected"); highArea.Connection.Hidden = true; highArea.Connection.BackgroundColor = UIColor.Clear; highArea.connectionColor.Layer.CornerRadius = 5; highArea.connectionColor.Layer.BorderColor = UIColor.Black.CGColor; highArea.connectionColor.Layer.BorderWidth = 1f; highArea.connectionColor.Hidden = true; highArea.subviewDivider.BackgroundColor = UIColor.Black; highArea.headingDivider.Hidden = true; highArea.headingDivider.BackgroundColor = UIColor.Black; highArea.snapArea.AddSubview(highArea.LabelTop); highArea.snapArea.AddSubview(highArea.LabelMiddle); highArea.snapArea.AddSubview(highArea.LabelBottom); highArea.snapArea.AddSubview(highArea.LabelSubview); highArea.snapArea.AddSubview(highArea.DeviceImage); highArea.snapArea.AddSubview(highArea.Connection); highArea.snapArea.AddSubview(highArea.subviewDivider); highArea.snapArea.AddSubview(highArea.headingDivider); highArea.snapArea.AddSubview(highArea.subviewHide); highArea.snapArea.BringSubviewToFront(highArea.headingDivider); highArea.snapArea.AddSubview(highArea.connectionColor); highArea.snapArea.BringSubviewToFront(highArea.Connection); highArea.snapArea.AddSubview(highArea.conDisButton); highArea.snapArea.BringSubviewToFront(highArea.conDisButton); highArea.snapArea.BringSubviewToFront(highArea.subviewDivider); lowArea.hideLHUI(); highArea.hideLHUI(); }
/// <summary> /// Adds the LH Device sensor from the low or high menu. /// </summary> /// <param name="area">Area.</param> /// <param name="sensor">Sensor.</param> public void addLHDeviceSensor(lowHighSensor area, GaugeDeviceSensor sensor) { ///DON'T ALLOW A USER TO ADD AN EXISTING SENSOR TO THE OPPOSITE SIDE. JUST LET THEM KNOW IT IS ALREADY ON THE ANALYZER ESide side; var exists = ion.currentAnalyzer.GetSideOfSensor(sensor, out side); if ((exists && area.location == "low" && side == ESide.High) || (exists && area.location == "high" && side == ESide.Low)) { UIAlertController fullPopup = UIAlertController.Create(Util.Strings.Analyzer.CANTMOVE, Util.Strings.Analyzer.SENSOREXISTS, UIAlertControllerStyle.Alert); fullPopup.AddAction(UIAlertAction.Create(Util.Strings.OK, UIAlertActionStyle.Default, (action) => { })); PresentViewController(fullPopup, true, null); return; } else { if (area.location == "low" && ion.currentAnalyzer.IsSensorOnSide(sensor, ESide.Low)) { var foundSensor = analyzerSensors.GetSlotFromSensor(sensor); foundSensor.topLabel.BackgroundColor = UIColor.Blue; foundSensor.topLabel.TextColor = UIColor.White; ion.currentAnalyzer.SetManifold(ESide.Low, sensor); lowHighSensors.lowArea.currentSensor = sensor; ion.currentAnalyzer.lowAccessibility = foundSensor.snapArea.AccessibilityIdentifier; area.snapArea.AccessibilityIdentifier = foundSensor.snapArea.AccessibilityIdentifier; } else if (area.location == "high" && ion.currentAnalyzer.IsSensorOnSide(sensor, ESide.High)) { var foundSensor = analyzerSensors.GetSlotFromSensor(sensor); foundSensor.topLabel.BackgroundColor = UIColor.Red; foundSensor.topLabel.TextColor = UIColor.White; ion.currentAnalyzer.SetManifold(ESide.High, sensor); lowHighSensors.highArea.currentSensor = sensor; ion.currentAnalyzer.highAccessibility = foundSensor.snapArea.AccessibilityIdentifier; area.snapArea.AccessibilityIdentifier = foundSensor.snapArea.AccessibilityIdentifier; } else { if (!ion.currentAnalyzer.sensorList.Contains(sensor)) { ion.currentAnalyzer.sensorList.Add(sensor); } var addedIndex = -1; if (area.location == "low") { ion.currentAnalyzer.AddSensorToSide(ESide.Low, sensor); addedIndex = ion.currentAnalyzer.IndexOfSensor(sensor); analyzerSensors.viewList[addedIndex].topLabel.BackgroundColor = UIColor.Blue; ion.currentAnalyzer.SetManifold(ESide.Low, sensor); lowHighSensors.lowArea.currentSensor = sensor; ion.currentAnalyzer.lowAccessibility = addedIndex.ToString(); } else { ion.currentAnalyzer.AddSensorToSide(ESide.High, sensor); addedIndex = ion.currentAnalyzer.IndexOfSensor(sensor); analyzerSensors.viewList[addedIndex].topLabel.BackgroundColor = UIColor.Red; ion.currentAnalyzer.SetManifold(ESide.High, sensor); lowHighSensors.highArea.currentSensor = sensor; ion.currentAnalyzer.highAccessibility = addedIndex.ToString(); } sensor.analyzerArea = Convert.ToInt32(analyzerSensors.viewList[addedIndex].snapArea.AccessibilityIdentifier); sensor.analyzerSlot = addedIndex; analyzerSensors.viewList[addedIndex].topLabel.TextColor = UIColor.White; analyzerSensors.viewList[addedIndex].isManual = false; analyzerSensors.viewList[addedIndex].currentSensor = sensor; analyzerSensors.viewList[addedIndex].updateUI(); area.snapArea.AccessibilityIdentifier = addedIndex.ToString(); area.setLHUI(); } } }
/// <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); }
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); }
public void makeEvents(lowHighSensor lhSensor, CGRect tableRect) { cellRoc = lhSensor.roc; cellSensor = lhSensor.currentSensor; cellRoc.onSensorPropertyChanged += OnSensorPropertyChanged; primaryColor = OxyColors.Blue; secondaryColor = OxyColors.Red; if (cellSensor.type == ESensorType.Temperature) { primaryColor = OxyColors.Red; secondaryColor = OxyColors.Blue; Console.WriteLine("Creating roc plotmodel for temperature sensor " + cellSensor.name); } else if (cellSensor.type == ESensorType.Vacuum) { primaryColor = OxyColors.Maroon; Console.WriteLine("Creating roc plotmodel for vacuum sensor " + cellSensor.name); } else { Console.WriteLine("Creating roc plotmodel for pressure sensor " + cellSensor.name); } Console.WriteLine("Cell height: " + this.Bounds.Height); cellHeader = new UILabel(new CGRect(0, 0, tableRect.Width, 36)); cellImage = new UIImageView(new CGRect(0, 36, 36, 36)); graphView = new UIView(new CGRect(0, 72, tableRect.Width, 72)); graphView.BackgroundColor = UIColor.Clear; ///SETUP THE TRENDING GRAPH if (plotView == null) { plotView = new PlotView(new CGRect(0, 0, graphView.Bounds.Width, graphView.Bounds.Height)) { Model = CreatePlotModel(), BackgroundColor = UIColor.Clear, }; plotView.Layer.BorderWidth = 1f; plotView.UserInteractionEnabled = false; graphView.AddSubview(plotView); } cellHeader.Text = "TREND"; cellHeader.TextColor = UIColor.White; cellHeader.BackgroundColor = UIColor.Black; cellHeader.Font = UIFont.FromName("Helvetica-Bold", 21f); cellHeader.TextAlignment = UITextAlignment.Center; cellHeader.AdjustsFontSizeToFitWidth = true; cellReading = lhSensor.rocReading; cellReading.Text = Util.Strings.Workbench.Viewer.ROC_STABLE; cellReading.TextAlignment = UITextAlignment.Right; cellReading.Font = UIFont.FromName("Helvetica-Bold", 18f); cellReading.AdjustsFontSizeToFitWidth = true; cellReading.Layer.BorderColor = UIColor.Black.CGColor; cellImage = lhSensor.rocImage; cellImage.Layer.BorderColor = UIColor.Black.CGColor; cellImage.Layer.BorderWidth = 1f; this.AddSubview(cellHeader); this.AddSubview(cellReading); this.AddSubview(cellImage); this.AddSubview(graphView); updateCellGraph(); }
public void makeEvents(lowHighSensor lhSensor, CGRect tableRect) { cellHeader = new UILabel(new CGRect(0, 0, 1.006 * tableRect.Width, .5 * lhSensor.cellHeight)); cellHeader = lhSensor.shFluidState; //lhSensor.shFluidState = cellHeader; cellHeader.TextColor = UIColor.White; cellHeader.BackgroundColor = UIColor.Black; cellHeader.Font = UIFont.FromName("Helvetica-Bold", 21f); cellHeader.TextAlignment = UITextAlignment.Center; cellHeader.AdjustsFontSizeToFitWidth = true; fluidType = lhSensor.shFluidType; fluidType.Text = ion.fluidManager.lastUsedFluid.name; fluidType.BackgroundColor = CGExtensions.FromARGB8888(lhSensor.ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); if (lhSensor.currentSensor.fluidState.Equals(Fluid.EState.Dew)) { cellHeader.Text = Util.Strings.Analyzer.SC; } else if (lhSensor.currentSensor.fluidState.Equals(Fluid.EState.Bubble)) { cellHeader.Text = Util.Strings.Analyzer.SH; } fluidType.TextAlignment = UITextAlignment.Center; fluidType.Font = UIFont.FromName("Helvetica", 18f); fluidType.AdjustsFontSizeToFitWidth = true; fluidType.Layer.BorderColor = UIColor.Black.CGColor; fluidType.Layer.BorderWidth = 1f; tempReading = lhSensor.shReading; if (lhSensor.currentSensor.linkedSensor != null) { var stateCheck = new ScalarSpan(); if (lhSensor.currentSensor.type == ESensorType.Pressure) { var calculation = ion.fluidManager.lastUsedFluid.CalculateTemperatureDelta(lhSensor.currentSensor.fluidState, lhSensor.currentSensor.measurement, lhSensor.currentSensor.linkedSensor.measurement, ion.locationManager.lastKnownLocation.altitude); stateCheck = calculation; if (!ion.fluidManager.lastUsedFluid.mixture && calculation < 0) { calculation = calculation * -1; } cellHeader.Text = lhSensor.shFluidState.Text; tempReading.Text = calculation.magnitude.ToString("N") + " " + calculation.unit.ToString(); } else { var calculation = ion.fluidManager.lastUsedFluid.CalculateTemperatureDelta(lhSensor.currentSensor.fluidState, lhSensor.currentSensor.linkedSensor.measurement, lhSensor.currentSensor.measurement, ion.locationManager.lastKnownLocation.altitude); stateCheck = calculation; if (!ion.fluidManager.lastUsedFluid.mixture && calculation < 0) { calculation = calculation * -1; } cellHeader.Text = lhSensor.shFluidState.Text; tempReading.Text = calculation.magnitude.ToString("N") + " " + calculation.unit.ToString(); } var ptAmount = stateCheck.magnitude; if (!ion.fluidManager.lastUsedFluid.mixture) { if (ptAmount < 0) { lhSensor.shFluidState.Text = Util.Strings.Analyzer.SC; } else { lhSensor.shFluidState.Text = Util.Strings.Analyzer.SH; } } else if (lhSensor.currentSensor.fluidState.Equals(Fluid.EState.Bubble)) { lhSensor.shFluidState.Text = Util.Strings.Analyzer.SC; } else if (lhSensor.currentSensor.fluidState.Equals(Fluid.EState.Dew)) { lhSensor.shFluidState.Text = Util.Strings.Analyzer.SH; } } else { tempReading.Text = Util.Strings.Analyzer.SETUP; } tempReading.AdjustsFontSizeToFitWidth = true; tempReading.TextAlignment = UITextAlignment.Center; this.AddSubview(cellHeader); this.AddSubview(lhSensor.shFluidType); this.AddSubview(tempReading); this.AddSubview(lhSensor.changeFluid); }