diff --git a/OWTrack/Form1.Designer.cs b/OWTrack/Form1.Designer.cs index e719c9d..56a4569 100644 --- a/OWTrack/Form1.Designer.cs +++ b/OWTrack/Form1.Designer.cs @@ -42,6 +42,7 @@ this.label4 = new System.Windows.Forms.Label(); this.reduceLossBut = new System.Windows.Forms.Button(); this.reduceWinBut = new System.Windows.Forms.Button(); + this.clearBut = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 @@ -168,15 +169,26 @@ this.reduceWinBut.Name = "reduceWinBut"; this.reduceWinBut.Size = new System.Drawing.Size(20, 24); this.reduceWinBut.TabIndex = 9; - this.reduceWinBut.Text = "+"; + this.reduceWinBut.Text = "-"; this.reduceWinBut.UseVisualStyleBackColor = true; this.reduceWinBut.Click += new System.EventHandler(this.reduceWinBut_Click); // + // clearBut + // + this.clearBut.Location = new System.Drawing.Point(209, 132); + this.clearBut.Name = "clearBut"; + this.clearBut.Size = new System.Drawing.Size(49, 25); + this.clearBut.TabIndex = 10; + this.clearBut.Text = "clear"; + this.clearBut.UseVisualStyleBackColor = true; + this.clearBut.Click += new System.EventHandler(this.clearBut_Click); + // // 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.Controls.Add(this.clearBut); this.Controls.Add(this.reduceWinBut); this.Controls.Add(this.reduceLossBut); this.Controls.Add(this.label4); @@ -214,6 +226,7 @@ private System.Windows.Forms.Label label4; private System.Windows.Forms.Button reduceLossBut; private System.Windows.Forms.Button reduceWinBut; + private System.Windows.Forms.Button clearBut; } } diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index cae2868..9f8fa9e 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -57,13 +57,29 @@ namespace OWTrack private bool saveExist() { - if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) { return true; } - else return false; + try + { + if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) { return true; } + else return false; + } + catch (Exception e) + { + MessageBox.Show(e.Message); + return false; + } } private Tracker savedTracker() { - return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + try + { + return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + return null; + } } private void timer1_Tick(object sender, EventArgs e) @@ -100,6 +116,11 @@ namespace OWTrack Wins.Text = tr.GetWins().ToString(); Losses.Text = tr.GetLosses().ToString(); } - + + private void clearBut_Click(object sender, EventArgs e) + { + tr.reset(); + update(); + } } } diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index 35bff94..73159b4 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -8,7 +8,7 @@ namespace OWTrack { static class Program { - public static string Version = "1.2.1"; + public static string Version = "1.2.2"; /// /// The main entry point for the application. /// diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index bd2977b..18f84b9 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -29,6 +29,7 @@ namespace OWTrack } } + public void reset() { wins = 0; losses = 0; } public void addWin() { wins++; } public void addLoss() { losses++; } public void reduceWin() { wins--; }