From 5e30eebda722bf8d1bd398846216d53022347f28 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 8 Sep 2018 14:32:12 +0300 Subject: [PATCH 01/13] MainForm Rename --- OWTrack/{Form1.Designer.cs => MainForm.Designer.cs} | 4 ++-- OWTrack/{Form1.cs => MainForm.cs} | 4 ++-- OWTrack/{Form1.resx => MainForm.resx} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename OWTrack/{Form1.Designer.cs => MainForm.Designer.cs} (99%) rename OWTrack/{Form1.cs => MainForm.cs} (98%) rename OWTrack/{Form1.resx => MainForm.resx} (100%) diff --git a/OWTrack/Form1.Designer.cs b/OWTrack/MainForm.Designer.cs similarity index 99% rename from OWTrack/Form1.Designer.cs rename to OWTrack/MainForm.Designer.cs index f37c593..ee3c09e 100644 --- a/OWTrack/Form1.Designer.cs +++ b/OWTrack/MainForm.Designer.cs @@ -1,6 +1,6 @@ namespace OWTrack { - partial class Form1 + partial class MainForm { /// /// Required designer variable. @@ -29,7 +29,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.label1 = new System.Windows.Forms.Label(); this.status = new System.Windows.Forms.Label(); this.timer1 = new System.Windows.Forms.Timer(this.components); diff --git a/OWTrack/Form1.cs b/OWTrack/MainForm.cs similarity index 98% rename from OWTrack/Form1.cs rename to OWTrack/MainForm.cs index ccf8ea5..69e8101 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/MainForm.cs @@ -7,14 +7,14 @@ using System.IO; namespace OWTrack { - public partial class Form1 : Form + public partial class MainForm : Form { Tracker tr = new Tracker(); private const string IS_RUNNING = "Running"; private const string NOT_RUNNING = " Not running"; private bool SRonce = false; - public Form1() + public MainForm() { InitializeComponent(); loadSave(); diff --git a/OWTrack/Form1.resx b/OWTrack/MainForm.resx similarity index 100% rename from OWTrack/Form1.resx rename to OWTrack/MainForm.resx -- 2.39.5 From 0632089d19b62f948d582f01f5359e0eb3702ad9 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 8 Sep 2018 14:33:07 +0300 Subject: [PATCH 02/13] rename fix --- OWTrack/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index 33cb5a5..fb7f39e 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -19,7 +19,7 @@ namespace OWTrack { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + Application.Run(new MainForm()); } public static string Version = "1.3.0"; -- 2.39.5 From 9ffdd871b6e7698517a869dbf49491dd9af6b50d Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 8 Sep 2018 14:53:05 +0300 Subject: [PATCH 03/13] savesPath --- OWTrack/Form1.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index ccf8ea5..391e4ed 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -12,6 +12,7 @@ namespace OWTrack Tracker tr = new Tracker(); private const string IS_RUNNING = "Running"; private const string NOT_RUNNING = " Not running"; + private string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json"; private bool SRonce = false; public Form1() @@ -21,8 +22,7 @@ namespace OWTrack checkStatus(); update(); label4.Text = Program.Version.ToString(); - Text = "OWTrack " + Program.Version.ToString(); - + Text = "OWTrack " + Program.Version.ToString(); } private void checkStatus() @@ -46,6 +46,7 @@ namespace OWTrack private void loadSave() { + Directory.CreateDirectory("saves"); if (saveExist()) { tr.wins = savedTracker().wins; @@ -61,9 +62,9 @@ namespace OWTrack { try { - if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) + if (File.Exists(savesPath)) { - using (StreamReader st = new StreamReader(Directory.GetCurrentDirectory() + "/data.json")) + using (StreamReader st = new StreamReader(savesPath)) { string line = st.ReadLine(); if (line.Contains("Overwatch.exe")) @@ -124,7 +125,7 @@ namespace OWTrack { try { - return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + return JsonConvert.DeserializeObject(File.ReadAllText(savesPath)); } catch (Exception e) { @@ -173,7 +174,7 @@ namespace OWTrack } else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); srTextBox.Text = null; - File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tr)); + File.WriteAllText(Directory.GetCurrentDirectory() + "/saves/data.json", JsonConvert.SerializeObject(tr)); } private void clearBut_Click(object sender, EventArgs e) -- 2.39.5 From ee39a3c7a538ec6b27916f9f985445581b57da6e Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 8 Sep 2018 15:12:27 +0300 Subject: [PATCH 04/13] fix files csproj --- OWTrack/OWTrack.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index d3e8d57..929e38e 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -106,17 +106,17 @@ - + Form - - Form1.cs + + MainForm.cs - - Form1.cs + + MainForm.cs ResXFileCodeGenerator -- 2.39.5 From ce876b7430c4cac9e9bb02bff3decf7cfc2063c8 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 8 Sep 2018 15:20:29 +0300 Subject: [PATCH 05/13] version --- OWTrack/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index fb7f39e..9dca964 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -22,7 +22,7 @@ namespace OWTrack Application.Run(new MainForm()); } - public static string Version = "1.3.0"; + public static string Version = "1.4.0a1"; //public static string Version = Application.ProductVersion; //public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; -- 2.39.5 From a1ee527747875ae45b3dbaa24e1b855b162840b8 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 14 Sep 2018 14:53:54 +0300 Subject: [PATCH 06/13] cleanup --- OWTrack/OWTrack.csproj | 2 +- OWTrack/Program.cs | 6 +----- OWTrack/Properties/AssemblyInfo.cs | 6 +++--- OWTrack/Tracker.cs | 8 ++------ OWTrack/app.manifest | 2 +- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index 929e38e..ac9b518 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -13,7 +13,7 @@ true false publish\ - true + false Disk false Foreground diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index 9dca964..f37ed81 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Deployment.Application; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; using System.Deployment.Application; @@ -22,7 +18,7 @@ namespace OWTrack Application.Run(new MainForm()); } - public static string Version = "1.4.0a1"; + public static string Version { get; } = "1.4.0a1"; //public static string Version = Application.ProductVersion; //public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; diff --git a/OWTrack/Properties/AssemblyInfo.cs b/OWTrack/Properties/AssemblyInfo.cs index 1f9aa77..a7ead64 100644 --- a/OWTrack/Properties/AssemblyInfo.cs +++ b/OWTrack/Properties/AssemblyInfo.cs @@ -7,7 +7,7 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OWTrack")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("Shitty SR Tracker")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Hesham Systems LLC")] [assembly: AssemblyProduct("OWTrack")] @@ -35,8 +35,8 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyVersion("2.0.*")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.3.0.3")] +[assembly: AssemblyFileVersion("1.3.0.3")] [assembly: NeutralResourcesLanguage("")] diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 7d3479a..ab55b4a 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -31,17 +31,13 @@ namespace OWTrack .FirstOrDefault(p => p.MainModule.FileName.StartsWith(gamePath)) != default(Process); return isRunning; } - catch (Exception e) + catch (Exception) { Exception ex = new Exception("Error in tracking Overwatch.exe"); throw ex; } } - - /// - /// Not Working! - /// - /// + public bool LoacteOW() { try diff --git a/OWTrack/app.manifest b/OWTrack/app.manifest index 80d5e99..1bb0779 100644 --- a/OWTrack/app.manifest +++ b/OWTrack/app.manifest @@ -20,7 +20,7 @@ - + -- 2.39.5 From 7aeecd511db7d7a55ba02b757d618474e152abaa Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 14 Sep 2018 14:56:18 +0300 Subject: [PATCH 07/13] assets folder --- OWTrack/OWTrack.csproj | 4 ++-- ...te-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico | Bin 2 files changed, 2 insertions(+), 2 deletions(-) rename OWTrack/{ => assets}/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico (100%) diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index ac9b518..6fb90ba 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -87,7 +87,7 @@ LocalIntranet - Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico + assets\Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico @@ -156,7 +156,7 @@ - + \ No newline at end of file diff --git a/OWTrack/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico b/OWTrack/assets/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico similarity index 100% rename from OWTrack/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico rename to OWTrack/assets/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico -- 2.39.5 From 83fad4d6caf9edda9f5caf172eb92046d12a2dd0 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 14 Sep 2018 15:38:42 +0300 Subject: [PATCH 08/13] saveManeger class & splash Form --- OWTrack/Form1.cs | 5 +- OWTrack/Splash.Designer.cs | 98 +++++++++++++++++++++++++++++ OWTrack/Splash.cs | 20 ++++++ OWTrack/Splash.resx | 123 +++++++++++++++++++++++++++++++++++++ OWTrack/saveManeger.cs | 92 +++++++++++++++++++++++++++ 5 files changed, 336 insertions(+), 2 deletions(-) create mode 100644 OWTrack/Splash.Designer.cs create mode 100644 OWTrack/Splash.cs create mode 100644 OWTrack/Splash.resx create mode 100644 OWTrack/saveManeger.cs diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index ccf8ea5..bb128c1 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -16,6 +16,7 @@ namespace OWTrack public Form1() { + InitializeComponent(); loadSave(); checkStatus(); @@ -120,7 +121,7 @@ namespace OWTrack update(); } - private Tracker savedTracker() + private Tracker savedTracker()// { try { @@ -173,7 +174,7 @@ namespace OWTrack } 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));// } private void clearBut_Click(object sender, EventArgs e) diff --git a/OWTrack/Splash.Designer.cs b/OWTrack/Splash.Designer.cs new file mode 100644 index 0000000..ca13c55 --- /dev/null +++ b/OWTrack/Splash.Designer.cs @@ -0,0 +1,98 @@ +namespace OWTrack +{ + partial class Splash + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.splashLabel = new System.Windows.Forms.Label(); + this.versionLabel = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(95, 57); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(196, 12); + this.progressBar1.TabIndex = 0; + // + // splashLabel + // + this.splashLabel.AutoSize = true; + this.splashLabel.Location = new System.Drawing.Point(171, 31); + this.splashLabel.Name = "splashLabel"; + this.splashLabel.Size = new System.Drawing.Size(0, 13); + this.splashLabel.TabIndex = 1; + this.splashLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // versionLabel + // + this.versionLabel.AutoSize = true; + this.versionLabel.Location = new System.Drawing.Point(13, 91); + this.versionLabel.Name = "versionLabel"; + this.versionLabel.Size = new System.Drawing.Size(0, 13); + this.versionLabel.TabIndex = 2; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.ForeColor = System.Drawing.Color.Gray; + this.label1.Location = new System.Drawing.Point(13, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(89, 24); + this.label1.TabIndex = 3; + this.label1.Text = "OWtrack"; + // + // Splash + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(402, 116); + this.Controls.Add(this.label1); + this.Controls.Add(this.versionLabel); + this.Controls.Add(this.splashLabel); + this.Controls.Add(this.progressBar1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "Splash"; + this.Text = "Splash"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.PageSetupDialog pageSetupDialog1; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Label splashLabel; + private System.Windows.Forms.Label versionLabel; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/OWTrack/Splash.cs b/OWTrack/Splash.cs new file mode 100644 index 0000000..84789ca --- /dev/null +++ b/OWTrack/Splash.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OWTrack +{ + public partial class Splash : Form + { + public Splash() + { + InitializeComponent(); + } + } +} diff --git a/OWTrack/Splash.resx b/OWTrack/Splash.resx new file mode 100644 index 0000000..6a68c91 --- /dev/null +++ b/OWTrack/Splash.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs new file mode 100644 index 0000000..7349658 --- /dev/null +++ b/OWTrack/saveManeger.cs @@ -0,0 +1,92 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OWTrack +{ + class saveManeger + { + public static Tracker GetSavedTracker() + { + try + { + return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + } + catch (Exception e) + { + throw e; + } + } + + //TODO: use para + public static Tracker GetSavedTracker(string customPath) + { + try + { + return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + } + catch (Exception e) + { + throw e; + } + } + + public static bool SaveJSON(Tracker tracker) + { + try + { + File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tracker)); + return true; + } + catch (Exception) + { + return false; + } + } + + //private bool saveExist() + //{ + // try + // { + // if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) + // { + // using (StreamReader st = new StreamReader(Directory.GetCurrentDirectory() + "/data.json")) + // { + // string line = st.ReadLine(); + // if (line.Contains("Overwatch.exe")) + // { + // st.Close(); + // return true; + // } + // else + // { + // if (!tr.LoacteOW()) + // { + // st.Close(); + // getGamePath(); + // } + // return true; + // } + // } + // } + // else + // { + // if (!tr.LoacteOW()) + // { + // getGamePath(); + // } + // return false; + // } + // } + // catch (Exception e) + // { + // MessageBox.Show(e.Message); + // return false; + // } + //} + } +} -- 2.39.5 From 23ff1420e6a575e74f554b173f216d0bb02a2a28 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 14 Sep 2018 15:39:53 +0300 Subject: [PATCH 09/13] csproj --- OWTrack/OWTrack.csproj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index d3e8d57..394401f 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -112,6 +112,13 @@ Form1.cs + + + Form + + + Splash.cs + @@ -127,6 +134,9 @@ True Resources.resx + + Splash.cs + -- 2.39.5 From 424983da5fcb568e8e637243e88cbe6715063487 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Thu, 20 Sep 2018 09:53:49 +0300 Subject: [PATCH 10/13] refactor --- OWTrack/MainForm.Designer.cs | 4 ++-- OWTrack/MainForm.cs | 31 +++++++++++++++---------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/OWTrack/MainForm.Designer.cs b/OWTrack/MainForm.Designer.cs index ee3c09e..1e31cf7 100644 --- a/OWTrack/MainForm.Designer.cs +++ b/OWTrack/MainForm.Designer.cs @@ -126,7 +126,7 @@ this.WinBut.TabIndex = 6; this.WinBut.Text = "win"; this.WinBut.UseVisualStyleBackColor = true; - this.WinBut.Click += new System.EventHandler(this.button1_Click); + this.WinBut.Click += new System.EventHandler(this.WinBtn_Click); // // button2 // @@ -136,7 +136,7 @@ this.button2.TabIndex = 6; this.button2.Text = "loss"; this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); + this.button2.Click += new System.EventHandler(this.LossBtn_Click); // // label2 // diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index f68d026..3e19ae7 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -87,7 +87,7 @@ namespace OWTrack { if (!tr.LoacteOW()) { - getGamePath(); + tr.gamePath = getGamePath(); } return false; } @@ -99,26 +99,28 @@ namespace OWTrack } } - private void getGamePath() + private string getGamePath() { openFileDialog1.Title = "Select Overwatch.exe"; openFileDialog1.DefaultExt = "exe"; openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; - openFileDialog1.CheckFileExists = true; - openFileDialog1.CheckPathExists = true; + //openFileDialog1.CheckFileExists = true; + //openFileDialog1.CheckPathExists = true; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { - tr.gamePath = openFileDialog1.FileName; + //tr.gamePath = openFileDialog1.FileName; + return openFileDialog1.FileName; } - else if (result == DialogResult.Cancel) + else { - Close(); + return null; + //Close(); } - FindForm(); - update(); + //Show(); + //update(); } private Tracker savedTracker() @@ -133,19 +135,16 @@ namespace OWTrack return null; } } - - private void timer1_Tick(object sender, EventArgs e) - { - checkStatus(); - } - private void button1_Click(object sender, EventArgs e) + private void timer1_Tick(object sender, EventArgs e) => checkStatus(); + + private void WinBtn_Click(object sender, EventArgs e) { tr.addWin(); update(); } - private void button2_Click(object sender, EventArgs e) + private void LossBtn_Click(object sender, EventArgs e) { tr.addLoss(); update(); -- 2.39.5 From 5ce37c59c09df6a1469e4444a3c9e5c53d40ca8a Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Thu, 20 Sep 2018 09:56:16 +0300 Subject: [PATCH 11/13] arrange --- OWTrack/MainForm.cs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 3e19ae7..ce47097 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -77,7 +77,7 @@ namespace OWTrack if (!tr.LoacteOW()) { st.Close(); - getGamePath(); + tr.gamePath = getGamePath(); } return true; } @@ -136,6 +136,21 @@ namespace OWTrack } } + private void update() + { + 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() + "/saves/data.json", JsonConvert.SerializeObject(tr)); + } + + #region Events private void timer1_Tick(object sender, EventArgs e) => checkStatus(); private void WinBtn_Click(object sender, EventArgs e) @@ -160,21 +175,7 @@ namespace OWTrack { tr.rediceLoss(); update(); - } - - private void update() - { - 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() + "/saves/data.json", JsonConvert.SerializeObject(tr)); - } + } private void clearBut_Click(object sender, EventArgs e) { @@ -209,6 +210,7 @@ namespace OWTrack else tr.newSR = sr; } update(); - } + } + #endregion } } -- 2.39.5 From d2cc397c69c51ba8a16084e906e28489d1be3389 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Thu, 20 Sep 2018 11:23:47 +0300 Subject: [PATCH 12/13] refactor, saveManeger --- OWTrack/MainForm.cs | 73 +++++++++++++++--------------------------- OWTrack/Program.cs | 2 +- OWTrack/Tracker.cs | 2 +- OWTrack/saveManeger.cs | 62 ++++++++++++----------------------- 4 files changed, 49 insertions(+), 90 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index ce47097..2da19ed 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -17,7 +17,7 @@ namespace OWTrack public MainForm() { - InitializeComponent(); + InitializeComponent(); loadSave(); checkStatus(); update(); @@ -47,80 +47,59 @@ namespace OWTrack private void loadSave() { Directory.CreateDirectory("saves"); - if (saveExist()) + if (saveManeger.saveExist()) { - tr.wins = savedTracker().wins; - tr.losses = savedTracker().losses; - tr.newSR = savedTracker().newSR; - tr.startSR = savedTracker().startSR; - tr.gamePath = savedTracker().gamePath; - update(); - } - } - - private bool saveExist() - { - try - { - if (File.Exists(savesPath)) - { + try + { using (StreamReader st = new StreamReader(savesPath)) { string line = st.ReadLine(); if (line.Contains("Overwatch.exe")) { - st.Close(); - return true; + tr = saveManeger.GetSavedTracker(); + st.Close(); } else { if (!tr.LoacteOW()) - { - st.Close(); + { tr.gamePath = getGamePath(); } - return true; + st.Close(); } - } - } - else - { - if (!tr.LoacteOW()) - { - tr.gamePath = getGamePath(); - } - return false; - } - } - catch (Exception e) - { - MessageBox.Show(e.Message); - return false; - } - } + } + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + update(); + } + else if (!tr.LoacteOW()) + { + tr.gamePath = getGamePath(); + } + } + private string getGamePath() { openFileDialog1.Title = "Select Overwatch.exe"; openFileDialog1.DefaultExt = "exe"; - openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; - //openFileDialog1.CheckFileExists = true; - //openFileDialog1.CheckPathExists = true; - + openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { //tr.gamePath = openFileDialog1.FileName; + MessageBox.Show("Saved Overwatch.exe location.\nPress Clear to rest\n" + openFileDialog1.FileName ); return openFileDialog1.FileName; } else { + update(); return null; - //Close(); - } - //Show(); - //update(); + } } private Tracker savedTracker() diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index f37ed81..963e7e6 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -18,7 +18,7 @@ namespace OWTrack Application.Run(new MainForm()); } - public static string Version { get; } = "1.4.0a1"; + public static string Version { get; } = "1.4.0a2"; //public static string Version = Application.ProductVersion; //public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index ab55b4a..a278053 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -13,7 +13,7 @@ namespace OWTrack public string gamePath; public void Track() { } - public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; } + public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; gamePath = null; } public void addWin() { wins++; } public void addLoss() { losses++; } public void reduceWin() { wins--; } diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs index 7349658..b903c23 100644 --- a/OWTrack/saveManeger.cs +++ b/OWTrack/saveManeger.cs @@ -10,11 +10,13 @@ namespace OWTrack { class saveManeger { + private static string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json"; + public static Tracker GetSavedTracker() { try { - return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + return JsonConvert.DeserializeObject(File.ReadAllText(savesPath)); } catch (Exception e) { @@ -48,45 +50,23 @@ namespace OWTrack } } - //private bool saveExist() - //{ - // try - // { - // if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) - // { - // using (StreamReader st = new StreamReader(Directory.GetCurrentDirectory() + "/data.json")) - // { - // string line = st.ReadLine(); - // if (line.Contains("Overwatch.exe")) - // { - // st.Close(); - // return true; - // } - // else - // { - // if (!tr.LoacteOW()) - // { - // st.Close(); - // getGamePath(); - // } - // return true; - // } - // } - // } - // else - // { - // if (!tr.LoacteOW()) - // { - // getGamePath(); - // } - // return false; - // } - // } - // catch (Exception e) - // { - // MessageBox.Show(e.Message); - // return false; - // } - //} + public static bool saveExist() + { + try + { + if (File.Exists(savesPath)) + { + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + throw e; + } + } } } -- 2.39.5 From fae9d2f50cd5bab7d4bacbbc61149b76bd657832 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Thu, 20 Sep 2018 11:33:26 +0300 Subject: [PATCH 13/13] nigative win/loss --- OWTrack/MainForm.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 2da19ed..cbb4641 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -146,14 +146,20 @@ namespace OWTrack private void reduceWinBut_Click(object sender, EventArgs e) { - tr.reduceWin(); - update(); + if (tr.wins > 0) + { + tr.reduceWin(); + update(); + } } private void reduceLossBut_Click(object sender, EventArgs e) { - tr.rediceLoss(); - update(); + if (tr.losses > 0) + { + tr.rediceLoss(); + update(); + } } private void clearBut_Click(object sender, EventArgs e) -- 2.39.5