Axiom.Samples.SdkSample.KeyPressed C# (CSharp) Method

KeyPressed() public method

public KeyPressed ( SharpInputSystem evt ) : bool
evt SharpInputSystem
return bool
		public override bool KeyPressed( SIS.KeyEventArgs evt )
		{
			if ( evt.Key == SIS.KeyCode.Key_H || evt.Key == SIS.KeyCode.Key_F1 ) // toggle visibility of help dialog
			{
				if ( !this.TrayManager.IsDialogVisible && Metadata[ "Help" ] != "" )
					this.TrayManager.ShowOkDialog( "Help", Metadata[ "Help" ] );
				else
					this.TrayManager.CloseDialog();
			}

			if ( this.TrayManager.IsDialogVisible )
				return true; // don't process any more keys if dialog is up

			if ( evt.Key == SIS.KeyCode.Key_F ) // toggle visibility of advanced frame stats
			{
				this.TrayManager.ToggleAdvancedFrameStats();
			}
			else if ( evt.Key == SIS.KeyCode.Key_G ) // toggle visibility of even rarer debugging details
			{
				if ( this.DetailsPanel.TrayLocation == TrayLocation.None )
				{
					this.TrayManager.MoveWidgetToTray( this.DetailsPanel, TrayLocation.TopRight, 0 );
					this.DetailsPanel.Show();
				}
				else
				{
					this.TrayManager.RemoveWidgetFromTray( this.DetailsPanel );
					this.DetailsPanel.Hide();
				}
			}
			else if ( evt.Key == SIS.KeyCode.Key_T ) // cycle polygon rendering mode
			{
				String newVal;
				TextureFiltering tfo;
				int aniso;

				switch ( this.DetailsPanel.GetParamValue( 9 )[ 0 ] )
				{
					case 'B':
						newVal = "Trilinear";
						tfo = TextureFiltering.Trilinear;
						aniso = 1;
						break;
					case 'T':
						newVal = "Anisotropic";
						tfo = TextureFiltering.Anisotropic;
						aniso = 8;
						break;
					case 'A':
						newVal = "None";
						tfo = TextureFiltering.None;
						aniso = 1;
						break;
					default:
						newVal = "Bilinear";
						tfo = TextureFiltering.Bilinear;
						aniso = 1;
						break;
				}

				MaterialManager.Instance.SetDefaultTextureFiltering( tfo );
				MaterialManager.Instance.DefaultAnisotropy = aniso;
				this.DetailsPanel.SetParamValue( 9, newVal );
			}
			else if ( evt.Key == SIS.KeyCode.Key_R ) // cycle polygon rendering mode
			{
				String newVal;
				PolygonMode pm;

				switch ( this.Camera.PolygonMode )
				{
					case PolygonMode.Solid:
						newVal = "Wireframe";
						pm = PolygonMode.Wireframe;
						break;
					case PolygonMode.Wireframe:
						newVal = "Points";
						pm = PolygonMode.Points;
						break;
					default:
						newVal = "Solid";
						pm = PolygonMode.Solid;
						break;
				}

				this.Camera.PolygonMode = pm;
				this.DetailsPanel.SetParamValue( 10, newVal );
			}
			else if ( evt.Key == SIS.KeyCode.Key_F5 ) // refresh all textures
			{
				TextureManager.Instance.ReloadAll();
			}
			else if ( evt.Key == SIS.KeyCode.Key_F9 ) // take a screenshot
			{
				String path = "screenshots\\screenshot_";
				Window.WriteContentsToFile( path + Root.CurrentFrameCount + ".jpg" );
			}

			this.CameraManager.injectKeyDown( evt );

			return true;
		}