Exemple #1
0
    public static Alarm GetAlarm(AlarmTypes alarmType)      //factory ensures that correct alarm is returned and right func pointer for trigger creator.
    {
        switch (alarmType)
        {
        case AlarmTypes.Heartbeat:
            return(GetHeartbeatAlarm());

        default:
            throw new ArgumentException("Unrecognized AlarmType: " + alarmType.ToString(), "alarmType");
        }
    }
        /// <summary>
        /// Constructor for this class.
        /// Place UI controls and text according to given alarm type
        /// </summary>
        /// <param name="type">The alarm type to show in this row</param>
        /// <seealso cref="AlarmTypes">
        public AlarmTypeRow(AlarmTypes type)
        {
            HeightRequest = 120;
            switch (type)
            {
            case AlarmTypes.Sound:
                mainStr = "Sound";
                break;

            case AlarmTypes.Vibration:
                mainStr = "Vibration";
                break;

            case AlarmTypes.SoundVibration:
                mainStr = "Vibration and sound";
                break;

            default:
                mainStr = "";
                break;
            }

            if (mainStr != null)
            {
                if (mainLabel == null)
                {
                    mainLabel = new Label
                    {
                        HeightRequest = 54,
                        Style         = AlarmStyle.T033,
                        Text          = mainStr,
                    };
                    // to meet To meet thin attribute for font, need to use custom feature
                    FontFormat.SetFontWeight(mainLabel, FontWeight.Light);
                }

                Children.Add(mainLabel,
                             Constraint.RelativeToParent((parent) => { return(32); }),
                             Constraint.RelativeToParent((parent) => { return((120 - 72) / 2); }));
            }

            typeRadio = new RadioButton
            {
                Text          = type.ToString(),
                GroupName     = "AlarmType",
                HeightRequest = 80,
                WidthRequest  = 80,
            };

            if (AlarmModel.BindableAlarmRecord.AlarmType == type)
            {
                typeRadio.IsSelected = true;
                oldValue             = newValue = type;
            }

            typeRadio.Selected += TypeRadio_Selected;

            Children.Add(typeRadio,
                         Constraint.RelativeToParent((parent) => (parent.X + parent.Width - (80 + 32))),
                         Constraint.RelativeToParent((parent) => { return((120 - 80) / 2); }));
        }