Ejemplo n.º 1
0
        public FindManager(IFindView view)
        {
            if (view == null)
                throw new ArgumentNullException("view");

            _view = view;

            object obj;
            ErrorUtil.ThrowOnFailure(((INiLocalRegistry)_view.GetService(typeof(INiLocalRegistry))).CreateInstance(
                new Guid(NiConstants.FindHelper),
                _view,
                out obj
            ));

            _findHelper = (INiFindHelper)obj;

            LoadSettings();
        }
Ejemplo n.º 2
0
        public FindManager(IFindView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            _view = view;

            object obj;

            ErrorUtil.ThrowOnFailure(((INiLocalRegistry)_view.GetService(typeof(INiLocalRegistry))).CreateInstance(
                                         new Guid(NiConstants.FindHelper),
                                         _view,
                                         out obj
                                         ));

            _findHelper = (INiFindHelper)obj;

            LoadSettings();
        }
Ejemplo n.º 3
0
        private void PerformFindSingle()
        {
            if (_state.BeforeFirst)
            {
                _state.BeforeFirst = false;

                if (!_state.Iterator.MoveNext())
                {
                    NoMoreOccurrences();
                    return;
                }
            }

            if (FindTarget != null)
            {
                PerformSingleFind(FindTarget);
                return;
            }

            do
            {
                string documentName = _state.Iterator.DocumentName;

                INiHierarchy   hier;
                INiWindowFrame windowFrame;
                ErrorUtil.ThrowOnFailure(((INiOpenDocumentManager)_view.GetService(typeof(INiOpenDocumentManager))).IsDocumentOpen(
                                             documentName,
                                             out hier,
                                             out windowFrame
                                             ));

                if (windowFrame == null)
                {
                    // Check whether the file has any match at all.

                    if (!HasAnyMatch(_state.Iterator.AllText))
                    {
                        continue;
                    }

                    // If we found a match, open the window frame and retry.

                    var activeProject = ((INiProjectManager)_view.GetService(typeof(INiProjectManager))).ActiveProject;

                    if (activeProject != null)
                    {
                        hier = activeProject.FindByDocument(documentName);

                        if (hier != null)
                        {
                            ErrorUtil.ThrowOnFailure(activeProject.OpenItem(hier, out windowFrame));
                        }
                    }

                    // If we couldn't open the window frame, continue.

                    if (windowFrame == null)
                    {
                        continue;
                    }
                }

                // Now retry on the window frame.

                var docView = (INiWindowPane)windowFrame.GetPropertyEx(NiFrameProperty.DocView);
                if (docView != null)
                {
                    var findTarget = docView as INiFindTarget;
                    if (findTarget != null && PerformSingleFind(findTarget))
                    {
                        return;
                    }
                }
            }while (_state.Iterator.MoveNext());

            NoMoreOccurrences();
        }