From cb9026c05e4c254788988604faae27a14124cebc Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Wed, 15 Aug 2018 07:21:28 +0300 Subject: [PATCH 1/5] Tracker Func and Var --- OWTrack/Tracker.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 18f84b9..9bb2eaa 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -7,7 +7,7 @@ namespace OWTrack { class Tracker { - public int wins, losses = 0; + public int wins, losses, startSR, newSR, = 0; public void Track() { @@ -36,5 +36,7 @@ namespace OWTrack public void rediceLoss() { losses--; } public int GetWins() { return wins; } public int GetLosses() { return losses; } + public void newSR(int SR) { newSR = SR; } + public int srDiff() {return newSR - startSR;} } } From fc422f6ee65b3b2210893fb7d7ec8da12801a4bd Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Wed, 15 Aug 2018 11:32:42 +0300 Subject: [PATCH 2/5] simple SR system --- OWTrack/Form1.Designer.cs | 66 ++++++++++++++++++++++++++++++--------- OWTrack/Form1.cs | 35 +++++++++++++++++++++ OWTrack/Tracker.cs | 28 +++++++---------- 3 files changed, 99 insertions(+), 30 deletions(-) diff --git a/OWTrack/Form1.Designer.cs b/OWTrack/Form1.Designer.cs index 56a4569..7058f7e 100644 --- a/OWTrack/Form1.Designer.cs +++ b/OWTrack/Form1.Designer.cs @@ -43,6 +43,9 @@ this.reduceLossBut = new System.Windows.Forms.Button(); this.reduceWinBut = 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(); // // label1 @@ -84,7 +87,7 @@ 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.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.Size = new System.Drawing.Size(40, 42); this.Wins.TabIndex = 3; @@ -95,7 +98,7 @@ 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.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.Size = new System.Drawing.Size(40, 42); this.Losses.TabIndex = 4; @@ -106,7 +109,7 @@ 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.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.Size = new System.Drawing.Size(40, 42); this.label3.TabIndex = 5; @@ -114,7 +117,7 @@ // // 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.Size = new System.Drawing.Size(52, 26); this.WinBut.TabIndex = 6; @@ -124,7 +127,7 @@ // // 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.Size = new System.Drawing.Size(52, 26); this.button2.TabIndex = 6; @@ -137,7 +140,7 @@ 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.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.Size = new System.Drawing.Size(42, 45); this.label2.TabIndex = 5; @@ -147,7 +150,7 @@ // 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.Location = new System.Drawing.Point(7, 153); + this.label4.Location = new System.Drawing.Point(12, 217); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(35, 11); this.label4.TabIndex = 7; @@ -155,7 +158,7 @@ // // 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.Size = new System.Drawing.Size(20, 24); this.reduceLossBut.TabIndex = 8; @@ -165,7 +168,7 @@ // // 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.Size = new System.Drawing.Size(20, 24); this.reduceWinBut.TabIndex = 9; @@ -175,7 +178,7 @@ // // 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.Size = new System.Drawing.Size(49, 25); this.clearBut.TabIndex = 10; @@ -183,11 +186,46 @@ this.clearBut.UseVisualStyleBackColor = true; 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 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.reduceWinBut); this.Controls.Add(this.reduceLossBut); @@ -198,9 +236,6 @@ this.Controls.Add(this.WinBut); this.Controls.Add(this.label2); this.Controls.Add(this.label3); - this.Controls.Add(this.Time); - this.Controls.Add(this.status); - this.Controls.Add(this.label1); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "Form1"; @@ -227,6 +262,9 @@ private System.Windows.Forms.Button reduceLossBut; private System.Windows.Forms.Button reduceWinBut; private System.Windows.Forms.Button clearBut; + private System.Windows.Forms.TextBox srTextBox; + private System.Windows.Forms.Button srBut; + private System.Windows.Forms.Label srLabel; } } diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index 694329f..4f0ba9d 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -11,6 +11,7 @@ namespace OWTrack Tracker tr = new Tracker(); private const string IS_RUNNING = "Running"; private const string NOT_RUNNING = " Not running"; + private bool SRonce = false; public Form1() { @@ -121,6 +122,40 @@ namespace OWTrack { tr.reset(); 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; + } + 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(); } } } diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 9bb2eaa..b293edc 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -7,12 +7,18 @@ namespace OWTrack { class Tracker { - public int wins, losses, startSR, newSR, = 0; + public int wins, losses, startSR, newSR = 0; - public void Track() - { - - } + public void Track() { } + 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; } + public void setNewSR(int SR) { newSR = SR; } + public int srDiff() { return newSR - startSR; } public bool owRunning() { @@ -27,16 +33,6 @@ namespace OWTrack Exception ex = new Exception("Error in tracking Overwatch.exe"); 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; } - public void newSR(int SR) { newSR = SR; } - public int srDiff() {return newSR - startSR;} + } } } From 9e80badd40c6977af840aea10fbc36ba640deed1 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Wed, 15 Aug 2018 11:33:58 +0300 Subject: [PATCH 3/5] Version bump --- OWTrack/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index 73159b4..9dfd33f 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -8,7 +8,7 @@ namespace OWTrack { static class Program { - public static string Version = "1.2.2"; + public static string Version = "1.2.3"; /// /// The main entry point for the application. /// From 7b9dc73085859abde0341a948535005c60b32896 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Wed, 15 Aug 2018 11:36:29 +0300 Subject: [PATCH 4/5] clear box after enter --- OWTrack/Form1.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index 4f0ba9d..7c08567 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Drawing; using System.Windows.Forms; using Newtonsoft.Json; @@ -156,6 +156,7 @@ namespace OWTrack else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); } else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); + srTextBox.Text = null; } } } From 29805eb926a0af94322bd1307756fd9d02fb9e10 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Wed, 15 Aug 2018 11:46:05 +0300 Subject: [PATCH 5/5] clear functionality --- OWTrack/Form1.cs | 15 ++++++++------- OWTrack/Tracker.cs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index 7c08567..f00e742 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -115,6 +115,13 @@ namespace OWTrack { Wins.Text = tr.GetWins().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)); } @@ -150,13 +157,7 @@ namespace OWTrack } else tr.newSR = sr; } - 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; + update(); } } } diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index b293edc..afdfe43 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -10,7 +10,7 @@ namespace OWTrack public int wins, losses, startSR, newSR = 0; public void Track() { } - public void reset() { wins = 0; losses = 0; } + public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; } public void addWin() { wins++; } public void addLoss() { losses++; } public void reduceWin() { wins--; }