Skip to content

Commit

Permalink
Missing HazMap.cs
Browse files Browse the repository at this point in the history
Forgot this file and lost the work I had done on it.
So redone it and a few more changes.
* Fixes crash on save dialog cancel
* Removed my failed crash prevention from
clipboardToolStripMenuItem_Click() (was moved to readscan.cs)
* Moved openfilediag() up other openToolStripMenuItem_Click()
* Added same check to textFileToolStripMenuItem_Click() as I did for
clipboardToolStripMenuItem_Click()
  • Loading branch information
Deantwo committed Apr 8, 2014
1 parent 651457a commit 3bc78bb
Showing 1 changed file with 42 additions and 23 deletions.
65 changes: 42 additions & 23 deletions HazMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,11 @@ public Point sides_ab(int hypotinuse, int angle_A, bool radians = true )

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
string filename = savefilediag(".hzm");
filehandling.SerializeObject(galaxy, filename);
string filename = savefilediag(".hzm");
if (filename != null)
{
filehandling.SerializeObject(galaxy, filename);
}
}

private string savefilediag(string extension)
Expand All @@ -260,8 +263,8 @@ private string savefilediag(string extension)
sfd.AddExtension = true;
sfd.DefaultExt = extension;
string filename = null;
DialogResult ofd_result = sfd.ShowDialog();
if (ofd_result == DialogResult.OK)
DialogResult sfd_result = sfd.ShowDialog();
if (sfd_result == DialogResult.OK)
{
filename = sfd.FileName;
}
Expand All @@ -278,17 +281,39 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
}
}

private string openfilediag(string extension)
{
OpenFileDialog ofd = new OpenFileDialog();
//ofd.Filter = "*" + extension;
ofd.DefaultExt = extension;
string filename = null;
DialogResult ofd_result = ofd.ShowDialog();
if (ofd_result == DialogResult.OK)
{
filename = ofd.FileName;
}
return filename;
}

private void clipboardToolStripMenuItem_Click(object sender, EventArgs e)
{
string hazscan = Clipboard.GetText();
string pastemesage = Readscan.readscan(hazscan, galaxy);
if (pastemesage != null)
// There has to be "System Survey of " in the clipboard, or else it isn't a scan report.
if (hazscan != null && hazscan.Contains("System Survey of "))
{
this.toolStripStatusLabel1.Text = pastemesage;
string pastemesage = Readscan.readscan(hazscan, galaxy);
if (pastemesage != null)
{
this.toolStripStatusLabel1.Text = pastemesage;
}
else
{
this.toolStripStatusLabel1.Text = "Paste failed";
}
}
else
{
this.toolStripStatusLabel1.Text = "Paste failed";
this.toolStripStatusLabel1.Text = "Paste invalid";
}
}

Expand All @@ -299,27 +324,21 @@ private void textFileToolStripMenuItem_Click(object sender, EventArgs e)
try
{
string scantext = File.ReadAllText(scanfile);
Readscan.readscan(scantext, galaxy);
if (scantext.Contains("System Survey of "))
{
Readscan.readscan(scantext, galaxy);
}
else
{
this.toolStripStatusLabel1.Text = "Text file invalid";
}
}
catch (IOException)
{
this.toolStripStatusLabel1.Text = "Text file read error";
}
}

private string openfilediag(string extension)
{
OpenFileDialog ofd = new OpenFileDialog();
//ofd.Filter = "*" + extension;
ofd.DefaultExt = extension;
string filename = null;
DialogResult ofd_result = ofd.ShowDialog();
if (ofd_result == DialogResult.OK)
{
filename = ofd.FileName;
}
return filename;
}

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
Expand Down

0 comments on commit 3bc78bb

Please sign in to comment.