示例#1
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value != null && value is String)
            {
                string[] parts = (value as String).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 0)
                {
                    return(null);
                }

                int[] values = ConvertArray(parts);

                var tolerance = new MobileTolerance()
                {
                    Top    = values.Length > 0 ? values[0] : 0,
                    Right  = values.Length > 1 ? values[1] : 0,
                    Bottom = values.Length > 2 ? values[2] : 0,
                    Left   = values.Length > 3 ? values[3] : 0
                };

                return(tolerance);
            }

            return(null);
        }
示例#2
0
    public MobileTolerance GetTolerance(Credentials credentials)
    {
        // If credentials not valid --> return false
        if (!Membership.ValidateUser(credentials.UserName, credentials.Password))
        {
            return(null);
        }

        // If we are here, credentials are fine, let's return his f**in tolerances..
        using (braceletEntities context = new braceletEntities())
        {
            Tolerance       t  = context.Tolerances.Where(o => o.aspnet_Users.UserName == credentials.UserName).FirstOrDefault();
            MobileTolerance mt = new MobileTolerance();

            if (t.AccelerationTolerance.HasValue)
            {
                mt.AccelerationMax = t.AccelerationTolerance.Value;
            }
            if (t.BloodOxygenToleranceHigh.HasValue)
            {
                mt.BloodOxygenMax = t.BloodOxygenToleranceHigh.Value;
            }
            if (t.BloodOxygenToleranceLow.HasValue)
            {
                mt.BloodOxygenMin = t.BloodOxygenToleranceLow.Value;
            }
            if (t.PulseToleranceHigh.HasValue)
            {
                mt.PulseMax = t.PulseToleranceHigh.Value;
            }
            if (t.PulseToleranceLow.HasValue)
            {
                mt.PulseMin = t.PulseToleranceLow.Value;
            }
            if (t.TempToleranceHigh.HasValue)
            {
                mt.TempMax = t.TempToleranceHigh.Value;
            }
            if (t.TempToleranceLow.HasValue)
            {
                mt.TempMin = t.TempToleranceLow.Value;
            }

            return(mt);
        }
    }
示例#3
0
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (value is MobileTolerance)
     {
         if (destinationType == typeof(string))
         {
             value.ToString();
         }
         if (destinationType == typeof(InstanceDescriptor))
         {
             MobileTolerance    tolerance   = value as MobileTolerance;
             ConstructorInfo    constructor = typeof(MobileTolerance).GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) });
             InstanceDescriptor instance    = new InstanceDescriptor(constructor, new object[] { tolerance.Top, tolerance.Right, tolerance.Bottom, tolerance.Left });
             return(instance);
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if(value != null && value is String) {
                string[] parts = (value as String).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if(parts.Length == 0) {
                    return null;
                }

                int[] values = ConvertArray(parts);

                var tolerance = new MobileTolerance() {
                    Top = values.Length > 0 ? values[0] : 0,
                    Right = values.Length > 1 ? values[1] : 0,
                    Bottom = values.Length > 2 ? values[2] : 0,
                    Left = values.Length > 3 ? values[3] : 0
                };

                return tolerance;
            }

            return null;
        }
示例#5
0
        public PopupWidget Options(Boolean corners = true, Boolean dismissable = true, String overlayTheme = null, Boolean shadow = true, MobileTolerance tolerance = null, String theme = null)
        {
            base.SetOptions(
                JuiceHelpers.GetMemberInfo(() => corners),
                JuiceHelpers.GetMemberInfo(() => dismissable),
                JuiceHelpers.GetMemberInfo(() => overlayTheme),
                JuiceHelpers.GetMemberInfo(() => shadow),
                JuiceHelpers.GetMemberInfo(() => tolerance),
                JuiceHelpers.GetMemberInfo(() => theme)
                );

            return(this);
        }
示例#6
0
        /// <summary>
        /// {summary}
        /// </summary>
        /// <param name="elementId">Sets the id attribute of the rendered element.</param>
        /// <param name="corners">Sets whether to draw the popup with rounded corners.</param>,
        /// <param name="dismissable">Allow popup to be closed.</param>,
        /// <param name="overlayTheme">Sets the color scheme (swatch) for the popup background, which covers the entire window.</param>,
        /// <param name="shadow">Sets whether to draw a shadow around the popup.</param>,
        /// <param name="tolerance">Sets the minimum distance from the edge of the window for the corresponding edge of the popup. By default, the values above will be used for the distance from the top, right, bottom, and left edge of the window, respectively.</param>,
        /// <param name="theme">Defines the theme swatch letter (a-z)</param>
        /// <returns>PopupWidget</returns>
        public PopupWidget BeginPopup(String elementId = "", Boolean corners = true, Boolean dismissable = true, String overlayTheme = null, Boolean shadow = true, MobileTolerance tolerance = null, String theme = null)
        {
            var widget = new PopupWidget(_helper);

            widget.SetCoreOptions(elementId, null);
            widget.Options(corners, dismissable, overlayTheme, shadow, tolerance, theme);

            return(widget);
        }