From 5b4578fedeabb2a3279f1ea501b0b08d1374e571 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 11:13:48 +0300 Subject: [PATCH 01/15] Settings & Match classes - Added settings class - Added Match class --- OWTrack/MainForm.cs | 32 ++++++++++++++++++------- OWTrack/Tracker.cs | 54 +++++++++++++++++++++++++----------------- OWTrack/saveManeger.cs | 13 ++++++++-- 3 files changed, 66 insertions(+), 33 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 66a9f48..1845d4e 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -56,7 +56,7 @@ namespace OWTrack } else { - if (tr.TrackOW) + if (tr.settings.TrackOW) { status.Text = NOT_RUNNING; status.ForeColor = Color.Black; @@ -90,6 +90,7 @@ namespace OWTrack string line = st.ReadToEnd(); if (line.Contains("Overwatch.exe")) { + MessageBox.Show(line); tr = saveManeger.GetSavedTracker(); if (tr.startSR > 0) SRonce = true; } @@ -97,7 +98,7 @@ namespace OWTrack { if (!tr.LoacteOW()) { - tr.gamePath = askForGamePath(); + tr.settings.GamePath = askForGamePath(); } } st.Close(); @@ -110,10 +111,10 @@ namespace OWTrack } else if (!tr.LoacteOW()) { - tr.gamePath = askForGamePath(); + tr.settings.GamePath = askForGamePath(); } - ExeTrackCheckBx.Checked = tr.TrackOW; - SRCheckBx.Checked = tr.TrackSR; + ExeTrackCheckBx.Checked = tr.settings.TrackOW; + SRCheckBx.Checked = tr.settings.TrackSR; update(); } @@ -135,12 +136,12 @@ namespace OWTrack { srBut.Enabled = state; srTextBox.Enabled = state; - tr.TrackSR = state; + tr.settings.TrackSR = state; } private void OWTrackFunc(bool state) { - tr.TrackOW = state; + tr.settings.TrackOW = state; } private void update() @@ -155,7 +156,19 @@ namespace OWTrack else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); srTextBox.Text = null; saveManeger.SaveJSON(tr); - } + } + + private void AddMatch() + { + Match match = new Match + { + oldSR = tr.startSR, + newSR = tr.newSR, + ChangeInSR = tr.srDiff(), + dateTime = DateTime.Now + }; + tr.matches.Add(match); + } #region Events private void timer1_Tick(object sender, EventArgs e) => checkStatus(); @@ -222,6 +235,7 @@ namespace OWTrack } else tr.newSR = sr; } + AddMatch(); update(); } @@ -239,7 +253,7 @@ namespace OWTrack private void ChngOWPathBtn_Click(object sender, EventArgs e) { - tr.gamePath = askForGamePath(); + tr.settings.GamePath = askForGamePath(); update(); } diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 21124fe..c08ec0a 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -30,9 +30,9 @@ namespace OWTrack class Tracker { public int wins, losses, startSR, newSR, totalMatches = 0; - public string gamePath; + //public string gamePath; public void Track() { }//Deserailize here - public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; gamePath = null; } + public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; settings.Reset(); } public void addWin() => wins++; public void addLoss() => losses++; public void reduceWin() => wins--; @@ -41,26 +41,18 @@ namespace OWTrack public int GetLosses() { return losses; } public int GetTotalMatches() { return wins + losses; } public void setNewSR(int SR) { newSR = SR; } - public int srDiff() { return newSR - startSR; } - public bool TrackOW = true; - public bool TrackSR = true; - - struct ProgramFiles - { - public static readonly string C = "C:\\Program Files"; - public static readonly string D = "D:\\Program Files"; - public static readonly string E = "E:\\Program Files"; - public static readonly string F = "F:\\Program Files"; - } + public int srDiff() { return newSR - startSR; } + public Settings settings = new Settings(); + public List matches = new List(); public bool owRunning() { - if (TrackOW) + if (settings.TrackOW) { try { bool isRunning = Process.GetProcessesByName("Overwatch") - .FirstOrDefault(p => p.MainModule.FileName.StartsWith(gamePath)) != default(Process); + .FirstOrDefault(p => p.MainModule.FileName.StartsWith(settings.GamePath)) != default(Process); return isRunning; } catch (Exception) @@ -83,8 +75,8 @@ namespace OWTrack //{ //paths.AddRange(GetFiles(drive.ToString(),"Overwatch.exe")); //} - paths.AddRange(GetFiles(ProgramFiles.C, "Overwatch.exe")); - paths.AddRange(GetFiles(ProgramFiles.D, "Overwatch.exe")); + paths.AddRange(GetFiles(Paths.ProgramFiles.C, "Overwatch.exe")); + paths.AddRange(GetFiles(Paths.ProgramFiles.D, "Overwatch.exe")); if (paths.Count > 1) { @@ -96,7 +88,7 @@ namespace OWTrack else if (paths.Count == 1 && paths[0].Contains("Overwatch.exe")) { - gamePath = paths[0]; + settings.GamePath = paths[0]; return true; } else return false; @@ -133,10 +125,28 @@ namespace OWTrack } } - - struct Settings + class Settings { - bool TrackSR, TrackOW; - string OWpath; + public bool TrackSR, TrackOW = true; + public string GamePath = ""; + + /// + /// Reset All values to defult + /// + public void Reset() + { + TrackOW = true; + TrackSR = true; + GamePath = ""; + } + } + + public class Match + { + public Match() { } + public DateTime dateTime { get; set; } + public int oldSR; + public int newSR; + public int ChangeInSR; } } diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs index 4ce8ac3..91c67d3 100644 --- a/OWTrack/saveManeger.cs +++ b/OWTrack/saveManeger.cs @@ -24,7 +24,7 @@ using System.IO; namespace OWTrack { - public static class Paths + public static class Paths { private static string curDir = Directory.GetCurrentDirectory(); private static string SAVES = curDir + "/saves/data.json"; @@ -32,10 +32,19 @@ namespace OWTrack public static string GetJSON() { return JSON; } public static string GetSaves() { return SAVES; } public static string GetCurrentDir() { return curDir; } + + public static class ProgramFiles + { + public static readonly string C = "C:\\Program Files"; + public static readonly string D = "D:\\Program Files"; + public static readonly string E = "E:\\Program Files"; + public static readonly string F = "F:\\Program Files"; + } + } class saveManeger - { + { /// /// Deserialize saved tracker instance. /// From 7ba2694c9546fa14646590da46aebbb490b96947 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 12:52:50 +0300 Subject: [PATCH 02/15] cleanup --- OWTrack/MainForm.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 1845d4e..b12100d 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -31,7 +31,7 @@ namespace OWTrack private const string IS_RUNNING = "Running"; private const string NOT_RUNNING = " Not running"; private bool SRonce = false; - int dummy = 0; + private string Version = Program.Version.ToString(); public MainForm() { @@ -40,8 +40,8 @@ namespace OWTrack loadSave(); checkStatus(); update(); - label4.Text = Program.Version.ToString(); - Text = "OWTrack " + Program.Version.ToString(); + label4.Text = Version; + Text = "OWTrack " + Version; } private void checkStatus() @@ -71,6 +71,8 @@ namespace OWTrack } } + //Move to saveManeger.cs ? + //Refactor!! private void loadSave() { try @@ -90,7 +92,6 @@ namespace OWTrack string line = st.ReadToEnd(); if (line.Contains("Overwatch.exe")) { - MessageBox.Show(line); tr = saveManeger.GetSavedTracker(); if (tr.startSR > 0) SRonce = true; } @@ -139,10 +140,7 @@ namespace OWTrack tr.settings.TrackSR = state; } - private void OWTrackFunc(bool state) - { - tr.settings.TrackOW = state; - } + private void OWTrackFunc(bool state) => tr.settings.TrackOW = state; private void update() { From 0434fc1f407237c36583104717bf7576848b1418 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 12:56:15 +0300 Subject: [PATCH 03/15] clean --- OWTrack/Tracker.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index c08ec0a..d42db0a 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -30,8 +30,6 @@ namespace OWTrack class Tracker { public int wins, losses, startSR, newSR, totalMatches = 0; - //public string gamePath; - public void Track() { }//Deserailize here public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; settings.Reset(); } public void addWin() => wins++; public void addLoss() => losses++; From 4906361a569aea838deb317d5ed95f0d26b955d2 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 15:34:11 +0300 Subject: [PATCH 04/15] Session class (Not Implemented) --- OWTrack/Tracker.cs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index d42db0a..742f85a 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -139,7 +139,38 @@ namespace OWTrack } } - public class Match + class Session + { + public int TotalMatches; + public int SkillChange; + public int StartSR; + List Matches = new List(); + DateTime date; + + public Session(int StartSR) + { + this.StartSR = StartSR; + date = DateTime.Now.Date; + } + + public bool IsNewSession() + { + if (Matches.Count == 0) return true; + else return false; + } + + public Match GetLastMatch() + { + return Matches.Last(); + } + + public void AddMatch(Match match) + { + this.Matches.Add(match); + } + } + + class Match { public Match() { } public DateTime dateTime { get; set; } From 470e2399f139fd2ebfcf5d981416528617db1710 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 15:51:42 +0300 Subject: [PATCH 05/15] incomplete implementation of sessions class --- OWTrack/Tracker.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 742f85a..18bb02f 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -41,8 +41,14 @@ namespace OWTrack public void setNewSR(int SR) { newSR = SR; } public int srDiff() { return newSR - startSR; } public Settings settings = new Settings(); - public List matches = new List(); + //public List matches = new List(); + public List sessions = new List(); + public void StartNewSeission() + { + Session ses = new Session(startSR); + //Re do SR input!! + } public bool owRunning() { if (settings.TrackOW) @@ -147,6 +153,9 @@ namespace OWTrack List Matches = new List(); DateTime date; + /// + /// Start a new session with a starting Skill Rating + /// public Session(int StartSR) { this.StartSR = StartSR; From 7f10e36e25d9e6c805bd2aed81e62ff13606ebb8 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 17:29:17 +0300 Subject: [PATCH 06/15] Total matches functions --- OWTrack/Tracker.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 18bb02f..ce1e43a 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -37,7 +37,21 @@ namespace OWTrack public void rediceLoss() => losses--; public int GetWins() { return wins; } public int GetLosses() { return losses; } - public int GetTotalMatches() { return wins + losses; } + public int GetTotalMatches() + { + int number = 0; + foreach (var session in sessions) + { + number += session.TotalMatches; + } + return number; + } + + public int GetCurrentSessionMatches() + { + return sessions.Last().TotalMatches; + } + public void setNewSR(int SR) { newSR = SR; } public int srDiff() { return newSR - startSR; } public Settings settings = new Settings(); @@ -160,6 +174,7 @@ namespace OWTrack { this.StartSR = StartSR; date = DateTime.Now.Date; + TotalMatches = 0; } public bool IsNewSession() @@ -176,6 +191,7 @@ namespace OWTrack public void AddMatch(Match match) { this.Matches.Add(match); + this.TotalMatches = Matches.Count(); } } From 7b3348a723170f3df9f884a1d40a77ef207499b5 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 17:30:16 +0300 Subject: [PATCH 07/15] add match function Adds a match to the last session in the sessions list --- OWTrack/Tracker.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index ce1e43a..704af58 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -63,6 +63,11 @@ namespace OWTrack Session ses = new Session(startSR); //Re do SR input!! } + + public void AddMatch(Match match) + { + sessions.Last().AddMatch(match); + } public bool owRunning() { if (settings.TrackOW) From 20d6844f2d4fb97b478bb5de46f062d64d6b05d8 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 17:30:47 +0300 Subject: [PATCH 08/15] follow up --- OWTrack/MainForm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index b12100d..04a051d 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -165,7 +165,7 @@ namespace OWTrack ChangeInSR = tr.srDiff(), dateTime = DateTime.Now }; - tr.matches.Add(match); + tr.AddMatch(match); } #region Events From 5d7640c0f0be0790d288bcb057c6a2a30dfbb140 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 18:17:47 +0300 Subject: [PATCH 09/15] Improved LoadSave Function --- OWTrack/MainForm.cs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 04a051d..aee21b6 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -86,24 +86,16 @@ namespace OWTrack if (saveManeger.saveExist()) { try - { - using (StreamReader st = new StreamReader(Paths.GetSaves())) + { + tr = saveManeger.GetSavedTracker(); + if (tr.startSR > 0) SRonce = true; + if (tr.settings.GamePath == "" || tr.settings.GamePath == null) { - string line = st.ReadToEnd(); - if (line.Contains("Overwatch.exe")) + if (!tr.LoacteOW()) { - tr = saveManeger.GetSavedTracker(); - if (tr.startSR > 0) SRonce = true; - } - else - { - if (!tr.LoacteOW()) - { - tr.settings.GamePath = askForGamePath(); - } - } - st.Close(); - } + tr.settings.GamePath = askForGamePath(); + } + } } catch (Exception e) { From 2d5771beb854e74f4592a54815f091caccd36b89 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 18:44:48 +0300 Subject: [PATCH 10/15] Start new session and other fixes --- OWTrack/MainForm.cs | 4 ++-- OWTrack/Tracker.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index aee21b6..7c45b9f 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -38,6 +38,7 @@ namespace OWTrack InitializeComponent(); tr = new Tracker(); loadSave(); + tr.StartNewSeission(); checkStatus(); update(); label4.Text = Version; @@ -108,7 +109,6 @@ namespace OWTrack } ExeTrackCheckBx.Checked = tr.settings.TrackOW; SRCheckBx.Checked = tr.settings.TrackSR; - update(); } private string askForGamePath() @@ -157,7 +157,7 @@ namespace OWTrack ChangeInSR = tr.srDiff(), dateTime = DateTime.Now }; - tr.AddMatch(match); + tr.GetCurrentSession().AddMatch(match); } #region Events diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 704af58..1b0dbda 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -61,12 +61,13 @@ namespace OWTrack public void StartNewSeission() { Session ses = new Session(startSR); + sessions.Add(ses); //Re do SR input!! } - public void AddMatch(Match match) + public Session GetCurrentSession() { - sessions.Last().AddMatch(match); + return sessions.Last(); } public bool owRunning() { From 035d9979d16156cbe84af398d450b01413ebcd9d Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 21:57:56 +0300 Subject: [PATCH 11/15] Formatting (White space) --- OWTrack/Tracker.cs | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 1b0dbda..f1c6455 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -37,28 +37,28 @@ namespace OWTrack public void rediceLoss() => losses--; public int GetWins() { return wins; } public int GetLosses() { return losses; } - public int GetTotalMatches() - { + public int GetTotalMatches() + { int number = 0; foreach (var session in sessions) { number += session.TotalMatches; } - return number; + return number; } public int GetCurrentSessionMatches() { return sessions.Last().TotalMatches; } - + public void setNewSR(int SR) { newSR = SR; } - public int srDiff() { return newSR - startSR; } + public int srDiff() { return newSR - startSR; } public Settings settings = new Settings(); //public List matches = new List(); - public List sessions = new List(); + public List sessions = new List(); - public void StartNewSeission() + public void StartNewSeission() { Session ses = new Session(startSR); sessions.Add(ses); @@ -87,17 +87,17 @@ namespace OWTrack } else return false; } - - public bool LoacteOW() + + public bool LoacteOW() { - try + try { DriveInfo[] driveInfo = DriveInfo.GetDrives(); List paths = new List(); //Searches all drives (too long) //foreach (var drive in driveInfo) //{ - //paths.AddRange(GetFiles(drive.ToString(),"Overwatch.exe")); + //paths.AddRange(GetFiles(drive.ToString(),"Overwatch.exe")); //} paths.AddRange(GetFiles(Paths.ProgramFiles.C, "Overwatch.exe")); paths.AddRange(GetFiles(Paths.ProgramFiles.D, "Overwatch.exe")); @@ -115,14 +115,14 @@ namespace OWTrack settings.GamePath = paths[0]; return true; } - else return false; + else return false; } catch (Exception e) { - MessageBox.Show(e.Message); + MessageBox.Show(e.Message); return false; - } - } + } + } public static IEnumerable GetFiles(string root, string searchPattern) { @@ -151,13 +151,13 @@ namespace OWTrack class Settings { - public bool TrackSR, TrackOW = true; - public string GamePath = ""; + public bool TrackSR, TrackOW = true; + public string GamePath = ""; /// /// Reset All values to defult /// - public void Reset() + public void Reset() { TrackOW = true; TrackSR = true; @@ -170,9 +170,9 @@ namespace OWTrack public int TotalMatches; public int SkillChange; public int StartSR; - List Matches = new List(); + List Matches = new List(); DateTime date; - + /// /// Start a new session with a starting Skill Rating /// @@ -183,7 +183,7 @@ namespace OWTrack TotalMatches = 0; } - public bool IsNewSession() + public bool IsNewSession() { if (Matches.Count == 0) return true; else return false; @@ -201,7 +201,7 @@ namespace OWTrack } } - class Match + class Match { public Match() { } public DateTime dateTime { get; set; } From 52fce485f8fbad1df35e374d0bf8ce7c929da31f Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 22:00:11 +0300 Subject: [PATCH 12/15] Matches not saved in JSON Bug fixed --- OWTrack/Tracker.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index f1c6455..26e7394 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -170,8 +170,8 @@ namespace OWTrack public int TotalMatches; public int SkillChange; public int StartSR; - List Matches = new List(); - DateTime date; + public List Matches = new List(); + public DateTime date; /// /// Start a new session with a starting Skill Rating From a28e09de89390c43d22580f5fd3ea48d407e77ef Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 22:00:33 +0300 Subject: [PATCH 13/15] Formatting White Space Clean --- OWTrack/MainForm.cs | 28 ++++++++++++++-------------- OWTrack/saveManeger.cs | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 7c45b9f..30b449f 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -44,9 +44,9 @@ namespace OWTrack label4.Text = Version; Text = "OWTrack " + Version; } - + private void checkStatus() - { + { Time.Text = DateTime.Now.ToString("h:mm tt"); try { @@ -88,20 +88,20 @@ namespace OWTrack { try { - tr = saveManeger.GetSavedTracker(); - if (tr.startSR > 0) SRonce = true; + tr = saveManeger.GetSavedTracker(); + if (tr.startSR > 0) SRonce = true; if (tr.settings.GamePath == "" || tr.settings.GamePath == null) { if (!tr.LoacteOW()) { tr.settings.GamePath = askForGamePath(); - } - } - } + } + } + } catch (Exception e) { MessageBox.Show(e.Message); - } + } } else if (!tr.LoacteOW()) { @@ -115,15 +115,15 @@ namespace OWTrack { openFileDialog1.Title = "Select Overwatch.exe"; openFileDialog1.DefaultExt = "exe"; - openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; + openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { MessageBox.Show("Saved Overwatch.exe location.\nPress Clear to rest"); return openFileDialog1.FileName; } - else return null; - } + else return null; + } private void SRSystem(bool state) { @@ -191,13 +191,13 @@ namespace OWTrack tr.rediceLoss(); update(); } - } + } private void clearBut_Click(object sender, EventArgs e) { tr.reset(); update(); - } + } private void srBut_Click(object sender, EventArgs e) { @@ -250,7 +250,7 @@ namespace OWTrack private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { notifyIcon1.Icon = null; - notifyIcon1.Dispose(); + notifyIcon1.Dispose(); } #endregion } diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs index 91c67d3..ab9fe1d 100644 --- a/OWTrack/saveManeger.cs +++ b/OWTrack/saveManeger.cs @@ -44,7 +44,7 @@ namespace OWTrack } class saveManeger - { + { /// /// Deserialize saved tracker instance. /// @@ -86,7 +86,7 @@ namespace OWTrack public static bool SaveJSON(Tracker tracker) { try - { + { File.WriteAllText(Paths.GetSaves(), JsonConvert.SerializeObject(tracker, Formatting.Indented)); return true; } From 003668dea40a40be9075e36e3002d6f7a03e21b0 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 23:23:59 +0300 Subject: [PATCH 14/15] Fixed bug and organize --- OWTrack/MainForm.cs | 15 +++-- OWTrack/OWTrack.csproj | 9 --- OWTrack/Splash.Designer.cs | 98 ----------------------------- OWTrack/Splash.cs | 20 ------ OWTrack/Splash.resx | 123 ------------------------------------- OWTrack/Tracker.cs | 28 ++++++--- 6 files changed, 26 insertions(+), 267 deletions(-) delete mode 100644 OWTrack/Splash.Designer.cs delete mode 100644 OWTrack/Splash.cs delete mode 100644 OWTrack/Splash.resx diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 30b449f..28713ab 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -34,15 +34,14 @@ namespace OWTrack private string Version = Program.Version.ToString(); public MainForm() - { + { InitializeComponent(); - tr = new Tracker(); + tr = new Tracker(); loadSave(); - tr.StartNewSeission(); checkStatus(); update(); label4.Text = Version; - Text = "OWTrack " + Version; + Text = "OWTrack " + Version; } private void checkStatus() @@ -72,8 +71,7 @@ namespace OWTrack } } - //Move to saveManeger.cs ? - //Refactor!! + //Move to saveManeger.cs ? private void loadSave() { try @@ -109,6 +107,7 @@ namespace OWTrack } ExeTrackCheckBx.Checked = tr.settings.TrackOW; SRCheckBx.Checked = tr.settings.TrackSR; + tr.StartNewSeission(); } private string askForGamePath() @@ -152,10 +151,10 @@ namespace OWTrack { Match match = new Match { - oldSR = tr.startSR, + StartSR = tr.startSR, newSR = tr.newSR, ChangeInSR = tr.srDiff(), - dateTime = DateTime.Now + dateTime = DateTime.Now.Date }; tr.GetCurrentSession().AddMatch(match); } diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index 9a402fc..a6997e9 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -113,12 +113,6 @@ MainForm.cs - - Form - - - Splash.cs - @@ -134,9 +128,6 @@ True Resources.resx - - Splash.cs - diff --git a/OWTrack/Splash.Designer.cs b/OWTrack/Splash.Designer.cs deleted file mode 100644 index ca13c55..0000000 --- a/OWTrack/Splash.Designer.cs +++ /dev/null @@ -1,98 +0,0 @@ -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 deleted file mode 100644 index 84789ca..0000000 --- a/OWTrack/Splash.cs +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 6a68c91..0000000 --- a/OWTrack/Splash.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/Tracker.cs b/OWTrack/Tracker.cs index 26e7394..b7f56ea 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -30,13 +30,17 @@ namespace OWTrack class Tracker { public int wins, losses, startSR, newSR, totalMatches = 0; - public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; settings.Reset(); } + 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 Settings settings = new Settings(); + public List sessions = new List(); public int GetTotalMatches() { int number = 0; @@ -52,12 +56,17 @@ namespace OWTrack return sessions.Last().TotalMatches; } - public void setNewSR(int SR) { newSR = SR; } - public int srDiff() { return newSR - startSR; } - public Settings settings = new Settings(); - //public List matches = new List(); - public List sessions = new List(); - + public void reset() + { + wins = 0; + losses = 0; + startSR = 0; + newSR = 0; + settings.Reset(); + sessions.Clear(); + StartNewSeission(); + } + public void StartNewSeission() { Session ses = new Session(startSR); @@ -69,6 +78,7 @@ namespace OWTrack { return sessions.Last(); } + public bool owRunning() { if (settings.TrackOW) @@ -170,8 +180,8 @@ namespace OWTrack public int TotalMatches; public int SkillChange; public int StartSR; - public List Matches = new List(); public DateTime date; + public List Matches = new List(); /// /// Start a new session with a starting Skill Rating @@ -205,7 +215,7 @@ namespace OWTrack { public Match() { } public DateTime dateTime { get; set; } - public int oldSR; + public int StartSR; public int newSR; public int ChangeInSR; } From ec9def19c467547639c1e46e1ec896da06154987 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Dec 2018 23:23:59 +0300 Subject: [PATCH 15/15] Fixed bug and organize #39 #33 #11 --- OWTrack/MainForm.cs | 15 +++-- OWTrack/OWTrack.csproj | 9 --- OWTrack/Splash.Designer.cs | 98 ----------------------------- OWTrack/Splash.cs | 20 ------ OWTrack/Splash.resx | 123 ------------------------------------- OWTrack/Tracker.cs | 28 ++++++--- 6 files changed, 26 insertions(+), 267 deletions(-) delete mode 100644 OWTrack/Splash.Designer.cs delete mode 100644 OWTrack/Splash.cs delete mode 100644 OWTrack/Splash.resx diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 30b449f..28713ab 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -34,15 +34,14 @@ namespace OWTrack private string Version = Program.Version.ToString(); public MainForm() - { + { InitializeComponent(); - tr = new Tracker(); + tr = new Tracker(); loadSave(); - tr.StartNewSeission(); checkStatus(); update(); label4.Text = Version; - Text = "OWTrack " + Version; + Text = "OWTrack " + Version; } private void checkStatus() @@ -72,8 +71,7 @@ namespace OWTrack } } - //Move to saveManeger.cs ? - //Refactor!! + //Move to saveManeger.cs ? private void loadSave() { try @@ -109,6 +107,7 @@ namespace OWTrack } ExeTrackCheckBx.Checked = tr.settings.TrackOW; SRCheckBx.Checked = tr.settings.TrackSR; + tr.StartNewSeission(); } private string askForGamePath() @@ -152,10 +151,10 @@ namespace OWTrack { Match match = new Match { - oldSR = tr.startSR, + StartSR = tr.startSR, newSR = tr.newSR, ChangeInSR = tr.srDiff(), - dateTime = DateTime.Now + dateTime = DateTime.Now.Date }; tr.GetCurrentSession().AddMatch(match); } diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index 9a402fc..a6997e9 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -113,12 +113,6 @@ MainForm.cs - - Form - - - Splash.cs - @@ -134,9 +128,6 @@ True Resources.resx - - Splash.cs - diff --git a/OWTrack/Splash.Designer.cs b/OWTrack/Splash.Designer.cs deleted file mode 100644 index ca13c55..0000000 --- a/OWTrack/Splash.Designer.cs +++ /dev/null @@ -1,98 +0,0 @@ -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 deleted file mode 100644 index 84789ca..0000000 --- a/OWTrack/Splash.cs +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 6a68c91..0000000 --- a/OWTrack/Splash.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/Tracker.cs b/OWTrack/Tracker.cs index 26e7394..b7f56ea 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -30,13 +30,17 @@ namespace OWTrack class Tracker { public int wins, losses, startSR, newSR, totalMatches = 0; - public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; settings.Reset(); } + 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 Settings settings = new Settings(); + public List sessions = new List(); public int GetTotalMatches() { int number = 0; @@ -52,12 +56,17 @@ namespace OWTrack return sessions.Last().TotalMatches; } - public void setNewSR(int SR) { newSR = SR; } - public int srDiff() { return newSR - startSR; } - public Settings settings = new Settings(); - //public List matches = new List(); - public List sessions = new List(); - + public void reset() + { + wins = 0; + losses = 0; + startSR = 0; + newSR = 0; + settings.Reset(); + sessions.Clear(); + StartNewSeission(); + } + public void StartNewSeission() { Session ses = new Session(startSR); @@ -69,6 +78,7 @@ namespace OWTrack { return sessions.Last(); } + public bool owRunning() { if (settings.TrackOW) @@ -170,8 +180,8 @@ namespace OWTrack public int TotalMatches; public int SkillChange; public int StartSR; - public List Matches = new List(); public DateTime date; + public List Matches = new List(); /// /// Start a new session with a starting Skill Rating @@ -205,7 +215,7 @@ namespace OWTrack { public Match() { } public DateTime dateTime { get; set; } - public int oldSR; + public int StartSR; public int newSR; public int ChangeInSR; }