コード例 #1
0
 public MenuDropDownWindow(MenuDropDown parent)
     : base(0, "")
 {
     _scrollBar        = new MenuScrollBar();
     _scrollBar.Width  = 10f;
     _scrollBar.Parent = this;
     _dropMenu         = parent;
 }
コード例 #2
0
        protected void CreateUnitDropDown()
        {
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner;

            if (gH_SwitcherComponent.EvalUnits != null && gH_SwitcherComponent.EvalUnits.Count != 0 && (gH_SwitcherComponent.EvalUnits.Count != 1 || gH_SwitcherComponent.UnitlessExistence))
            {
                MenuPanel menuPanel = new MenuPanel(0, "panel_units");
                menuPanel.Header = "Unit selection";
                string text = gH_SwitcherComponent.UnitMenuName;
                if (text == null)
                {
                    text = "Evaluation Units";
                }
                string text2 = gH_SwitcherComponent.UnitMenuHeader;
                if (text2 == null)
                {
                    text2 = "Select evaluation unit";
                }
                unitMenuCollection = new GH_MenuCollection();
                GH_ExtendableMenu gH_ExtendableMenu = new GH_ExtendableMenu(0, "menu_units");
                gH_ExtendableMenu.Name   = text;
                gH_ExtendableMenu.Header = text2;
                gH_ExtendableMenu.AddControl(menuPanel);
                _UnitDrop = new MenuDropDown(0, "dropdown_units", "units");
                _UnitDrop.VisibleItemCount = 10;
                _UnitDrop.ValueChanged    += _UnitDrop__valueChanged;
                _UnitDrop.Header           = "Evaluation unit selector";
                menuPanel.AddControl(_UnitDrop);
                List <EvaluationUnit> evalUnits = gH_SwitcherComponent.EvalUnits;
                if (gH_SwitcherComponent.UnitlessExistence)
                {
                    _UnitDrop.AddItem("--NONE--", null);
                }
                for (int i = 0; i < evalUnits.Count; i++)
                {
                    _UnitDrop.AddItem(evalUnits[i].Name, evalUnits[i].DisplayName, evalUnits[i]);
                }
                gH_ExtendableMenu.Expand();
                unitMenuCollection.AddMenu(gH_ExtendableMenu);
            }
        }
コード例 #3
0
 private void _UnitDrop__valueChanged(object sender, EventArgs e)
 {
     try
     {
         MenuDropDown       menuDropDown = (MenuDropDown)sender;
         MenuDropDown.Entry entry        = menuDropDown.Items[menuDropDown.Value];
         if (entry.data != null)
         {
             EvaluationUnit evaluationUnit = (EvaluationUnit)entry.data;
             ((GH_SwitcherComponent)base.Owner).SwitchUnit(evaluationUnit.Name);
         }
         else
         {
             ((GH_SwitcherComponent)base.Owner).ClearUnit();
         }
     }
     catch (Exception ex)
     {
         RhinoApp.WriteLine("Error selection:" + ex.StackTrace);
     }
 }