Exemple #1
0
 public void MockData()
 {
     for (int i = 1; i <= 24; i++)
     {
         var it = new CalendarItemVM(this)
         {
             Tag         = i.ToString("00") + ":00",
             TotalPoints = 521,
             Points      = 0
         };
         Items.Add(it);
     }
 }
Exemple #2
0
        public bool SetData(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return(false);
            }
            var ret = new List <CalendarItemVM>();

            Items.Clear();
            var segments = data.Split("|".ToCharArray());

            if (segments.Length != 2)
            {
                return(false);
            }
            var tags   = segments[0].Split("!".ToCharArray());
            var points = segments[1].Split("!".ToCharArray());

            if (tags.Length == 0 || tags.Length != points.Length)
            {
                return(false);
            }

            for (int i = 0; i < tags.Length; i++)
            {
                var stag    = tags[i];
                var spoints = points[i];
                if (string.IsNullOrEmpty(stag))
                {
                    return(false);
                }
                if (string.IsNullOrEmpty(spoints))
                {
                    return(false);
                }
                var tagparts = stag.Split(";".ToCharArray());
                if (tagparts.Length != 2)
                {
                    return(false);
                }
                var pointsparts = spoints.Split(";".ToCharArray());
                if (pointsparts.Length != 2)
                {
                    return(false);
                }
                var tag     = tagparts[0];
                var tpoints = tagparts[1];
                var ppoints = pointsparts[1];
                if (string.IsNullOrEmpty(tag))
                {
                    return(false);
                }
                if (string.IsNullOrEmpty(tpoints))
                {
                    return(false);
                }
                if (!int.TryParse(tpoints, out int tp))
                {
                    return(false);
                }
                if (!int.TryParse(ppoints, out int p))
                {
                    return(false);
                }
                var it = new CalendarItemVM(this)
                {
                    Tag         = tag,
                    TotalPoints = tp,
                    Points      = p
                };
                ret.Add(it);
            }
            MaxPoints  = 5;
            UsedPoints = ret.Sum(d => d.Points);
            foreach (var it in ret)
            {
                Items.Add(it);
            }
            CurrenData = data;
            return(true);
        }