Esempio n. 1
0
		/// <summary>
		/// Handles button widget events.
		/// </summary>
		/// <param name="b"></param>
		public void OnButtonHit( object sender, Button b )
		{
			if ( ButtonHit != null )
			{
				ButtonHit( sender, b );
			}

			if ( b.Name == "StartStop" ) // start or stop sample
			{
				if ( b.Caption == "Start Sample" )
				{
					if ( this.LoadedSamples.Count == 0 )
					{
						this.TrayManager.ShowOkDialog( "Error!", "No sample selected!" );
					}
						// use the sample pointer we stored inside the thumbnail
					else
					{
						RunSample( (Sample)( this.Thumbs[ this.SampleMenu.SelectionIndex ].UserData ) );
					}
				}
				else
				{
					RunSample( null );
				}
			}
			else if ( b.Name == "UnloadReload" ) // unload or reload sample plugins and update controls
			{
				if ( b.Caption == "Unload Samples" )
				{
					if ( CurrentSample != null )
					{
						this.TrayManager.ShowYesNoDialog( "Warning!", "This will stop the current sample. Unload anyway?" );
					}
					else
					{
						// save off current view and try to restore it on the next reload
						this.LastViewTitle = this.SampleMenu.SelectionIndex;
						this.LastViewCategory = this.CategoryMenu.SelectionIndex;

						UnloadSamples();
						PopulateSampleMenus();
						b.Caption = "Reload Samples";
					}
				}
				else
				{
					LoadSamples();
					PopulateSampleMenus();
					if ( !( this.LoadedSamples.Count == 0 ) )
					{
						b.Caption = "Unload Samples";
					}

					try // attempt to restore the last view before unloading samples
					{
						this.CategoryMenu.SelectItem( this.LastViewCategory );
						this.SampleMenu.SelectItem( this.LastViewTitle );
					}
					catch ( Exception )
					{
						// swallowing Exception on purpose
					}
				}
			}
			else if ( b.Name == "Configure" ) // enter configuration screen
			{
				this.TrayManager.RemoveWidgetFromTray( "StartStop" );
				this.TrayManager.RemoveWidgetFromTray( "UnloadReload" );
				this.TrayManager.RemoveWidgetFromTray( "Configure" );
				this.TrayManager.RemoveWidgetFromTray( "Quit" );
				this.TrayManager.MoveWidgetToTray( "Apply", TrayLocation.Right );
				this.TrayManager.MoveWidgetToTray( "Back", TrayLocation.Right );

				for ( int i = 0; i < this.Thumbs.Count; i++ )
				{
					this.Thumbs[ i ].Hide();
				}

				while ( this.TrayManager.TrayContainer[ (int)TrayLocation.Center ].IsVisible )
				{
					this.TrayManager.RemoveWidgetFromTray( TrayLocation.Center, 0 );
				}

				while ( this.TrayManager.TrayContainer[ (int)TrayLocation.Left ].IsVisible )
				{
					this.TrayManager.RemoveWidgetFromTray( TrayLocation.Left, 0 );
				}

				this.TrayManager.MoveWidgetToTray( "ConfigLabel", TrayLocation.Left );
				this.TrayManager.MoveWidgetToTray( this.RendererMenu, TrayLocation.Left );
				this.TrayManager.MoveWidgetToTray( "ConfigSeparator", TrayLocation.Left );

				this.RendererMenu.SelectItem( Root.RenderSystem.Name );

				WindowResized( RenderWindow );
			}
			else if ( b.Name == "Back" ) // leave configuration screen
			{
				while ( this.TrayManager.GetWidgetCount( this.RendererMenu.TrayLocation ) > 3 )
				{
					this.TrayManager.DestroyWidget( this.RendererMenu.TrayLocation, 3 );
				}

				while ( this.TrayManager.GetWidgetCount( TrayLocation.None ) != 0 )
				{
					this.TrayManager.MoveWidgetToTray( TrayLocation.None, 0, TrayLocation.Left );
				}

				this.TrayManager.RemoveWidgetFromTray( "Apply" );
				this.TrayManager.RemoveWidgetFromTray( "Back" );
				this.TrayManager.RemoveWidgetFromTray( "ConfigLabel" );
				this.TrayManager.RemoveWidgetFromTray( this.RendererMenu );
				this.TrayManager.RemoveWidgetFromTray( "ConfigSeparator" );

				this.TrayManager.MoveWidgetToTray( "StartStop", TrayLocation.Right );
				this.TrayManager.MoveWidgetToTray( "UnloadReload", TrayLocation.Right );
				this.TrayManager.MoveWidgetToTray( "Configure", TrayLocation.Right );
				this.TrayManager.MoveWidgetToTray( "Quit", TrayLocation.Right );

				WindowResized( RenderWindow );
			}
			else if ( b.Name == "Apply" ) // apply any changes made in the configuration screen
			{
				bool reset = false;

				string selectedRenderSystem = string.Empty;
				switch ( this.RendererMenu.SelectedItem )
				{
					case "Axiom DirectX9 Rendering Subsystem":
						selectedRenderSystem = "DirectX9";
						break;
					case "Axiom Xna Rendering Subsystem":
						selectedRenderSystem = "Xna";
						break;
					case "Axiom OpenGL (OpenTK) Rendering Subsystem":
						selectedRenderSystem = "OpenGL";
						break;
					default:
						throw new NotImplementedException();
				}
				if ( selectedRenderSystem != string.Empty )
				{
					var options = Root.RenderSystems[ selectedRenderSystem ].ConfigOptions;

					var newOptions = new Collections.NameValuePairList();
					// collect new settings and decide if a reset is needed

					if ( this.RendererMenu.SelectedItem != Root.RenderSystem.Name )
					{
						reset = true;
					}

					for ( int i = 3; i < this.TrayManager.GetWidgetCount( this.RendererMenu.TrayLocation ); i++ )
					{
						var menu = (SelectMenu)this.TrayManager.GetWidget( this.RendererMenu.TrayLocation, i );
						if ( menu.SelectedItem != options[ menu.Caption ].Value )
						{
							reset = true;
						}
						newOptions[ menu.Caption ] = menu.SelectedItem;
					}

					// reset with new settings if necessary
					if ( reset )
					{
						Reconfigure( selectedRenderSystem, newOptions );
					}
				}
			}
			else
			{
				Root.QueueEndRendering(); // exit browser	
			}
		}
