Exemple #1
0
 private void ReplaceTextIfNeeded(IScript script,
                                  IScriptEditorControl scriptEditorControl)
 {
     if (_dialog.IsReplace && TextToFindIsCurrentlySelected(scriptEditorControl))
     {
         scriptEditorControl.ReplaceSelectedText(_dialog.TextToReplaceWith);
     }
 }
Exemple #2
0
        private ScriptTokenReference FindReplaceNextOccurence(bool showAll, 
            ref bool foundOneReference, bool jumpToStart, 
            List<ScriptTokenReference> results, IScript script, 
            ref IScriptEditorControl scriptEditorControl)
        {
            ScriptTokenReference scriptTokenReference;

            if ((_dialog.IsReplace) && (TextToFindIsCurrentlySelected(scriptEditorControl)))
            {
                scriptTokenReference = scriptEditorControl.GetTokenReferenceForCurrentState();
            }
            else
            {
                scriptTokenReference = scriptEditorControl.FindNextOccurrence(_dialog.TextToFind, _dialog.CaseSensitive, jumpToStart);
            }

            if ((scriptTokenReference != null) && showAll && _dialog.IsReplace)
            {
                // get a visible editor if we need to make changes to the text
                scriptEditorControl = Factory.GUIController.GetScriptEditorControl(script.FileName, true);
            }

            while (scriptTokenReference != null)
            {
                foundOneReference = true;

                ZoomToFileIfNeeded(script, ref scriptEditorControl, 
                    scriptTokenReference, showAll);
                ReplaceTextIfNeeded(script, scriptEditorControl);

                if (showAll)
                {
                    if (scriptTokenReference.Script == null)
                    {
                        scriptTokenReference.Script = script;
                    }
                    results.Add(scriptTokenReference);

                    scriptTokenReference = scriptEditorControl.FindNextOccurrence(_dialog.TextToFind, _dialog.CaseSensitive, jumpToStart);
                }
                else if (_dialog.IsReplace)
                {
                    scriptTokenReference = scriptEditorControl.FindNextOccurrence(_dialog.TextToFind, _dialog.CaseSensitive, jumpToStart);
                    break;
                }
                else
                {
                    break;
                }
            }
            return scriptTokenReference;
        }
Exemple #3
0
 private void ZoomToFileIfNeeded(IScript script, 
     ref IScriptEditorControl scriptEditorControl,
     ScriptTokenReference scriptTokenReference, bool showAll)
 {
     if (showAll && !_dialog.IsReplace) return;
     if (TextToFindIsCurrentlySelected(scriptEditorControl))
     {
         int startPos = scriptEditorControl.CursorPosition - _dialog.TextToFind.Length;
         Factory.GUIController.ZoomToFile(script.FileName, ZoomToFileZoomType.ZoomToCharacterPosition,
             startPos, false, false, null, false);
         scriptEditorControl = Factory.GUIController.GetScriptEditorControl(script.FileName, false);
         scriptEditorControl.SetSelection(startPos, _dialog.TextToFind.Length);                
         scriptEditorControl.ActivateTextEditor();
         _dialog.Activate();
     }
 }
Exemple #4
0
        private bool FindReplaceInScript(bool showAll, ref int currentScript, 
            ref bool foundOneReference, bool jumpToStart, 
            List<IScript> scriptsForFindReplace, 
            List<ScriptTokenReference> results)
        {
            IScript script = scriptsForFindReplace[currentScript];
            
            IScriptEditorControl scriptEditorControl = Factory.GUIController.GetScriptEditorControl(script.FileName, false);

            if (scriptEditorControl != null)
            {
                if (showAll)
                {
                    ResetSelection(scriptEditorControl);
                }
                else
                {
                    //scriptEditorControl.ActivateTextEditor();
                }

                ScriptTokenReference scriptTokenReference =
                    FindReplaceNextOccurence(showAll,
                    ref foundOneReference, jumpToStart,
                    results, script, ref scriptEditorControl);

                if (scriptTokenReference != null && scriptTokenReference.Script == null)
                {
                    scriptTokenReference.Script = script;
                }

                if (foundOneReference && !showAll)
                {
                    currentScript = JumpToFirstScriptIfNeeded(currentScript,
                        scriptsForFindReplace, scriptTokenReference);
                    return false;
                }
                if (!showAll)
                {
                    ResetSelection(scriptEditorControl);
                }
            }
            return true;
        }
