From bc83f16ab231ac9a775eea90f6c67821a0d1978c Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 31 Aug 2018 20:56:47 +0300 Subject: [PATCH] working dialog --- OWTrack/Form1.Designer.cs | 1 - OWTrack/Form1.cs | 39 ++++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/OWTrack/Form1.Designer.cs b/OWTrack/Form1.Designer.cs index 39a2946..e7c457c 100644 --- a/OWTrack/Form1.Designer.cs +++ b/OWTrack/Form1.Designer.cs @@ -221,7 +221,6 @@ this.openFileDialog1.FileName = "Overwatch.exe"; this.openFileDialog1.InitialDirectory = "C:\\"; this.openFileDialog1.RestoreDirectory = true; - this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk); // // Form1 // diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index 237cfed..6224511 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -48,22 +48,25 @@ namespace OWTrack tr.wins = savedTracker().wins; tr.losses = savedTracker().losses; tr.gamePath = savedTracker().gamePath; - if (tr.gamePath == "" || tr.gamePath == null) - { - openFileDialog1.Title = "Select Overwatch.exe"; - openFileDialog1.ShowDialog(); - } + //if (tr.gamePath == "" || tr.gamePath == null) + //{ + + //} update(); } else MessageBox.Show("no save"); - } + } private bool saveExist() { try { if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) { return true; } - else return false; + else + { + getGamePath(); + return false; + } } catch (Exception e) { @@ -72,6 +75,21 @@ namespace OWTrack } } + void getGamePath() + { + openFileDialog1.Title = "Select Overwatch.exe"; + openFileDialog1.DefaultExt = "exe"; + openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; + openFileDialog1.CheckFileExists = true; + openFileDialog1.CheckPathExists = true; + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + tr.gamePath = openFileDialog1.FileName; + MessageBox.Show(openFileDialog1.FileName); + } + } + private Tracker savedTracker() { try @@ -161,11 +179,6 @@ namespace OWTrack else tr.newSR = sr; } update(); - } - - private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e) - { - MessageBox.Show("ok"); - } + } } }