summaryrefslogtreecommitdiff
path: root/Aktywator/Tournament.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Aktywator/Tournament.cs')
-rw-r--r--Aktywator/Tournament.cs89
1 files changed, 89 insertions, 0 deletions
diff --git a/Aktywator/Tournament.cs b/Aktywator/Tournament.cs
index cbe9bf9..87fa759 100644
--- a/Aktywator/Tournament.cs
+++ b/Aktywator/Tournament.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;
+using System.Windows.Forms;
+using System.Drawing;
namespace Aktywator
{
@@ -38,6 +40,77 @@ namespace Aktywator
return new Dictionary<int, List<string>>();
}
+ virtual public void displayNameList(DataGridView grid)
+ {
+ Dictionary<int, List<string>> names = this.getNameList();
+ foreach (KeyValuePair<int, List<string>> item in names) {
+ if (!this.updateNameListRow(grid, item.Key, item.Value))
+ {
+ this.addNameListRow(grid, item.Key, item.Value);
+ }
+ }
+ List<DataGridViewRow> toDelete = new List<DataGridViewRow>();
+ foreach (DataGridViewRow row in grid.Rows)
+ {
+ if (!names.ContainsKey(Int32.Parse(row.Cells[0].Value.ToString())))
+ {
+ toDelete.Add(row);
+ }
+ }
+ foreach (DataGridViewRow r in toDelete)
+ {
+ grid.Rows.Remove(r);
+ }
+ }
+
+ virtual internal bool updateNameListRow(DataGridView grid, int pairNumber, List<string> names)
+ {
+ foreach (DataGridViewRow row in grid.Rows)
+ {
+ if (Int32.Parse(row.Cells[0].Value.ToString()) == pairNumber)
+ {
+ for (int i = 1; i < 3; i++)
+ {
+ if (!(bool)row.Cells[i].Tag)
+ {
+ row.Cells[i].Value = names[i - 1];
+ row.Cells[i].Tag = false;
+ row.Cells[i].Style.BackColor = Color.White;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ virtual internal void addNameListRow(DataGridView grid, int pairNumber, List<string> names)
+ {
+ DataGridViewRow row = new DataGridViewRow();
+ row.Cells.Add(new DataGridViewTextBoxCell());
+ row.Cells[0].Value = pairNumber.ToString();
+ foreach (string name in names)
+ {
+ DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
+ cell.Value = name;
+ cell.Tag = false;
+ row.Cells.Add(cell);
+ }
+ grid.Rows.Add(row);
+ }
+
+ virtual internal void clearCellLocks(DataGridView grid)
+ {
+ foreach (DataGridViewRow row in grid.Rows)
+ {
+ for (int i = 1; i < 3; i++)
+ {
+ row.Cells[i].Tag = false;
+ row.Cells[i].Style.BackColor = Color.White;
+ }
+ }
+ }
+
virtual internal string shortenNameToBWS(string name)
{
if ("pauza".Equals(name.Trim()))
@@ -54,5 +127,21 @@ namespace Aktywator
return String.Join(" ", nameParts);
}
}
+
+ virtual public Dictionary<int, List<string>> getBWSNames(DataGridView grid)
+ {
+ Dictionary<int, List<string>> dict = new Dictionary<int, List<string>>();
+ foreach (DataGridViewRow row in grid.Rows)
+ {
+ List<string> names = new List<string>();
+ for (int i = 1; i < 3; i++)
+ {
+ names.Add(this.shortenNameToBWS(row.Cells[i].Value.ToString()));
+ }
+ dict.Add(Int32.Parse(row.Cells[0].Value.ToString()), names);
+ }
+ return dict;
+ }
+
}
}