public bool?IsElementObsolete(IDeclaredElement element, out RichTextBlock obsoleteDescription,
                                      DeclaredElementDescriptionStyle style)
        {
            obsoleteDescription = null;
            var obsoletable = element as IObsoletable;

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

            if (!obsoletable.Obsolete && !obsoletable.NonStandard)
            {
                return(false);
            }

            obsoleteDescription = new RichTextBlock();
            var richText = new RichText();

            if (obsoletable.Obsolete)
            {
                richText.Append("Obsolete!", new TextStyle(FontStyle.Bold));
            }
            else if (obsoletable.NonStandard)
            {
                richText.Append("Non-standard!", new TextStyle(FontStyle.Bold));
            }

            obsoleteDescription.Add(richText);

            return(true);
        }
Пример #2
0
        public bool DecorateNode(IResource res, RichText nodeText)
        {
            if (res.HasProp(Core.Props.ShowTotalCount))
            {
                IResource wsp = Core.WorkspaceManager.ActiveWorkspace;
                if (res.Type == FilterManagerProps.ViewResName)
                {
                    IResourceList total = Core.FilterEngine.ExecView(res);
                    if (!res.HasProp("ShowDeletedItems"))
                    {
                        total = total.Minus(_allDeleted);
                    }
                    total = total.Intersect(_allTyped);
                    if (wsp != null)
                    {
                        total = total.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true);
                    }

                    if (total.Count != 0)
                    {
                        nodeText.Append(" ");
                        nodeText.Append("[" + total.Count + "]", _textStyle);
                    }
                    return(true);
                }
                else
                if (res.Type == "Category")
                {
                    bool          leafCategory = (res.GetLinksTo(null, Core.Props.Parent).Count == 0);
                    IResourceList inThis = Core.ResourceStore.EmptyResourceList, total;

                    if (leafCategory)
                    {
                        total = CollectResources(res, wsp);
                    }
                    else
                    {
                        CollectResources(res, wsp, out inThis, out total);
                    }

                    if (total.Count != 0)
                    {
                        nodeText.Append(" ");
                        if (leafCategory)
                        {
                            nodeText.Append("[" + total.Count + "]", _textStyle);
                        }
                        else
                        {
                            nodeText.Append("[" + inThis.Count + "|" + total.Count + "]", _textStyle);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
        public void AppendText([CanBeNull] string text, [CanBeNull] string highlighterAttributeId)
        {
            if (text.IsEmpty())
            {
                return;
            }

            TextStyle textStyle = _textStyleHighlighterManager.GetHighlighterTextStyle(highlighterAttributeId);

            _richText.Append(text, textStyle);
        }
        private ArgumentRoleTooltipContent TryGetArgumentRoleContent([NotNull] ITreeNode node, [NotNull] IContextBoundSettingsStore settings)
        {
            if (!settings.GetValue((IdentifierTooltipSettings s) => s.ShowArgumentsRole))
            {
                return(null);
            }

            var argument = node.GetContainingNode <IArgument>();
            DeclaredElementInstance <IParameter> parameterInstance = argument?.MatchingParameter;

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

            IParameter       parameter       = parameterInstance.Element;
            IParametersOwner parametersOwner = parameter.ContainingParametersOwner;

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

            HighlighterIdProvider highlighterIdProvider = _highlighterIdProviderFactory.CreateProvider(settings);

            RichText final = new RichText("Argument of ", TextStyle.Default);

            final.Append(_colorizerPresenter.TryPresent(
                             new DeclaredElementInstance(parametersOwner, parameterInstance.Substitution),
                             PresenterOptions.ForArgumentRoleParametersOwnerToolTip(settings),
                             argument.Language,
                             highlighterIdProvider));
            final.Append(": ", TextStyle.Default);
            final.Append(_colorizerPresenter.TryPresent(
                             parameterInstance,
                             PresenterOptions.ForArgumentRoleParameterToolTip(settings),
                             argument.Language,
                             highlighterIdProvider));

            var content = new ArgumentRoleTooltipContent(final, argument.GetDocumentRange().TextRange)
            {
                Description = TryGetDescription(parameter, parameter.Module, argument.Language, DeclaredElementDescriptionStyle.NO_OBSOLETE_SUMMARY_STYLE)
            };

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowIcon))
            {
                content.Icon = PsiSymbolsThemedIcons.Parameter.Id;
            }

            return(content);
        }
Пример #5
0
 public bool DecorateNode(IResource res, RichText nodeText)
 {
     if (res.Type == "RSSFeedGroup")
     {
         int unreadCount = GetGroupUnreadCount(res);
         if (unreadCount > 0)
         {
             nodeText.Append(" ");
             nodeText.SetStyle(FontStyle.Bold, 0, res.DisplayName.Length);
             nodeText.Append("(" + unreadCount + ")", _unreadTextStyle);
         }
         return(true);
     }
     return(false);
 }
Пример #6
0
        public bool DecorateNode(IResource res, RichText nodeText)
        {
            if (res.Type == NntpPlugin._newsGroup)
            {
                int count = 0;

                if (_groups2watchedHeads.ContainsKey(res))
                {
                    IResourceList groupItems = NntpPlugin.CollectArticles(res, false);
                    groupItems = groupItems.Intersect(_unreadArticles);

                    List <IResource> heads = _groups2watchedHeads[res];
                    foreach (IResource head in heads)
                    {
                        IResourceList thread = ConversationBuilder.UnrollConversationFromCurrent(head);
                        count += thread.Intersect(groupItems).Count;
                    }
                }

                if (count != 0)
                {
                    nodeText.Append(" !", _watchedTextStyle);
                }
                return(count != 0);
            }
            return(false);
        }
Пример #7
0
        public bool DecorateNode(IResource res, RichText nodeText)
        {
            int unreadCount = (_unreadState == null)
                ? Core.UnreadManager.GetUnreadCount(res)
                : _unreadState.GetUnreadCount(res);

            if (_unreadState != null && _traceUnreadCounters)
            {
                Trace.WriteLine("Decorating node " + res + " with count " + unreadCount + " from " + _unreadState);
            }
            if (unreadCount != 0)
            {
                nodeText.Append(" ");
                nodeText.SetStyle(FontStyle.Bold, 0, res.DisplayName.Length);
                nodeText.Append("(" + unreadCount + ")", _unreadTextStyle);
            }
            return(true);
        }
Пример #8
0
 public bool DecorateNode(IResource res, RichText nodeText)
 {
     if (res.HasProp(Core.Props.ShowTotalCount))
     {
         IResource     wsp   = Core.WorkspaceManager.ActiveWorkspace;
         IResourceList total = GetNodeResourceList(res);
         if (wsp != null)
         {
             total = total.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true);
         }
         if (total.Count != 0)
         {
             nodeText.Append(" ");
             nodeText.Append("[" + total.Count + "]", _textStyle);
         }
         return(true);
     }
     return(false);
 }
        protected Title GenerateTitle(string titleText)
        {
            ParagraphProperties paragraphProperties = new ParagraphProperties();

            paragraphProperties.Append(new DefaultRunProperties());

            Run  run  = new Run();
            Text text = new Text();

            text.Text = titleText;

            run.Append(new RunProperties()
            {
                Language = "en-US"
            });
            run.Append(text);

            Paragraph paragraph = new Paragraph();

            paragraph.Append(paragraphProperties);
            paragraph.Append(run);

            RichText richText = new RichText();

            richText.Append(new BodyProperties());
            richText.Append(new ListStyle());
            richText.Append(paragraph);

            ChartText chartText = new ChartText();

            chartText.Append(richText);

            Title title = new Title();

            title.Append(chartText);
            title.Append(new Layout());
            title.Append(new Overlay()
            {
                Val = false
            });
            return(title);
        }
Пример #10
0
        public static void Run()
        {
            // ExStart:SetProofingLanguageForText
            // ExFor:TextStyle
            // ExFor:TextStyle.Language
            // ExFor:RichText
            // ExFor:RichText.Append(System.String,TextStyle)
            // ExSummary:Set proofing language for a text.
            var document    = new Document();
            var page        = new Page();
            var outline     = new Outline();
            var outlineElem = new OutlineElement();

            var text = new RichText()
            {
                ParagraphStyle = ParagraphStyle.Default
            };

            text.Append("United States", new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("en-US")
            })
            .Append(" Germany", new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("de-DE")
            })
            .Append(" China", new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("zh-CN")
            });

            outlineElem.AppendChildLast(text);
            outline.AppendChildLast(outlineElem);
            page.AppendChildLast(outline);
            document.AppendChildLast(page);

            document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetProofingLanguageForText.one"));

            // ExEnd:SetProofingLanguageForText
        }
