/// <summary>
        /// Event callback to set proper alarm type value
        /// </summary>
        /// <param name="sender">Event object sender</param>
        /// <param name="e">Event argument</param>
        private void TypeRadio_Selected(object sender, SelectedEventArgs e)
        {
            RadioButton button = sender as RadioButton;

            if (button.IsSelected)
            {
                switch (button.Text)
                {
                case "Sound":
                    newValue = AlarmTypes.Sound;
                    break;

                case "SoundVibration":
                    newValue = AlarmTypes.SoundVibration;
                    break;

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

                default:
                    newValue = AlarmTypes.Sound;
                    break;
                }
            }
        }
Example #2
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");
        }
    }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            AlarmTypes flag = (AlarmTypes)value;

            if (flag == AlarmTypes.Sound)
            {
                return("Sound");
            }
            else if (flag == AlarmTypes.Vibration)
            {
                return("Vibration");
            }
            else
            {
                return("Vibration and sound");
            }
        }
 /// <summary>
 /// Constructor for this class
 /// Sets proper controls to this class
 /// </summary>
 /// <param name="type">The type of alarm type</param>
 /// <seealso cref="AlarmTypes">
 /// <param name="page">The content page which includes this table view cell</param>
 /// <seealso cref="ContentPage">
 public AlarmTypeTableCell(AlarmTypes type, ContentPage page)
 {
     Type      = type;
     Container = page;
     View      = new AlarmTypeRow(type);
 }
Example #5
0
 public Alarm(AlarmTypes alarmType)
 {
     AlarmType = alarmType;
 }
Example #6
0
        /// <summary>
        /// Converting source value to target value
        /// </summary>
        /// <param name="value">Source object</param>
        /// <seealso cref="System.object">
        /// <param name="targetType">The target type to convert</param>
        /// <seealso cref="Type">
        /// <param name="CultureInfo">The culture info</param>
        /// <seealso cref="CultureInfo">
        /// <returns>Returns converted string</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // Check alarm type
            if (value.GetType() == typeof(AlarmTypes))
            {
                AlarmTypes modelValue = (AlarmTypes)value;
                string     s          = "";

                switch (modelValue)
                {
                // case of sound type
                case AlarmTypes.Sound:
                    s = "Sound";
                    break;

                // case of vibration type
                case AlarmTypes.Vibration:
                    s = "Vibration";
                    break;

                // case of sound and vibration
                case AlarmTypes.SoundVibration:
                    s = "Vibration and sound";
                    break;
                }

                return(s);
            }
            // Check alarm tone type
            else if (value.GetType() == typeof(AlarmToneTypes))
            {
                AlarmToneTypes modelValue = (AlarmToneTypes)value;
                string         s          = "";

                switch (modelValue)
                {
                // case of default
                case AlarmToneTypes.Default:
                    s = "Default";
                    break;

                // case of alarm mp3
                case AlarmToneTypes.AlarmMp3:
                    s = "alarm.mp3";
                    break;

                // case of rington sdk
                case AlarmToneTypes.RingtoneSdk:
                    s = "ringtone_sdk.mp3";
                    break;
                }

                return(s);
            }
            else if (value.GetType() == typeof(AlarmWeekFlag))
            {
                string        s    = "";
                AlarmWeekFlag flag = (AlarmWeekFlag)value;
                // case of week flag never
                if (flag == AlarmWeekFlag.Never)
                {
                    // case of never
                    s = "Never";
                }
                // case of all days
                else if (flag == AlarmWeekFlag.AllDays)
                {
                    // case of everyday
                    s = "Everyday";
                }
                // case of week other
                else
                {
                    for (int i = 1; i < 7; i++)
                    {
                        int mask = 1 << i;
                        if (((int)flag & mask) > 0)
                        {
                            switch (mask)
                            {
                            case (int)AlarmWeekFlag.Monday:
                                s += "Mon ";
                                break;

                            case (int)AlarmWeekFlag.Tuesday:
                                s += "Tue ";
                                break;

                            case (int)AlarmWeekFlag.Wednesday:
                                s += "Wed ";
                                break;

                            case (int)AlarmWeekFlag.Thursday:
                                s += "Thu ";
                                break;

                            case (int)AlarmWeekFlag.Friday:
                                s += "Fri ";
                                break;

                            case (int)AlarmWeekFlag.Saturday:
                                s += "Sat ";
                                break;
                            }
                        }
                    }

                    if (((int)flag & 0x1) > 0)
                    {
                        s += "Sun ";
                    }
                }

                return(s);
            }
            else
            {
                return(null);
            }
        }
