コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }
            long exp   = 0;
            int  level = 0;

            for (int i = 0; i < ExpTable.Count(); i++)
            {
                if ((long)value < exp)
                {
                    break;
                }
                exp  += ExpTable[i];
                level = i;
            }
            return(level);
        }
コード例 #2
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var st = value.ToString();

            if (string.IsNullOrEmpty(st))
            {
                st = "0";
            }
            int lvl = Int32.Parse(st);

            if (lvl > ExpTable.Count())
            {
                lvl = ExpTable.Count();
            }
            long exp = 0;

            for (int i = 0; i < lvl; i++)
            {
                exp += ExpTable[i];
            }
            return(exp);
        }