示例#1
0
        public IFindInFilesItemActivator FindNearestViableActivator(IFindInFilesItem item, out Form window)
        {
            window = null;
            IFindInFilesItemActivator activator = (IFindInFilesItemActivator)item;

            while (activator != null)
            {
                try
                {
                    window = mainWindow.CreateAndShowEditor(activator.DataObject);
                    break;
                }
                catch (ArgumentException)
                {
                    activator = activator.Parent;
                }
            }
            return(activator);
        }
示例#2
0
        public void SetSelection(IFindInFilesItem item, int startLine, int startChar, int endLine, int endCharPlusOne)
        {
            IFindInFilesItemActivator activator = (IFindInFilesItemActivator)item;

            if (activator.DataObject is NoteObjectRec)
            {
                // special case for track elements
                Form window;
                if (application.FindNearestViableActivator(item, out window) == null)
                {
                    Debug.Assert(false);
                    throw new ArgumentException();
                }
                TrackWindow trackWindow = (TrackWindow)window;
                trackWindow.Edit.View.TrackViewTrySingleNoteOrCommandSelection((NoteObjectRec)activator.DataObject);
            }
            else
            {
                Control edit = FindControl(window.Controls, activator.Property);
                if (edit != null)
                {
                    if (edit is TextEditControl)
                    {
                        ((TextEditControl)edit).SetSelection(startLine, startChar, endLine, endCharPlusOne);
                    }
                    else if (edit is TextBox)
                    {
                        TextBox textBox = (TextBox)edit;
                        int     start   = textBox.GetFirstCharIndexFromLine(startLine) + startChar;
                        int     end     = textBox.GetFirstCharIndexFromLine(endLine) + endCharPlusOne;
                        textBox.SelectionStart  = start;
                        textBox.SelectionLength = end - start;
                    }
                    edit.Focus();
                }
            }
        }