private void Edit_Tokens_Load( object sender, EventArgs e ) { WavesToolbar = ( Token_Toolbar )this.Owner; InitElementGrid(); InitElemEnglishApprox(); InitMOgrid(); InitMIgrid(); InitElementList(); InitLevel1List(); InitLevel2List(); // Set the form's color scheme appropriately SetFormColors(); // Set whether this window will be on top of all other windows this.TopMost = WavesToolbar.MENU_View_AlwaysOnTop.Checked; }
/// <summary> /// Determines the shortcut that a specified button should react to. /// </summary> /// <param name="button">The button to which the determined shortcut should be assigned</param> /// <param name="tok">The token (or element) which the specified button represents</param> /// <param name="isElement">Whether the specified button represents an element or token... use true if it is an element</param> public void GetWavesTokenShortcut( Token_Toolbar tt, Button button, bool isElement ) { // The Control key is always required for button shortcuts _ctrl = true; // Assume the Alt key is not required; will reset it if it is _alt = false; // Assume the main key is "0"... it will be determined later, but this will serve as a default _mainKey = "0"; // Determine the main key by button position if( isElement ) { // If this button is an element, the answer will always be between 1 and 5 inclusive; Alt key not set int num; for( num = ( Token_Toolbar.NUM_CONTROLS ); num < ( Token_Toolbar.NUM_CONTROLS + tt.NumElements ); num++ ) if( button == tt.Controls[ num ] ) break; _mainKey = ( num - Token_Toolbar.NUM_CONTROLS + 1 ).ToString(); } else { // This is an MO or MI token. int num; for( num = ( Token_Toolbar.NUM_CONTROLS + tt.NumElements ); num < tt.Controls.Count; num++ ) if( button == tt.Controls[ num ] ) break; // MO and MI tokens are either 1st or 2nd level. // There are 5 possible 1st level tokens (Control + <6 to 0>). // There are 10 possible 2nd level tokens (Control + Alt + <1 to 0>). if( num < ( Token_Toolbar.NUM_CONTROLS + tt.NumElements + tt.NumLevel1 ) ) { // This is a level 1 token _mainKey = ( num + ( 5 - tt.NumElements ) - Token_Toolbar.NUM_CONTROLS + 1 ).ToString(); } else { // This is a level 2 token _mainKey = ( num - ( tt.NumElements + tt.NumLevel1 + Token_Toolbar.NUM_CONTROLS ) + 1 ).ToString(); _alt = true; } // If the answer we determined is "10", then make the key "0". This is required because of the "0"'s place on the keyboard. if( _mainKey == "10" ) _mainKey = "0"; } }
private void Edit_Keys_Load( object sender, EventArgs e ) { WavesToolbar = ( Token_Toolbar )this.Owner; // Make sure nothing gets edited when the DataViewGrid gets populated lockKeys = true; // Create a second copy of our list of KeyCommand. Since when the DataListGrid is edited, it also actually // edits the "DataSource" (which will be KeyCommand), we need this second copy in case the user makes a // mistake in selecting a shortcut key for a menu. If this validation fails, the backup will be a fallback. for ( int i = 0; i < Token_Toolbar.KeyCommand.Count(); i++ ) { keyCommandsBackup[ i ] = new KeyCombo(); keyCommandsBackup[ i ]._alt = Token_Toolbar.KeyCommand[ i ]._alt; keyCommandsBackup[ i ]._ctrl = Token_Toolbar.KeyCommand[ i ]._ctrl; keyCommandsBackup[ i ]._mainKey = Token_Toolbar.KeyCommand[ i ]._mainKey; } // Initialize the DataGridView control. DATAGRID_Keys.DataSource = Token_Toolbar.KeyCommand; DATAGRID_Keys.RowHeadersWidth = 225; SetHeaders(); DATAGRID_Keys.AutoResizeColumns(); DATAGRID_Keys.Columns[ 2 ].Width = 75; // This makes the 4th column invisible DATAGRID_Keys.Columns[ 3 ].Visible = false; // Set the form's color scheme appropriately SetFormColors(); // Set whether this window will be on top of all other windows this.TopMost = WavesToolbar.MENU_View_AlwaysOnTop.Checked; // Everything is alright to go! lockKeys = false; }
// ******************************************************************************************************************* // These functions initialize the Token and Element buttons in the Repository window, and configure the GUI. // ******************************************************************************************************************* private void Level3_Load( object sender, EventArgs e ) { WavesToolbar = ( Token_Toolbar )this.Owner; // Populate the Repository with all pre-loaded elements and tokens moCount = PopulateToolbar( "mo", 0 ); miCount = PopulateToolbar( "mi", moCount ); elemCount = PopulateElements(); // Set the color scheme SetFormColors(); // The first MathML element is selected this.Controls[ moCount + miCount ].Select(); // Set whether this window will be on top of all other windows this.TopMost = WavesToolbar.MENU_View_AlwaysOnTop.Checked; // Set the Repository's default size this.Width = 750; }