From 8248450127ab128fb4c257aaab20c4cdd5d953f9 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 2 Sep 2018 14:24:55 +0300 Subject: [PATCH 1/9] Search Function (not tested) --- OWTrack/Tracker.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 5f3ca97..6d5e16f 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -9,6 +9,8 @@ namespace OWTrack { public int wins, losses, startSR, newSR = 0; public string gamePath; + + private string[] commonDir = ["C:\Program Files","D:\Program Files"]; public void Track() { } public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; } @@ -35,6 +37,33 @@ namespace OWTrack Exception ex = new Exception("Error in tracking Overwatch.exe"); throw ex; } + } + + public void LoacteOW() + { + try + { + string[] files = []; + for (int i = 0; i < commonDir.count; i++) + { + files.append(Directory.GetFiles(commonDir[i], "Overwatch*",SearchOption.AllDirectories)); + } + if (files.contians("Overwatch.exe")) + { + foreach (string "*Overwatch.exe" in files) + { + + } + } + + } + catch (Exception e) + { + MesssageBox.show(e.message); + } + + + } } } From 9e33f09b8e7279d8c30693ea57faebb566298502 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 3 Sep 2018 22:11:05 +0300 Subject: [PATCH 2/9] LocateOW 2 + search algo --- OWTrack/Form1.cs | 22 +++++++++++++- OWTrack/Tracker.cs | 74 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 76 insertions(+), 20 deletions(-) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index a75d396..7a628cb 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -50,6 +50,7 @@ namespace OWTrack tr.losses = savedTracker().losses; tr.newSR = savedTracker().newSR; tr.startSR = savedTracker().startSR; + tr.gamePath = savedTracker().gamePath; update(); } else MessageBox.Show("no save"); @@ -59,9 +60,27 @@ namespace OWTrack { try { - if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) { return true; } + 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 + { + getGamePath(); + st.Close(); + return true; + } + } + } else { + MessageBox.Show("NO data.json"); getGamePath(); return false; } @@ -84,6 +103,7 @@ namespace OWTrack if (openFileDialog1.ShowDialog() == DialogResult.OK) { tr.gamePath = openFileDialog1.FileName; + update(); } } diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 6d5e16f..7d3479a 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -2,15 +2,15 @@ using System.Diagnostics; using System.Linq; using System.IO; +using System.Windows.Forms; +using System.Collections.Generic; namespace OWTrack { class Tracker { public int wins, losses, startSR, newSR = 0; - public string gamePath; - - private string[] commonDir = ["C:\Program Files","D:\Program Files"]; + public string gamePath; public void Track() { } public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; } @@ -23,7 +23,6 @@ namespace OWTrack public void setNewSR(int SR) { newSR = SR; } public int srDiff() { return newSR - startSR; } - public bool owRunning() { try @@ -39,31 +38,68 @@ namespace OWTrack } } - public void LoacteOW() + /// + /// Not Working! + /// + /// + public bool LoacteOW() { try { - string[] files = []; - for (int i = 0; i < commonDir.count; i++) + List paths = new List(); + string[] filesC = null; + string[] filesD = null; + + if (ProgramFilesExist('c')) { filesC = Directory.GetFiles("C:\\Program Files", "Overwatch.exe", SearchOption.AllDirectories); } + if (ProgramFilesExist('d')) { filesD = Directory.GetFiles("D:\\Program Files", "Overwatch.exe", SearchOption.AllDirectories); } + + if (filesC != null) { - files.append(Directory.GetFiles(commonDir[i], "Overwatch*",SearchOption.AllDirectories)); - } - if (files.contians("Overwatch.exe")) - { - foreach (string "*Overwatch.exe" in files) + for (int i = 0; i < filesC.Length; i++) { - + if (filesC[i].Contains("Overwatch.exe")) + { + paths.Add(filesC[i]); + } } } + if (filesD != null) + { + for (int i = 0; i < filesD.Length - 1; i++) + { + if (filesD[i].Contains("Overwatch.exe")) + { + paths.Add(filesD[i]); + } + } + } + + if (paths.Count > 1) + { + //TODO: ask about correct path + return true; + } + + else if (paths.Count == 1) + { + gamePath = paths[0]; + return true; + } + + else return false; + } catch (Exception e) { - MesssageBox.show(e.message); - } - - - - } + MessageBox.Show(e.Message); + return false; + } + } + + private bool ProgramFilesExist(char drive) + { + return Directory.Exists(drive+":\\Program Files"); + } } } From 42e8b80999998b250955006d6c328b405cde2f14 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 3 Sep 2018 22:30:34 +0300 Subject: [PATCH 3/9] exe search ready --- OWTrack/Form1.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index 7a628cb..acc1e58 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -52,8 +52,7 @@ namespace OWTrack tr.startSR = savedTracker().startSR; tr.gamePath = savedTracker().gamePath; update(); - } - else MessageBox.Show("no save"); + } } private bool saveExist() @@ -72,16 +71,21 @@ namespace OWTrack } else { - getGamePath(); - st.Close(); + if (!tr.LoacteOW()) + { + getGamePath(); + st.Close(); + } return true; } } } else { - MessageBox.Show("NO data.json"); - getGamePath(); + if (!tr.LoacteOW()) + { + getGamePath(); + } return false; } } From d152a05e48e9e365c51ad11d75c7ee62ed62a4eb Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 3 Sep 2018 23:29:40 +0300 Subject: [PATCH 4/9] attempt 1 (add Brakpoints) --- OWTrack/Form1.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index acc1e58..18616bf 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -4,6 +4,7 @@ using System.Windows.Forms; using Newtonsoft.Json; using System.IO; + namespace OWTrack { public partial class Form1 : Form @@ -20,7 +21,8 @@ namespace OWTrack checkStatus(); update(); label4.Text = Program.Version.ToString(); - Text = "OWTrack " + Program.Version.ToString(); + Text = "OWTrack " + Program.Version.ToString(); + } private void checkStatus() @@ -72,9 +74,9 @@ namespace OWTrack else { if (!tr.LoacteOW()) - { - getGamePath(); + { st.Close(); + getGamePath(); } return true; } @@ -104,11 +106,17 @@ namespace OWTrack openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; - if (openFileDialog1.ShowDialog() == DialogResult.OK) + DialogResult result = openFileDialog1.ShowDialog(); + + if (result == DialogResult.OK) { tr.gamePath = openFileDialog1.FileName; - update(); } + else if (result == DialogResult.Cancel) + { + Close(); + } + update(); } private Tracker savedTracker() From abfcb8a351dc6ffa10484493754b89bfdb3df408 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 4 Sep 2018 19:13:56 +0300 Subject: [PATCH 5/9] Labels --- OWTrack/Form1.Designer.cs | 26 +++++++++++++++++++------- OWTrack/Form1.cs | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/OWTrack/Form1.Designer.cs b/OWTrack/Form1.Designer.cs index e7c457c..b781d6d 100644 --- a/OWTrack/Form1.Designer.cs +++ b/OWTrack/Form1.Designer.cs @@ -47,6 +47,7 @@ this.srBut = new System.Windows.Forms.Button(); this.srLabel = new System.Windows.Forms.Label(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.label5 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 @@ -139,21 +140,21 @@ // label2 // 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("Microsoft Sans Serif", 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(142, 76); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(42, 45); + this.label2.Size = new System.Drawing.Size(31, 42); this.label2.TabIndex = 5; this.label2.Text = "-"; // // label4 // 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("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Location = new System.Drawing.Point(12, 217); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(35, 11); + this.label4.Size = new System.Drawing.Size(29, 12); this.label4.TabIndex = 7; this.label4.Text = "label4"; // @@ -210,11 +211,11 @@ 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.Location = new System.Drawing.Point(189, 36); this.srLabel.Name = "srLabel"; - this.srLabel.Size = new System.Drawing.Size(21, 23); + this.srLabel.Size = new System.Drawing.Size(65, 23); this.srLabel.TabIndex = 13; - this.srLabel.Text = "0"; + this.srLabel.Text = "0 - 0"; // // openFileDialog1 // @@ -222,11 +223,21 @@ this.openFileDialog1.InitialDirectory = "C:\\"; this.openFileDialog1.RestoreDirectory = true; // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(190, 13); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(87, 13); + this.label5.TabIndex = 14; + this.label5.Text = "Start - Gain/Loss"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(332, 237); + this.Controls.Add(this.label5); this.Controls.Add(this.srLabel); this.Controls.Add(this.srBut); this.Controls.Add(this.srTextBox); @@ -273,6 +284,7 @@ private System.Windows.Forms.Button srBut; private System.Windows.Forms.Label srLabel; private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Label label5; } } diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index acc1e58..9270dfe 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -15,7 +15,7 @@ namespace OWTrack public Form1() { - InitializeComponent(); + InitializeComponent(); loadSave(); checkStatus(); update(); From 7347c37ce6d4bbf27f7c0bfd5774057942366657 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 4 Sep 2018 20:45:09 +0300 Subject: [PATCH 6/9] Solved hidden Form --- OWTrack/Form1.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index 18616bf..975d183 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -116,6 +116,7 @@ namespace OWTrack { Close(); } + FindForm(); update(); } From e14682e26f2fde3c99d43a06e62c0d59d47b5a84 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 4 Sep 2018 20:50:02 +0300 Subject: [PATCH 7/9] Version 1.3 --- OWTrack/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index 12db818..33cb5a5 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -22,7 +22,7 @@ namespace OWTrack Application.Run(new Form1()); } - public static string Version = "1.2.4"; + public static string Version = "1.3.0"; //public static string Version = Application.ProductVersion; //public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; From 89075aa941695d1878ee5bf7b73ec38b2e1826d5 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 4 Sep 2018 20:52:34 +0300 Subject: [PATCH 8/9] app.manifest --- OWTrack/app.manifest | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 OWTrack/app.manifest diff --git a/OWTrack/app.manifest b/OWTrack/app.manifest new file mode 100644 index 0000000..5910f3c --- /dev/null +++ b/OWTrack/app.manifest @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From cadb5dfea21fa76df8ff89885bf87fc34bf5c727 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 4 Sep 2018 20:58:00 +0300 Subject: [PATCH 9/9] Admin access --- OWTrack/OWTrack.csproj | 9 ++++++++- OWTrack/app.manifest | 20 +++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index e87106e..5959d12 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -75,11 +75,17 @@ OWTrack_TemporaryKey.pfx - true + false true + + app.manifest + + + LocalIntranet + ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll @@ -118,6 +124,7 @@ True Resources.resx + diff --git a/OWTrack/app.manifest b/OWTrack/app.manifest index 5910f3c..2ef6a60 100644 --- a/OWTrack/app.manifest +++ b/OWTrack/app.manifest @@ -1,6 +1,6 @@  - + @@ -16,35 +16,31 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + + + + + - - - - - - - - - - - + \ No newline at end of file