Esempio n. 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));
        }
Esempio n. 2
0
        private static void ExpandParentAndSelectObjectXceedGrid(enumTypeHierarchy parentType, int parentId,
                                                                 IFreeHierarchyObject hierarchyObject, DataGridControl xamTree)
        {
            IFreeHierarchyObject parent = null;

            switch (parentType)
            {
            case enumTypeHierarchy.Dict_PS:
            case enumTypeHierarchy.USPD:
            case enumTypeHierarchy.E422:
                parent = EnumClientServiceDictionary.DetailPSList[parentId];
                break;

            case enumTypeHierarchy.Info_TP:
                var tps = EnumClientServiceDictionary.GetTps();
                if (tps != null)
                {
                    parent = tps[parentId];
                }
                break;
            }

            if (parent == null)
            {
                return;
            }

            var chain = new Stack();

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

            FinderHelper.FindFirstElement(source, parent, chain);
#if DEBUG
            sw.Stop();
            Console.WriteLine("Поиск {0} млс", sw.ElapsedMilliseconds);
#endif
            if (chain.Count <= 0)
            {
                return;
            }

            var arr = new object[chain.Count];
            chain.CopyTo(arr, 0);
            //Array.Reverse(arr);

            chain = new Stack(arr);

            xamTree.ExpandandSelectXceedGrid(chain, hierarchyObject);
        }
Esempio n. 3
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);
            }
        }