summaryrefslogtreecommitdiff
path: root/Aktywator
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-09-19 19:30:38 +0200
committeremkael <emkael@tlen.pl>2017-09-19 19:31:53 +0200
commit4bab40908ea6fc5ccde7801b690442d341a5d6cf (patch)
tree7c964836409889be06af8ad07dfd15777fa2b64d /Aktywator
parent2c40aed6e5dd3913d10c656c47932938632f26c4 (diff)
Settings form for fetching additional information in Teamy tournaments
Diffstat (limited to 'Aktywator')
-rw-r--r--Aktywator/Aktywator.csproj9
-rw-r--r--Aktywator/TeamNamesSettings.Designer.cs206
-rw-r--r--Aktywator/TeamNamesSettings.cs154
-rw-r--r--Aktywator/TeamNamesSettings.resx120
4 files changed, 489 insertions, 0 deletions
diff --git a/Aktywator/Aktywator.csproj b/Aktywator/Aktywator.csproj
index 661a578..2e4c4ac 100644
--- a/Aktywator/Aktywator.csproj
+++ b/Aktywator/Aktywator.csproj
@@ -110,6 +110,12 @@
<Compile Include="Settings.cs" />
<Compile Include="Sql.cs" />
<Compile Include="MySQLTournament.cs" />
+ <Compile Include="TeamNamesSettings.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="TeamNamesSettings.Designer.cs">
+ <DependentUpon>TeamNamesSettings.cs</DependentUpon>
+ </Compile>
<Compile Include="TeamyTournament.cs" />
<Compile Include="Tournament.cs" />
<EmbeddedResource Include="ChooseTournament.resx">
@@ -131,6 +137,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
+ <EmbeddedResource Include="TeamNamesSettings.resx">
+ <DependentUpon>TeamNamesSettings.cs</DependentUpon>
+ </EmbeddedResource>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
diff --git a/Aktywator/TeamNamesSettings.Designer.cs b/Aktywator/TeamNamesSettings.Designer.cs
new file mode 100644
index 0000000..07b1d97
--- /dev/null
+++ b/Aktywator/TeamNamesSettings.Designer.cs
@@ -0,0 +1,206 @@
+namespace Aktywator
+{
+ partial class TeamNamesSettings
+ {
+ /// <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 Windows Form 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.label1 = new System.Windows.Forms.Label();
+ this.lTournamentName = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.cbRounds = new System.Windows.Forms.ComboBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.cbSegments = new System.Windows.Forms.ComboBox();
+ this.label5 = new System.Windows.Forms.Label();
+ this.rbShowTeamNames = new System.Windows.Forms.RadioButton();
+ this.label6 = new System.Windows.Forms.Label();
+ this.cbSecondRow = new System.Windows.Forms.ComboBox();
+ this.rbShowPlayerNames = new System.Windows.Forms.RadioButton();
+ this.bClose = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(13, 13);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(42, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Turniej:";
+ //
+ // lTournamentName
+ //
+ this.lTournamentName.AutoSize = true;
+ this.lTournamentName.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
+ this.lTournamentName.Location = new System.Drawing.Point(61, 13);
+ this.lTournamentName.Name = "lTournamentName";
+ this.lTournamentName.Size = new System.Drawing.Size(109, 13);
+ this.lTournamentName.TabIndex = 1;
+ this.lTournamentName.Text = "lTournamentName";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(13, 42);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(42, 13);
+ this.label3.TabIndex = 2;
+ this.label3.Text = "Runda:";
+ //
+ // cbRounds
+ //
+ this.cbRounds.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbRounds.FormattingEnabled = true;
+ this.cbRounds.Location = new System.Drawing.Point(61, 39);
+ this.cbRounds.Name = "cbRounds";
+ this.cbRounds.Size = new System.Drawing.Size(41, 21);
+ this.cbRounds.TabIndex = 3;
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(108, 42);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(52, 13);
+ this.label4.TabIndex = 4;
+ this.label4.Text = "Segment:";
+ //
+ // cbSegments
+ //
+ this.cbSegments.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbSegments.FormattingEnabled = true;
+ this.cbSegments.Location = new System.Drawing.Point(166, 39);
+ this.cbSegments.Name = "cbSegments";
+ this.cbSegments.Size = new System.Drawing.Size(41, 21);
+ this.cbSegments.TabIndex = 5;
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(13, 69);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(52, 13);
+ this.label5.TabIndex = 6;
+ this.label5.Text = "Wyświetl:";
+ //
+ // rbShowTeamNames
+ //
+ this.rbShowTeamNames.AutoSize = true;
+ this.rbShowTeamNames.Checked = true;
+ this.rbShowTeamNames.Location = new System.Drawing.Point(16, 90);
+ this.rbShowTeamNames.Name = "rbShowTeamNames";
+ this.rbShowTeamNames.Size = new System.Drawing.Size(95, 17);
+ this.rbShowTeamNames.TabIndex = 7;
+ this.rbShowTeamNames.TabStop = true;
+ this.rbShowTeamNames.Text = "nazwy teamów";
+ this.rbShowTeamNames.UseVisualStyleBackColor = true;
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(32, 115);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(65, 13);
+ this.label6.TabIndex = 8;
+ this.label6.Text = "drugi wiersz:";
+ //
+ // cbSecondRow
+ //
+ this.cbSecondRow.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbSecondRow.FormattingEnabled = true;
+ this.cbSecondRow.Items.AddRange(new object[] {
+ "nic",
+ "wynik meczu w IMP",
+ "wynik drużyny w VP"});
+ this.cbSecondRow.Location = new System.Drawing.Point(103, 112);
+ this.cbSecondRow.Name = "cbSecondRow";
+ this.cbSecondRow.Size = new System.Drawing.Size(115, 21);
+ this.cbSecondRow.TabIndex = 9;
+ //
+ // rbShowPlayerNames
+ //
+ this.rbShowPlayerNames.AutoSize = true;
+ this.rbShowPlayerNames.Location = new System.Drawing.Point(16, 137);
+ this.rbShowPlayerNames.Name = "rbShowPlayerNames";
+ this.rbShowPlayerNames.Size = new System.Drawing.Size(114, 17);
+ this.rbShowPlayerNames.TabIndex = 10;
+ this.rbShowPlayerNames.Text = "nazwiska z lineupu";
+ this.rbShowPlayerNames.UseVisualStyleBackColor = true;
+ this.rbShowPlayerNames.CheckedChanged += new System.EventHandler(this.rbShowPlayerNames_CheckedChanged);
+ //
+ // bClose
+ //
+ this.bClose.Location = new System.Drawing.Point(16, 164);
+ this.bClose.Name = "bClose";
+ this.bClose.Size = new System.Drawing.Size(202, 23);
+ this.bClose.TabIndex = 11;
+ this.bClose.Text = "Zamknij";
+ this.bClose.UseVisualStyleBackColor = true;
+ this.bClose.Click += new System.EventHandler(this.bClose_Click);
+ //
+ // TeamNamesSettings
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(230, 199);
+ this.Controls.Add(this.bClose);
+ this.Controls.Add(this.rbShowPlayerNames);
+ this.Controls.Add(this.cbSecondRow);
+ this.Controls.Add(this.label6);
+ this.Controls.Add(this.rbShowTeamNames);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.cbSegments);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.cbRounds);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.lTournamentName);
+ this.Controls.Add(this.label1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "TeamNamesSettings";
+ this.Text = "JFR Teamy - nazwiska";
+ this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.TeamNamesSettings_FormClosed);
+ this.Shown += new System.EventHandler(this.TeamNamesSettings_Shown);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label lTournamentName;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.ComboBox cbRounds;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.ComboBox cbSegments;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.RadioButton rbShowTeamNames;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.ComboBox cbSecondRow;
+ private System.Windows.Forms.RadioButton rbShowPlayerNames;
+ private System.Windows.Forms.Button bClose;
+ }
+} \ No newline at end of file
diff --git a/Aktywator/TeamNamesSettings.cs b/Aktywator/TeamNamesSettings.cs
new file mode 100644
index 0000000..65d5601
--- /dev/null
+++ b/Aktywator/TeamNamesSettings.cs
@@ -0,0 +1,154 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Aktywator
+{
+ public partial class TeamNamesSettings : Form
+ {
+ public TeamNamesSettings()
+ {
+ InitializeComponent();
+ }
+
+ private MainForm form;
+ private TeamyTournament tournament;
+ public const int OpenClosedDiff = 1000;
+
+ internal void initTournament(TeamyTournament tournament, MainForm form)
+ {
+ this.form = form;
+ this.tournament = tournament;
+ lTournamentName.Text = this.tournament.getName();
+ int rounds = this.tournament.getRoundsNum();
+ int segments = this.tournament.getSegmentsNum();
+ cbRounds.Items.Clear();
+ for (int i = 1; i <= rounds; i++)
+ {
+ cbRounds.Items.Add(i.ToString());
+ }
+ cbSegments.Items.Clear();
+ for (int i = 1; i <= segments; i++)
+ {
+ cbSegments.Items.Add(i.ToString());
+ }
+ List<int> currentSegment = this.tournament.getCurrentSegment();
+ cbRounds.SelectedIndex = currentSegment[0] - 1;
+ cbSegments.SelectedIndex = currentSegment[1] - 1;
+ cbSecondRow.SelectedIndex = 0;
+ }
+
+ public string getLabel()
+ {
+ StringBuilder ret = new StringBuilder();
+ ret.Append(cbRounds.SelectedItem);
+ ret.Append('-');
+ ret.Append(cbSegments.SelectedItem);
+ ret.Append(", ");
+ if (rbShowTeamNames.Checked)
+ {
+ ret.Append("teamy");
+ if (cbSecondRow.SelectedIndex == 1)
+ {
+ ret.Append(" + IMP");
+ }
+ if (cbSecondRow.SelectedIndex == 2)
+ {
+ ret.Append(" + VP");
+ }
+ }
+ else
+ {
+ ret.Append("lineup");
+ }
+ return ret.ToString();
+ }
+
+ public bool arePlayerNamesDisplayed()
+ {
+ return rbShowPlayerNames.Checked;
+ }
+
+ public string getQuery()
+ {
+ StringBuilder ret = new StringBuilder();
+ ret.Append("SELECT teams.id, ");
+ if (rbShowTeamNames.Checked)
+ {
+ ret.Append("fullname, ");
+ switch (cbSecondRow.SelectedIndex) {
+ case 0:
+ ret.Append("'' FROM teams ORDER BY teams.id");
+ break;
+ case 1:
+ ret.Append("CONCAT(SUM(IF(segments.homet = teams.id, impH+corrH, impV+corrV)), ' IMP') FROM teams LEFT JOIN segments ON (teams.id = segments.homet OR teams.id = segments.visit) AND segments.rnd = ");
+ ret.Append(cbRounds.SelectedItem);
+ ret.Append(" AND segments.segment < ");
+ ret.Append(cbSegments.SelectedItem);
+ ret.Append(" GROUP BY teams.id ORDER BY teams.id");
+ break;
+ case 2:
+ ret.Append("CONCAT(SUM(IF(matches.homet = teams.id, vph+corrh, vpv+corrv)), ' VP') FROM teams LEFT JOIN matches ON (teams.id = matches.homet OR teams.id = matches.visit) AND matches.rnd <= ");
+ ret.Append(cbRounds.SelectedItem);
+ ret.Append(" GROUP BY teams.id ORDER BY teams.id");
+ break;
+ }
+ }
+ else
+ {
+ ret.Append("CONCAT(p1.gname, ' ', p1.sname), CONCAT(p2.gname, ' ', p2.sname) FROM teams JOIN segments ON segments.rnd = ");
+ ret.Append(cbRounds.SelectedItem);
+ ret.Append(" AND segments.segment = ");
+ ret.Append(cbSegments.SelectedItem);
+ ret.Append(" AND teams.id = segments.homet LEFT JOIN players p1 ON p1.id = segments.openN LEFT JOIN players p2 ON p2.id = segments.openS");
+
+ ret.Append(" UNION SELECT teams.id, CONCAT(p1.gname, ' ', p1.sname), CONCAT(p2.gname, ' ', p2.sname) FROM teams JOIN segments ON segments.rnd = ");
+ ret.Append(cbRounds.SelectedItem);
+ ret.Append(" AND segments.segment = ");
+ ret.Append(cbSegments.SelectedItem);
+ ret.Append(" AND teams.id = segments.visit LEFT JOIN players p1 ON p1.id = segments.openE LEFT JOIN players p2 ON p2.id = segments.openW");
+
+ ret.Append(" UNION SELECT teams.id + ");
+ ret.Append(TeamNamesSettings.OpenClosedDiff);
+ ret.Append(", CONCAT(p1.gname, ' ', p1.sname), CONCAT(p2.gname, ' ', p2.sname) FROM teams JOIN segments ON segments.rnd = ");
+ ret.Append(cbRounds.SelectedItem);
+ ret.Append(" AND segments.segment = ");
+ ret.Append(cbSegments.SelectedItem);
+ ret.Append(" AND teams.id = segments.homet LEFT JOIN players p1 ON p1.id = segments.closeE LEFT JOIN players p2 ON p2.id = segments.closeW");
+
+ ret.Append(" UNION SELECT teams.id + ");
+ ret.Append(TeamNamesSettings.OpenClosedDiff);
+ ret.Append(", CONCAT(p1.gname, ' ', p1.sname), CONCAT(p2.gname, ' ', p2.sname) FROM teams JOIN segments ON segments.rnd = ");
+ ret.Append(cbRounds.SelectedItem);
+ ret.Append(" AND segments.segment = ");
+ ret.Append(cbSegments.SelectedItem);
+ ret.Append(" AND teams.id = segments.visit LEFT JOIN players p1 ON p1.id = segments.closeN LEFT JOIN players p2 ON p2.id = segments.closeS");
+ ret.Append(" ORDER BY id");
+ }
+ Console.WriteLine(ret.ToString());
+ return ret.ToString();
+ }
+
+ private void rbShowPlayerNames_CheckedChanged(object sender, EventArgs e)
+ {
+ cbSecondRow.Enabled = !rbShowPlayerNames.Checked;
+ }
+
+ private void bClose_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void TeamNamesSettings_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ }
+
+ private void TeamNamesSettings_Shown(object sender, EventArgs e)
+ {
+ }
+ }
+}
diff --git a/Aktywator/TeamNamesSettings.resx b/Aktywator/TeamNamesSettings.resx
new file mode 100644
index 0000000..7080a7d
--- /dev/null
+++ b/Aktywator/TeamNamesSettings.resx
@@ -0,0 +1,120 @@
+<?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.
+ -->
+ <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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file