// Overridden from BaseIONViewController public override void ViewDidLoad() { base.ViewDidLoad(); if (sensor == null) { throw new Exception("Cannot start " + typeof(SensorAlarmViewController).Name + ": sensor cannot be null."); } View.AddGestureRecognizer(new UITapGestureRecognizer(() => { editLowAlarmMeasurement.ResignFirstResponder(); editHighAlarmMeasurement.ResignFirstResponder(); })); editLowAlarmMeasurement.ShouldReturn += (textField) => { textField.ResignFirstResponder(); return(true); }; editHighAlarmMeasurement.ShouldReturn += (textField) => { textField.ResignFirstResponder(); return(true); }; ion = AppState.context; lowAlarm = ion.alarmManager.GetAlarmOfTypeFromHost <LowSensorAlarm>(sensor); highAlarm = ion.alarmManager.GetAlarmOfTypeFromHost <HighSensorAlarm>(sensor); if (lowAlarm == null) { lowAlarm = new LowSensorAlarm("", "", sensor); ion.alarmManager.RegisterAlarmToHost(sensor, lowAlarm); } if (highAlarm == null) { highAlarm = new HighSensorAlarm("", "", sensor); ion.alarmManager.RegisterAlarmToHost(sensor, highAlarm); } lowAlarm.name = Strings.Alarms.LOW_ALARM; highAlarm.name = Strings.Alarms.HIGH_ALARM; UpdateAlarmDescriptions(); switchLowAlarmEnabler.On = lowAlarm.enabled; switchHighAlarmEnabler.On = highAlarm.enabled; /* * buttonLowAlarmUnit.TouchUpInside += (source, args) => { * var dialog = CommonDialogs.CreateUnitPicker(Strings.Measure.PICK_UNIT, lowAlarm.sensor.supportedUnits, (obj, unit) => { * lowAlarm.sensor.unit = unit; * buttonLowAlarmUnit.SetTitle(unit.ToString(), UIControlState.Normal); * }); * PresentViewController(dialog, true, null); * }; */ }
/// <summary> /// Creates a new low sensor alarm. /// </summary> /// <returns>The low sensor alarm.</returns> private BoundedSensorAlarm CreateLowSensorAlarm(Sensor sensor) { var ret = ion.alarmManager.GetAlarmOfTypeFromHost <LowSensorAlarm>(sensor); if (ret == null) { ret = new LowSensorAlarm(GetString(Resource.String.alarm_low), GetString(Resource.String.alarm_low_summary), sensor); ion.alarmManager.RegisterAlarmToHost(sensor, ret); } return(ret); }