Example #1
0
        public SummonerDetails(SummonerStats data, List<LogData> logs, Main form)
        {
            mainForm = form;
              InitializeComponent();
              Data = data;
              logData = logs;

              headerLabel.Text = data.Name;
              if (!String.IsNullOrEmpty(data.Server)) {
            headerLabel.Text += " (" + data.Server + ")";
              }

              var gamesDetails = new List<string>();
              if (data.GamesWith > 0) {
            gamesDetails.Add("with: " + data.GamesWith);
              }
              if (data.GamesAgainst > 0) {
            gamesDetails.Add("against: " + data.GamesAgainst);
              }
              int spec = data.Games - data.GamesWith - data.GamesAgainst - data.GamesAs;
              if (spec > 0) {
            gamesDetails.Add("spec: " + spec);
              }
              if (data.GamesAs > 0 && gamesDetails.Count > 0) {
            gamesDetails.Insert(0, "as: " + data.GamesAs);
              }
              var gamesText = gamesPlayedLabel.Text =
            String.Format("Games: {0}{1}", data.Games, gamesDetails.Count > 0 ? " (" + String.Join(", ", gamesDetails.ToArray()) + ")" : "");

              // Create links
              string[] labels = {"Games", "as", "with", "against", "spec"};
              foreach (var label in labels) {
            var match = Regex.Match(gamesText, label + ": ([0-9]+)");
            if (match.Success) {
              var type = label == "Games" ? "" : label;
              gamesPlayedLabel.Links.Add(new LinkLabel.Link(match.Groups[1].Index, match.Groups[1].Length, type));
            }
              }

              var recordDetails = new List<string>();
              if (data.WinsAs + data.LossesAs > 0) {
            recordDetails.Insert(0, "as: " + data.WinsAs + "-" + data.LossesAs);
              }
              if (data.WinsWith + data.LossesWith > 0) {
            recordDetails.Add("with: " + data.WinsWith + "-" + data.LossesWith);
              }
              int winsAgainst = data.KnownWins - data.WinsWith - data.WinsAs;
              int lossesAgainst = data.KnownLosses - data.LossesWith - data.LossesAs;
              if (winsAgainst + lossesAgainst > 0) {
            recordDetails.Add("against: " + lossesAgainst + "-" + winsAgainst);
              }
              recordLabel.Text = "Known record" + (recordDetails.Count > 0 ? " " + String.Join(", ", recordDetails.ToArray()) : ": 0-0");

              timeLabel.Text = "Total time logged: " + Util.FormatTime(data.TimePlayed);

              LoadChampionStats();
              LoadDeathStats();
        }
Example #2
0
        private void LoadData()
        {
            Invoke(new Action(Show));

              logData = database.Select();
              Invoke(new Action(() => {
            gameTable.DataSource = gameData = new SortableBindingList<GameStats>(logData.Select(log => new GameStats(log)));
            gameData.SetDefaultDirection("Date", -1);
              }));

              summoners = new Dictionary<string, SummonerStats>();
              foreach (var row in logData) {
            foreach (var x in row.BlueTeam.Concat(row.PurpleTeam)) {
              if (!x.IsBot && (!row.BotGame || !x.Name.EndsWith(" Bot"))) {
            var key = x.Name;
            // Is this someone on a different server?
            if (summoners.ContainsKey(x.Name) && !String.IsNullOrEmpty(row.Server) && !String.IsNullOrEmpty(summoners[x.Name].Server)) {
              if (row.Server != summoners[x.Name].Server) {
                key = x.Name + "_" + row.Server;
              }
            }
            if (!summoners.ContainsKey(key)) {
              summoners[key] = new SummonerStats(x.Name);
            }
            summoners[key].AddGame(row);
              }
            }
              }

              Invoke(new Action(() => {
            summonerTable.DataSource = summonerData = new SortableBindingList<SummonerStats>(summoners.Values.OrderByDescending(x => x.Games));
            summonerData.SetDefaultDirection("Games", -1);
            summonerData.SetDefaultDirection("PlayedWith", -1);
            summonerData.SetDefaultDirection("PlayedVs", -1);
            summonerData.SetDefaultDirection("KnownWins", -1);
            summonerData.SetDefaultDirection("KnownLosses", -1);
              }));
        }