working dialog

This commit is contained in:
HeshamTB 2018-08-31 20:56:47 +03:00
parent e948a1964a
commit bc83f16ab2
2 changed files with 26 additions and 14 deletions

View File

@ -221,7 +221,6 @@
this.openFileDialog1.FileName = "Overwatch.exe"; this.openFileDialog1.FileName = "Overwatch.exe";
this.openFileDialog1.InitialDirectory = "C:\\"; this.openFileDialog1.InitialDirectory = "C:\\";
this.openFileDialog1.RestoreDirectory = true; this.openFileDialog1.RestoreDirectory = true;
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
// //
// Form1 // Form1
// //

View File

@ -48,22 +48,25 @@ namespace OWTrack
tr.wins = savedTracker().wins; tr.wins = savedTracker().wins;
tr.losses = savedTracker().losses; tr.losses = savedTracker().losses;
tr.gamePath = savedTracker().gamePath; tr.gamePath = savedTracker().gamePath;
if (tr.gamePath == "" || tr.gamePath == null) //if (tr.gamePath == "" || tr.gamePath == null)
{ //{
openFileDialog1.Title = "Select Overwatch.exe";
openFileDialog1.ShowDialog(); //}
}
update(); update();
} }
else MessageBox.Show("no save"); else MessageBox.Show("no save");
} }
private bool saveExist() private bool saveExist()
{ {
try try
{ {
if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) { return true; } if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) { return true; }
else return false; else
{
getGamePath();
return false;
}
} }
catch (Exception e) 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() private Tracker savedTracker()
{ {
try try
@ -161,11 +179,6 @@ namespace OWTrack
else tr.newSR = sr; else tr.newSR = sr;
} }
update(); update();
} }
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
MessageBox.Show("ok");
}
} }
} }