• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ITextControl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITextControl的典型用法代码示例。如果您正苦于以下问题:C# ITextControl类的具体用法?C# ITextControl怎么用?C# ITextControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITextControl类属于命名空间,在下文中一共展示了ITextControl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AcceptExpression

            protected override void AcceptExpression(
        ITextControl textControl, ISolution solution, TextRange resultRange, ICSharpExpression expression)
            {
                // set selection for introduce field
                textControl.Selection.SetRanges(new[] {TextControlPosRange.FromDocRange(textControl, resultRange)});

                const string name = "IntroFieldAction";
                var rules = DataRules
                  .AddRule(name, ProjectModel.DataContext.DataConstants.SOLUTION, solution)
                  .AddRule(name, DataConstants.DOCUMENT, textControl.Document)
                  .AddRule(name, TextControl.DataContext.DataConstants.TEXT_CONTROL, textControl)
                  .AddRule(name, Psi.Services.DataConstants.SELECTED_EXPRESSION, expression);

                Lifetimes.Using(lifetime =>
                  WorkflowExecuter.ExecuteBatch(
                Shell.Instance.GetComponent<DataContexts>().CreateWithDataRules(lifetime, rules),
                new IntroFieldWorkflow(solution, null)));

                // todo: rename hotspots

                var ranges = textControl.Selection.Ranges.Value;
                if (ranges.Count == 1) // reset selection
                {
                  var endPos = ranges[0].End;
                  textControl.Selection.SetRanges(new[] {new TextControlPosRange(endPos, endPos)});
                }
            }
开发者ID:Restuta,项目名称:PostfixCompletion,代码行数:27,代码来源:IntroduceFieldTemplateProvider.cs


示例2: ExecuteTransactionInner

        /// <inheritdoc />
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            IDeclaration declaration = Utils.GetTypeClosestToTextControl<IDeclaration>(solution, textControl);

            // Fixes SA1604, 1605
            new DocumentationRules().InsertMissingSummaryElement(declaration);
        }
开发者ID:icnocop,项目名称:StyleCop,代码行数:8,代码来源:SA1604ElementDocumentationMustHaveSummaryBulbItem.cs


示例3: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            IElement element = Utils.GetElementAtCaret(solution, textControl);

            if (element == null)
            {
                return;
            }

            IUsingListNode usingList = element.GetContainingElement(typeof(IUsingListNode), false) as IUsingListNode;

            if (usingList == null)
            {
                return;
            }

            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            // This violation will only run if there are some using statements and definately at least 1 namespace
            // so [0] index will always be OK.
            ICSharpNamespaceDeclaration firstNamespace = file.NamespaceDeclarations[0];

            foreach (IUsingDirectiveNode usingDirectiveNode in usingList.Imports)
            {
                firstNamespace.AddImportBefore(usingDirectiveNode, null);

                file.RemoveImport(usingDirectiveNode);
            }
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:38,代码来源:MoveUsings.cs


示例4: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            IRangeMarker marker = this.DocumentRange.CreateRangeMarker();
            file.ArrangeThisQualifier(marker);
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:16,代码来源:PrefixLocalCallsWithThis.cs


