Smrf.NodeXL.ExcelTemplate.OpenUcinetFileDialog.btnOK_Click C# (CSharp) Method

btnOK_Click() private method

private btnOK_Click ( object sender, System e ) : void
sender object
e System
return void
    btnOK_Click
    (
        object sender,
        System.EventArgs e
    )
    {
        AssertValid();

        if ( !DoDataExchange(true) )
        {
            return;
        }

        this.Cursor = Cursors.WaitCursor;
        Exception oExpectedException = null;

        try
        {
            OpenUcinetFile();
        }
        catch (IOException oIOException)
        {
            oExpectedException = oIOException;
        }
        catch (UnauthorizedAccessException oUnauthorizedAccessException)
        {
            oExpectedException = oUnauthorizedAccessException;
        }
        catch (FormatException oFormatException)
        {
            oExpectedException = oFormatException;
        }
        catch (Exception oUnexpectedException)
        {
            ErrorUtil.OnException(oUnexpectedException);
            return;
        }
        finally
        {
            this.Cursor = Cursors.Default;
        }

        if (oExpectedException != null)
        {
            String sMessage = 
                "The file could not be opened.  Details:\n\n"
                + oExpectedException.Message;

            if (oExpectedException is FormatException)
            {
                sMessage +=
                    "\n\nThis does not appear to be a UCINET full matrix DL"
                    + " file.  "
                    + FormatMessage
                    ;
            }

            this.ShowWarning(sMessage);
            return;
        }

        DialogResult = DialogResult.OK;
        this.Close();
    }