Ejemplo n.º 1
0
            public void Initialize(NavBarItem navItem, int width, ITheme theme, int depth)
            {
                _navItem = navItem;
                _theme   = theme;
                _depth   = depth;

                Height    = navItem.Height;
                Width     = width;
                BackColor = theme.BackgroundColor(depth);

                _initialized = true;
            }
Ejemplo n.º 2
0
        private void ResetAll(NavBarItem item)
        {
            foreach (var c in item.Childs)
            {
                c.Selected = false;
                c.Expanded = false;
                c.Content  = false;

                if (c.Childs != null && c.Childs.Count > 0)
                {
                    ResetAll(c);
                }
            }
        }
Ejemplo n.º 3
0
        private void VisibilityItemChild(NavBarItem item, bool visible, int itemID)
        {
            foreach (var c in item.Childs)
            {
                if (c.ID == itemID)
                {
                    c.Visible = visible;
                }

                if (c.Childs != null && c.Childs.Count > 0)
                {
                    VisibilityItemChild(c, visible, itemID);
                }
            }
        }
Ejemplo n.º 4
0
        private void EnableItemChild(NavBarItem item, bool enable, int itemID)
        {
            foreach (var c in item.Childs)
            {
                if (c.ID == itemID)
                {
                    c.Enabled = enable;
                }

                if (c.Childs != null && c.Childs.Count > 0)
                {
                    EnableItemChild(c, enable, itemID);
                }
            }
        }
Ejemplo n.º 5
0
        private void ResetAllSelect(NavBarItem item, int itemID)
        {
            foreach (var c in item.Childs)
            {
                c.Selected = false;
                c.Expanded = false;
                c.Content  = false;

                if (c.ID == itemID)
                {
                    _JRIT_item = c;
                }

                if (c.Childs != null && c.Childs.Count > 0)
                {
                    ResetAllSelect(c, itemID);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Select item in run-time
        /// </summary>
        /// <param name="itemID">item ID we want to select</param>
        public void ItemSelect(int itemID)
        {
            foreach (var nbi in _navBarItems)
            {
                nbi.Selected = false;
                nbi.Expanded = false;
                nbi.Content  = false;
                if (nbi.ID == itemID)
                {
                    _JRIT_item = nbi;
                }

                if (nbi.Childs != null && nbi.Childs.Count > 0)
                {
                    ResetAllSelect(nbi, itemID);
                }
            }

            OnItemClick(_JRIT_item);
        }
Ejemplo n.º 7
0
        private void AddChild(NavBarItem item, int parentID, string text, int itemID, int leftChild = 10)
        {
            foreach (var c in item.Childs)
            {
                if (c.ID == parentID)
                {
                    if (c.Childs == null)
                    {
                        c.Childs = new List <NavBarItem>();
                    }

                    NavBarItem newItem = new NavBarItem {
                        ID = itemID, ParentID = parentID, Text = text, LeftChild = leftChild
                    };

                    c.Childs.Add(newItem);
                }

                if (c.Childs != null && c.Childs.Count > 0)
                {
                    AddChild(c, parentID, text, itemID, leftChild);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// This item is fired when we click on a NavBarItemPanel UserControl
        /// </summary>
        /// <param name="item"></param>
        private void OnItemClick(NavBarItem item)
        {
            // By default we 'reset' all items as:
            // Not selected
            // Not expanded
            // Not Content
            // -----------------------------------------------------------------------------------------

            foreach (var nbi in _navBarItems)
            {
                nbi.Selected = false;
                nbi.Expanded = false;
                nbi.Content  = false;
                if (nbi.Childs != null && nbi.Childs.Count > 0)
                {
                    ResetAll(nbi);
                }
            }
            // -----------------------------------------------------------------------------------------

            _parentID_List = new List <int>();
            GetAllParents(item);
            _parentID_List = _parentID_List.Distinct().ToList();
            _parentID_List.Reverse();

            _bChildFound = false;

            // Get the 1st available item :
            if (item.Childs != null && item.Childs.Count > 0)
            {
                GetFirsAvailable(item);
            }

            _parentID_index = 0;

            foreach (var nbi in _navBarItems)
            {
                if (nbi.ID == _parentID_List[0])
                {
                    _parentID_index += 1;
                    nbi.Selected     = true;
                    nbi.Expanded     = true;
                    if (_parentID_List.Count == 1)
                    {
                        nbi.Content = true;

                        if (item.ParentID != null)
                        {
                            var p = _navBarItems.Find(c => c.ID == item.ParentID);
                            p.Selected = true;
                            p.Expanded = true;

                            item.Selected     = true;
                            finalSelectedItem = item;
                            if (SelectedItem != null)
                            {
                                SelectedItem.Invoke(item);
                            }
                            break; // foreach Exit For
                        }
                        else // autoexpand first child or root
                        {
                            if (nbi.Childs != null && nbi.Childs.Count > 0)
                            {
                                nbi.Childs[0].Selected = true;
                                finalSelectedItem      = nbi.Childs[0];
                                if (SelectedItem != null)
                                {
                                    SelectedItem.Invoke(nbi.Childs[0]);
                                }
                            }
                            else
                            {
                                finalSelectedItem = item;
                                if (SelectedItem != null)
                                {
                                    SelectedItem.Invoke(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        AutoExpand(item, nbi);
                    }
                }
            }

            _parentID_index = 0;

            DrawControlItems();
        }
Ejemplo n.º 9
0
        private void AutoExpand(NavBarItem clickedItem, NavBarItem item)
        {
            foreach (var nbi in item.Childs)
            {
                if (_parentID_index == _parentID_List.Count)
                {
                    break; // foreach Exit For
                }
                if (nbi.ID == _parentID_List[_parentID_index])
                {
                    _parentID_index += 1;
                    nbi.Selected     = true;
                    nbi.Expanded     = true;
                    if (_parentID_index < _parentID_List.Count)
                    {
                        AutoExpand(clickedItem, nbi);
                    }
                    else
                    {
                        if (nbi.ParentID == clickedItem.ParentID | (clickedItem.ParentID == null))
                        {
                            nbi.Content            = true;
                            nbi.Childs[0].Selected = true;
                            finalSelectedItem      = nbi.Childs[0];
                            if (SelectedItem != null)
                            {
                                SelectedItem.Invoke(nbi.Childs[0]);
                            }
                        }
                        else
                        {
                            bool selected = false;
                            foreach (var nbic in nbi.Childs)
                            {
                                if ((nbic.ID == clickedItem.ID))
                                {
                                    nbi.Content       = true;
                                    nbic.Selected     = true;
                                    nbi.Expanded      = true;
                                    finalSelectedItem = clickedItem;
                                    selected          = true;
                                    if (SelectedItem != null)
                                    {
                                        SelectedItem.Invoke(clickedItem);
                                    }
                                    break; // foreach Exit For
                                }
                            }

                            if (!selected)
                            {
                                nbi.Content            = true;
                                nbi.Childs[0].Selected = true;
                                finalSelectedItem      = nbi.Childs[0];
                                if (SelectedItem != null)
                                {
                                    SelectedItem.Invoke(nbi.Childs[0]);
                                }
                            }
                        }
                        break; // foreach Exit For
                    }
                }
            }
        }