示例5: ExecuteTransactionInner

 /// <summary>
 /// The execute transaction inner.
 /// </summary>
 /// <param name="solution">
 /// The solution.
 /// </param>
 /// <param name="textControl">
 /// The text control.
 /// </param>
 public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
 {
     string documentation = this.DocumentRange.GetText();
     Regex regEx = new Regex("(((///[ ^ ] *)))|((///))");
     documentation = regEx.Replace(documentation, "/// ");
     textControl.Document.ReplaceText(this.DocumentRange.TextRange, documentation);
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:16,代码来源:FormatDocumentationHeader.cs


示例6: Execute

        public void Execute(ISolution solution, ITextControl textControl)
        {
            // TODO extract add attribute to another class
            // method name  IDeclaredParameter AddDeclaredParameter()

            if (missedParameterError.Descriptor.IsAttribute)
            {
                IDocument document = textControl.Document;
                using (ModificationCookie cookie = document.EnsureWritable())
                {
                    int navigationOffset = -1;

                    try
                    {
                        CommandProcessor.Instance.BeginCommand("TextControl:AddAttribute");
                        string toInsert = " " + this.missedParameterError.Descriptor.Name + "=\"\"";
                        document.InsertText(this.headerNameRange.TextRange.EndOffset, toInsert);
                        navigationOffset = (this.headerNameRange.TextRange.EndOffset + toInsert.Length) - 1;
                    }
                    finally
                    {
                        CommandProcessor.Instance.EndCommand();
                    }
                    if (navigationOffset != -1)
                    {
                        textControl.CaretModel.MoveTo(navigationOffset, TextControlScrollType.MAKE_VISIBLE);
                        // todo run Completion Action
                    }
                }
            }
            else
            {
                Assert.Fail();
            }
        }
开发者ID:willrawls,项目名称:arp,代码行数:35,代码来源:CreateMissedParameterFix.cs


示例7: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ITreeNode element = Utils.GetElementAtCaret(solution, textControl);
            IBlock containingBlock = element.GetContainingNode<IBlock>(true);

            if (containingBlock != null)
            {
                //// CSharpFormatterHelper.FormatterInstance.Format(containingBlock);
                ICSharpCodeFormatter codeFormatter = (ICSharpCodeFormatter)CSharpLanguage.Instance.LanguageService().CodeFormatter;
                codeFormatter.Format(containingBlock);

                new LayoutRules().CurlyBracketsForMultiLineStatementsMustNotShareLine(containingBlock);
            }
            else
            {
                IFieldDeclaration fieldDeclarationNode = element.GetContainingNode<IFieldDeclaration>(true);
                if (fieldDeclarationNode != null)
                {
                    //// CSharpFormatterHelper.FormatterInstance.Format(fieldDeclarationNode);
                    ICSharpCodeFormatter codeFormatter = (ICSharpCodeFormatter)CSharpLanguage.Instance.LanguageService().CodeFormatter;
                    codeFormatter.Format(fieldDeclarationNode);

                    new LayoutRules().CurlyBracketsForMultiLineStatementsMustNotShareLine(fieldDeclarationNode);
                }
            }
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:35,代码来源:SA1500CurlyBracketsForMultiLineStatementsMustNotShareLineBulbItem.cs


示例8: ExecuteTransactionInner

        /// <summary>
        /// The execute inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpModifiersOwnerDeclaration declaration = Utils.GetTypeClosestToTextControl<ICSharpModifiersOwnerDeclaration>(solution, textControl);

            if (declaration != null)
            {
                string rulesNamespace = this.Rule.Namespace;

                string ruleText = string.Format("{0}:{1}", this.Rule.CheckId, this.Rule.Name);

                IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, solution);

                string justificationText = settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.SuppressStyleCopAttributeJustificationText);

                IAttributesOwnerDeclaration attributesOwnerDeclaration = declaration as IAttributesOwnerDeclaration;

                CSharpElementFactory factory = CSharpElementFactory.GetInstance(declaration.GetPsiModule());

                ITypeElement typeElement = Utils.GetTypeElement(declaration, "System.Diagnostics.CodeAnalysis.SuppressMessageAttribute");

                IAttribute attribute = factory.CreateAttribute(typeElement);

                ICSharpArgument newArg1 = attribute.AddArgumentAfter(Utils.CreateConstructorArgumentValueExpression(declaration.GetPsiModule(), rulesNamespace), null);

                ICSharpArgument newArg2 = attribute.AddArgumentAfter(Utils.CreateConstructorArgumentValueExpression(declaration.GetPsiModule(), ruleText), newArg1);

                attribute.AddArgumentAfter(Utils.CreateArgumentValueExpression(declaration.GetPsiModule(), "Justification = \"" + justificationText + "\""), newArg2);

                attributesOwnerDeclaration.AddAttributeAfter(attribute, null);
            }
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:40,代码来源:SuppressMessageBulbItem.cs


示例9: RenderFooterHtmlToControl

 /// <summary>
 /// Renders the footer tag and appropriate html to the given text control
 /// </summary>
 /// <param name="page">Page to get the content from that is supposed to be rendered</param>
 /// <param name="footerControl">The control to render the html to</param>
 public static void RenderFooterHtmlToControl(Page page, ITextControl footerControl)
 {
     if (!string.IsNullOrEmpty(page.FooterHtml))
     {
         footerControl.Text = "<footer>" + HttpUtility.HtmlEncode(page.FooterHtml) + "</footer>";
     }
 }
开发者ID:KyleGobel,项目名称:DailyEZ,代码行数:12,代码来源:PageRenderer.cs


示例10: RenderHtmlHeaderToControl

 /// <summary>
 /// Renders the header tag and appropriate html to the given text control
 /// </summary>
 /// <param name="page">Page to get the content from that is suppose to be rendered</param>
 /// <param name="headerControl">The control to render the html to</param>
 public static void RenderHtmlHeaderToControl(Page page, ITextControl headerControl)
 {
     if (!string.IsNullOrEmpty(page.HeaderHtml))
     {
         headerControl.Text = "<header>" + HttpUtility.HtmlEncode(page.HeaderHtml) + "</header>";
     }
 }
开发者ID:KyleGobel,项目名称:DailyEZ,代码行数:12,代码来源:PageRenderer.cs


示例11: RenderCanonicalUrlToControl

 /// <summary>
 /// Renders the CanonicalUrl to the passed in text control
 /// </summary>
 /// <param name="page">The page object to get the canonicalUrl from</param>
 /// <param name="canonicalLinkControl">The control to render the html to</param>
 public static void RenderCanonicalUrlToControl(Page page, ITextControl canonicalLinkControl)
 {
     if (!string.IsNullOrEmpty(page.CanonicalUrl))
     {
         canonicalLinkControl.Text = "<link rel=\"canonical\" href=\"" + HttpUtility.HtmlEncode(page.CanonicalUrl) + "\"/>";
     }
 }
