public void GetLeaderboard(XboxLiveUser user, string statName, LeaderboardQuery query)
        {
            if (!LocalUsers.Contains(user))
            {
                throw new ArgumentException("Local User needs to be added.");
            }

            if (!mStats.ContainsKey(statName))
            {
                mStats[statName] = new StatisticValue()
                {
                    Name      = statName,
                    AsInteger = 300,
                    AsNumber  = 300,
                    DataType  = StatisticDataType.Number
                };
            }

            StatisticValue stat = mStats[statName];

            List <LeaderboardRow> rows = new List <LeaderboardRow>();
            uint maxScore      = query.MaxItems * 100;
            uint rankOffset    = query.SkipResultToRank == 0 ? 1 : query.SkipResultToRank;
            bool userDisplayed = false;

            for (uint i = 0; i < query.MaxItems; i++)
            {
                uint           score = maxScore - i * 100;
                LeaderboardRow row;
                if (!userDisplayed && stat.DataType == StatisticDataType.Number && (stat.AsNumber >= score || stat.AsInteger >= score))
                {
                    userDisplayed = true;
                    row           = new LeaderboardRow(new List <string> {
                        stat.AsNumber.ToString()
                    }, i + rankOffset, 0.8, user.XboxUserId, user.Gamertag);
                }
                else
                {
                    row = new LeaderboardRow(new List <string> {
                        score.ToString()
                    }, i + rankOffset, 0.8, string.Format("{0}{0}{0}{0}{0}{0}{0}{0}", i), string.Format("Gamertag {0}", i));
                }

                rows.Add(row);
            }

            List <LeaderboardColumn> cols = new List <LeaderboardColumn>();

            cols.Add(new LeaderboardColumn(stat.DataType == StatisticDataType.String ? LeaderboardStatType.String : LeaderboardStatType.Integer, ""));

            LeaderboardResult result = new LeaderboardResult(rows, cols, query.MaxItems);

            LeaderboardResultEventArgs args = new LeaderboardResultEventArgs(result);

            mStatEventList.Add(new StatisticEvent(StatisticEventType.GetLeaderboardComplete, user, args));
        }
        internal StatisticEvent(IntPtr statEventPtr)
        {
            STATISTIC_EVENT cStatEvent = Marshal.PtrToStructure <STATISTIC_EVENT>(statEventPtr);

            EventType = cStatEvent.EventType;

            try
            {
                EventArgs = new LeaderboardResultEventArgs(cStatEvent.EventArgs);
            }
            catch (Exception)
            {
                // not LeaderboardResultEventArgs
            }

            User = new XboxLiveUser(cStatEvent.LocalUser);

            ErrorCode    = cStatEvent.ErrorCode;
            ErrorMessage = MarshalingHelpers.Utf8ToString(cStatEvent.ErrorMessage);
        }