Exemple #5
0
 private bool TextToFindIsCurrentlySelected(IScriptEditorControl scriptEditorControl)
 {
     return (scriptEditorControl.SelectedText.ToLower() == _dialog.TextToFind.ToLower());
 }
Exemple #6
0
 private void ResetSelection(IScriptEditorControl scriptEditorControl)
 {
     scriptEditorControl.ResetSelection();
 }
Exemple #7
0
 private void ReplaceTextIfNeeded(IScript script, 
     IScriptEditorControl scriptEditorControl)
 {
     if (_dialog.IsReplace && TextToFindIsCurrentlySelected(scriptEditorControl))
         scriptEditorControl.ReplaceSelectedText(_dialog.TextToReplaceWith);            
 }
Exemple #8
0
 private void ZoomToFileIfNeeded(IScript script, 
     ref IScriptEditorControl scriptEditorControl,
     ScriptTokenReference scriptTokenReference, bool showAll)
 {
     if (showAll && !_dialog.IsReplace) return;
     if (TextToFindIsCurrentlySelected(scriptEditorControl))
     {
         int startPos = scriptEditorControl.CursorPosition - _dialog.TextToFind.Length;
         Factory.GUIController.ZoomToFile(script.FileName, ZoomToFileZoomType.ZoomToCharacterPosition,
             startPos, false, false, null, false);
         scriptEditorControl = Factory.GUIController.GetScriptEditorControl(script.FileName, false);
         scriptEditorControl.SetSelection(startPos, _dialog.TextToFind.Length);                
         scriptEditorControl.ActivateTextEditor();
         _dialog.Activate();
     }
 }
Exemple #9
0
 private bool TextToFindIsCurrentlySelected(IScriptEditorControl scriptEditorControl)
 {
     return (scriptEditorControl.SelectedText.ToLower() == _dialog.TextToFind.ToLower());
 }
Exemple #10
0
        private ScriptTokenReference FindReplaceNextOccurence(bool showAll, 
            ref bool foundOneReference, bool jumpToStart, 
            List<ScriptTokenReference> results, IScript script, 
            ref IScriptEditorControl scriptEditorControl)
        {
            ScriptTokenReference scriptTokenReference;

            if ((_dialog.IsReplace) && (TextToFindIsCurrentlySelected(scriptEditorControl)))
            {
                scriptTokenReference = scriptEditorControl.GetTokenReferenceForCurrentState();
            }
            else
            {
                scriptTokenReference = scriptEditorControl.FindNextOccurrence(_dialog.TextToFind, _dialog.CaseSensitive, jumpToStart);
            }

            if ((scriptTokenReference != null) && showAll && _dialog.IsReplace)
            {
                // get a visible editor if we need to make changes to the text
                scriptEditorControl = Factory.GUIController.GetScriptEditorControl(script.FileName, true);
            }

            while (scriptTokenReference != null)
            {
                foundOneReference = true;

                ZoomToFileIfNeeded(script, ref scriptEditorControl, 
                    scriptTokenReference, showAll);
                ReplaceTextIfNeeded(script, scriptEditorControl);

                if (showAll)
                {
                    if (scriptTokenReference.Script == null)
                    {
                        scriptTokenReference.Script = script;
                    }
                    results.Add(scriptTokenReference);

                    scriptTokenReference = scriptEditorControl.FindNextOccurrence(_dialog.TextToFind, _dialog.CaseSensitive, jumpToStart);
                }
                else if (_dialog.IsReplace)
                {
                    scriptTokenReference = scriptEditorControl.FindNextOccurrence(_dialog.TextToFind, _dialog.CaseSensitive, jumpToStart);
                    break;
                }
                else
                {
                    break;
                }
            }
            return scriptTokenReference;
        }
Exemple #11
0
 private void ResetSelection(IScriptEditorControl scriptEditorControl)
 {
     scriptEditorControl.ResetSelection();
 }