Esempio n. 1
0
        public object Convert(object value, Type type, object parameter, CultureInfo culture)
        {
            if (ValueConverterUtil.IsNull(value))
            {
                //** 2016-12-22 TOYAMA **//
                //** 空腹時には00:00を代入します **//
                //return string.Empty;
                return("00:00");
            }

            int i = 0;

            if (value is int?)
            {
                i = ((int?)value).Value;
            }
            else if (value is int)
            {
                i = (int)value;
            }
            else
            {
                if (int.TryParse(value.ToString(), out i))
                {
                }
            }

            int i2 = i / 100;
            int i1 = i - i2 * 100;

            return(i2.ToString("00") + ":" + i1.ToString("00"));
        }
Esempio n. 2
0
        public object Convert(object value, Type type, object parameter, CultureInfo culture)
        {
            if (ValueConverterUtil.IsNull(value))
            {
                return(ValueConverterUtil.NullObj);
            }

            try {
                return(value.ToString());
            } catch (Exception) {
                return(ValueConverterUtil.NullObj);
            }
        }
Esempio n. 3
0
        public object ConvertBack(object value, Type type, object parameter, CultureInfo culture)
        {
            if (ValueConverterUtil.IsNull(value))
            {
                return(ValueConverterUtil.NullObj);
            }

            string s = ""; //(string)value;

            if (value is TimeSpan)
            {
                TimeSpan ts = (TimeSpan)value;
                s = ts.ToString();
            }
            else if (value is string)
            {
                s = value as string;
            }
            else
            {
                s = value.ToString();
            }

            if (string.IsNullOrWhiteSpace(s))
            {
                return(ValueConverterUtil.NullObj);
            }

            try {
                var aaa = s.Split(':');
                if (aaa.Length >= 2)
                {
                    return(int.Parse(aaa[0]) * 100 + int.Parse(aaa[1]));
                }
                else
                {
                    return(int.Parse(s));
                }
            } catch (Exception) {
                return(ValueConverterUtil.NullObj);
            }
        }
Esempio n. 4
0
        public object ConvertBack(object value, Type type, object parameter, CultureInfo culture)
        {
            try {
                if (ValueConverterUtil.IsNull(value))
                {
                    return(ValueConverterUtil.NullObj);
                }

                var typeee = value.GetType();
                var tc     = Type.GetTypeCode(typeee);
                switch (tc)
                {
                case TypeCode.Int32: {
                    return((int)value);
                }

                case TypeCode.Int64: {
                    return((int)((long)value));
                }

                case TypeCode.Int16: {
                    return((int)((short)value));
                }

                case TypeCode.Decimal: {
                    return((int)((decimal)value));
                }

                case TypeCode.Double: {
                    return((int)((double)value));
                }

                case TypeCode.Single: {
                    return((int)((float)value));
                }
                }


                string s = "";
                if (value is string)
                {
                    s = value as string;
                }
                else
                {
                    s = value.ToString();
                }

                //int? v;
                if (string.IsNullOrEmpty(s))
                {
                    return(ValueConverterUtil.NullObj);
                }
                else
                {
                    int v2 = 0;
                    if (int.TryParse(s, NumberStyles.AllowHexSpecifier, null, out v2))
                    {
                        return(v2);
                    }
                }
                return(ValueConverterUtil.NullObj);
            } catch (Exception ex) {
                string s = ex.Message;
                return(ValueConverterUtil.NullObj);
            }
        }