예제 #1
0
        public static XamDataTreeNode ExpandAndSelectHierObject(object hierarchyObject, XamDataTree xamTree)
        {
            var pathToFounded = new ConcurrentStack <object>();

#if DEBUG
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
#endif
            var source = xamTree.ItemsSource as IEnumerable <object>;
            if (source == null)
            {
                return(null);
            }

            var foundedObject = FinderHelper.FindFirstElementAsync(source, hierarchyObject, pathToFounded);
#if DEBUG
            sw.Stop();
            Console.WriteLine("Поиск {0} млс", sw.ElapsedMilliseconds);
#endif
            if (foundedObject == null || pathToFounded.Count <= 0)
            {
                return(null);
            }
            return(xamTree.ExpandAndSelectXamTreeSync(pathToFounded, true));
        }
예제 #2
0
        private static void ExpandAndSelectUaNodeXamTree(UaFindNodeResult findedNodeResult, XamDataTree xamTree)
        {
            if (!findedNodeResult.FdUaNodeId.HasValue)
            {
                return;
            }

            //Родитель через который идет переход на обычные узлы FreeHierarchy
            var parentNode = UAHierarchyDictionaries.UANodesDict[findedNodeResult.FdUaNodeId.Value];

            if (parentNode == null)
            {
                return;
            }

            //Непосредственный родитель
            var pathToFounded = new ConcurrentStack <object>();

#if DEBUG
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
#endif
            var foundedObject = FinderHelper.FindFirstElementAsync(xamTree.ItemsSource as IEnumerable <object>, parentNode, pathToFounded);
#if DEBUG
            sw.Stop();
            Console.WriteLine("Поиск 1 {0} млс", sw.ElapsedMilliseconds);
#endif
            var treeItem = foundedObject as FreeHierarchyTreeItem;
            if (treeItem != null && treeItem.Descriptor != null)
            {
                //Подгружаем объекты
                treeItem.ReloadUaNodeBranch(new Queue <long>(findedNodeResult.ParentIds.Skip(1)));
            }
            pathToFounded.Clear();

#if DEBUG
            sw.Restart();
#endif
            foundedObject = FinderHelper.FindFirstElementAsync(xamTree.ItemsSource as IEnumerable <object>, findedNodeResult.Node, pathToFounded);
#if DEBUG
            sw.Stop();
            Console.WriteLine("Поиск 2 {0} млс", sw.ElapsedMilliseconds);
#endif
            //На данный момент объект подгружен, просто позиционируем на него
            if (foundedObject != null && pathToFounded.Count > 0)
            {
                xamTree.ExpandAndSelectXamTreeAsync(pathToFounded, false);
            }
        }