Esempio n. 1
0
 internal FloatOptionsEntry(OptionAttribute oa, PropertyInfo prop) : base(prop?.Name,
                                                                          oa)
 {
     textField = null;
     value     = 0.0f;
     limits    = FindLimitAttribute(prop);
 }
Esempio n. 2
0
		internal FloatOptionsEntry(string title, string tooltip, PropertyInfo prop) :
				base(prop?.Name, title, tooltip) {
			LimitAttribute fieldLimits = null;
			textField = null;
			value = 0.0f;
			// Look for limits
			foreach (var attr in prop.GetCustomAttributes(false))
				if ((fieldLimits = GetLimits(attr)) != null)
					break;
			limits = fieldLimits;
		}
Esempio n. 3
0
        /// <summary>
        /// Searches for LimitAttribute attributes on the property wrapped by an OptionsEntry.
        /// </summary>
        /// <param name="prop">The property with annotations.</param>
        /// <returns>The Limit attribute if present, or null if none is.</returns>
        protected static LimitAttribute FindLimitAttribute(PropertyInfo prop)
        {
            LimitAttribute fieldLimits = null;

            foreach (var attr in prop.GetCustomAttributes(false))
            {
                if ((fieldLimits = LimitAttribute.CreateFrom(attr)) != null)
                {
                    break;
                }
            }
            return(fieldLimits);
        }
Esempio n. 4
0
 public StringOptionsEntry(string field, IOptionSpec spec,
                           LimitAttribute limit = null) : base(field, spec)
 {
     // Use the maximum limit value for the max length, if present
     if (limit != null)
     {
         maxLength = Math.Max(2, (int)Math.Round(limit.Maximum));
     }
     else
     {
         maxLength = 256;
     }
     textField = null;
     value     = "";
 }
        internal IntOptionsEntry(OptionAttribute oa, PropertyInfo prop) : base(prop?.Name, oa)
        {
            LimitAttribute fieldLimits = null;

            textField = null;
            value     = 0;
            // Look for limits
            foreach (var attr in prop.GetCustomAttributes(false))
            {
                if ((fieldLimits = GetLimits(attr)) != null)
                {
                    break;
                }
            }
            limits = fieldLimits;
        }
Esempio n. 6
0
        internal StringOptionsEntry(OptionAttribute oa, PropertyInfo prop) : base(prop?.Name,
                                                                                  oa)
        {
            var limits = LimitAttribute.FindFrom(prop);

            // Use the maximum limit value for the max length, if present
            if (limits != null)
            {
                maxLength = Math.Max(2, (int)Math.Round(limits.Maximum));
            }
            else
            {
                maxLength = 256;
            }
            textField = null;
            value     = "";
        }
Esempio n. 7
0
        /// <summary>
        /// Tries to retrieve the limits for an option.
        /// </summary>
        /// <param name="attr">The annotation to check.</param>
        /// <returns>The LimitAttribute matching that annotation, or null if it is not a LimitAttribute.</returns>
        internal static LimitAttribute GetLimits(object attr)
        {
            if (attr == null)
            {
                throw new ArgumentNullException("attr");
            }
            LimitAttribute la = null;

            if (attr.GetType().Name == typeof(LimitAttribute).Name)
            {
                // Has limit type
                var    trAttr = Traverse.Create(attr);
                double min    = trAttr.GetProperty <double>(nameof(LimitAttribute.Minimum)),
                       max    = trAttr.GetProperty <double>(nameof(LimitAttribute.Maximum));
                if (min != 0.0 || max != 0.0)
                {
                    la = new LimitAttribute(min, max);
                }
            }
            return(la);
        }
 public NullableFloatOptionsEntry(string field, IOptionSpec spec,
                                  LimitAttribute limit = null) : base(field, spec, limit)
 {
     textField = null;
     value     = null;
 }
Esempio n. 9
0
 protected IntOptionsEntry(string title, string tooltip, string category = "",
                           LimitAttribute limits = null) : base(title, tooltip, category, limits)
 {
     textField = null;
     value     = 0;
 }
Esempio n. 10
0
 protected SlidingBaseOptionsEntry(string field, IOptionSpec spec,
                                   LimitAttribute limit = null) : base(field, spec)
 {
     limits = limit;
     slider = null;
 }
Esempio n. 11
0
 protected SlidingBaseOptionsEntry(OptionAttribute oa, PropertyInfo prop) : base(prop?.
                                                                                 Name, oa)
 {
     limits = LimitAttribute.FindFrom(prop);
     slider = null;
 }
Esempio n. 12
0
 protected SlidingBaseOptionsEntry(string title, string tooltip, string category,
                                   LimitAttribute limits) : base(title, tooltip, category)
 {
     this.limits = limits;
     slider      = null;
 }