Пример #11
0
        public override RichText GetDisplayText()
        {
            var declaredElement = DeclaredElementPointer.FindDeclaredElement();

            if (declaredElement == null)
            {
                return(base.GetDisplayText());
            }

            var solution          = GetSolution();
            var valuePresentation = InspectorVariableUsage.Value.GetPresentation(solution, declaredElement, true);

            if (SourceFile.GetLocation().IsAsset())
            {
                return(valuePresentation);
            }

            var richText   = new RichText(valuePresentation);
            var inText     = new RichText(" in ", TextStyle.FromForeColor(Color.DarkGray));
            var objectText = base.GetDisplayText();

            return(richText.Append(inText).Append(objectText));
        }
    /// <summary>
    /// Presents the specified descriptor.
    /// </summary>
    /// <param name="descriptor">The descriptor.</param>
    /// <param name="occurence">The occurence.</param>
    /// <param name="occurencePresentationOptions">The occurence presentation options.</param>
    /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
    public bool Present(IMenuItemDescriptor descriptor, IOccurence occurence, OccurencePresentationOptions occurencePresentationOptions)
    {
      var itemOccurence = occurence as ItemOccurence;
      if (itemOccurence == null)
      {
        return false;
      }

      var greyTextStyle = TextStyle.FromForeColor(SystemColors.GrayText);

      var richText = new RichText(itemOccurence.ItemName, TextStyle.FromForeColor(Color.Tomato));

      if (!string.IsNullOrEmpty(itemOccurence.ParentPath))
      {
        richText.Append(string.Format(" (in {0})", itemOccurence.ParentPath), greyTextStyle);
      }

      descriptor.Text = richText;
      descriptor.Style = MenuItemStyle.Enabled;
      descriptor.ShortcutText = new RichText(itemOccurence.ItemUri.Site.Name + "/" + itemOccurence.ItemUri.DatabaseName, greyTextStyle);

      return true;
    }