Esempio n. 2
0
		/// <summary>
		/// Destroys dialog widgets, notifies listener, and ends high priority session.
		/// </summary>
		/// <param name="button"></param>
		public void OnButtonHit( object sender, Button button )
		{
			if ( this.listener != null )
			{
				if ( button == this.mOk )
				{
					this.listener.OkDialogClosed( this.Dialog.Text );
				}
				else
				{
					this.listener.YesNoDialogClosed( this.Dialog.Text, button == this.mYes );
				}
			}
			CloseDialog();

			if ( ButtonHit != null )
			{
				ButtonHit( sender, button );
			}
		}
Esempio n. 3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="trayLoc"></param>
		/// <param name="name"></param>
		/// <param name="caption"></param>
		/// <param name="width"></param>
		/// <returns></returns>
		public Button CreateButton( TrayLocation trayLoc, String name, String caption, Real width )
		{
			var b = new Button( name, caption, width );
			MoveWidgetToTray( b, trayLoc );
			b.AssignedTrayListener = this.listener;
			return b;
		}
Esempio n. 4
0
		/// <summary>
		/// Hides whatever dialog is currently showing.
		/// </summary>
		public void CloseDialog()
		{
			if ( this.Dialog != null )
			{
				if ( this.mOk != null )
				{
					this.mOk.Cleanup();
					this.mOk = null;
				}
				else
				{
					if ( this.mYes != null )
					{
						this.mYes.Cleanup();
					}
					if ( this.mNo != null )
					{
						this.mNo.Cleanup();
					}

					this.mYes = null;
					this.mNo = null;
				}
				this.mDialogShade.Hide();
				this.Dialog.Cleanup();
				this.Dialog = null;
				if ( !this.CursorWasVisible )
				{
					HideCursor();
				}
			}
		}
