/*****************************************************************************/

/*** Can't be too careful. ***************************************************/

/*****************************************************************************/

int buttonNum = Convert . ToInt32 ( ( int ) keyCode ) ;

/*****************************************************************************/

/*** Parentheses improve readability. ****************************************/

/*****************************************************************************/

while ( ( ( stringFinis ) < text . Length ) &&

( ( Char . IsDigit ( text, stringFinis ) ) ||

( text . Subsring ( stringFinis, 1 ) == "." ) ) ) {

stringFinis ++;

stringLen ++;

}

/*****************************************************************************/

/*** Nevermind, we didn't need those quotes. *********************************/

/*****************************************************************************/

string message = "The value is \" " + value + " \" ." ;

if ( ! showQuotes )

message = "The value is " + value + "." ;

/*****************************************************************************/

/*** This pattern was extremely common. **************************************/

/*****************************************************************************/

// Keycodes which will do nothing

if ( e . KeyCode == Keys . None )

return ;

if ( e . KeyCode == Keys . ShiftKey )

return ;

if ( e . KeyCode == Keys . Down )

return ;

if ( e . KeyCode == Keys . Up )

return ;

/*****************************************************************************/

/*** So was this one. ********************************************************/

/*****************************************************************************/

public string GetKeyCombo ( )

{

string answer = "" ;

if ( _ctrl == true )

answer += "Ctrl+" ;

if ( _alt == true )

answer += "Alt+" ;

answer += _mainKey ;

return answer ;

}

/*****************************************************************************/

/*** More booleans. **********************************************************/

/*****************************************************************************/

// Set Control key state

if ( e . Modifiers == Keys . Control )

dgv [ 0 , row ] . Value = true ;

else

dgv [ 0 , row ] . Value = false ;

// Set Alt key state

if ( e . Modifiers == Keys . Alt )

dgv [ 1 , row ] . Value = true ;

else

dgv [ 1 , row ] . Value = false ;

/*****************************************************************************/

/*** Booleans are hard. ******************************************************/

/*****************************************************************************/

public bool haveContents ( )

{

if ( haveData ( ) || haveText ( ) )

return true ;

return false ;

}

/*****************************************************************************/

/*** Very interesting control flow. ******************************************/

/*****************************************************************************/

if ( _ctrl ) if ( e . Modifiers != Keys . Control ) return false ;

if ( ! _ctrl ) if ( e . Control ) return false ;

if ( _alt ) if ( e . Modifiers != Keys . Alt ) return false ;

if ( ! _alt ) if ( e . Alt ) return false ;

/*****************************************************************************/

/*** The second argument to ArgumentException is supposed to be the name

of the argument that caused the exception. *******************************/

/*****************************************************************************/

public Convert ( bool useExtension )

{

// ...

if ( _data . Parse ( ) == - 1 ) {

throw new ArgumentException ( "Did not find Master Data File" , "no_Master-data-file" ) ;

}

// ...

}

/*****************************************************************************/

/*** This one caused some confusion. *****************************************/

/*****************************************************************************/

private string Name ;

private bool Ctrl ;

private bool Alt ;

private string Key ;

public bool _ctrl { get { return Ctrl ; } set { Ctrl = value ; } }

public bool _alt { get { return Alt ; } set { Alt = value ; } }

public bool _mainKey { get { return Key ; } set { Key = value ; } }

public bool _name { get { return Name ; } set { Name = value ; } }

/*****************************************************************************/

/*** I wonder what it does. **************************************************/

/*****************************************************************************/

private void MENU_Formula_Close_Click ( object sender, EventArgs e )

{

// This is what happens when the "Close" menu item is clicked.

Close ( ) ;

} // Close Window click event

/*****************************************************************************/

/*** Yeah. *******************************************************************/

/*****************************************************************************/

// String.Compare returns "< 0" for less than, "> 0" for greater than, or 0 for equals. Yeah.

if ( String . Compare ( saveExt, ".gif" , true ) == 0 ) { saveAs = System. Drawing . Imaging . ImageFormat . Gif ; }

if ( String . Compare ( saveExt, ".jpg" , true ) == 0 ) { saveAs = System. Drawing . Imaging . ImageFormat . Jpeg ; }

if ( String . Compare ( saveExt, ".bmp" , true ) == 0 ) { saveAs = System. Drawing . Imaging . ImageFormat . Bmp ; }

if ( String . Compare ( saveExt, ".tif" , true ) == 0 ) { saveAs = System. Drawing . Imaging . ImageFormat . Tiff ; }

if ( String . Compare ( saveExt, ".tiff" , true ) == 0 ) { saveAs = System. Drawing . Imaging . ImageFormat . Tiff ; }

/*****************************************************************************/

/*** if (isIncluded) _mainKey = (button.TabIndex + 1).ToString(); ************/

/*****************************************************************************/

// Determine the main key by button position

if ( isIncluded ) {

// If this button is included, the answer will always be between 1 and 5 inclusive; Alt key not set

int num ;

//for (num = 0; num < (Button_Toolbar.NUM_CONTROLS + bt.NumElements); num++)

// if (button == bt.Controls[num])

// break;

// Get the TabIndex of this button; that will be the main shortcut key

num = button . TabIndex + 1 ;

//_mainKey = (num - Button_Toolbar.NUM_CONTROLS + 1).ToString();

_mainKey = ( num ) . ToString ( ) ;

//_mainKey = (1 + num).ToString();

}

/*****************************************************************************/

/*** Exceptions are easier than conditionals. ********************************/

/*****************************************************************************/

// This function opens or closes the Settings window.

private void toggleSettings ( )

{

try {

if ( _settingsWindow . Visible ) {

// This code executes if the Settings window is visible

_settingsWindow . Close ( ) ;

_settingsWindow = null ;

}

else {

// This code will dispose properly of a closed Settings window, and trigger a re-showing (creates an exception)

_settingsWindow = null ;

if ( _settingsWindow != null ) {

_settingsWindow . Visible = true ;

}

}

}

catch {

// This code shows the Settings

_settingsWindow = new SettingsWindow { Owner = this , StartPosition = FormStartPosition . CenterParent } ;

_settingsWindow . Show ( ) ;

}

} // Toggle settings window

/*****************************************************************************/

/*** This one's probably my favorite. ****************************************/

/*****************************************************************************/

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// These following functions used to have a purpose, but they don't now.

///////////////////////////////////////////////////////////////////////////////////////////////////////////

private void DATAGRID_Keys_RowPostPaint ( object sender, DataGridViewRowPostPaintEvenArgs e )

{

// This removes the triangle in the header of the current row.

// Since we want an entire row to be selected at all times, this actually is counter-productive.

//e.PaintHeader(DataGridViewPaintParts.All & ~DataGridViewPaintParts.ContentBackground);

} // Make sure that the unsightly triangle is painted over.

private void DATAGRID_Keys_CellValueChanged ( object sender, DataGridViewCellEventArgs e )

{

// We use a different method to change the values of the cells... and of the underlying DataSource

if ( lockKeys == true )

return ;