Пример #1
0
        public static void FilterActivityStats(List <ActivityStatsHeader <ActivityStatsData> > p_list)
        {
            foreach (ActivityStatsHeader <ActivityStatsData> header in p_list)
            {
                ActivityStatsHeader <ActivityStatsData> headerHolder = ActivityStatsHeader <ActivityStatsData> .CopyData(header);

                header.Clear();
                foreach (ActivityStatsData cell in headerHolder)
                {
                    if (!header.Contains(cell.ActType))
                    {
                        header.Add(cell);
                    }
                    else
                    {
                        ActivityStatsData filtered = header.GetAny(cell.ActType);
                        filtered.Steps    += cell.Steps;
                        filtered.Distance += cell.Distance;
                        filtered.Calories += cell.Calories;
                        filtered.Altitude += cell.Altitude;
                    }
                }

                // update data for sub slider
                foreach (ActivityStatsData cell in header)
                {
                    cell.UpdateData();
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Clears and Readd stat values for Sub Slider.
 /// </summary>
 public void UpdateData()
 {
     this.Stats.Clear();
     this.Stats.Add(ActivityStatsData.CreateStat("steps", this.Steps.ToString()));
     this.Stats.Add(ActivityStatsData.CreateStat("distance", this.Distance.ToString()));
     this.Stats.Add(ActivityStatsData.CreateStat("calories", this.Calories.ToString()));
     this.Stats.Add(ActivityStatsData.CreateStat("altitude", this.Altitude.ToString()));
 }
Пример #3
0
        }                                                  // Sub scroller data

        /****************************************************************
         * Constructors
         **/
        public ActivityStatsData(
            EAct_Types p_type,
            ulong p_epoch   = 0, // seconds passed since 1/1/1970
            uint p_steps    = 0,
            uint p_distance = 0,
            uint p_calories = 0,
            uint p_altitude = 0
            )
        {
            this.EpochTime = p_epoch;
            this.Steps     = p_steps;
            this.Distance  = p_distance;
            this.Calories  = p_calories;
            this.Altitude  = p_altitude;
            this.ActType   = p_type;

            // Test print
            DateTime date = KreyosUtils.ToDateTime((long)p_epoch);

            KreyosUtils.Log("ActivityStatsData::Constructor", "epoch:" + p_epoch + " date:" + date + " epochDate:" + date.ToShortDateString());// date.ToShortDateString()

            // Add display values
            this.TxtTime     = date.Hour + ":" + date.Minute + date.ToString("tt").ToLower().Substring(0, 1); // Add am or pm after the minute value
            this.TxtActImage = ActivityStatsData.ActImage(p_type);
            this.TxtActTitle = ActivityStatsData.ActToString(p_type);

            this.Hour   = date.Hour;
            this.Minute = date.Minute;
            this.Second = date.Second;

            // display altitude values for cycling.
            // Hard coded D:
            if (this.ActType == EAct_Types.ECycling)
            {
                this.TxtItemTitle = "altitude";
                this.TxtItemValue = p_altitude.ToString();
            }
            else
            {
                this.TxtItemTitle = "calories";
                this.TxtItemValue = p_calories.ToString();
            }

            // Create sub scroller data
            this.Stats = new List <StatsData>();
            this.UpdateData();
        }
Пример #4
0
        /// <summary>
        /// Returns any element at random index of the same 'p_type'.
        /// Note: Unused 'ST' template, it was added just to fix compiler errors.
        /// </summary>
        /// <param name="p_type"></param>
        /// <returns></returns>
        public ActivityStatsData GetAny(EAct_Types p_type)
        {
            if (this.Count <= 0)
            {
                return(null);
            }

            foreach (T cell in this)
            {
                ActivityStatsData c = (ActivityStatsData)Convert.ChangeType(cell, typeof(ActivityStatsData));
                if (c.ActType == p_type)
                {
                    return(c);
                }
            }

            return(null);
        }
Пример #5
0
        /// <summary>
        /// Returns true if one of it's elements contains an action type 'p_type'
        /// </summary>
        /// <param name="p_type"></param>
        /// <returns></returns>
        public bool Contains(EAct_Types p_type)
        {
            if (this.Count <= 0)
            {
                return(false);
            }

            foreach (T cell in this)
            {
                ActivityStatsData c = (ActivityStatsData)Convert.ChangeType(cell, typeof(ActivityStatsData));
                if (c.ActType == p_type)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #6
0
        /****************************************************************
         * Public Methods
         **/
        /// <summary>
        /// Updates total Values.
        /// Sum of all of it's unit values
        /// </summary>
        public void UpdateTotalValues()
        {
            uint totalSteps = 0;
            uint totalDist  = 0;
            uint totalCal   = 0;

            foreach (T cell in this)
            {
                ActivityStatsData c = (ActivityStatsData)Convert.ChangeType(cell, typeof(ActivityStatsData));
                totalSteps += c.Steps;
                totalDist  += c.Distance;
                totalCal   += c.Calories;
            }

            // TODO: Compute total Hrs, Min & Sec here

            TotalSteps    = totalSteps;
            TotalDistance = totalDist;
            TotalCalories = totalCal;
        }
        public ActivityStatsData ToActivityView()
        {
            ActivityStatsData viewData = new ActivityStatsData(
                (EAct_Types)this.Sport_ID,
                (ulong)this.CreatedTime,
                (uint)this.ActivitySteps,
                (uint)this.ActivityDistance,
                (uint)this.ActivityCalories,
                (uint)this.ActivityHeart);

            return viewData;
        }