SR tracking system v1 #2

Merged
Hesham merged 5 commits from Dev/SRTracking into master 2018-08-15 11:35:56 +02:00
4 changed files with 103 additions and 30 deletions

View File

@ -43,6 +43,9 @@
this.reduceLossBut = new System.Windows.Forms.Button(); this.reduceLossBut = new System.Windows.Forms.Button();
this.reduceWinBut = new System.Windows.Forms.Button(); this.reduceWinBut = new System.Windows.Forms.Button();
this.clearBut = new System.Windows.Forms.Button(); this.clearBut = new System.Windows.Forms.Button();
this.srTextBox = new System.Windows.Forms.TextBox();
this.srBut = new System.Windows.Forms.Button();
this.srLabel = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
@ -84,7 +87,7 @@
this.Wins.AutoSize = true; this.Wins.AutoSize = true;
this.Wins.Font = new System.Drawing.Font("Miriam Mono CLM", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); this.Wins.Font = new System.Drawing.Font("Miriam Mono CLM", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177)));
this.Wins.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); this.Wins.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.Wins.Location = new System.Drawing.Point(68, 75); this.Wins.Location = new System.Drawing.Point(107, 78);
this.Wins.Name = "Wins"; this.Wins.Name = "Wins";
this.Wins.Size = new System.Drawing.Size(40, 42); this.Wins.Size = new System.Drawing.Size(40, 42);
this.Wins.TabIndex = 3; this.Wins.TabIndex = 3;
@ -95,7 +98,7 @@
this.Losses.AutoSize = true; this.Losses.AutoSize = true;
this.Losses.Font = new System.Drawing.Font("Miriam Mono CLM", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); this.Losses.Font = new System.Drawing.Font("Miriam Mono CLM", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177)));
this.Losses.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.Losses.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.Losses.Location = new System.Drawing.Point(137, 75); this.Losses.Location = new System.Drawing.Point(176, 78);
this.Losses.Name = "Losses"; this.Losses.Name = "Losses";
this.Losses.Size = new System.Drawing.Size(40, 42); this.Losses.Size = new System.Drawing.Size(40, 42);
this.Losses.TabIndex = 4; this.Losses.TabIndex = 4;
@ -106,7 +109,7 @@
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Miriam Mono CLM", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); this.label3.Font = new System.Drawing.Font("Miriam Mono CLM", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177)));
this.label3.ForeColor = System.Drawing.Color.Black; this.label3.ForeColor = System.Drawing.Color.Black;
this.label3.Location = new System.Drawing.Point(112, 72); this.label3.Location = new System.Drawing.Point(151, 75);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(40, 42); this.label3.Size = new System.Drawing.Size(40, 42);
this.label3.TabIndex = 5; this.label3.TabIndex = 5;
@ -114,7 +117,7 @@
// //
// WinBut // WinBut
// //
this.WinBut.Location = new System.Drawing.Point(67, 132); this.WinBut.Location = new System.Drawing.Point(106, 136);
this.WinBut.Name = "WinBut"; this.WinBut.Name = "WinBut";
this.WinBut.Size = new System.Drawing.Size(52, 26); this.WinBut.Size = new System.Drawing.Size(52, 26);
this.WinBut.TabIndex = 6; this.WinBut.TabIndex = 6;
@ -124,7 +127,7 @@
// //
// button2 // button2
// //
this.button2.Location = new System.Drawing.Point(125, 132); this.button2.Location = new System.Drawing.Point(164, 136);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(52, 26); this.button2.Size = new System.Drawing.Size(52, 26);
this.button2.TabIndex = 6; this.button2.TabIndex = 6;
@ -137,7 +140,7 @@
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Monospac821 BT", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Font = new System.Drawing.Font("Monospac821 BT", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.Black; this.label2.ForeColor = System.Drawing.Color.Black;
this.label2.Location = new System.Drawing.Point(103, 73); this.label2.Location = new System.Drawing.Point(142, 76);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(42, 45); this.label2.Size = new System.Drawing.Size(42, 45);
this.label2.TabIndex = 5; this.label2.TabIndex = 5;
@ -147,7 +150,7 @@
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Monospac821 BT", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Font = new System.Drawing.Font("Monospac821 BT", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(7, 153); this.label4.Location = new System.Drawing.Point(12, 217);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(35, 11); this.label4.Size = new System.Drawing.Size(35, 11);
this.label4.TabIndex = 7; this.label4.TabIndex = 7;
@ -155,7 +158,7 @@
// //
// reduceLossBut // reduceLossBut
// //
this.reduceLossBut.Location = new System.Drawing.Point(183, 133); this.reduceLossBut.Location = new System.Drawing.Point(222, 137);
this.reduceLossBut.Name = "reduceLossBut"; this.reduceLossBut.Name = "reduceLossBut";
this.reduceLossBut.Size = new System.Drawing.Size(20, 24); this.reduceLossBut.Size = new System.Drawing.Size(20, 24);
this.reduceLossBut.TabIndex = 8; this.reduceLossBut.TabIndex = 8;
@ -165,7 +168,7 @@
// //
// reduceWinBut // reduceWinBut
// //
this.reduceWinBut.Location = new System.Drawing.Point(43, 133); this.reduceWinBut.Location = new System.Drawing.Point(82, 137);
this.reduceWinBut.Name = "reduceWinBut"; this.reduceWinBut.Name = "reduceWinBut";
this.reduceWinBut.Size = new System.Drawing.Size(20, 24); this.reduceWinBut.Size = new System.Drawing.Size(20, 24);
this.reduceWinBut.TabIndex = 9; this.reduceWinBut.TabIndex = 9;
@ -175,7 +178,7 @@
// //
// clearBut // clearBut
// //
this.clearBut.Location = new System.Drawing.Point(209, 132); this.clearBut.Location = new System.Drawing.Point(271, 200);
this.clearBut.Name = "clearBut"; this.clearBut.Name = "clearBut";
this.clearBut.Size = new System.Drawing.Size(49, 25); this.clearBut.Size = new System.Drawing.Size(49, 25);
this.clearBut.TabIndex = 10; this.clearBut.TabIndex = 10;
@ -183,11 +186,46 @@
this.clearBut.UseVisualStyleBackColor = true; this.clearBut.UseVisualStyleBackColor = true;
this.clearBut.Click += new System.EventHandler(this.clearBut_Click); this.clearBut.Click += new System.EventHandler(this.clearBut_Click);
// //
// srTextBox
//
this.srTextBox.Location = new System.Drawing.Point(114, 168);
this.srTextBox.Name = "srTextBox";
this.srTextBox.Size = new System.Drawing.Size(100, 20);
this.srTextBox.TabIndex = 11;
this.srTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// srBut
//
this.srBut.Location = new System.Drawing.Point(129, 194);
this.srBut.Name = "srBut";
this.srBut.Size = new System.Drawing.Size(75, 23);
this.srBut.TabIndex = 12;
this.srBut.Text = "Enter";
this.srBut.UseVisualStyleBackColor = true;
this.srBut.Click += new System.EventHandler(this.srBut_Click);
//
// srLabel
//
this.srLabel.AutoSize = true;
this.srLabel.Font = new System.Drawing.Font("Noto Mono", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.srLabel.ForeColor = System.Drawing.Color.DarkOrchid;
this.srLabel.Location = new System.Drawing.Point(183, 26);
this.srLabel.Name = "srLabel";
this.srLabel.Size = new System.Drawing.Size(21, 23);
this.srLabel.TabIndex = 13;
this.srLabel.Text = "0";
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(263, 170); this.ClientSize = new System.Drawing.Size(332, 237);
this.Controls.Add(this.srLabel);
this.Controls.Add(this.srBut);
this.Controls.Add(this.srTextBox);
this.Controls.Add(this.Time);
this.Controls.Add(this.status);
this.Controls.Add(this.label1);
this.Controls.Add(this.clearBut); this.Controls.Add(this.clearBut);
this.Controls.Add(this.reduceWinBut); this.Controls.Add(this.reduceWinBut);
this.Controls.Add(this.reduceLossBut); this.Controls.Add(this.reduceLossBut);
@ -198,9 +236,6 @@
this.Controls.Add(this.WinBut); this.Controls.Add(this.WinBut);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.Time);
this.Controls.Add(this.status);
this.Controls.Add(this.label1);
this.DoubleBuffered = true; this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "Form1"; this.Name = "Form1";
@ -227,6 +262,9 @@
private System.Windows.Forms.Button reduceLossBut; private System.Windows.Forms.Button reduceLossBut;
private System.Windows.Forms.Button reduceWinBut; private System.Windows.Forms.Button reduceWinBut;
private System.Windows.Forms.Button clearBut; private System.Windows.Forms.Button clearBut;
private System.Windows.Forms.TextBox srTextBox;
private System.Windows.Forms.Button srBut;
private System.Windows.Forms.Label srLabel;
} }
} }

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -11,6 +11,7 @@ namespace OWTrack
Tracker tr = new Tracker(); Tracker tr = new Tracker();
private const string IS_RUNNING = "Running"; private const string IS_RUNNING = "Running";
private const string NOT_RUNNING = " Not running"; private const string NOT_RUNNING = " Not running";
private bool SRonce = false;
public Form1() public Form1()
{ {
@ -114,6 +115,13 @@ namespace OWTrack
{ {
Wins.Text = tr.GetWins().ToString(); Wins.Text = tr.GetWins().ToString();
Losses.Text = tr.GetLosses().ToString(); Losses.Text = tr.GetLosses().ToString();
if (tr.newSR == 0)
{
if (tr.srDiff() < 1) { srLabel.Text = tr.startSR.ToString() + " - 0"; }
else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff();
}
else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff();
srTextBox.Text = null;
File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tr)); File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tr));
} }
@ -122,5 +130,34 @@ namespace OWTrack
tr.reset(); tr.reset();
update(); update();
} }
private void srBut_Click(object sender, EventArgs e)
{
int sr = 0;
try
{
sr = Convert.ToInt32(srTextBox.Text);
}
catch (FormatException)
{
MessageBox.Show("Enter a Number!");
return;
}
catch (OverflowException ex)
{
MessageBox.Show(ex.Message);
return;
}
finally
{
if (!SRonce)
{
tr.startSR = sr;
SRonce = true;
}
else tr.newSR = sr;
}
update();
}
} }
} }

View File

@ -8,7 +8,7 @@ namespace OWTrack
{ {
static class Program static class Program
{ {
public static string Version = "1.2.2"; public static string Version = "1.2.3";
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>

View File

@ -7,12 +7,18 @@ namespace OWTrack
{ {
class Tracker class Tracker
{ {
public int wins, losses = 0; public int wins, losses, startSR, newSR = 0;
public void Track() public void Track() { }
{ public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; }
public void addWin() { wins++; }
} public void addLoss() { losses++; }
public void reduceWin() { wins--; }
public void rediceLoss() { losses--; }
public int GetWins() { return wins; }
public int GetLosses() { return losses; }
public void setNewSR(int SR) { newSR = SR; }
public int srDiff() { return newSR - startSR; }
public bool owRunning() public bool owRunning()
{ {
@ -28,13 +34,5 @@ namespace OWTrack
throw ex; throw ex;
} }
} }
public void reset() { wins = 0; losses = 0; }
public void addWin() { wins++; }
public void addLoss() { losses++; }
public void reduceWin() { wins--; }
public void rediceLoss() { losses--; }
public int GetWins() { return wins; }
public int GetLosses() { return losses; }
} }
} }