예제 #1
0
        protected override void OnInitialize()
        {
            title = "Toolbox";

            m_buttonMapping = new Dictionary<Button, CachedControl>();
            m_controlsCache = new ToolboxControlCache();

            m_root = new Control();
            m_root.AddDecorator( new StackContent( StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow ) );
            m_root.AddDecorator( new Scrollbars( true, false, true ) );
            m_root.SetSize( 100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage );

            // Create category foldouts, index them by name so we can assign our controls
            Dictionary< string, FoldoutList > foldouts = new Dictionary<string, FoldoutList>();

            foreach( string category in m_controlsCache.Categories )
            {
                FoldoutList foldout = new FoldoutList( category, 4.0f, true );
                foldout.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
                m_root.AddChild( foldout );

                foldouts.Add( category, foldout );
            }

            foreach( CachedControl c in m_controlsCache.Controls )
            {
                Button button = new Button( c.name );
                button.SetSize( 100.0f, CONTROL_DISPLAY_HEIGHT, Control.MetricsUnits.Percentage, Control.MetricsUnits.Pixel );
                button.Clicked += HandleControlButtonClick;

                m_buttonMapping.Add( button, c );

                foldouts[ c.category ].AddItem( button );
            }

            AddChild( m_root );
        }
예제 #2
0
        protected override void OnInitialize()
        {
            title = "Toolbox";

            m_buttonMapping = new Dictionary <Button, CachedControl>();
            m_controlsCache = new ToolboxControlCache();

            m_root = new Control();
            m_root.AddDecorator(new StackContent(StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow));
            m_root.AddDecorator(new Scrollbars(true, false, true));
            m_root.SetSize(100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage);

            // Create category foldouts, index them by name so we can assign our controls
            Dictionary <string, FoldoutList> foldouts = new Dictionary <string, FoldoutList>();

            foreach (string category in m_controlsCache.Categories)
            {
                FoldoutList foldout = new FoldoutList(category, 4.0f, true);
                foldout.SetWidth(100.0f, Control.MetricsUnits.Percentage);
                m_root.AddChild(foldout);

                foldouts.Add(category, foldout);
            }

            foreach (CachedControl c in m_controlsCache.Controls)
            {
                Button button = new Button(c.name);
                button.SetSize(100.0f, CONTROL_DISPLAY_HEIGHT, Control.MetricsUnits.Percentage, Control.MetricsUnits.Pixel);
                button.Clicked += HandleControlButtonClick;

                m_buttonMapping.Add(button, c);

                foldouts[c.category].AddItem(button);
            }

            AddChild(m_root);
        }