Esempio n. 1
0
        public IUSHierarchyItem GetParentOf(IUSHierarchyItem item)
        {
            if (RootItems.Contains(item))
            {
                return(null);
            }

            IUSHierarchyItem itemsParent = null;

            for (var i = 0; i < RootItems.Count; i++)
            {
                itemsParent = GetParentOfChild(RootItems[i], item);
                if (itemsParent != null)
                {
                    break;
                }
            }

            return(itemsParent);
        }
Esempio n. 2
0
        //##############################################################################################################

        //-----------------------------------------------------------------------
        public void FocusItem(DataItem item)
        {
            if (item == m_proxyRootItem)
            {
                m_focusedItemsPath.Clear();
                RootItems.Clear();
                foreach (var child in m_storedRootItems)
                {
                    RootItems.Add(child);
                }
            }
            else if (RootItems.Contains(item))
            {
                return;
            }
            else
            {
                item.Focus();

                m_focusedItemsPath.Clear();

                DataItem current = null;
                if (item is GraphNodeItem)
                {
                    current = (item as GraphNodeItem).LinkParents.FirstOrDefault();
                }
                else
                {
                    current = item.Parent;
                }

                while (current != null)
                {
                    if (current is CollectionChildItem || current is GraphNodeItem || !(current.Parent is CollectionChildItem))
                    {
                        m_focusedItemsPath.Add(current);
                    }

                    if (current is GraphNodeItem)
                    {
                        current = (current as GraphNodeItem).LinkParents.FirstOrDefault();
                    }
                    else
                    {
                        current = current.Parent;
                    }
                }
                m_focusedItemsPath.Remove(m_focusedItemsPath.Last());
                m_focusedItemsPath.Add(m_proxyRootItem);

                for (int i = 0; i < m_focusedItemsPath.Count; i++)
                {
                    m_focusedItemsPath[i].ZIndex    = i;
                    m_focusedItemsPath[i].FirstItem = Visibility.Visible;
                }

                for (int i = 0; i < m_focusedItemsPath.Count; i++)
                {
                    m_focusedItemsPath.Move(m_focusedItemsPath.Count - 1, i);
                }

                m_focusedItemsPath[0].FirstItem = Visibility.Hidden;

                RootItems.Clear();
                RootItems.Add(item);
                item.IsExpanded = true;

                if (m_lastFocusedItem != null)
                {
                    if (m_lastFocusedItem is CollectionItem)
                    {
                        CollectionItem collectionItem = m_lastFocusedItem as CollectionItem;
                        //collectionItem.IsFocused = false;
                    }
                }
                m_lastFocusedItem = item;
                if (m_lastFocusedItem != null)
                {
                    if (m_lastFocusedItem is CollectionItem)
                    {
                        CollectionItem collectionItem = m_lastFocusedItem as CollectionItem;
                        //collectionItem.IsFocused = true;
                    }
                }
            }

            IsFocusing = m_focusedItemsPath.Count > 0;

            RaisePropertyChangedEvent("RootItems");
        }