title: c#/WPF openFileDialog box opens twice
body: <p>When I click the button to open a file the <code>OpenFileDialog</code> box opens twice. The first box only opens the image files and the second box text files. If the user decides to close out the first box without choosing a file the second box pops up as well. I'm not sure what I am over looking on this issue. Any help would be appreciated. Thanks!  </p>
  
  <pre><code>OpenFileDialog of = new OpenFileDialog();   
  of.Filter = "All Image Formats|*.jpg;*.png;*.bmp;*.gif;*.ico;*.txt|JPG Image|*.jpg|BMP image|*.bmp|PNG image|*.png|GIF Image|*.gif|Icon|*.ico|Text File|*.txt";
  
  if (of.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  {
  try
  {
     image1.Source = new BitmapImage(new Uri(of.FileName));
  
      // enable the buttons to function (previous page, next page, rotate left/right, zoom in/out)
      button1.IsEnabled = false;
      button2.IsEnabled = false;
      button3.IsEnabled = false;
      button4.IsEnabled = false;
      button5.IsEnabled = true;
      button6.IsEnabled = true;
      button7.IsEnabled = true;
      button8.IsEnabled = true;                          
  }
  catch (ArgumentException)
  {
      // Show messagebox when argument exception arises, when user tries to open corrupted file
      System.Windows.Forms.MessageBox.Show("Invalid File");
  }
   }
   else if(of.ShowDialog() == System.Windows.Forms.DialogResult.OK)
   {
  try
  {
      using (StreamReader sr = new StreamReader(of.FileName))
      {
          textBox2.Text = sr.ReadToEnd();
          button1.IsEnabled = true;
          button2.IsEnabled = true;
          button3.IsEnabled = true;
          button4.IsEnabled = true;
          button5.IsEnabled = true;
          button6.IsEnabled = true;
          button7.IsEnabled = true;
          button8.IsEnabled = true;
  
      }
  }
  catch (ArgumentException)
  {
      System.Windows.Forms.MessageBox.Show("Invalid File");
  }
  } 
  </code></pre>