Esempio n. 1
0
        /// <summary>
        /// Draw child items (Recursive)
        /// </summary>
        /// <param name="item"></param>
        private void DrawChilds(Z80NavBar.NavBarItem item)
        {
            if (item.Expanded & item.Visible)
            {
                foreach (var c in item.Childs)
                {
                    if (c.Visible)
                    {
                        NavBarItemPanel mPanel = new NavBarItemPanel();
                        mPanel.Location  = new Point(0, _item_yLocation);
                        mPanel.Anchor    = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                        _item_yLocation += c.Height;
                        mPanel.Initialize(c, this.Width, _theme, _childDepth);

                        mPanel.ItemClick += OnItemClick;
                        Panel1.Controls.Add(mPanel);

                        if (c.Childs != null && c.Childs.Count > 0)
                        {
                            _childDepth += 1;
                            DrawChilds(c);
                            _childDepth -= 1;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 'MAIN' method that draws all the items
        /// </summary>
        private void DrawControlItems()
        {
            this.BackColor = _theme.BackgroundColor(0);

            Panel1.Controls.Clear();
            Panel1.BackColor = _theme.BackgroundColor(0);

            foreach (var item in _navBarItems)
            {
                _childDepth = 0;

                if (item.Visible)
                {
                    NavBarItemPanel mPanel = new NavBarItemPanel();
                    mPanel.Location  = new Point(0, _item_yLocation);
                    mPanel.Anchor    = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                    _item_yLocation += item.Height;
                    mPanel.Initialize(item, this.Width, _theme, _childDepth);

                    mPanel.ItemClick += OnItemClick;
                    Panel1.Controls.Add(mPanel);

                    if (item.Childs != null && item.Childs.Count > 0)
                    {
                        _childDepth += 1;
                        DrawChilds(item);
                    }
                }
            }

            _item_yLocation = 0;

            foreach (var p in Panel1.Controls.OfType <NavBarItemPanel>())
            {
                if (finalSelectedItem != null)
                {
                    if (p._navItem.ID == finalSelectedItem.ID)
                    {
                        if (p.Location.Y > (this.Height / 2) + (this.Height / 4))
                        {
                            Panel1.AutoScrollPosition = new Point(0, p.Location.Y);
                        }
                    }
                }
            }

            // YES, you are right, this 2 lines are a completely shit:
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }