Esempio n. 1
0
        public void MakeHierarchy(IHierarchicalInfoAnalyser[] analysers, bool[] orders)
        {
            CardViewModel saveSelected = null;

            if (Selected is HierarchicalResultNodeViewModel selected)
            {
                saveSelected = selected.Card;
            }

            _buildingRoot.Children.Clear();
            _globalStatictics.Reset();

            foreach (CardViewModel card in _getCardViewModels(Name))
            {
                MakeHierarchy(analysers, orders, card);
                _globalStatictics.Add(card);
            }

            Root = (new List <HierarchicalResultViewModel> {
                _buildingRoot
            });

            if (saveSelected != null)
            {
                HierarchicalResultNodeViewModel bestmatch = FindBestName(_buildingRoot, saveSelected);
                if (bestmatch != null)
                {
                    Selected = bestmatch;
                }
            }
        }
Esempio n. 2
0
        private Matching FindBestMatch(HierarchicalResultNodeViewModel hrnvm, CardViewModel saveSelected)
        {
            if (hrnvm == null || hrnvm.Card == null)
            {
                return(Matching.None);
            }

            CardViewModel card = hrnvm.Card;

            if (card.Name != saveSelected.Name)
            {
                return(Matching.None);
            }

            return(card.IdGatherer == saveSelected.IdGatherer ? Matching.Full : Matching.Name);
        }
Esempio n. 3
0
        private HierarchicalResultNodeViewModel FindBestName(HierarchicalResultViewModel toInspect, CardViewModel saveSelected)
        {
            if (toInspect == null || saveSelected == null)
            {
                return(null);
            }

            HierarchicalResultNodeViewModel res    = null;
            HierarchicalResultNodeViewModel nodevm = toInspect as HierarchicalResultNodeViewModel;
            Matching resMatch = FindBestMatch(nodevm, saveSelected);

            if (resMatch == Matching.Full)
            {
                return(nodevm);
            }

            if (resMatch == Matching.Name)
            {
                res = nodevm;
            }

            foreach (HierarchicalResultViewModel child in toInspect.Children)
            {
                nodevm = FindBestName(child, saveSelected);

                resMatch = FindBestMatch(nodevm, saveSelected);
                if (resMatch == Matching.Full)
                {
                    return(nodevm);
                }

                if (resMatch == Matching.Name && res == null)
                {
                    res = nodevm;
                }
            }

            return(res);
        }