开发者ID:KyleGobel,项目名称:DailyEZ,代码行数:12,代码来源:PageRenderer.cs


示例12: Execute

    public void Execute(ISolution solution, ITextControl textControl)
    {
      if (!_literalExpression.IsValid())
        return;

      IFile containingFile = _literalExpression.GetContainingFile();

      CSharpElementFactory elementFactory = CSharpElementFactory.GetInstance(_literalExpression.GetPsiModule());

      IExpression newExpression = null;
      _literalExpression.GetPsiServices().PsiManager.DoTransaction(
        () =>
          {
            using (solution.GetComponent<IShellLocks>().UsingWriteLock())
              newExpression = ModificationUtil.ReplaceChild(
                _literalExpression, elementFactory.CreateExpression("System.Int16.MaxValue"));
          }, GetType().Name);

      if (newExpression != null)
      {
        IRangeMarker marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
        containingFile.OptimizeImportsAndRefs(
          marker, false, true, NullProgressIndicator.Instance);
      }
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:25,代码来源:UseOfInt16MaxValueLiteralBulbItem.cs


示例13: SetCaretPosition

 protected static void SetCaretPosition(ITextControl textControl, PsiIntentionResult result)
 {
   if (result.PrefferedSelection != DocumentRange.InvalidRange)
   {
     textControl.Selection.SetRange(result.PrefferedSelection.TextRange);
   }
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:PsiIntentionResultBehavior.cs


示例14: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            // Fixes SA1639
            DocumentationRules.InsertFileHeaderSummary(file);
        }
开发者ID:RainsSoft,项目名称:StyleCop,代码行数:16,代码来源:SA1639FileHeaderMustHaveSummaryBulbItem.cs


示例15: Execute

        public void Execute(ISolution solution, ITextControl textControl)
        {
            if (!MethodDeclaration.IsValid())
            {
                return;
            }

            var containingFile = MethodDeclaration.GetContainingFile();
            var psiModule = MethodDeclaration.GetPsiModule();
            var elementFactory = CSharpElementFactory.GetInstance(psiModule);
            var declared = MethodDeclaration.DeclaredElement;
            if (declared != null)
            {
                var newName = declared.ShortName + "Async";

                var refactoringService = solution.GetComponent<RenameRefactoringService>();
                var suggests = new List<string> {newName};
                SearchDomainFactory searchDomainFactory = solution.GetComponent<SearchDomainFactory>();
                var workflow = (IRefactoringWorkflow)new MethodRenameWorkflow(suggests, solution.GetComponent<IShellLocks>(), searchDomainFactory, refactoringService, solution, "TypoRename");

                var renames = RenameRefactoringService.Instance.CreateAtomicRenames(declared, newName, true).ToList();
               // var workflow = RenameFromContexts.InitFromNameChanges(solution, renames);
                //                workflow.CreateRefactoring();
                Lifetimes.Using(lifetime => RefactoringActionUtil.ExecuteRefactoring(solution.GetComponent<IActionManager>().DataContexts.CreateOnSelection(lifetime, DataRules.AddRule("DoTypoRenameWorkflow", DataConstants.SOLUTION, solution)), workflow));
            }
        }
开发者ID:miniBill,项目名称:AsyncSuffix,代码行数:26,代码来源:ConsiderUsingAsyncSuffixBulbItem.cs


示例16: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            IRangeMarker marker = PsiManager.GetInstance(solution).CreatePsiRangeMarker(this.DocumentRange);

            file.ArrangeThisQualifier(marker);
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:17,代码来源:PrefixLocalCallsWithThis.cs


示例17: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ITreeNode element = Utils.GetElementAtCaret(solution, textControl);

            IMethodDeclaration memberDeclaration = element.GetContainingNode<IMethodDeclaration>(true);

            new DocumentationRules().RemoveReturnsElement(memberDeclaration);
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:17,代码来源:SA1617VoidReturnValueMustNotBeDocumentedBulbItem.cs


示例18: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ITreeNode element = Utils.GetElementAtCaret(solution, textControl);

            ITreeNode currentNode = element;

            currentNode.FindFormattingRangeToLeft().InsertNewLineAfter();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:17,代码来源:SA1515SingleLineCommentsMustBePrecededByBlankLineBulbItem.cs


示例19: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ITreeNode element = Utils.GetElementAtCaret(solution, textControl);

            IDeclaration declaration = element.GetContainingNode<IDeclaration>(true);

            new DocumentationRules().EnsureDocumentationHasNoBlankLines(declaration);
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:17,代码来源:SA1644DocumentationHeadersMustNotContainBlankLinesBulbItem.cs


示例20: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ITreeNode element = Utils.GetElementAtCaret(solution, textControl);

            IDeclaration declaration = element.GetContainingNode<IDeclaration>(true);

            new DocumentationRules().InsertMissingTypeParamElement(declaration);
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:17,代码来源:SA1618GenericTypeParametersMustBeDocumentedBulbItem.cs



注:本文中的ITextControl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITextDocument类代码示例发布时间:2022-05-24
下一篇:
C# ITextBufferFactoryService类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap