Axiom.Samples.SelectMenu.SelectItem C# (CSharp) Метод

SelectItem() публичный Метод

public SelectItem ( String item ) : void
item String
Результат void
		public void SelectItem( String item )
		{
			SelectItem( item, true );
		}

Same methods

SelectMenu::SelectItem ( String item, bool notifyListener ) : void
SelectMenu::SelectItem ( int index ) : void
SelectMenu::SelectItem ( int index, bool notifyListener ) : void

Usage Example

Пример #1
0
        /// <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);
            }
        }