public ValidatableNumericEntry(
            double?entryFontSize,
            string stringFormat,
            INumericEntryValidationBehavior validator,
            Keyboard keyboard    = default,
            bool asleepInitially = false
            )
            : base(entryFontSize: entryFontSize, keyboard: keyboard, asleepInitially: asleepInitially)
        {
            _validator = validator;

            Converter =
                new StringToNumericConverter
            {
                StringFormat   = stringFormat,
                ValidationType = validator.IsNotNullOrDefault()
                  ? validator.ValidationType
                  : ValidationTypes.DecimalNumber
            };

            if (!IsConstructing)
            {
                RecreateAllViewsBindingsAndStyles();
            }
        }
예제 #2
0
        public static string GetFormattedValue(CustomParamValue cpv)
        {
            if (cpv == null)
            {
                return(null);
            }
            var cp = cpv.Cp;

            if (cp == null)
            {
                return(null);
            }

            var value = cpv.CPVValue;

            if (!string.IsNullOrEmpty(cp.ObjectlookupCode_R))
            {
                return(LookupHelper.GetDispalyMemberValue(cp.ObjectlookupCode_R, value));
            }

            var fieldType = GetValueType(cpv);

            if (fieldType == null)
            {
                return(value);
            }
            var type         = fieldType.GetNonNullableType();
            var existsFormat = !string.IsNullOrEmpty(cp.CustomParamFormat);

            if (type == typeof(DateTime))
            {
                var dtvalue = new StringToDateTimeConverter().Convert(value, null, GetDateTimeFormat(),
                                                                      Thread.CurrentThread.CurrentCulture) as DateTime?;
                if (dtvalue.HasValue)
                {
                    return(existsFormat
                        ? dtvalue.Value.ToString(cp.CustomParamFormat)
                        : dtvalue.Value.ToShortDateString());
                }
                return(null);
            }

            if (type.IsPrimitive || type == typeof(decimal))
            {
                var nvalue = new StringToNumericConverter().Convert(value, null, fieldType, Thread.CurrentThread.CurrentCulture);
                if (nvalue != null)
                {
                    return(existsFormat ? string.Format("{0}:" + cp.CustomParamFormat, nvalue) : nvalue.ToString());
                }
                return(null);
            }

            return(value);
        }
예제 #3
0
        public override INode Create(object value)
        {
            value = GetScaledValue(value);
            var cellValue = StringToNumericConverter.Convert(value, Format);

            cellValue = ReplaceThousandSeparator(cellValue);
            string formattedValue;

            if (cellValue == StringToNumericConverter.NullValueIndicator)
            {
                formattedValue = cellValue;
            }
            else
            {
                formattedValue = Prefix + cellValue + Suffix;
            }

            var data = new SimpleNode("div", formattedValue);

            data.Styles.Add("display", "inline");
            return(data);
        }