private void button1_Click(object sender, EventArgs e) { Dictionary <string, Player> cParticipatingPlayers1 = new Dictionary <string, Player>(); Dictionary <string, Player> cParticipatingPlayers2 = new Dictionary <string, Player>(); Dictionary <string, Player> cParticipatingAllPlayer = new Dictionary <string, Player>(); double iTotal = 0; foreach (GroupBox cb in groupBox1.Controls.OfType <GroupBox>()) { if (cb is GroupBox) { if (cb.Enabled) { foreach (ComboBox combo in cb.Controls.OfType <ComboBox>()) { if (combo.SelectedValue == null) { continue; } Player cP = (Player)combo.SelectedValue; if (cP.Name == "") { continue; } if (cParticipatingPlayers1.ContainsKey(cP.Name)) { string sMessage = cP.Name + "은 이미 이 팀에 있습니다..."; MessageBox.Show(sMessage); continue; } if (cParticipatingAllPlayer.ContainsKey(cP.Name)) { string sMessage = cP.Name + "은 이미 이 상대팀에 있습니다..."; MessageBox.Show(sMessage); continue; } cParticipatingPlayers1.Add(cP.Name, cP); cParticipatingAllPlayer.Add(cP.Name, cP); iTotal += cP.PSR; } } } } foreach (GroupBox cb in groupBox7.Controls.OfType <GroupBox>()) { if (cb is GroupBox) { if (cb.Enabled) { foreach (ComboBox combo in cb.Controls.OfType <ComboBox>()) { if (combo.SelectedValue == null) { continue; } Player cP = (Player)combo.SelectedValue; if (cP.Name == "") { continue; } if (cParticipatingPlayers2.ContainsKey(cP.Name)) { string sMessage = cP.Name + "은 이미 이 팀에 있습니다..."; MessageBox.Show(sMessage); continue; } if (cParticipatingAllPlayer.ContainsKey(cP.Name)) { string sMessage = cP.Name + "은 이미 이 상대팀에 있습니다..."; MessageBox.Show(sMessage); continue; } cParticipatingPlayers2.Add(cP.Name, cP); cParticipatingAllPlayer.Add(cP.Name, cP); iTotal += cP.PSR; } } } } // Balance here.. string sToAppend = "Total: " + iTotal.ToString(); AppendStringTab1(sToAppend); cPSR = new DotaPSR(cParticipatingPlayers1.Values.ToList(), cParticipatingPlayers2.Values.ToList()); AppendStringTab1(cPSR.sDebugString); foreach (GroupBox cb in groupBox1.Controls.OfType <GroupBox>().Reverse()) { groupBox1.Text = "team 1 : " + cPSR.iTeam1WinPerc.ToString(); if (cb is GroupBox) { if (cb.Enabled) { foreach (ComboBox combo in cb.Controls.OfType <ComboBox>()) { if (combo.SelectedIndex == 0) { cb.Text = "No Player"; continue; } if (combo.Text == "") { continue; } DotaPlayerPSR cPlayer; cPSR.cWinLoseDic.TryGetValue(combo.Text, out cPlayer); cb.Text = cPlayer.Name + ":" + cPlayer.fWinPoint + "/" + cPlayer.fLosePoint; } } } } foreach (GroupBox cb in groupBox7.Controls.OfType <GroupBox>().Reverse()) { groupBox7.Text = "team 2 : " + cPSR.iTeam2WinPerc.ToString(); if (cb is GroupBox) { if (cb.Enabled) { foreach (ComboBox combo in cb.Controls.OfType <ComboBox>()) { if (combo.SelectedIndex == 0) { cb.Text = "No Player"; continue; } if (combo.Text == "") { continue; } DotaPlayerPSR cPlayer; cPSR.cWinLoseDic.TryGetValue(combo.Text, out cPlayer); cb.Text = cPlayer.Name + ":" + cPlayer.fWinPoint + "/" + cPlayer.fLosePoint; } } } } bAnalyzed = true; }
private void button1_Click(object sender, EventArgs e) { Dictionary<string, Player> cParticipatingPlayers1 = new Dictionary<string, Player>(); Dictionary<string, Player> cParticipatingPlayers2 = new Dictionary<string, Player>(); Dictionary<string, Player> cParticipatingAllPlayer = new Dictionary<string, Player>(); double iTotal = 0; foreach (GroupBox cb in groupBox1.Controls.OfType<GroupBox>()) { if (cb is GroupBox) { if (cb.Enabled) { foreach (ComboBox combo in cb.Controls.OfType<ComboBox>()) { if (combo.SelectedValue == null) continue; Player cP = (Player)combo.SelectedValue; if (cP.Name == "") continue; if (cParticipatingPlayers1.ContainsKey(cP.Name)) { string sMessage = cP.Name + "은 이미 이 팀에 있습니다..."; MessageBox.Show(sMessage); continue; } if (cParticipatingAllPlayer.ContainsKey(cP.Name)) { string sMessage = cP.Name + "은 이미 이 상대팀에 있습니다..."; MessageBox.Show(sMessage); continue; } cParticipatingPlayers1.Add(cP.Name, cP); cParticipatingAllPlayer.Add(cP.Name, cP); iTotal += cP.PSR; } } } } foreach (GroupBox cb in groupBox7.Controls.OfType<GroupBox>()) { if (cb is GroupBox) { if (cb.Enabled) { foreach (ComboBox combo in cb.Controls.OfType<ComboBox>()) { if (combo.SelectedValue == null) continue; Player cP = (Player)combo.SelectedValue; if (cP.Name == "") continue; if (cParticipatingPlayers2.ContainsKey(cP.Name)) { string sMessage = cP.Name + "은 이미 이 팀에 있습니다..."; MessageBox.Show(sMessage); continue; } if (cParticipatingAllPlayer.ContainsKey(cP.Name)) { string sMessage = cP.Name + "은 이미 이 상대팀에 있습니다..."; MessageBox.Show(sMessage); continue; } cParticipatingPlayers2.Add(cP.Name, cP); cParticipatingAllPlayer.Add(cP.Name, cP); iTotal += cP.PSR; } } } } // Balance here.. string sToAppend = "Total: " + iTotal.ToString(); AppendStringTab1(sToAppend); cPSR = new DotaPSR(cParticipatingPlayers1.Values.ToList(), cParticipatingPlayers2.Values.ToList()); AppendStringTab1(cPSR.sDebugString); foreach (GroupBox cb in groupBox1.Controls.OfType<GroupBox>().Reverse()) { groupBox1.Text = "team 1 : " + cPSR.iTeam1WinPerc.ToString(); if (cb is GroupBox) { if (cb.Enabled) { foreach (ComboBox combo in cb.Controls.OfType<ComboBox>()) { if (combo.SelectedIndex == 0) { cb.Text = "No Player"; continue; } if (combo.Text == "") continue; DotaPlayerPSR cPlayer; cPSR.cWinLoseDic.TryGetValue(combo.Text, out cPlayer); cb.Text = cPlayer.Name + ":" + cPlayer.fWinPoint + "/" + cPlayer.fLosePoint; } } } } foreach (GroupBox cb in groupBox7.Controls.OfType<GroupBox>().Reverse()) { groupBox7.Text = "team 2 : " + cPSR.iTeam2WinPerc.ToString(); if (cb is GroupBox) { if (cb.Enabled) { foreach (ComboBox combo in cb.Controls.OfType<ComboBox>()) { if (combo.SelectedIndex == 0) { cb.Text = "No Player"; continue; } if (combo.Text == "") continue; DotaPlayerPSR cPlayer; cPSR.cWinLoseDic.TryGetValue(combo.Text, out cPlayer); cb.Text = cPlayer.Name + ":" + cPlayer.fWinPoint + "/" + cPlayer.fLosePoint; } } } } bAnalyzed = true; }