Esempio n. 5
0
		/// <summary>
		/// Pops up a question dialog with Yes and No buttons.
		/// </summary>
		/// <param name="caption"></param>
		/// <param name="question"></param>
		public void ShowYesNoDialog( DisplayString caption, DisplayString question )
		{
			OverlayElement e;
			if ( this.Dialog != null )
			{
				this.Dialog.Caption = caption;
				this.Dialog.Text = question;
				if ( this.mOk != null )
				{
					if ( this.mOk != null )
					{
						this.mOk.Cleanup();
					}

					this.mOk = null;
				}
				else
				{
					return;
				}
			}
			else
			{
				// give widgets a chance to reset in case they're in the middle of something
				for ( int i = 0; i < 10; i++ )
				{
					for ( int j = 0; j < this.mWidgets[ i ].Count; j++ )
					{
						this.mWidgets[ i ][ j ].OnLostFocus();
					}
				}
				this.mDialogShade.Show();
				this.Dialog = new TextBox( this.mName + "/DialogBox", caption, 300, 208 );
				this.Dialog.Text = question;
				e = this.Dialog.OverlayElement;
				this.mDialogShade.AddChild( e );
				e.VerticalAlignment = VerticalAlignment.Center;
				e.Left = -( e.Width/2 );
				e.Top = -( e.Height/2 );
				this.CursorWasVisible = IsCursorVisible;
				ShowCursor();
			}
			this.mYes = new Button( this.mName + "/YesButton", "Yes", 58 );
			this.mYes.AssignedTrayListener = this;
			e = this.mYes.OverlayElement;
			this.mDialogShade.AddChild( e );
			e.VerticalAlignment = VerticalAlignment.Center;
			e.Left = -( e.Width + 2 );
			e.Top = this.Dialog.OverlayElement.Top + this.Dialog.OverlayElement.Height + 5;
			this.mNo = new Button( this.mName + "/NoButton", "No", 50 );
			this.mNo.AssignedTrayListener = this;
			e = this.mNo.OverlayElement;
			this.mDialogShade.AddChild( e );
			e.VerticalAlignment = VerticalAlignment.Center;
			e.Left = 3;
			e.Top = this.Dialog.OverlayElement.Top + this.Dialog.OverlayElement.Height + 5;
		}
Esempio n. 6
0
		/// <summary>
		/// Destroys dialog widgets, notifies listener, and ends high priority session.
		/// </summary>
		/// <param name="button"></param>
		public void OnButtonHit( object sender, Button button )
		{
			if ( listener != null )
			{
				if ( button == mOk )
					listener.OkDialogClosed( Dialog.Text );
				else
					listener.YesNoDialogClosed( Dialog.Text, button == mYes );
			}
			CloseDialog();

			if ( ButtonHit != null )
				ButtonHit( sender, button );
		}
Esempio n. 7
0
		/// <summary>
		/// Hides whatever dialog is currently showing.
		/// </summary>
		public void CloseDialog()
		{
			if ( Dialog != null )
			{
				if ( mOk != null )
				{
					mOk.Cleanup();
					mOk = null;
				}
				else
				{
					if ( mYes != null )
						mYes.Cleanup();
					if ( mNo != null )
						mNo.Cleanup();

					mYes = null;
					mNo = null;
				}
				mDialogShade.Hide();
				Dialog.Cleanup();
				Dialog = null;
				if ( !CursorWasVisible )
					HideCursor();
			}
		}
Esempio n. 8
0
		/// <summary>
		/// Pops up a message dialog with an OK button.
		/// </summary>
		/// <param name="caption"></param>
		/// <param name="message"></param>
		public void ShowOkDialog( DisplayString caption, DisplayString message )
		{
			OverlayElement e;
			if ( Dialog != null )
			{
				Dialog.Caption = caption;
				Dialog.Text = message;
				if ( mOk != null )
					return;
				else
				{
					if ( mYes != null )
						mYes.Cleanup();
					if ( mNo != null )
						mNo.Cleanup();

					mYes = null;
					mNo = null;
				}
			}
			else
			{
				// give widgets a chance to reset in case they're in the middle of something
				for ( int i = 0; i < 10; i++ )
				{
					for ( int j = 0; j < mWidgets[ i ].Count; j++ )
					{
						mWidgets[ i ][ j ].OnLostFocus();
					}
				}
				mDialogShade.Show();
				Dialog = new TextBox( mName + "/DialogBox", caption, 300, 208 );
				Dialog.Text = message;
				e = Dialog.OverlayElement;
				mDialogShade.AddChild( e );
				e.VerticalAlignment = VerticalAlignment.Center;
				e.Left = -( e.Width / 2 );
				e.Top = -( e.Height / 2 );
				CursorWasVisible = IsCursorVisible;
				ShowCursor();
			}
			mOk = new Button( mName + "/OkButton", "OK", 60 );
			mOk.AssignedTrayListener = this;
			e = mOk.OverlayElement;
			mDialogShade.AddChild( e );
			e.VerticalAlignment = VerticalAlignment.Center;
			e.Left = -( e.Width / 2 );
			e.Top = Dialog.OverlayElement.Top + Dialog.OverlayElement.Height + 5;
		}