/// <summary> /// /// </summary> protected override void Shutdown() { if (this.TrayManager != null) { this.TrayManager = null; } if (CurrentSample == null) { DestroyDummyScene(); } this.CategoryMenu = null; this.SampleMenu = null; this.SampleSlider = null; this.TitleLabel = null; this.DescBox = null; this.RendererMenu = null; this.HiddenOverlays.Clear(); this.Thumbs.Clear(); this.CarouselPlace = 0; base.Shutdown(); UnloadSamples(); }
/// <summary> /// Raises the Selected Index Changed event. /// </summary> /// <param name="sender"></param> public virtual void OnSelectedIndexChanged(SelectMenu sender) { if (SelectedIndexChanged != null) { SelectedIndexChanged(sender); } }
/// <summary> /// Raises the Selected Index Changed event. /// </summary> /// <param name="sender"></param> public virtual void OnSelectedIndexChanged( SelectMenu sender ) { if ( SelectedIndexChanged != null ) { SelectedIndexChanged( sender ); } }
/// <summary> /// Sets up main page for browsing samples. /// </summary> protected virtual void SetupWidgets() { this.TrayManager.DestroyAllWidgets(); // create main navigation tray this.TrayManager.ShowLogo(TrayLocation.Right); this.TrayManager.CreateSeparator(TrayLocation.Right, "LogoSep"); this.TrayManager.CreateButton(TrayLocation.Right, "StartStop", "Start Sample"); this.TrayManager.CreateButton(TrayLocation.Right, "UnloadReload", this.LoadedSamples.Count == 0 ? "Reload Samples" : "Unload Samples"); this.TrayManager.CreateButton(TrayLocation.Right, "Configure", "Configure"); this.TrayManager.CreateButton(TrayLocation.Right, "Quit", "Quit"); // // create sample viewing controls this.TitleLabel = this.TrayManager.CreateLabel(TrayLocation.Left, "SampleTitle", ""); this.DescBox = this.TrayManager.CreateTextBox(TrayLocation.Left, "SampleInfo", "Sample Info", 250, 208); this.CategoryMenu = this.TrayManager.CreateThickSelectMenu(TrayLocation.Left, "CategoryMenu", "Select Category", 250, 10); this.SampleMenu = this.TrayManager.CreateThickSelectMenu(TrayLocation.Left, "SampleMenu", "Select Sample", 250, 10); this.SampleSlider = this.TrayManager.CreateThickSlider(TrayLocation.Left, "SampleSlider", "Slide Samples", 250, 80, 0, 0, 0); /* Sliders do not notify their listeners on creation, so we manually call the callback here to format the slider value correctly. */ SliderMoved(this.SampleSlider); // create configuration screen button tray this.TrayManager.CreateButton(TrayLocation.None, "Apply", "Apply Changes"); this.TrayManager.CreateButton(TrayLocation.None, "Back", "Go Back"); // create configuration screen label and renderer menu this.TrayManager.CreateLabel(TrayLocation.None, "ConfigLabel", "Configuration"); this.RendererMenu = this.TrayManager.CreateLongSelectMenu(TrayLocation.None, "RendererMenu", "Render System", 450, 240, 10); this.TrayManager.CreateSeparator(TrayLocation.None, "ConfigSeparator"); // populate render system names var rsNames = from rs in Root.RenderSystems.Values select rs.Name; this.RendererMenu.Items = rsNames.ToList(); PopulateSampleMenus(); }
/// <summary> /// Sets up main page for browsing samples. /// </summary> protected virtual void SetupWidgets() { this.TrayManager.DestroyAllWidgets(); // create main navigation tray this.TrayManager.ShowLogo( TrayLocation.Right ); this.TrayManager.CreateSeparator( TrayLocation.Right, "LogoSep" ); this.TrayManager.CreateButton( TrayLocation.Right, "StartStop", "Start Sample" ); this.TrayManager.CreateButton( TrayLocation.Right, "UnloadReload", this.LoadedSamples.Count == 0 ? "Reload Samples" : "Unload Samples" ); this.TrayManager.CreateButton( TrayLocation.Right, "Configure", "Configure" ); this.TrayManager.CreateButton( TrayLocation.Right, "Quit", "Quit" ); // // create sample viewing controls this.TitleLabel = this.TrayManager.CreateLabel( TrayLocation.Left, "SampleTitle", "" ); this.DescBox = this.TrayManager.CreateTextBox( TrayLocation.Left, "SampleInfo", "Sample Info", 250, 208 ); this.CategoryMenu = this.TrayManager.CreateThickSelectMenu( TrayLocation.Left, "CategoryMenu", "Select Category", 250, 10 ); this.SampleMenu = this.TrayManager.CreateThickSelectMenu( TrayLocation.Left, "SampleMenu", "Select Sample", 250, 10 ); this.SampleSlider = this.TrayManager.CreateThickSlider( TrayLocation.Left, "SampleSlider", "Slide Samples", 250, 80, 0, 0, 0 ); /* Sliders do not notify their listeners on creation, so we manually call the callback here to format the slider value correctly. */ SliderMoved( this.SampleSlider ); // create configuration screen button tray this.TrayManager.CreateButton( TrayLocation.None, "Apply", "Apply Changes" ); this.TrayManager.CreateButton( TrayLocation.None, "Back", "Go Back" ); // create configuration screen label and renderer menu this.TrayManager.CreateLabel( TrayLocation.None, "ConfigLabel", "Configuration" ); this.RendererMenu = this.TrayManager.CreateLongSelectMenu( TrayLocation.None, "RendererMenu", "Render System", 450, 240, 10 ); this.TrayManager.CreateSeparator( TrayLocation.None, "ConfigSeparator" ); // populate render system names var rsNames = from rs in Root.RenderSystems.Values select rs.Name; this.RendererMenu.Items = rsNames.ToList(); PopulateSampleMenus(); }
/// <summary> /// /// </summary> /// <param name="menu"></param> public virtual void ItemSelected( SelectMenu menu ) { if ( menu == this.CategoryMenu ) // category changed, so update the sample menu, carousel, and slider { for ( int i = 0; i < this.Thumbs.Count; i++ ) // destroy all thumbnails in carousel { MaterialManager.Instance.Remove( this.Thumbs[ i ].Name ); Widget.NukeOverlayElement( this.Thumbs[ i ] ); } this.Thumbs.Clear(); OverlayManager om = OverlayManager.Instance; String selectedCategory = string.Empty; if ( menu.SelectionIndex != -1 ) { selectedCategory = menu.SelectedItem; } else { this.TitleLabel.Caption = ""; this.DescBox.Text = ""; } bool all = selectedCategory == "All"; var sampleTitles = new List<string>(); var templateMat = (Material)MaterialManager.Instance.GetByName( "SampleThumbnail" ); // populate the sample menu and carousel with filtered samples foreach ( Sample i in this.LoadedSamples ) { Collections.NameValuePairList info = i.Metadata; if ( all || info[ "Category" ] == selectedCategory ) { String name = "SampleThumb" + sampleTitles.Count + 1; // clone a new material for sample thumbnail Material newMat = templateMat.Clone( name ); TextureUnitState tus = newMat.GetTechnique( 0 ).GetPass( 0 ).GetTextureUnitState( 0 ); if ( ResourceGroupManager.Instance.ResourceExists( "Essential", info[ "Thumbnail" ] ) ) { tus.SetTextureName( info[ "Thumbnail" ] ); } else { tus.SetTextureName( "thumb_error.png" ); } // create sample thumbnail overlay var bp = (Overlays.Elements.BorderPanel)om.Elements.CreateElementFromTemplate( "SdkTrays/Picture", "BorderPanel", name ); bp.HorizontalAlignment = HorizontalAlignment.Right; bp.VerticalAlignment = VerticalAlignment.Center; bp.MaterialName = name; bp.UserData = i; this.TrayManager.TraysLayer.AddElement( bp ); // add sample thumbnail and title this.Thumbs.Add( bp ); sampleTitles.Add( i.Metadata[ "Title" ] ); } } this.CarouselPlace = 0; // reset carousel this.SampleMenu.Items = sampleTitles; if ( this.SampleMenu.ItemsCount != 0 ) { ItemSelected( this.SampleMenu ); } this.SampleSlider.SetRange( 1, sampleTitles.Count, sampleTitles.Count ); } else if ( menu == this.SampleMenu ) // sample changed, so update slider, label and description { if ( this.SampleSlider.Value != menu.SelectionIndex + 1 ) { this.SampleSlider.Value = menu.SelectionIndex + 1; } var s = (Sample)( this.Thumbs[ menu.SelectionIndex ].UserData ); this.TitleLabel.Caption = menu.SelectedItem; this.DescBox.Text = "Category: " + s.Metadata[ "Category" ] + "\nDescription: " + s.Metadata[ "Description" ]; if ( CurrentSample != s ) { ( (Button)this.TrayManager.GetWidget( "StartStop" ) ).Caption = "Start Sample"; } else { ( (Button)this.TrayManager.GetWidget( "StartStop" ) ).Caption = "Stop Sample"; } } else if ( menu == this.RendererMenu ) // renderer selected, so update all settings { while ( this.TrayManager.GetWidgetCount( this.RendererMenu.TrayLocation ) > 3 ) { this.TrayManager.DestroyWidget( this.RendererMenu.TrayLocation, 3 ); } var options = Root.RenderSystems[ menu.SelectionIndex ].ConfigOptions; int i = 0; // create all the config option select menus foreach ( Configuration.ConfigOption it in options ) { SelectMenu optionMenu = this.TrayManager.CreateLongSelectMenu( TrayLocation.Left, "ConfigOption" + i++, it.Name, 450, 240, 10 ); optionMenu.Items = (List<string>)it.PossibleValues.Values.ToList(); // if the current config value is not in the menu, add it try { optionMenu.SelectItem( it.Value ); } catch ( Exception ) { optionMenu.AddItem( it.Value ); optionMenu.SelectItem( it.Value ); } } WindowResized( RenderWindow ); } }
/// <summary> /// /// </summary> protected override void Shutdown() { if ( this.TrayManager != null ) { this.TrayManager = null; } if ( CurrentSample == null ) { DestroyDummyScene(); } this.CategoryMenu = null; this.SampleMenu = null; this.SampleSlider = null; this.TitleLabel = null; this.DescBox = null; this.RendererMenu = null; this.HiddenOverlays.Clear(); this.Thumbs.Clear(); this.CarouselPlace = 0; base.Shutdown(); UnloadSamples(); }
/// <summary> /// /// </summary> /// <param name="menu"></param> public virtual void ItemSelected(SelectMenu menu) { if (menu == this.CategoryMenu) // category changed, so update the sample menu, carousel, and slider { for (int i = 0; i < this.Thumbs.Count; i++) // destroy all thumbnails in carousel { MaterialManager.Instance.Remove(this.Thumbs[i].Name); Widget.NukeOverlayElement(this.Thumbs[i]); } this.Thumbs.Clear(); OverlayManager om = OverlayManager.Instance; String selectedCategory = string.Empty; if (menu.SelectionIndex != -1) { selectedCategory = menu.SelectedItem; } else { this.TitleLabel.Caption = ""; this.DescBox.Text = ""; } bool all = selectedCategory == "All"; var sampleTitles = new List <string>(); var templateMat = (Material)MaterialManager.Instance.GetByName("SampleThumbnail"); // populate the sample menu and carousel with filtered samples foreach (Sample i in this.LoadedSamples) { Collections.NameValuePairList info = i.Metadata; if (all || info["Category"] == selectedCategory) { String name = "SampleThumb" + sampleTitles.Count + 1; // clone a new material for sample thumbnail Material newMat = templateMat.Clone(name); TextureUnitState tus = newMat.GetTechnique(0).GetPass(0).GetTextureUnitState(0); if (ResourceGroupManager.Instance.ResourceExists("Essential", info["Thumbnail"])) { tus.SetTextureName(info["Thumbnail"]); } else { tus.SetTextureName("thumb_error.png"); } // create sample thumbnail overlay var bp = (Overlays.Elements.BorderPanel)om.Elements.CreateElementFromTemplate("SdkTrays/Picture", "BorderPanel", name); bp.HorizontalAlignment = HorizontalAlignment.Right; bp.VerticalAlignment = VerticalAlignment.Center; bp.MaterialName = name; bp.UserData = i; this.TrayManager.TraysLayer.AddElement(bp); // add sample thumbnail and title this.Thumbs.Add(bp); sampleTitles.Add(i.Metadata["Title"]); } } this.CarouselPlace = 0; // reset carousel this.SampleMenu.Items = sampleTitles; if (this.SampleMenu.ItemsCount != 0) { ItemSelected(this.SampleMenu); } this.SampleSlider.SetRange(1, sampleTitles.Count, sampleTitles.Count); } else if (menu == this.SampleMenu) // sample changed, so update slider, label and description { if (this.SampleSlider.Value != menu.SelectionIndex + 1) { this.SampleSlider.Value = menu.SelectionIndex + 1; } var s = (Sample)(this.Thumbs[menu.SelectionIndex].UserData); this.TitleLabel.Caption = menu.SelectedItem; this.DescBox.Text = "Category: " + s.Metadata["Category"] + "\nDescription: " + s.Metadata["Description"]; if (CurrentSample != s) { ((Button)this.TrayManager.GetWidget("StartStop")).Caption = "Start Sample"; } else { ((Button)this.TrayManager.GetWidget("StartStop")).Caption = "Stop Sample"; } } else if (menu == this.RendererMenu) // renderer selected, so update all settings { while (this.TrayManager.GetWidgetCount(this.RendererMenu.TrayLocation) > 3) { this.TrayManager.DestroyWidget(this.RendererMenu.TrayLocation, 3); } var options = Root.RenderSystems[menu.SelectionIndex].ConfigOptions; int i = 0; // create all the config option select menus foreach (Configuration.ConfigOption it in options) { SelectMenu optionMenu = this.TrayManager.CreateLongSelectMenu(TrayLocation.Left, "ConfigOption" + i++, it.Name, 450, 240, 10); optionMenu.Items = (List <string>)it.PossibleValues.Values.ToList(); // if the current config value is not in the menu, add it try { optionMenu.SelectItem(it.Value); } catch (Exception) { optionMenu.AddItem(it.Value); optionMenu.SelectItem(it.Value); } } WindowResized(RenderWindow); } }
/// <summary> /// /// </summary> /// <param name="trayLoc"></param> /// <param name="name"></param> /// <param name="caption"></param> /// <param name="width"></param> /// <param name="maxItemsShown"></param> /// <param name="items"></param> /// <returns></returns> public SelectMenu CreateThickSelectMenu( TrayLocation trayLoc, String name, DisplayString caption, Real width, int maxItemsShown, IList<String> items ) { var sm = new SelectMenu( name, caption, width, 0, maxItemsShown ); MoveWidgetToTray( sm, trayLoc ); sm.AssignedTrayListener = this.listener; if ( !( items.Count == 0 ) ) { sm.Items = items; } return sm; }
/// <summary> /// /// </summary> /// <param name="menu"></param> public void ItemSelected( SelectMenu menu ) { }
/// <summary> /// /// </summary> /// <param name="trayLoc"></param> /// <param name="name"></param> /// <param name="caption"></param> /// <param name="width"></param> /// <param name="boxWidth"></param> /// <param name="maxItemsShown"></param> /// <param name="items"></param> /// <returns></returns> public SelectMenu CreateLongSelectMenu( TrayLocation trayLoc, String name, DisplayString caption, Real width, Real boxWidth, int maxItemsShown, IList<String> items ) { SelectMenu sm = new SelectMenu( name, caption, width, boxWidth, maxItemsShown ); MoveWidgetToTray( sm, trayLoc ); sm.AssignedTrayListener = listener; if ( !( items.Count == 0 ) ) sm.Items = items; return sm; }