protected override void OnAttach()
		{
			base.OnAttach();

			EngineApp.Instance.Config.RegisterClassParameters( GetType() );

			instance = this;

			window = ControlDeclarationManager.Instance.CreateControl( "GUI\\ProfilingTool\\ProfilingToolWindow.gui" );
			Controls.Add( window );

			backgroundCheckBox = (CheckBox)window.Controls[ "Background" ];
			backgroundCheckBox.Checked = background;
			backgroundCheckBox.CheckedChange += Background_CheckedChange;

			Button closeButton = (Button)window.Controls[ "Close" ];
			closeButton.Click += delegate( Button sender )
			{
				SetShouldDetach();
			};
			if( PlatformInfo.Platform == PlatformInfo.Platforms.MacOSX )
				closeButton.Text = closeButton.Text.Replace( "F11", "Fn+F5" );

			pageSelectionComboBox = (ComboBox)window.Controls[ "PageSelection" ];
			pageSelectionComboBox.SelectedIndexChange += pageSelectionComboBox_SelectedIndexChange;

			pagePreviousButton = (Button)window.Controls[ "PagePrevious" ];
			pagePreviousButton.Click += new Button.ClickDelegate( pagePreviousButton_Click );

			pageNextButton = (Button)window.Controls[ "PageNext" ];
			pageNextButton.Click += new Button.ClickDelegate( pageNextButton_Click );

			pageAreaControl = window.Controls[ "PageArea" ];

			//add pages
			pages.Add( new FrameStatisticsPage( "Frame Statistics", "FrameStatisticsPage.gui" ) );
			pages.Add( new SettngsPage( "Settings", "SettingsPage.gui" ) );
			pages.Add( new FullScreenEffectsPage( "Full-Screen Effects", "FullScreenEffectsPage.gui" ) );
			pages.Add( new TimePage( "Time Management", "TimeManagementPage.gui" ) );
			pages.Add( new RenderingSystemPage( "Rendering System", "RenderingSystemPage.gui" ) );
			pages.Add( new PhysicsSystemPage( "Physics System", "PhysicsSystemPage.gui" ) );
			pages.Add( new SoundSystemPage( "Sound System", "SoundSystemPage.gui" ) );
			pages.Add( new EntitySystemPage( "Entity System", "EntitySystemPage.gui" ) );
			pages.Add( new MemoryManagementPage( "Memory Management", "MemoryManagementPage.gui" ) );
			pages.Add( new DLLPage( "Assemblies and DLLs", "DLLPage.gui" ) );
			pages.Add( new NetworkingPage( "Networking", "NetworkingPage.gui" ) );
			pages.Add( new InputDevicesPage( "Input Devices", "InputDevicesPage.gui" ) );
			pages.Add( new FileSystemPage( "File System", "FileSystemPage.gui" ) );
			pages.Add( new ProjectSpecificPage( "Project Specific", "ProjectSpecificPage.gui" ) );

			//update pageSelectionComboBox
			foreach( Page page in pages )
				pageSelectionComboBox.Items.Add( page.Caption );
			if( lastPageSelectionIndex >= 0 && lastPageSelectionIndex < pages.Count )
				pageSelectionComboBox.SelectedIndex = lastPageSelectionIndex;
			else
				pageSelectionComboBox.SelectedIndex = 0;

			UpdateColorMultiplier();
		}
 public static void ShowProfilingTool(bool show)
 {
     if (show)
     {
         if (ProfilingToolWindow.Instance == null)
         {
             ProfilingToolWindow window = new ProfilingToolWindow();
             Instance.ControlManager.Controls.Add(window);
         }
     }
     else
     {
         if (ProfilingToolWindow.Instance != null)
             ProfilingToolWindow.Instance.SetShouldDetach();
     }
 }
		protected override void OnDetach()
		{
			foreach( Page page in pages )
				page.OnDestroy();
			pages.Clear();

			instance = null;

			base.OnDetach();
		}