//// Updates the calculations and labels for a pt cell public void updatePTCell() { if (currentSensor.type == ESensorType.Pressure) { ptFluidType.Text = ion.fluidManager.lastUsedFluid.name; ptFluidType.BackgroundColor = CGExtensions.FromARGB8888(ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); var ptcalc = ion.fluidManager.lastUsedFluid.GetSaturatedTemperature(currentSensor.fluidState, currentSensor.measurement, ion.locationManager.lastKnownLocation.altitude); ptReading.Text = ptcalc.ConvertTo(tUnit).amount.ToString("N") + " " + ptcalc.unit; } else if (currentSensor.type == ESensorType.Temperature) { ptFluidType.Text = ion.fluidManager.lastUsedFluid.name; ptFluidType.BackgroundColor = CGExtensions.FromARGB8888(ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); var ptcalc = ion.fluidManager.lastUsedFluid.GetPressureFromSaturatedTemperature(currentSensor.fluidState, currentSensor.measurement, ion.locationManager.lastKnownLocation.altitude); ptcalc = ion.fluidManager.lastUsedFluid.ConvertAbsolutePressureToRelative(ptcalc, ion.locationManager.lastKnownLocation.altitude); ptReading.Text = ptcalc.ConvertTo(pUnit).amount.ToString("N") + " " + ptcalc.unit; } if (!ion.fluidManager.lastUsedFluid.mixture) { ptFluidState.Text = "PT"; } else if (currentSensor.fluidState.Equals(Fluid.EState.Bubble)) { ptFluidState.Text = "PTBub"; } else if (currentSensor.fluidState.Equals(Fluid.EState.Dew)) { ptFluidState.Text = "PTDew"; } }
public void UpdateTo(string fluidName, int fluidColor, bool selected, bool preferred, EventHandler <string> favoriteClicked = null) { var safetyInfo = ion.fluidManager.GetFluidSafety(fluidName); this.fluidName = fluidName; viewFluidColor.BackgroundColor = CGExtensions.FromARGB8888(fluidColor); labelFluidName.Text = fluidName; onFavoriteClicked = favoriteClicked; if (safetyInfo != Fluid.ESafety.Unknown) { safetyClassification.Text = safetyInfo.ToString(); } else { safetyClassification.Text = "N/A"; } imageSelected.BackgroundColor = CGExtensions.FromARGB8888(safetyInfo.Color()); if (selected) { this.BackgroundColor = UIColor.FromRGB(176, 176, 176); } else { this.BackgroundColor = UIColor.White; } if (preferred) { imageFavorite.TintColor = new UIColor(Colors.GOLD); } else { imageFavorite.TintColor = new UIColor(Colors.BLACK); } }
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); }
/// <summary> /// Initializes all of view controller's fluid control widgets. /// </summary> private void InitializeFluidControlWidgets() { viewFluidColor.BackgroundColor = CGExtensions.FromARGB8888(ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); labelFluidName.Text = ion.fluidManager.lastUsedFluid.name; viewFluidHeader.AddGestureRecognizer(new UITapGestureRecognizer(() => { var sb = InflateViewController <FluidManagerViewController>(VC_FLUID_MANAGER); sb.onFluidSelectedDelegate = (Fluid fluid) => { viewFluidColor.BackgroundColor = CGExtensions.FromARGB8888(ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); labelFluidName.Text = ion.fluidManager.lastUsedFluid.name; if (pressureSensor != null) { OnPressureSensorChanged(new SensorEvent(SensorEvent.EType.Invalidated, pressureSensor)); } }; NavigationController.PushViewController(sb, true); })); switchFluidState.ValueChanged += (object sender, EventArgs e) => { Log.D(this, "Altitude: " + ion.locationManager.lastKnownLocation.altitude); switch ((int)switchFluidState.SelectedSegment) { case SECTION_DEW: pressureSensor.fluidState = Fluid.EState.Dew; break; case SECTION_BUBBLE: pressureSensor.fluidState = Fluid.EState.Bubble; break; } if (pressureSensor != null) { OnPressureSensorChanged(new SensorEvent(SensorEvent.EType.Invalidated, pressureSensor)); } }; }
/// <summary> /// Initializes the states and event handlers the for ptchart widgets /// </summary> private void InitPTChartWidgets() { viewFluidColor.BackgroundColor = CGExtensions.FromARGB8888(ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); labelFluidName.Text = ion.fluidManager.lastUsedFluid.name; viewFluidHeader.AddGestureRecognizer(new UITapGestureRecognizer(() => { var sb = InflateViewController <FluidManagerViewController>(VC_FLUID_MANAGER); sb.onFluidSelectedDelegate = (Fluid fluid) => { ion.preferences.fluid.preferredFluid = fluid.name; viewFluidColor.BackgroundColor = CGExtensions.FromARGB8888(ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); labelFluidName.Text = ion.fluidManager.lastUsedFluid.name; if (pressureSensor is GaugeDeviceSensor) { entryMode = new SensorEntryMode(this, pressureSensor, temperatureUnit, editPressure, editTemperature); } else if (temperatureSensor is GaugeDeviceSensor) { entryMode = new SensorEntryMode(this, temperatureSensor, pressureUnit, editTemperature, editPressure); } else { if (pressureSensor != null) { entryMode = new SensorEntryMode(this, pressureSensor, temperatureUnit, editPressure, editTemperature); } else if (temperatureSensor != null) { entryMode = new SensorEntryMode(this, temperatureSensor, pressureUnit, editTemperature, editPressure); } } if (pressureSensor != null && pressureSensor is GaugeDeviceSensor) { if (ptSlider != null) { ptSlider.ptView.resetData(pressureUnit, temperatureUnit); ptSlider.setOffsetFromSensorMeasurement(new SensorEvent(SensorEvent.EType.Invalidated, pressureSensor)); } } else if (temperatureSensor != null && temperatureSensor is GaugeDeviceSensor) { if (ptSlider != null) { ptSlider.ptView.resetData(pressureUnit, temperatureUnit); ptSlider.setOffsetFromSensorMeasurement(new SensorEvent(SensorEvent.EType.Invalidated, temperatureSensor)); } } else { recalculateSlider(pressureUnit, temperatureUnit); } InvalidateViewController(); }; NavigationController.PushViewController(sb, true); })); switchFluidState.ValueChanged += (object sender, EventArgs e) => { var activeSensor = pressureSensor; if (activeSensor == null) { activeSensor = temperatureSensor; } switch ((int)switchFluidState.SelectedSegment) { case SECTION_BUBBLE: activeSensor.fluidState = Fluid.EState.Bubble; break; case SECTION_DEW: activeSensor.fluidState = Fluid.EState.Dew; break; } if (pressureSensor != null) { entryMode = new SensorEntryMode(this, pressureSensor, temperatureUnit, editPressure, editTemperature); } else { entryMode = new SensorEntryMode(this, temperatureSensor, pressureUnit, editTemperature, editPressure); } if (pressureSensor != null && pressureSensor is GaugeDeviceSensor) { if (ptSlider != null) { ptSlider.ptView.resetData(pressureUnit, temperatureUnit); ptSlider.setOffsetFromSensorMeasurement(new SensorEvent(SensorEvent.EType.Invalidated, pressureSensor)); } } else if (temperatureSensor != null && temperatureSensor is GaugeDeviceSensor) { if (ptSlider != null) { ptSlider.ptView.resetData(pressureUnit, temperatureUnit); ptSlider.setOffsetFromSensorMeasurement(new SensorEvent(SensorEvent.EType.Invalidated, temperatureSensor)); } } else { recalculateSlider(pressureUnit, temperatureUnit); } InvalidateViewController(); }; }
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); }
//// Updates the calculations and labels for a SH/SC cell public void updateSHSCCell() { //Console.WriteLine("lowHighSensor updateSHSCCell"); if (currentSensor.linkedSensor != null) { //Console.WriteLine("Secondary sensor is not null"); isLinked = true; if (currentSensor.type == ESensorType.Pressure) { shFluidType.Text = ion.fluidManager.lastUsedFluid.name; shFluidType.BackgroundColor = CGExtensions.FromARGB8888(ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); var calculation = ion.fluidManager.lastUsedFluid.CalculateTemperatureDelta(currentSensor.fluidState, currentSensor.measurement, currentSensor.linkedSensor.measurement, ion.locationManager.lastKnownLocation.altitude); ptAmount = calculation.magnitude; if (!ion.fluidManager.lastUsedFluid.mixture && calculation < 0) { calculation = calculation * -1; } shReading.Text = calculation.magnitude.ToString("N") + calculation.unit.ToString(); } else if (currentSensor.type == ESensorType.Temperature) { shFluidType.Text = ion.fluidManager.lastUsedFluid.name; shFluidType.BackgroundColor = CGExtensions.FromARGB8888(ion.fluidManager.GetFluidColor(ion.fluidManager.lastUsedFluid.name)); var calculation = ion.fluidManager.lastUsedFluid.CalculateTemperatureDelta(currentSensor.fluidState, currentSensor.linkedSensor.measurement, currentSensor.measurement, ion.locationManager.lastKnownLocation.altitude); ptAmount = calculation.magnitude; if (!ion.fluidManager.lastUsedFluid.mixture && calculation < 0) { calculation = calculation * -1; } shReading.Text = calculation.magnitude.ToString("N") + calculation.unit.ToString(); } } else { shReading.Text = Util.Strings.Analyzer.SETUP; if (isLinked.Equals(true)) { isLinked = false; if (attachedSensor != null) { attachedSensor.topLabel.BackgroundColor = UIColor.Clear; attachedSensor.topLabel.TextColor = UIColor.Black; attachedSensor = null; } } } if (!ion.fluidManager.lastUsedFluid.mixture) { if (ptAmount < 0) { shFluidState.Text = Util.Strings.Analyzer.SC; } else { shFluidState.Text = Util.Strings.Analyzer.SH; } } else if (currentSensor.fluidState.Equals(Fluid.EState.Bubble)) { shFluidState.Text = Util.Strings.Analyzer.SC; } else if (currentSensor.fluidState.Equals(Fluid.EState.Dew)) { shFluidState.Text = Util.Strings.Analyzer.SH; } }