Пример #1
0
        private IEnumerable<DataNode> FindNode(DataNode node)
        {
            lock (_lock) {
                if (_cancel)
                    yield break;
            }

            if (node == null)
                yield break;

            bool searchExpanded = false;
            if (!node.IsExpanded) {
                node.Expand();
                searchExpanded = true;
            }

            TagDataNode tagNode = node as TagDataNode;
            if (tagNode != null) {
                bool mName = _state.SearchName == null;
                bool mValue = _state.SearchValue == null;

                if (_state.SearchName != null) {
                    string tagName = node.NodeName;
                    if (tagName != null)
                        mName = tagName.Contains(_state.SearchName);
                }
                if (_state.SearchValue != null) {
                    string tagValue = node.NodeDisplay;
                    if (tagValue != null)
                        mValue = tagValue.Contains(_state.SearchValue);
                }

                if (mName && mValue) {
                    InvokeDiscoverCallback(node);
                    yield return node;
                }
            }

            foreach (DataNode sub in node.Nodes) {
                foreach (DataNode s in FindNode(sub))
                    yield return s;
            }

            if (searchExpanded) {
                if (!node.IsModified) {
                    node.Collapse();
                    InvokeCollapseCallback(node);
                }
            }
        }
Пример #2
0
        private IEnumerable<DataNode> FindNode(DataNode node)
        {
            lock (_lock) {
                if (_cancel)
                    yield break;
            }

            if (node == null)
                yield break;

            bool searchExpanded = false;
            if (!node.IsExpanded) {
                node.Expand();
                searchExpanded = true;
            }

            TagDataNode tagNode = node as TagDataNode;
            if (tagNode != null) {
                float currentSampleTime = (float)_progressWatch.Elapsed.TotalSeconds;
                _progressTime += (currentSampleTime - _lastSampleTime);
                _lastSampleTime = currentSampleTime;

                if (_progressTime > _state.ProgressRate) {
                    InvokeProgressCallback(node);
                    _progressTime -= _state.ProgressRate;
                }

                if (_state.TestNode(tagNode)) {
                    InvokeDiscoverCallback(node);
                    if (_state.TerminateOnDiscover)
                        yield return node;
                }

                /*bool mName = _state.SearchName == null;
                bool mValue = _state.SearchValue == null;

                if (_state.SearchName != null) {
                    string tagName = node.NodeName;
                    if (tagName != null)
                        mName = tagName.Contains(_state.SearchName);
                }
                if (_state.SearchValue != null) {
                    string tagValue = node.NodeDisplay;
                    if (tagValue != null)
                        mValue = tagValue.Contains(_state.SearchValue);
                }

                if (mName && mValue) {
                    InvokeDiscoverCallback(node);
                    yield return node;
                }*/
            }

            using (node.Nodes.Snapshot()) {
                foreach (DataNode sub in node.Nodes) {
                    foreach (DataNode s in FindNode(sub))
                        yield return s;
                }
            }

            /*IList<DataNode> nodeList = node.Nodes;
            for (int i = 0; i < nodeList.Count; i++) {
                int changeset = node.Nodes.ChangeCount;
                foreach (DataNode s in FindNode(nodeList[i])) {

                }
            }

                foreach (DataNode sub in node.Nodes) {
                    foreach (DataNode s in FindNode(sub))
                        yield return s;
                }*/

            if (searchExpanded) {
                if (!node.IsModified) {
                    node.Collapse();
                    InvokeCollapseCallback(node);
                }
            }
        }