Exemple #1
0
        /// <summary>
        ///		Busca la siguiente coincidencia con el texto
        /// </summary>
        public bool SearchNext(string textToFind, bool upToDown, bool caseSensitive, bool wholeWord, bool useRegex, bool useWildcards)
        {
            Regex regex = GetRegEx(textToFind, upToDown, caseSensitive, wholeWord, useRegex, useWildcards);
            int   start = regex.Options.HasFlag(RegexOptions.RightToLeft) ? txtEditor.SelectionStart : txtEditor.SelectionStart + txtEditor.SelectionLength;
            Match match = regex.Match(txtEditor.Text, start);

            // Si no se ha encontrado nada, comienza de nuevo por el inicio o el final
            // Si se ha encontrado alga, lo selecciona
            if (!match.Success)
            {
                if (regex.Options.HasFlag(RegexOptions.RightToLeft))
                {
                    match = regex.Match(txtEditor.Text, txtEditor.Text.Length);
                }
                else
                {
                    match = regex.Match(txtEditor.Text, 0);
                }
            }
            else
            {
                ICSharpCode.AvalonEdit.Document.TextLocation loc = txtEditor.Document.GetLocation(match.Index);

                // Selecciona el texto
                txtEditor.Select(match.Index, match.Length);
                // Posiciona el control
                txtEditor.ScrollTo(loc.Line, loc.Column);
            }
            // Devuelve el valor que indica si se ha encontrado algo más
            return(match.Success);
        }
        InsertCtorDialog CreateDialog(InsertionContext context)
        {
            ITextEditor textEditor = context.TextArea.GetService(typeof(ITextEditor)) as ITextEditor;

            if (textEditor == null)
            {
                return(null);
            }

            IEditorUIService uiService = textEditor.GetService(typeof(IEditorUIService)) as IEditorUIService;

            if (uiService == null)
            {
                return(null);
            }

            ParseInformation parseInfo = ParserService.GetParseInformation(textEditor.FileName);

            if (parseInfo == null)
            {
                return(null);
            }

            CodeGenerator generator = parseInfo.CompilationUnit.Language.CodeGenerator;

            // cannot use insertion position at this point, because it might not be
            // valid, because we are still generating the elements.
            // DOM is not updated
            ICSharpCode.AvalonEdit.Document.TextLocation loc = context.Document.GetLocation(context.StartPosition);

            IClass current = parseInfo.CompilationUnit.GetInnermostClass(loc.Line, loc.Column);

            if (current == null)
            {
                return(null);
            }

            List <PropertyOrFieldWrapper> parameters = CreateCtorParams(current).ToList();

            if (!parameters.Any())
            {
                return(null);
            }

            ITextAnchor anchor = textEditor.Document.CreateAnchor(context.InsertionPosition);

            anchor.MovementType = AnchorMovementType.BeforeInsertion;

            InsertCtorDialog dialog = new InsertCtorDialog(context, textEditor, anchor, current, parameters);

            dialog.Element = uiService.CreateInlineUIElement(anchor, dialog);

            return(dialog);
        }