Пример #13
0
        public override RichText GetSignature(string[] namedArguments, AnnotationsDisplayKind showAnnotations,
                                              out TextRange[] parameterRanges, out int[] mapToOriginalOrder, out ExtensionMethodInfo extensionMethodInfo)
        {
            var parameters         = myCandidate.Parameters;
            var text               = new RichText("(");
            var newParameterRanges = new TextRange[parameters.Length];
            var parametersOrder    = SortParameters(parameters, namedArguments, out var orderChanged);

            if (parameters.IsEmpty())
            {
                text.Append("<no parameters>");
            }
            else
            {
                for (var i = 0; i < parameters.Length; i++)
                {
                    var paramRangeStart = text.Length;
                    if (orderChanged)
                    {
                        text.Append("[");
                    }
                    text.Append(parameters[parametersOrder[i]].Display.ToRichText());
                    if (orderChanged)
                    {
                        text.Append("]");
                    }
                    var paramRangeEnd = text.Length;

                    newParameterRanges[i] = new TextRange(paramRangeStart, paramRangeEnd);
                    if (i < parameters.Length - 1)
                    {
                        text.Append(", ");
                    }
                }
            }

            text.Append(")" + myCandidate.ReturnTypeText.ToRichText());

            extensionMethodInfo = ExtensionMethodInfo.NoExtension;
            parameterRanges     = newParameterRanges;
            mapToOriginalOrder  = parametersOrder;
            return(text);
        }
        public bool? IsElementObsolete(IDeclaredElement element, out RichTextBlock obsoleteDescription,
                                       DeclaredElementDescriptionStyle style)
        {
            obsoleteDescription = null;
            var obsoletable = element as IObsoletable;
            if (obsoletable == null)
                return null;

            if (!obsoletable.Obsolete && !obsoletable.NonStandard)
                return false;

            obsoleteDescription = new RichTextBlock();
            var richText = new RichText();
            if (obsoletable.Obsolete)
                richText.Append("Obsolete!", new TextStyle(FontStyle.Bold));
            else if (obsoletable.NonStandard)
                richText.Append("Non-standard!", new TextStyle(FontStyle.Bold));

            obsoleteDescription.Add(richText);

            return true;
        }
Пример #15
0
 public void BoldParsing()
 {
     _richText.Append("Shrek is *love*");
     Assert.AreEqual("Shrek is <b>love</b>", _richText.ToString());
 }
Пример #16
0
        public bool DecorateNode(IResource res, RichText nodeText)
        {
            if (res.Type == NntpPlugin._newsFolder || res.Type == NntpPlugin._newsServer)
            {
                int count;
                if (NewsFolders.IsDefaultFolder(res))
                {
                    IResourceList folderItems = NntpPlugin.CollectArticles(res, false);
                    IResource     wsp         = Core.WorkspaceManager.ActiveWorkspace;
                    if (wsp != null)
                    {
                        folderItems = folderItems.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true);
                    }
                    if (NewsFolders.IsSentItems(res))
                    {
                        folderItems = folderItems.Intersect(_allUnread, true);
                    }
                    else
                    {
                        folderItems = folderItems.Minus(Core.ResourceStore.FindResourcesWithProp(null, Core.Props.IsDeleted));
                    }
                    count = folderItems.Count;
                }
                else
                {
                    IResourceList groups = new NewsTreeNode(res).Groups;
                    IResource     wsp    = Core.WorkspaceManager.ActiveWorkspace;
                    if (wsp != null)
                    {
                        groups = groups.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true);
                    }
                    IResourceList articles = Core.ResourceStore.EmptyResourceList;
                    foreach (IResource group in groups.ValidResources)
                    {
                        articles = articles.Union(
                            group.GetLinksTo(null, NntpPlugin._propTo).Intersect(_allUnread), true);
                    }
                    count = articles.Count;
                }
                if (count != 0)
                {
                    nodeText.Append(" ");
                    nodeText.SetStyle(FontStyle.Bold, 0, res.DisplayName.Length);

                    /////////////////////////////////////////////////////////////////////
                    /// NewsFolders.IsDefaultFolder doesn't synchronously create folders,
                    /// so the check is necessary to avoid RunJobs to resource thread
                    /////////////////////////////////////////////////////////////////////
                    if (NewsFolders.IsDrafts(res))
                    {
                        nodeText.Append("[" + count + "]", _draftsTextStyle);
                    }
                    else
                    {
                        nodeText.Append("(" + count + ")", _unreadTextStyle);
                    }
                }
                return(true);
            }
            return(false);
        }