Example #7
0
 public virtual bool AddSecurityInfoForAddress(string addressId, bool requireAlarmCode, AlarmTypes alarmType, string alarmCode, bool requireGateAccess)
 {
     throw new System.NotImplementedException();
 }
        /// <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); }));
        }
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Units != null)
                {
                    hash = hash * 59 + Units.GetHashCode();
                }

                if (TimeFormat != null)
                {
                    hash = hash * 59 + TimeFormat.GetHashCode();
                }

                if (CustomTitle != null)
                {
                    hash = hash * 59 + CustomTitle.GetHashCode();
                }

                if (NightMode != null)
                {
                    hash = hash * 59 + NightMode.GetHashCode();
                }

                if (Theme != null)
                {
                    hash = hash * 59 + Theme.GetHashCode();
                }

                if (Language != null)
                {
                    hash = hash * 59 + Language.GetHashCode();
                }

                if (ShowPlugins != null)
                {
                    hash = hash * 59 + ShowPlugins.GetHashCode();
                }

                if (ShowRawbg != null)
                {
                    hash = hash * 59 + ShowRawbg.GetHashCode();
                }

                if (AlarmTypes != null)
                {
                    hash = hash * 59 + AlarmTypes.GetHashCode();
                }

                if (AlarmUrgentHigh != null)
                {
                    hash = hash * 59 + AlarmUrgentHigh.GetHashCode();
                }

                if (AlarmHigh != null)
                {
                    hash = hash * 59 + AlarmHigh.GetHashCode();
                }

                if (AlarmLow != null)
                {
                    hash = hash * 59 + AlarmLow.GetHashCode();
                }

                if (AlarmUrgentLow != null)
                {
                    hash = hash * 59 + AlarmUrgentLow.GetHashCode();
                }

                if (AlarmTimeagoWarn != null)
                {
                    hash = hash * 59 + AlarmTimeagoWarn.GetHashCode();
                }

                if (AlarmTimeagoWarnMins != null)
                {
                    hash = hash * 59 + AlarmTimeagoWarnMins.GetHashCode();
                }

                if (AlarmTimeagoUrgent != null)
                {
                    hash = hash * 59 + AlarmTimeagoUrgent.GetHashCode();
                }

                if (AlarmTimeagoUrgentMins != null)
                {
                    hash = hash * 59 + AlarmTimeagoUrgentMins.GetHashCode();
                }

                if (Enable != null)
                {
                    hash = hash * 59 + Enable.GetHashCode();
                }

                if (Thresholds != null)
                {
                    hash = hash * 59 + Thresholds.GetHashCode();
                }

                return(hash);
            }
        }
        /// <summary>
        /// Returns true if Settings instances are equal
        /// </summary>
        /// <param name="other">Instance of Settings to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Settings other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Units == other.Units ||
                     Units != null &&
                     Units.Equals(other.Units)
                     ) &&
                 (
                     TimeFormat == other.TimeFormat ||
                     TimeFormat != null &&
                     TimeFormat.Equals(other.TimeFormat)
                 ) &&
                 (
                     CustomTitle == other.CustomTitle ||
                     CustomTitle != null &&
                     CustomTitle.Equals(other.CustomTitle)
                 ) &&
                 (
                     NightMode == other.NightMode ||
                     NightMode != null &&
                     NightMode.Equals(other.NightMode)
                 ) &&
                 (
                     Theme == other.Theme ||
                     Theme != null &&
                     Theme.Equals(other.Theme)
                 ) &&
                 (
                     Language == other.Language ||
                     Language != null &&
                     Language.Equals(other.Language)
                 ) &&
                 (
                     ShowPlugins == other.ShowPlugins ||
                     ShowPlugins != null &&
                     ShowPlugins.Equals(other.ShowPlugins)
                 ) &&
                 (
                     ShowRawbg == other.ShowRawbg ||
                     ShowRawbg != null &&
                     ShowRawbg.Equals(other.ShowRawbg)
                 ) &&
                 (
                     AlarmTypes == other.AlarmTypes ||
                     AlarmTypes != null &&
                     AlarmTypes.SequenceEqual(other.AlarmTypes)
                 ) &&
                 (
                     AlarmUrgentHigh == other.AlarmUrgentHigh ||
                     AlarmUrgentHigh != null &&
                     AlarmUrgentHigh.Equals(other.AlarmUrgentHigh)
                 ) &&
                 (
                     AlarmHigh == other.AlarmHigh ||
                     AlarmHigh != null &&
                     AlarmHigh.Equals(other.AlarmHigh)
                 ) &&
                 (
                     AlarmLow == other.AlarmLow ||
                     AlarmLow != null &&
                     AlarmLow.Equals(other.AlarmLow)
                 ) &&
                 (
                     AlarmUrgentLow == other.AlarmUrgentLow ||
                     AlarmUrgentLow != null &&
                     AlarmUrgentLow.Equals(other.AlarmUrgentLow)
                 ) &&
                 (
                     AlarmTimeagoWarn == other.AlarmTimeagoWarn ||
                     AlarmTimeagoWarn != null &&
                     AlarmTimeagoWarn.Equals(other.AlarmTimeagoWarn)
                 ) &&
                 (
                     AlarmTimeagoWarnMins == other.AlarmTimeagoWarnMins ||
                     AlarmTimeagoWarnMins != null &&
                     AlarmTimeagoWarnMins.Equals(other.AlarmTimeagoWarnMins)
                 ) &&
                 (
                     AlarmTimeagoUrgent == other.AlarmTimeagoUrgent ||
                     AlarmTimeagoUrgent != null &&
                     AlarmTimeagoUrgent.Equals(other.AlarmTimeagoUrgent)
                 ) &&
                 (
                     AlarmTimeagoUrgentMins == other.AlarmTimeagoUrgentMins ||
                     AlarmTimeagoUrgentMins != null &&
                     AlarmTimeagoUrgentMins.Equals(other.AlarmTimeagoUrgentMins)
                 ) &&
                 (
                     Enable == other.Enable ||
                     Enable != null &&
                     Enable.SequenceEqual(other.Enable)
                 ) &&
                 (
                     Thresholds == other.Thresholds ||
                     Thresholds != null &&
                     Thresholds.Equals(other.Thresholds)
                 ));
        }
 public AlarmTypeConverter()
 {
     AlarmTypes.ForEach(type => _alarmTypeMap[Loader.GetString(type.ToString())] = type);
 }