From 83fad4d6caf9edda9f5caf172eb92046d12a2dd0 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 14 Sep 2018 15:38:42 +0300 Subject: [PATCH 1/2] 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; + // } + //} + } +} From 23ff1420e6a575e74f554b173f216d0bb02a2a28 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 14 Sep 2018 15:39:53 +0300 Subject: [PATCH 2/2] 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 +