diff --git a/.vs/TournamentManager/DesignTimeBuild/.dtbcache.v2 b/.vs/TournamentManager/DesignTimeBuild/.dtbcache.v2 index 7ea6d93c7cf94b40bf6de3e00371a34c2d9b775f..e5076c70ac9cda529afde7927fc1dff71499ceb4 100644 Binary files a/.vs/TournamentManager/DesignTimeBuild/.dtbcache.v2 and b/.vs/TournamentManager/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/TournamentManager/v16/.suo b/.vs/TournamentManager/v16/.suo index 2aa9fa15e9c58f4b1ad0d70da046d7c428c48a90..99bee51a68bf15ba9fd68d62c8344795d85ad1c2 100644 Binary files a/.vs/TournamentManager/v16/.suo and b/.vs/TournamentManager/v16/.suo differ diff --git a/TournamentManager.csproj.user b/TournamentManager.csproj.user index bb8a556dc66d309f029d141ea923cf707c206816..d81df0bb4c5c1793b6b08d1da0a40db8b091eadd 100644 --- a/TournamentManager.csproj.user +++ b/TournamentManager.csproj.user @@ -4,6 +4,9 @@ <ShowAllFiles>false</ShowAllFiles> </PropertyGroup> <ItemGroup> + <Compile Update="src\CalculateControl.cs"> + <SubType>UserControl</SubType> + </Compile> <Compile Update="src\ExportControl.cs"> <SubType>UserControl</SubType> </Compile> diff --git a/obj/Debug/net5.0-windows/TournamentManager.csproj.CoreCompileInputs.cache b/obj/Debug/net5.0-windows/TournamentManager.csproj.CoreCompileInputs.cache index ba67ddca2a15310b35d501acf229f7c92cdbf9a4..de3e3dc56b3f067a9917313ddd455227431c3248 100644 --- a/obj/Debug/net5.0-windows/TournamentManager.csproj.CoreCompileInputs.cache +++ b/obj/Debug/net5.0-windows/TournamentManager.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -6e5ca88c712bf3b5a92f367155b7ffc624cd7a70 +6dbd88745d59fa151ec2b15eaaf1ea837c62dd6e diff --git a/obj/Debug/net5.0-windows/TournamentManager.csproj.FileListAbsolute.txt b/obj/Debug/net5.0-windows/TournamentManager.csproj.FileListAbsolute.txt index 9cbe3b18ea3c37285fd87e47847759b4845be58b..66ce1be8491dea720e0b44e462355d801bf3f4ac 100644 --- a/obj/Debug/net5.0-windows/TournamentManager.csproj.FileListAbsolute.txt +++ b/obj/Debug/net5.0-windows/TournamentManager.csproj.FileListAbsolute.txt @@ -51,3 +51,5 @@ C:\Users\micha\School\RiderProjects\c-sharp-semestral-project-1\obj\Debug\net5.0 C:\Users\micha\School\RiderProjects\c-sharp-semestral-project-1\obj\Debug\net5.0-windows\TournamentManager.pdb C:\Users\micha\School\RiderProjects\c-sharp-semestral-project-1\obj\Debug\net5.0-windows\TournamentManager.genruntimeconfig.cache C:\Users\micha\School\RiderProjects\c-sharp-semestral-project-1\obj\Debug\net5.0-windows\TournamentManager.src.GroupControl.resources +C:\Users\micha\School\RiderProjects\c-sharp-semestral-project-1\obj\Debug\net5.0-windows\TournamentManager.src.ExportControl.resources +C:\Users\micha\School\RiderProjects\c-sharp-semestral-project-1\obj\Debug\net5.0-windows\TournamentManager.src.CalculateControl.resources diff --git a/obj/Debug/net5.0-windows/TournamentManager.csproj.GenerateResource.cache b/obj/Debug/net5.0-windows/TournamentManager.csproj.GenerateResource.cache index f2447ad0d2ed0b89a8b9586784d6572d2b64271a..e254cb66747a75cdef819599c1502b7666335de9 100644 Binary files a/obj/Debug/net5.0-windows/TournamentManager.csproj.GenerateResource.cache and b/obj/Debug/net5.0-windows/TournamentManager.csproj.GenerateResource.cache differ diff --git a/obj/Debug/net5.0-windows/TournamentManager.csprojAssemblyReference.cache b/obj/Debug/net5.0-windows/TournamentManager.csprojAssemblyReference.cache index 480d75008485368cdf5c5f62d4027881bfeccf9f..548aebadef402014a6cfe8edc074acecb859d308 100644 Binary files a/obj/Debug/net5.0-windows/TournamentManager.csprojAssemblyReference.cache and b/obj/Debug/net5.0-windows/TournamentManager.csprojAssemblyReference.cache differ diff --git a/obj/Debug/net5.0-windows/TournamentManager.dll b/obj/Debug/net5.0-windows/TournamentManager.dll index 00178bf05622154bc9922fe8a7df38df28008ccd..78fa5521844df9e3162bd1306b99a113c2fc37ea 100644 Binary files a/obj/Debug/net5.0-windows/TournamentManager.dll and b/obj/Debug/net5.0-windows/TournamentManager.dll differ diff --git a/obj/Debug/net5.0-windows/TournamentManager.pdb b/obj/Debug/net5.0-windows/TournamentManager.pdb index 9efe8c8148972fe962870c784266434fa82bb499..4821a48d2ebe34c5fa11a61df2481eae986fafe0 100644 Binary files a/obj/Debug/net5.0-windows/TournamentManager.pdb and b/obj/Debug/net5.0-windows/TournamentManager.pdb differ diff --git a/obj/Debug/net5.0-windows/TournamentManager.src.CalculateControl.resources b/obj/Debug/net5.0-windows/TournamentManager.src.CalculateControl.resources new file mode 100644 index 0000000000000000000000000000000000000000..6c05a9776bd7cbae976fdcec7e3a254e93018279 Binary files /dev/null and b/obj/Debug/net5.0-windows/TournamentManager.src.CalculateControl.resources differ diff --git a/obj/Debug/net5.0-windows/TournamentManager.src.ExportControl.resources b/obj/Debug/net5.0-windows/TournamentManager.src.ExportControl.resources new file mode 100644 index 0000000000000000000000000000000000000000..6c05a9776bd7cbae976fdcec7e3a254e93018279 Binary files /dev/null and b/obj/Debug/net5.0-windows/TournamentManager.src.ExportControl.resources differ diff --git a/obj/Debug/net5.0-windows/ref/TournamentManager.dll b/obj/Debug/net5.0-windows/ref/TournamentManager.dll index 7c4f2845e90bf8100d890eb42e7dc3e796fc884e..83052901726b04117b977803cd68016e9b3efa9a 100644 Binary files a/obj/Debug/net5.0-windows/ref/TournamentManager.dll and b/obj/Debug/net5.0-windows/ref/TournamentManager.dll differ diff --git a/obj/TournamentManager.csproj.nuget.dgspec.json b/obj/TournamentManager.csproj.nuget.dgspec.json index e77d8e92becc933da122a5ed2968a364b9596ec6..8193c420661e33e564749b3c09b80ebdfb856ae4 100644 --- a/obj/TournamentManager.csproj.nuget.dgspec.json +++ b/obj/TournamentManager.csproj.nuget.dgspec.json @@ -22,7 +22,7 @@ "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" ], "originalTargetFrameworks": [ - "net5.0-windows" + "net5.0-windows7.0" ], "sources": { "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, diff --git a/obj/TournamentManager.csproj.nuget.g.props b/obj/TournamentManager.csproj.nuget.g.props index 4411bfa3095a41919a54414b7f894488d2711854..fd44c976c105a4b30c1199cf048f8c2e5fd704c2 100644 --- a/obj/TournamentManager.csproj.nuget.g.props +++ b/obj/TournamentManager.csproj.nuget.g.props @@ -7,10 +7,11 @@ <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot> <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\micha\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders> <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle> - <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.8.0</NuGetToolVersion> + <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.9.1</NuGetToolVersion> </PropertyGroup> <ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> - <SourceRoot Include="$([MSBuild]::EnsureTrailingSlash($(NuGetPackageFolders)))" /> + <SourceRoot Include="C:\Users\micha\.nuget\packages\" /> + <SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" /> </ItemGroup> <PropertyGroup> <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> diff --git a/obj/project.assets.json b/obj/project.assets.json index 9e36234e71f12b941720b79e28d0b6445267f9b6..ee563469de198cd0ab5482ac1bf514e5fd784553 100644 --- a/obj/project.assets.json +++ b/obj/project.assets.json @@ -74,7 +74,7 @@ "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" ], "originalTargetFrameworks": [ - "net5.0-windows" + "net5.0-windows7.0" ], "sources": { "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, diff --git a/obj/project.nuget.cache b/obj/project.nuget.cache index b2ac104cc0ff2b934e2161280895de53226766b9..f18c7ee364890660cc14f8786af4d8ab8f2e3e09 100644 --- a/obj/project.nuget.cache +++ b/obj/project.nuget.cache @@ -1,6 +1,6 @@ { "version": 2, - "dgSpecHash": "H71bVF2tvvTKiX1pmF6aHb9K3KX+isneTQJ5VfOpVIgT/zpQhwsdigl9to5pbHKJjGW9eAmRAA+cQgirv1ofvA==", + "dgSpecHash": "umcWTwWm5FWSLXrCLi1hAiSKMk34e+8HmDyYsi0ix1KwxZS3E/m1Qv9UliO6bACM5E/u5fBHvrSo9PIkJD0wTA==", "success": true, "projectFilePath": "C:\\Users\\micha\\School\\RiderProjects\\c-sharp-semestral-project-1\\TournamentManager.csproj", "expectedPackageFiles": [ diff --git a/obj/rider.project.restore.info b/obj/rider.project.restore.info index f365a93c97cbe8208309957d321b2d55f0cbaa29..c114ea24721db3ce29cd1300f7d0ea1c3c731836 100644 --- a/obj/rider.project.restore.info +++ b/obj/rider.project.restore.info @@ -1 +1 @@ -16225451119597750 \ No newline at end of file +16225471957581258 \ No newline at end of file diff --git a/src/CalculateControl.Designer.cs b/src/CalculateControl.Designer.cs new file mode 100644 index 0000000000000000000000000000000000000000..e7c195fb299b9dfe9761f509346d68c185e8d447 --- /dev/null +++ b/src/CalculateControl.Designer.cs @@ -0,0 +1,126 @@ + +namespace TournamentManager.src +{ + partial class CalculateControl + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.btnGroups = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.cbGroupSize = new System.Windows.Forms.ComboBox(); + this.btnPlayOff = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.cbEliminate = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // btnGroups + // + this.btnGroups.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnGroups.Location = new System.Drawing.Point(0, 0); + this.btnGroups.Name = "btnGroups"; + this.btnGroups.Size = new System.Drawing.Size(200, 57); + this.btnGroups.TabIndex = 0; + this.btnGroups.Text = "Calculate Groups"; + this.btnGroups.UseVisualStyleBackColor = true; + this.btnGroups.Click += new System.EventHandler(this.btnGroups_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(0, 60); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(78, 21); + this.label1.TabIndex = 1; + this.label1.Text = "Max Size:"; + // + // cbGroupSize + // + this.cbGroupSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbGroupSize.FormattingEnabled = true; + this.cbGroupSize.Location = new System.Drawing.Point(84, 60); + this.cbGroupSize.Name = "cbGroupSize"; + this.cbGroupSize.Size = new System.Drawing.Size(80, 23); + this.cbGroupSize.TabIndex = 2; + // + // btnPlayOff + // + this.btnPlayOff.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnPlayOff.Location = new System.Drawing.Point(290, 0); + this.btnPlayOff.Name = "btnPlayOff"; + this.btnPlayOff.Size = new System.Drawing.Size(200, 57); + this.btnPlayOff.TabIndex = 3; + this.btnPlayOff.Text = "Calculate PlayOff"; + this.btnPlayOff.UseVisualStyleBackColor = true; + this.btnPlayOff.Click += new System.EventHandler(this.btnPlayOff_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label2.Location = new System.Drawing.Point(286, 60); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(118, 21); + this.label2.TabIndex = 4; + this.label2.Text = "% to eliminate:"; + // + // cbEliminate + // + this.cbEliminate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbEliminate.FormattingEnabled = true; + this.cbEliminate.Location = new System.Drawing.Point(410, 60); + this.cbEliminate.Name = "cbEliminate"; + this.cbEliminate.Size = new System.Drawing.Size(80, 23); + this.cbEliminate.TabIndex = 5; + // + // CalculateControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cbEliminate); + this.Controls.Add(this.label2); + this.Controls.Add(this.btnPlayOff); + this.Controls.Add(this.cbGroupSize); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnGroups); + this.Name = "CalculateControl"; + this.Size = new System.Drawing.Size(490, 92); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnGroups; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox cbGroupSize; + private System.Windows.Forms.Button btnPlayOff; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox cbEliminate; + } +} diff --git a/src/CalculateControl.cs b/src/CalculateControl.cs new file mode 100644 index 0000000000000000000000000000000000000000..f8f1bd7f9a19a2e6ee9d94ebe89f712a40fdaf4f --- /dev/null +++ b/src/CalculateControl.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace TournamentManager.src +{ + public partial class CalculateControl : UserControl + { + public event CalculateGroupsEventArgsDelegate CalculateGroups; + + public delegate void CalculateGroupsEventArgsDelegate(object sender, CalculateGroupsEventArgs e); + protected void OnCalculateGroups(CalculateGroupsEventArgs args) => CalculateGroups?.Invoke(this, args); + + public CalculateControl() + { + InitializeComponent(); + Func<int, int, int, IEnumerable<string> > createRange = (x, y, z) => + Enumerable.Range(x, y).Select(n => (n*z).ToString()); + cbGroupSize.Items.AddRange( (string[])createRange(4, 4, 1) + .ToArray() ); + cbEliminate.Items.AddRange( (string[])createRange(0, 5, 10) + .ToArray() ); + } + + private void btnGroups_Click(object sender, EventArgs e) + { + if (cbGroupSize.SelectedItem == null) + { + //TODO: throw some message + return; + } + OnCalculateGroups(new CalculateGroupsEventArgs(int.Parse(cbGroupSize.SelectedItem.ToString()!))); + } + + private void btnPlayOff_Click(object sender, EventArgs e) + { + //TODO: Calculate playoff + } + } +} diff --git a/src/CalculateControl.resx b/src/CalculateControl.resx new file mode 100644 index 0000000000000000000000000000000000000000..f298a7be80982ebd538a05758a03bc827419d418 --- /dev/null +++ b/src/CalculateControl.resx @@ -0,0 +1,60 @@ +<root> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/src/CalculateGroupsEventArgs.cs b/src/CalculateGroupsEventArgs.cs new file mode 100644 index 0000000000000000000000000000000000000000..2a16a293eab1b1aa700962f5e7bc2f106b95a649 --- /dev/null +++ b/src/CalculateGroupsEventArgs.cs @@ -0,0 +1,12 @@ +namespace TournamentManager +{ + public class CalculateGroupsEventArgs + { + public int GroupSize { get; } + + public CalculateGroupsEventArgs(int groupSize) + { + GroupSize = groupSize; + } + } +} \ No newline at end of file diff --git a/src/CbItemSelectedEventArgs.cs b/src/CbItemSelectedEventArgs.cs new file mode 100644 index 0000000000000000000000000000000000000000..2340e71da20f7bb7fd9204c3c9a9fc3955d805a3 --- /dev/null +++ b/src/CbItemSelectedEventArgs.cs @@ -0,0 +1,12 @@ +namespace TournamentManager +{ + public class CbItemSelectedEventArgs + { + public string ItemName { get; } + + public CbItemSelectedEventArgs(string itemName) + { + ItemName = itemName; + } + } +} \ No newline at end of file diff --git a/src/Group.cs b/src/Group.cs index e3b61bbb9d71dabed703cd7f1544a3fce5aa1aee..a3d1c752f265d62fbf956df3b96d149f83534b19 100644 --- a/src/Group.cs +++ b/src/Group.cs @@ -1,9 +1,13 @@ -using System.Runtime.Serialization; +using System.Collections.Generic; +using System.Runtime.Serialization; namespace TournamentManager { public class Group : ISerializable { + public List<Participant> Members { get; set; } + public List<Match> Matches { get; set; } + public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new System.NotImplementedException(); diff --git a/src/GroupControl.Designer.cs b/src/GroupControl.Designer.cs index 3e4cc76dba727f8d03dbc2d91ad000a00f3fc464..4816a3095ae2febddcf7900191c425148817b8fc 100644 --- a/src/GroupControl.Designer.cs +++ b/src/GroupControl.Designer.cs @@ -30,10 +30,10 @@ namespace TournamentManager.src private void InitializeComponent() { this.cbGroup = new System.Windows.Forms.ComboBox(); - this.cbParticipant1 = new System.Windows.Forms.ComboBox(); - this.cbParticipant2 = new System.Windows.Forms.ComboBox(); - this.tbParticipant2 = new System.Windows.Forms.TextBox(); - this.tbParticipant1 = new System.Windows.Forms.TextBox(); + this.cbFirstOpponent = new System.Windows.Forms.ComboBox(); + this.cbSecondOpponent = new System.Windows.Forms.ComboBox(); + this.tbSecondOpponentScore = new System.Windows.Forms.TextBox(); + this.tbFirstOpponentScore = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.btnSubmit = new System.Windows.Forms.Button(); @@ -42,46 +42,55 @@ namespace TournamentManager.src // cbGroup // this.cbGroup.FormattingEnabled = true; - this.cbGroup.Location = new System.Drawing.Point(53, 8); + this.cbGroup.Location = new System.Drawing.Point(62, 9); + this.cbGroup.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cbGroup.Name = "cbGroup"; - this.cbGroup.Size = new System.Drawing.Size(128, 21); + this.cbGroup.Size = new System.Drawing.Size(149, 23); this.cbGroup.TabIndex = 0; + this.cbGroup.SelectedIndexChanged += new System.EventHandler(this.cbGroup_SelectedIndexChanged); // - // cbParticipant1 + // cbFirstOpponent // - this.cbParticipant1.FormattingEnabled = true; - this.cbParticipant1.Location = new System.Drawing.Point(0, 42); - this.cbParticipant1.Name = "cbParticipant1"; - this.cbParticipant1.Size = new System.Drawing.Size(115, 21); - this.cbParticipant1.TabIndex = 1; + this.cbFirstOpponent.FormattingEnabled = true; + this.cbFirstOpponent.Location = new System.Drawing.Point(0, 48); + this.cbFirstOpponent.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.cbFirstOpponent.Name = "cbFirstOpponent"; + this.cbFirstOpponent.Size = new System.Drawing.Size(134, 23); + this.cbFirstOpponent.TabIndex = 1; + this.cbFirstOpponent.SelectedIndexChanged += new System.EventHandler(this.cbFirstOpponent_SelectedIndexChanged); // - // cbParticipant2 + // cbSecondOpponent // - this.cbParticipant2.FormattingEnabled = true; - this.cbParticipant2.Location = new System.Drawing.Point(303, 42); - this.cbParticipant2.Name = "cbParticipant2"; - this.cbParticipant2.Size = new System.Drawing.Size(118, 21); - this.cbParticipant2.TabIndex = 2; + this.cbSecondOpponent.FormattingEnabled = true; + this.cbSecondOpponent.Location = new System.Drawing.Point(354, 48); + this.cbSecondOpponent.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.cbSecondOpponent.Name = "cbSecondOpponent"; + this.cbSecondOpponent.Size = new System.Drawing.Size(137, 23); + this.cbSecondOpponent.TabIndex = 2; + this.cbSecondOpponent.SelectedIndexChanged += new System.EventHandler(this.cbSecondOpponent_SelectedIndexChanged); // - // tbParticipant2 + // tbSecondOpponentScore // - this.tbParticipant2.Location = new System.Drawing.Point(244, 42); - this.tbParticipant2.Name = "tbParticipant2"; - this.tbParticipant2.Size = new System.Drawing.Size(54, 20); - this.tbParticipant2.TabIndex = 3; + this.tbSecondOpponentScore.Location = new System.Drawing.Point(285, 48); + this.tbSecondOpponentScore.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tbSecondOpponentScore.Name = "tbSecondOpponentScore"; + this.tbSecondOpponentScore.Size = new System.Drawing.Size(62, 23); + this.tbSecondOpponentScore.TabIndex = 3; // - // tbParticipant1 + // tbFirstOpponentScore // - this.tbParticipant1.Location = new System.Drawing.Point(120, 42); - this.tbParticipant1.Name = "tbParticipant1"; - this.tbParticipant1.Size = new System.Drawing.Size(54, 20); - this.tbParticipant1.TabIndex = 4; + this.tbFirstOpponentScore.Location = new System.Drawing.Point(140, 48); + this.tbFirstOpponentScore.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tbFirstOpponentScore.Name = "tbFirstOpponentScore"; + this.tbFirstOpponentScore.Size = new System.Drawing.Size(62, 23); + this.tbFirstOpponentScore.TabIndex = 4; // // label1 // this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold); - this.label1.Location = new System.Drawing.Point(197, 44); + this.label1.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(230, 51); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(27, 20); this.label1.TabIndex = 5; @@ -90,8 +99,9 @@ namespace TournamentManager.src // label2 // this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold); - this.label2.Location = new System.Drawing.Point(0, 8); + this.label2.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label2.Location = new System.Drawing.Point(0, 9); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(56, 20); this.label2.TabIndex = 6; @@ -99,42 +109,45 @@ namespace TournamentManager.src // // btnSubmit // - this.btnSubmit.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold); - this.btnSubmit.Location = new System.Drawing.Point(294, 75); + this.btnSubmit.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnSubmit.Location = new System.Drawing.Point(343, 87); + this.btnSubmit.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnSubmit.Name = "btnSubmit"; - this.btnSubmit.Size = new System.Drawing.Size(118, 29); + this.btnSubmit.Size = new System.Drawing.Size(138, 33); this.btnSubmit.TabIndex = 7; this.btnSubmit.Text = "Submit"; this.btnSubmit.UseVisualStyleBackColor = true; // // GroupControl // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.btnSubmit); this.Controls.Add(this.label2); this.Controls.Add(this.label1); - this.Controls.Add(this.tbParticipant1); - this.Controls.Add(this.tbParticipant2); - this.Controls.Add(this.cbParticipant2); - this.Controls.Add(this.cbParticipant1); + this.Controls.Add(this.tbFirstOpponentScore); + this.Controls.Add(this.tbSecondOpponentScore); + this.Controls.Add(this.cbSecondOpponent); + this.Controls.Add(this.cbFirstOpponent); this.Controls.Add(this.cbGroup); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.Name = "GroupControl"; - this.Size = new System.Drawing.Size(423, 111); + this.Size = new System.Drawing.Size(493, 128); this.ResumeLayout(false); this.PerformLayout(); + } #endregion private System.Windows.Forms.ComboBox cbGroup; - private System.Windows.Forms.ComboBox cbParticipant1; + private System.Windows.Forms.ComboBox cbFirstOpponent; private System.Windows.Forms.ComboBox comboBox3; - private System.Windows.Forms.TextBox tbParticipant2; - private System.Windows.Forms.TextBox tbParticipant1; + private System.Windows.Forms.TextBox tbSecondOpponentScore; + private System.Windows.Forms.TextBox tbFirstOpponentScore; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; - private System.Windows.Forms.ComboBox cbParticipant2; + private System.Windows.Forms.ComboBox cbSecondOpponent; private System.Windows.Forms.Button btnSubmit; } } diff --git a/src/GroupControl.cs b/src/GroupControl.cs index ac6f1448a935d869501b6c51c2cec5b3ed25dc3d..2a785a302b05257c6565783c5bbe9c9ff3bf4a92 100644 --- a/src/GroupControl.cs +++ b/src/GroupControl.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Data; using System.Drawing; @@ -7,14 +8,82 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; namespace TournamentManager.src { public partial class GroupControl : UserControl { + public delegate void CbItemSelectedDelegate(object sender, CbItemSelectedEventArgs e); + + public event CbItemSelectedDelegate CbGroupItemSelected; + public event CbItemSelectedDelegate CbFirstOpponentSelected; + public event CbItemSelectedDelegate CbSecondOpponentSelected; + + protected void OnGroupSelected(CbItemSelectedEventArgs e) => CbGroupItemSelected?.Invoke(this, e); + protected void OnFirstOpponentSelected(CbItemSelectedEventArgs e) => + CbFirstOpponentSelected?.Invoke(this, e); + protected void OnSecondOpponentSelected(CbItemSelectedEventArgs e) => + CbSecondOpponentSelected?.Invoke(this, e); + public GroupControl() { InitializeComponent(); } + + public void AddGroups(int groupCount) + { + for (int i = 0; i < groupCount; i++) + { + cbGroup.Items.Add($"Group {i + 1}"); + } + } + + public void AddToFirstOpponentList(string[] itemNames) + { + cbFirstOpponent.Items.AddRange((string[])itemNames); + } + + public void AddToSecondOpponentList(string[] itemNames) + { + cbFirstOpponent.Items.AddRange((string[])itemNames); + } + + private void cbGroup_SelectedIndexChanged(object sender, EventArgs e) + { + ClearComboBox(ref cbFirstOpponent); + ClearComboBox(ref cbSecondOpponent); + ClearTextBoxes(); + OnGroupSelected(new CbItemSelectedEventArgs(cbGroup.SelectedItem.ToString())); + } + + private void cbFirstOpponent_SelectedIndexChanged(object sender, EventArgs e) + { + ClearComboBox(ref cbSecondOpponent); + ClearTextBoxes(); + OnFirstOpponentSelected(new CbItemSelectedEventArgs(cbFirstOpponent.SelectedItem.ToString())); + } + + private void cbSecondOpponent_SelectedIndexChanged(object sender, EventArgs e) + { + ClearTextBoxes(); + OnSecondOpponentSelected(new CbItemSelectedEventArgs(cbSecondOpponent.SelectedItem.ToString())); + } + + #region HelperFunctions + + private void ClearComboBox(ref ComboBox comboBox) + { + comboBox.Items.Clear(); + comboBox.Text = String.Empty; + } + + private void ClearTextBoxes() + { + tbFirstOpponentScore.Clear(); + tbSecondOpponentScore.Clear(); + } + + #endregion } } diff --git a/src/GroupControl.resx b/src/GroupControl.resx index 1af7de150c99c12dd67a509fe57c10d63e4eeb04..f298a7be80982ebd538a05758a03bc827419d418 100644 --- a/src/GroupControl.resx +++ b/src/GroupControl.resx @@ -1,64 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> -<root> - <!-- - Microsoft ResX Schema - - Version 2.0 - - The primary goals of this format is to allow a simple XML format - that is mostly human readable. The generation and parsing of the - various data types are done through the TypeConverter classes - associated with the data types. - - Example: - - ... ado.net/XML headers & schema ... - <resheader name="resmimetype">text/microsoft-resx</resheader> - <resheader name="version">2.0</resheader> - <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> - <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> - <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> - <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> - <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> - <value>[base64 mime encoded serialized .NET Framework object]</value> - </data> - <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> - <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> - <comment>This is a comment</comment> - </data> - - There are any number of "resheader" rows that contain simple - name/value pairs. - - Each data row contains a name, and value. The row also contains a - type or mimetype. Type corresponds to a .NET class that support - text/value conversion through the TypeConverter architecture. - Classes that don't support this are serialized and stored with the - mimetype set. - - The mimetype is used for serialized objects, and tells the - ResXResourceReader how to depersist the object. This is currently not - extensible. For a given mimetype the value must be set accordingly: - - Note - application/x-microsoft.net.object.binary.base64 is the format - that the ResXResourceWriter will generate, however the reader can - read any of the formats listed below. - - mimetype: application/x-microsoft.net.object.binary.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.soap.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Soap.SoapFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.bytearray.base64 - value : The object must be serialized into a byte array - : using a System.ComponentModel.TypeConverter - : and then encoded with base64 encoding. - --> +<root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> diff --git a/src/ManageTournamentForm.Designer.cs b/src/ManageTournamentForm.Designer.cs index be8cb40bfebfced9cb73d7580e9edec422e8bf5b..5fad2fd4a92f686a633c02c425e144de4c6d09bd 100644 --- a/src/ManageTournamentForm.Designer.cs +++ b/src/ManageTournamentForm.Designer.cs @@ -36,11 +36,10 @@ namespace TournamentManager this.groupBox2 = new System.Windows.Forms.GroupBox(); this.manageParticipantsControl = new TournamentManager.src.ManageParticipantsControl(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.groupControl1 = new TournamentManager.src.GroupControl(); + this.groupControl = new TournamentManager.src.GroupControl(); this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.calculateControl = new TournamentManager.src.CalculateControl(); this.groupBox5 = new System.Windows.Forms.GroupBox(); - this.btnGroups = new System.Windows.Forms.Button(); - this.btnPlayOff = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -83,7 +82,7 @@ namespace TournamentManager // // groupBox3 // - this.groupBox3.Controls.Add(this.groupControl1); + this.groupBox3.Controls.Add(this.groupControl); this.groupBox3.Location = new System.Drawing.Point(394, 12); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(502, 154); @@ -91,54 +90,40 @@ namespace TournamentManager this.groupBox3.TabStop = false; this.groupBox3.Text = "Manage Group"; // - // groupControl1 + // groupControl // - this.groupControl1.Location = new System.Drawing.Point(6, 22); - this.groupControl1.Name = "groupControl1"; - this.groupControl1.Size = new System.Drawing.Size(491, 123); - this.groupControl1.TabIndex = 0; + this.groupControl.Location = new System.Drawing.Point(6, 22); + this.groupControl.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.groupControl.Name = "groupControl"; + this.groupControl.Size = new System.Drawing.Size(491, 123); + this.groupControl.TabIndex = 0; // // groupBox4 // - this.groupBox4.Controls.Add(this.btnPlayOff); - this.groupBox4.Controls.Add(this.btnGroups); + this.groupBox4.Controls.Add(this.calculateControl); this.groupBox4.Location = new System.Drawing.Point(395, 172); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(501, 93); + this.groupBox4.Size = new System.Drawing.Size(501, 138); this.groupBox4.TabIndex = 3; this.groupBox4.TabStop = false; this.groupBox4.Text = "Calculate"; // + // calculateControl + // + this.calculateControl.Location = new System.Drawing.Point(5, 22); + this.calculateControl.Name = "calculateControl"; + this.calculateControl.Size = new System.Drawing.Size(491, 111); + this.calculateControl.TabIndex = 0; + // // groupBox5 // - this.groupBox5.Location = new System.Drawing.Point(394, 271); + this.groupBox5.Location = new System.Drawing.Point(394, 316); this.groupBox5.Name = "groupBox5"; - this.groupBox5.Size = new System.Drawing.Size(502, 285); + this.groupBox5.Size = new System.Drawing.Size(502, 240); this.groupBox5.TabIndex = 4; this.groupBox5.TabStop = false; this.groupBox5.Text = "Export Data"; // - // btnGroups - // - this.btnGroups.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); - this.btnGroups.Location = new System.Drawing.Point(6, 22); - this.btnGroups.Name = "btnGroups"; - this.btnGroups.Size = new System.Drawing.Size(194, 56); - this.btnGroups.TabIndex = 0; - this.btnGroups.Text = "Calculate Groups"; - this.btnGroups.UseVisualStyleBackColor = true; - this.btnGroups.Click += new System.EventHandler(this.btnGroups_Click); - // - // btnPlayOff - // - this.btnPlayOff.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); - this.btnPlayOff.Location = new System.Drawing.Point(301, 22); - this.btnPlayOff.Name = "btnPlayOff"; - this.btnPlayOff.Size = new System.Drawing.Size(194, 56); - this.btnPlayOff.TabIndex = 1; - this.btnPlayOff.Text = "Calculate Play Off"; - this.btnPlayOff.UseVisualStyleBackColor = true; - // // ManageTournamentForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -166,10 +151,9 @@ namespace TournamentManager private System.Windows.Forms.GroupBox groupBox2; private src.ManageParticipantsControl manageParticipantsControl; private System.Windows.Forms.GroupBox groupBox3; - private src.GroupControl groupControl1; + private src.GroupControl groupControl; private System.Windows.Forms.GroupBox groupBox4; - private System.Windows.Forms.Button btnPlayOff; - private System.Windows.Forms.Button btnGroups; private System.Windows.Forms.GroupBox groupBox5; + private src.CalculateControl calculateControl; } } \ No newline at end of file diff --git a/src/ManageTournamentForm.cs b/src/ManageTournamentForm.cs index 41d8e5d532b1a871323d13412344b2b8765d7336..807adbbe7406d14c5c1d0ffdfec986ec5d5ef653 100644 --- a/src/ManageTournamentForm.cs +++ b/src/ManageTournamentForm.cs @@ -12,7 +12,8 @@ namespace TournamentManager private const string RemoveParticipantError = "Participant with this name is already signed in competition"; private const string EditParticipantError = "Participant with this name is already signed in competition"; private const string ErrorCaption = "Error"; - private readonly ObservableCollection<Participant> _participants = new (); + private readonly ObservableCollection<Participant> _participants = new(); + private readonly ObservableCollection<Group> _groups = new(); public ManageTournamentForm(string path) { @@ -20,6 +21,8 @@ namespace TournamentManager enterantCntrl.SubmitParticipantClick += OnSubmitParticipantClicked; _participants.CollectionChanged += HandleParticipantsChanged; manageParticipantsControl.ParticipantsModified += HandleParticipantRemoved; + calculateControl.CalculateGroups += HandleCalculateGroups; + groupControl.CbGroupItemSelected += HandleGroupItemSelected; foreach (var p in _participants) { manageParticipantsControl.CbAddParticipant($"{p.FirstName} {p.Surname}"); @@ -71,9 +74,39 @@ namespace TournamentManager } - private void btnGroups_Click(object sender, EventArgs e) + private void HandleCalculateGroups(object sender, CalculateGroupsEventArgs e) { + var numberOfGroups = (_participants.Count - 1) / e.GroupSize + 1; + var groupIndex = 0; + var orderedParticipants = _participants.OrderBy(x => x.Rating); + groupControl.AddGroups(numberOfGroups); + + for (int i = 0; i < numberOfGroups; i++) + { + _groups.Add(new Group()); + } + + foreach (var participant in orderedParticipants) + { + + if (groupIndex >= numberOfGroups) + { + groupIndex = 0; + } + _groups[groupIndex].Members.Add(participant); + + } + } + + private void HandleGroupItemSelected(object sender, CbItemSelectedEventArgs e) + { + if (!int.TryParse(e.ItemName.Split(" ")[1], out var result)) + { + return; + } + groupControl.AddToFirstOpponentList(_groups[result - 1].Members + .Select(x => $"{x.FirstName} {x.Surname}").ToArray()); } } } \ No newline at end of file diff --git a/src/Match.cs b/src/Match.cs new file mode 100644 index 0000000000000000000000000000000000000000..44f2140715754cf5dfbb6b18cd51d1c54c32e726 --- /dev/null +++ b/src/Match.cs @@ -0,0 +1,10 @@ +using System; + +namespace TournamentManager +{ + public class Match + { + public Tuple<Participant, Participant> Opponent { get; set; } + public (int first, int second) Score { get; set; } + } +} \ No newline at end of file