public async Task RenderDescription(ISymbol symbol, double lineHeight) { VectSharp.Font labelFont = new VectSharp.Font(Editor.OpenSansRegular, this.FontSize); VectSharp.Font codeFont = new VectSharp.Font(Editor.RobotoMonoRegular, this.FontSize); VectSharp.Font parameterNameFont = new VectSharp.Font(Editor.OpenSansBoldItalic, this.FontSize); VectSharp.Font parameterDescriptionFont = new VectSharp.Font(Editor.OpenSansItalic, this.FontSize); double availableWidth = this.Parent.Bounds.Width - 22 - 14 - 5; double availableHeightBottom = this.Parent.Bounds.Height - RenderPosition.Y - 22 - 4; double availableHeightTop = RenderPosition.Y - lineHeight; ImmutableArray <SymbolDisplayPart> parts = symbol.ToDisplayParts(/*SemanticModel, Position, */ new SymbolDisplayFormat( globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.OmittedAsContaining, typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeConstraints | SymbolDisplayGenericsOptions.IncludeVariance, memberOptions: SymbolDisplayMemberOptions.IncludeType | SymbolDisplayMemberOptions.IncludeContainingType | SymbolDisplayMemberOptions.IncludeParameters | SymbolDisplayMemberOptions.IncludeConstantValue | SymbolDisplayMemberOptions.IncludeExplicitInterface, delegateStyle: SymbolDisplayDelegateStyle.NameAndSignature, extensionMethodStyle: SymbolDisplayExtensionMethodStyle.Default, parameterOptions: SymbolDisplayParameterOptions.IncludeExtensionThis | SymbolDisplayParameterOptions.IncludeParamsRefOut | SymbolDisplayParameterOptions.IncludeType | SymbolDisplayParameterOptions.IncludeName | SymbolDisplayParameterOptions.IncludeDefaultValue | SymbolDisplayParameterOptions.IncludeOptionalBrackets, propertyStyle: SymbolDisplayPropertyStyle.ShowReadWriteDescriptor, localOptions: SymbolDisplayLocalOptions.IncludeType | SymbolDisplayLocalOptions.IncludeConstantValue, kindOptions: SymbolDisplayKindOptions.IncludeNamespaceKeyword | SymbolDisplayKindOptions.IncludeTypeKeyword | SymbolDisplayKindOptions.IncludeMemberKeyword, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseErrorTypeSymbolName | SymbolDisplayMiscellaneousOptions.UseSpecialTypes )); string documentationId = symbol.GetDocumentationCommentId(); string documentationXml = symbol.GetDocumentationCommentXml(); if (string.IsNullOrEmpty(documentationXml) && !string.IsNullOrEmpty(documentationId)) { (await Utils.GetReferenceDocumentation()).TryGetValue(documentationId, out documentationXml); } FormattedText description = FormattedText.FormatDescription(from el in parts select el.ToTaggedText(), documentationXml, labelFont, codeFont); if (description.Paragraphs.Count == 1) { description.Paragraphs[0].SpaceAfter = description.Paragraphs[0].Lines[0].GetAverageFontSize() * 0.4; } Canvas iconCanvas = new Canvas() { Width = 16, Height = 16 }; switch (symbol.Kind) { case SymbolKind.Property: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.PropertyIcon(), Width = 16, Height = 16 }); break; case SymbolKind.Event: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.EventIcon(), Width = 16, Height = 16 }); break; case SymbolKind.Field: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.FieldIcon(), Width = 16, Height = 16 }); break; case SymbolKind.Method: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.MethodIcon(), Width = 16, Height = 16 }); break; case SymbolKind.NamedType: case SymbolKind.DynamicType: case SymbolKind.ArrayType: case SymbolKind.PointerType: switch (((ITypeSymbol)symbol).TypeKind) { case TypeKind.Class: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.ClassIcon(), Width = 16, Height = 16 }); break; case TypeKind.Struct: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.StructIcon(), Width = 16, Height = 16 }); break; case TypeKind.Interface: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.InterfaceIcon(), Width = 16, Height = 16 }); break; case TypeKind.Enum: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.EnumIcon(), Width = 16, Height = 16 }); break; case TypeKind.Delegate: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.DelegateIcon(), Width = 16, Height = 16 }); break; default: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.UnknownIcon(), Width = 16, Height = 16 }); break; } break; case SymbolKind.Namespace: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.NamespaceIcon(), Width = 16, Height = 16 }); break; case SymbolKind.Local: case SymbolKind.Parameter: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.LocalIcon(), Width = 16, Height = 16 }); break; default: iconCanvas.Children.Add(new Viewbox() { Child = new IntellisenseIcon.UnknownIcon(), Width = 16, Height = 16 }); break; } Canvas content = description.Render(availableWidth, false, iconCanvas); content.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left; content.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top; double desiredWidth = content.Width; double desiredHeight = content.Height; if (desiredHeight <= availableHeightBottom) { this.Width = Math.Min(availableWidth, desiredWidth) + 10 + 4; this.Height = Math.Max(desiredHeight, 25) + 4; this.FindControl <Border>("ContainerBorder").Child = content; this.FindControl <Border>("ContainerBorder").Width = Math.Min(availableWidth, desiredWidth) + 10; this.FindControl <Border>("ContainerBorder").Height = content.Height; this.RenderTransform = new TranslateTransform() { X = Math.Min(RenderPosition.X, this.Parent.Bounds.Width - 22 - this.Width), Y = RenderPosition.Y }; this.IsVisible = true; } else if (desiredHeight <= availableHeightTop) { this.Width = Math.Min(availableWidth, desiredWidth) + 10 + 4; this.Height = Math.Max(desiredHeight, 25) + 4; this.FindControl <Border>("ContainerBorder").Child = content; this.FindControl <Border>("ContainerBorder").Width = Math.Min(availableWidth, desiredWidth) + 10; this.FindControl <Border>("ContainerBorder").Height = content.Height; this.RenderTransform = new TranslateTransform() { X = Math.Min(RenderPosition.X, this.Parent.Bounds.Width - 22 - this.Width), Y = RenderPosition.Y - this.Height - lineHeight }; this.IsVisible = true; } else { this.IsVisible = false; } }
public void RenderDescription(List <Diagnostic> diagnostics, double lineHeight) { VectSharp.Font labelFont = new VectSharp.Font(Editor.OpenSansRegular, this.FontSize); VectSharp.Font codeFont = new VectSharp.Font(Editor.RobotoMonoRegular, this.FontSize); double availableWidth = this.Parent.Bounds.Width - 22 - 14 - 5; double availableHeightBottom = this.Parent.Bounds.Height - RenderPosition.Y - 22 - 4; double availableHeightTop = RenderPosition.Y - lineHeight; StackPanel contentPanel = new StackPanel(); double desiredWidth = 0; double desiredHeight = 0; foreach (Diagnostic diagnostic in diagnostics) { FormattedText description = FormattedText.FormatDescription(FormattedText.TokenizeText(diagnostic.Id + ": " + diagnostic.GetMessage(System.Globalization.CultureInfo.InvariantCulture)), null, labelFont, codeFont); if (description.Paragraphs.Count == 1) { description.Paragraphs[0].SpaceAfter = description.Paragraphs[0].Lines[0].GetAverageFontSize() * 0.4; } Canvas iconCanvas = new Canvas() { Width = 16, Height = 16 }; switch (diagnostic.Severity) { case DiagnosticSeverity.Error: iconCanvas.Children.Add(new Viewbox() { Child = new DiagnosticIcons.ErrorIcon(), Width = 16, Height = 16 }); break; case DiagnosticSeverity.Warning: iconCanvas.Children.Add(new Viewbox() { Child = new DiagnosticIcons.WarningIcon(), Width = 16, Height = 16 }); break; } Canvas content = description.Render(availableWidth, false, iconCanvas, true); content.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left; content.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top; contentPanel.Children.Add(content); desiredWidth = Math.Max(desiredWidth, content.Width); desiredHeight += content.Height; } if (desiredHeight <= availableHeightBottom) { this.Width = Math.Min(availableWidth, desiredWidth) + 10 + 4; this.Height = Math.Max(desiredHeight, 25) + 4; this.FindControl <Border>("ContainerBorder").Child = contentPanel; this.FindControl <Border>("ContainerBorder").Width = Math.Min(availableWidth, desiredWidth) + 10; this.FindControl <Border>("ContainerBorder").Height = desiredHeight; this.RenderTransform = new TranslateTransform() { X = Math.Min(RenderPosition.X, this.Parent.Bounds.Width - 22 - this.Width), Y = RenderPosition.Y }; this.IsVisible = true; } else if (desiredHeight <= availableHeightTop) { this.Width = Math.Min(availableWidth, desiredWidth) + 10 + 4; this.Height = Math.Max(desiredHeight, 25) + 4; this.FindControl <Border>("ContainerBorder").Child = contentPanel; this.FindControl <Border>("ContainerBorder").Width = Math.Min(availableWidth, desiredWidth) + 10; this.FindControl <Border>("ContainerBorder").Height = desiredHeight; this.RenderTransform = new TranslateTransform() { X = Math.Min(RenderPosition.X, this.Parent.Bounds.Width - 22 - this.Width), Y = RenderPosition.Y - this.Height - lineHeight }; this.IsVisible = true; } else { this.IsVisible = false; } }
private void ShowDocumentationComments(CompletionDescription description, string documentationXml, double offset) { if (string.IsNullOrEmpty(description.Text) && string.IsNullOrEmpty(documentationXml)) { this.FindControl <Border>("DocumentationBorder").IsVisible = false; } else { VectSharp.Font labelFont = new VectSharp.Font(Editor.OpenSansRegular, this.FontSize); VectSharp.Font codeFont = new VectSharp.Font(Editor.RobotoMonoRegular, this.FontSize); double thisX = 0; double thisY = 0; if (this.RenderTransform != null) { thisY = ((TranslateTransform)this.RenderTransform).Y; thisX = ((TranslateTransform)this.RenderTransform).X; } double maxHeight = this.Parent.Bounds.Height - thisY - offset - 10 - 20; double maxWidthRight = this.Parent.Bounds.Width - thisX - this.Width - 12; double maxWidthLeft = thisX - 12; Control unlimitedContent = FormattedText.FormatDescription(description.TaggedParts, documentationXml, labelFont, codeFont).Render(double.PositiveInfinity, false); unlimitedContent.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left; unlimitedContent.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top; if (unlimitedContent.Width < maxWidthRight) { this.FindControl <ScrollViewer>("DocumentationScrollViewer").Content = unlimitedContent; this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <Border>("DocumentationBorder").Height = Math.Min(maxHeight, unlimitedContent.Height + 4); if (unlimitedContent.Height + 4 > maxHeight) { this.FindControl <Border>("DocumentationBorder").Width = unlimitedContent.Width + 12 + 20; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Visible; } else { this.FindControl <Border>("DocumentationBorder").Width = unlimitedContent.Width + 12; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; } this.FindControl <Border>("DocumentationBorder").RenderTransform = new TranslateTransform() { X = this.Width, Y = offset }; } else if (unlimitedContent.Width < maxWidthLeft) { this.FindControl <ScrollViewer>("DocumentationScrollViewer").Content = unlimitedContent; this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <Border>("DocumentationBorder").Height = Math.Min(maxHeight, unlimitedContent.Height + 4); if (unlimitedContent.Height + 4 > maxHeight) { this.FindControl <Border>("DocumentationBorder").Width = unlimitedContent.Width + 12 + 20; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Visible; } else { this.FindControl <Border>("DocumentationBorder").Width = unlimitedContent.Width + 12; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; } this.FindControl <Border>("DocumentationBorder").RenderTransform = new TranslateTransform() { X = -this.FindControl <Border>("DocumentationBorder").Width, Y = offset }; } else if (maxWidthRight >= maxWidthLeft) { Control content = FormattedText.FormatDescription(description.TaggedParts, documentationXml, labelFont, codeFont).Render(maxWidthRight - 20 - 12, false); content.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left; content.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top; this.FindControl <ScrollViewer>("DocumentationScrollViewer").Content = content; if (content.Width + 12 <= maxWidthRight && content.Height + 4 <= maxHeight) { this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <Border>("DocumentationBorder").Width = content.Width + 12; this.FindControl <Border>("DocumentationBorder").Height = content.Height + 4; } else if (content.Width + 12 + 20 <= maxWidthRight && content.Height + 4 > maxHeight) { this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Visible; this.FindControl <Border>("DocumentationBorder").Width = content.Width + 12 + 20; this.FindControl <Border>("DocumentationBorder").Height = maxHeight + (shifterY *= -1); } else if (content.Width + 12 > maxWidthRight && content.Height + 4 + 20 <= maxHeight) { this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <Border>("DocumentationBorder").Width = maxWidthRight + (shifterX *= -1); this.FindControl <Border>("DocumentationBorder").Height = content.Height + 4 + 20; } else { this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Visible; this.FindControl <Border>("DocumentationBorder").Width = maxWidthRight + (shifterX *= -1); this.FindControl <Border>("DocumentationBorder").Height = maxHeight + (shifterY *= -1); } this.FindControl <Border>("DocumentationBorder").RenderTransform = new TranslateTransform() { X = this.Width, Y = offset }; } else { Control content = FormattedText.FormatDescription(description.TaggedParts, documentationXml, labelFont, codeFont).Render(maxWidthLeft - 20 - 12, false); content.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left; content.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top; this.FindControl <ScrollViewer>("DocumentationScrollViewer").Content = content; if (content.Width + 12 <= maxWidthLeft && content.Height + 4 <= maxHeight) { this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <Border>("DocumentationBorder").Width = content.Width + 12; this.FindControl <Border>("DocumentationBorder").Height = content.Height + 4; } else if (content.Width + 12 + 20 <= maxWidthLeft && content.Height + 4 > maxHeight) { this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Visible; this.FindControl <Border>("DocumentationBorder").Width = content.Width + 12 + 20; this.FindControl <Border>("DocumentationBorder").Height = maxHeight + (shifterY *= -1); } else if (content.Width + 12 > maxWidthLeft && content.Height + 4 + 20 <= maxHeight) { this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; this.FindControl <Border>("DocumentationBorder").Width = maxWidthLeft + (shifterX *= -1); this.FindControl <Border>("DocumentationBorder").Height = content.Height + 4 + 20; } else { this.FindControl <ScrollViewer>("DocumentationScrollViewer").HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; this.FindControl <ScrollViewer>("DocumentationScrollViewer").VerticalScrollBarVisibility = ScrollBarVisibility.Visible; this.FindControl <Border>("DocumentationBorder").Width = maxWidthLeft + (shifterX *= -1); this.FindControl <Border>("DocumentationBorder").Height = maxHeight + (shifterY *= -1); } this.FindControl <Border>("DocumentationBorder").RenderTransform = new TranslateTransform() { X = -this.FindControl <Border>("DocumentationBorder").Width, Y = offset }; } this.FindControl <Border>("DocumentationBorder").IsVisible = true; } }
public VariableExpander(string variableName, object variableValue, TaggedText[] variableDisplayName, ToggleButton nonPublicVisibilityToggle, double fontSize = 14, bool isProperty = false, bool isField = false, bool isPrivate = false) { this.InitializeComponent(); this.NonPublicVisibilityToggle = nonPublicVisibilityToggle; VectSharp.Font labelFont = new VectSharp.Font(Editor.OpenSansRegular, fontSize); VectSharp.Font codeFont = new VectSharp.Font(Editor.RobotoMonoRegular, fontSize); Canvas iconCanvas = new Canvas() { Width = 18, Height = 16 }; Control nameControl; Control valueControl; if (variableValue is string str) { iconCanvas.Children.Add(new TypeIcons.StringIcon()); string stringLiteral = str.Substring(0, Math.Min(str.Length, 30)); if (str.Length > 30) { stringLiteral += "…"; } stringLiteral = stringLiteral.ToLiteral(); valueControl = FormattedText.FormatDescription(new TaggedText[] { new TaggedText(TextTags.Operator, "="), new TaggedText(TextTags.Space, " "), new TaggedText(TextTags.StringLiteral, stringLiteral) }, null, labelFont, codeFont).Render(double.PositiveInfinity, false); ToolTip.SetTip(this, str); this.FindControl <Button>("InspectButton").IsVisible = true; this.FindControl <Button>("InspectButton").Click += async(s, e) => { Window window = new Window() { Width = 450, Height = 200 }; window.Title = "Inspect string"; window.Content = new TextBox() { Text = str, IsReadOnly = true, AcceptsReturn = true, FontSize = fontSize, FontFamily = FontFamily.Parse("resm:CSharpEditor.Fonts.?assembly=CSharpEditor#Roboto Mono") }; await window.ShowDialog(this.FindAncestorOfType <Window>()); }; } else if (variableValue is char chr) { string stringLiteral = chr.ToLiteral(); iconCanvas.Children.Add(new TypeIcons.CharIcon()); valueControl = FormattedText.FormatDescription(new TaggedText[] { new TaggedText(TextTags.Operator, "="), new TaggedText(TextTags.Space, " "), new TaggedText(TextTags.StringLiteral, stringLiteral) }, null, labelFont, codeFont).Render(double.PositiveInfinity, false); ToolTip.SetTip(this, chr); } else if (variableValue is long || variableValue is int || variableValue is double || variableValue is decimal || variableValue is ulong || variableValue is uint || variableValue is short || variableValue is ushort || variableValue is byte || variableValue is sbyte || variableValue is float) { iconCanvas.Children.Add(new TypeIcons.NumberIcon()); string stringValue = Convert.ToString(variableValue, System.Globalization.CultureInfo.InvariantCulture); valueControl = FormattedText.FormatDescription(new TaggedText[] { new TaggedText(TextTags.Operator, "="), new TaggedText(TextTags.Space, " "), new TaggedText(TextTags.NumericLiteral, stringValue) }, null, labelFont, codeFont).Render(double.PositiveInfinity, false); ToolTip.SetTip(this, stringValue); } else if (variableValue is bool bol) { iconCanvas.Children.Add(new TypeIcons.BoolIcon()); valueControl = FormattedText.FormatDescription(new TaggedText[] { new TaggedText(TextTags.Operator, "="), new TaggedText(TextTags.Space, " "), new TaggedText(TextTags.Keyword, bol.ToString().ToLower()) }, null, labelFont, codeFont).Render(double.PositiveInfinity, false); ToolTip.SetTip(this, bol.ToString().ToLower()); } else if (variableValue is null) { iconCanvas.Children.Add(new TypeIcons.NullIcon()); valueControl = FormattedText.FormatDescription(new TaggedText[] { new TaggedText(TextTags.Operator, "="), new TaggedText(TextTags.Space, " "), new TaggedText(TextTags.Keyword, "null") }, null, labelFont, codeFont).Render(double.PositiveInfinity, false); ToolTip.SetTip(this, "null"); } else if (variableValue is IEnumerable enumerable) { string enumerableType = ""; int count = -1; foreach (Type interf in ((Type)variableValue.GetType()).GetInterfaces()) { if (interf.IsGenericType && interf.GetGenericTypeDefinition() == typeof(IEnumerable <>)) { foreach (Type tp in interf.GetGenericArguments()) { enumerableType += tp.Name + ", "; } } } if (enumerableType.Length > 2) { enumerableType = enumerableType[0..^ 2];
public async Task RenderDescription(ISymbol symbol) { VectSharp.Font labelFont = new VectSharp.Font(Editor.OpenSansRegular, this.FontSize); VectSharp.Font codeFont = new VectSharp.Font(Editor.RobotoMonoRegular, this.FontSize); VectSharp.Font parameterNameFont = new VectSharp.Font(Editor.OpenSansBoldItalic, this.FontSize); VectSharp.Font parameterDescriptionFont = new VectSharp.Font(Editor.OpenSansItalic, this.FontSize); double availableWidth = this.Parent.Bounds.Width - 22 - (this.Items.Count > 1 ? ItemNumberWidth : 0) - 14 - 5; double availableHeightBottom = this.Parent.Bounds.Height - RenderPosition.Y - 22 - 4; double availableHeightTop = RenderPosition.Y - CharacterHeight - 4; ImmutableArray <SymbolDisplayPart> parts = symbol.ToMinimalDisplayParts(SemanticModel, Position); string documentationId = symbol.GetDocumentationCommentId(); string documentationXml = symbol.GetDocumentationCommentXml(); if (string.IsNullOrEmpty(documentationXml) && !string.IsNullOrEmpty(documentationId)) { (await Utils.GetReferenceDocumentation()).TryGetValue(documentationId, out documentationXml); } FormattedText description = FormattedText.FormatDescription(from el in parts select el.ToTaggedText(), documentationXml, labelFont, codeFont); Canvas content = description.Render(availableWidth, false); content.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left; content.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top; double desiredWidth = content.Width; FormattedText parameters = new FormattedText(); if (ShowsTypeParameters) { FormattedText.FormatTypeParameterList(parameters, documentationXml, parameterNameFont, parameterDescriptionFont, codeFont); } else { FormattedText.FormatTypeParameterList(parameters, documentationXml, parameterNameFont, parameterDescriptionFont, codeFont); FormattedText.FormatParameterList(parameters, documentationXml, parameterNameFont, parameterDescriptionFont, codeFont); } Canvas parameterContents = null; double parameterContentsHeight = 0; if (parameters.Paragraphs.Count > 0) { parameterContents = parameters.Render(availableWidth, false); parameterContents.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left; parameterContents.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top; parameterContentsHeight = Math.Min(parameterContents.Height, this.FontSize * (3 * 1.8 + 0.4)); desiredWidth = Math.Max(desiredWidth, parameterContents.Width); this.FindControl <ScrollViewer>("MethodParametersContainer").IsVisible = true; if (parameterContents.Height > parameterContentsHeight) { this.FindControl <ScrollViewer>("MethodParametersContainer").VerticalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Visible; desiredWidth = Math.Max(desiredWidth, parameterContents.Width + 20); } else { this.FindControl <ScrollViewer>("MethodParametersContainer").VerticalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Disabled; } } else { this.FindControl <ScrollViewer>("MethodParametersContainer").IsVisible = false; } double desiredHeight = content.Height + parameterContentsHeight; if (desiredWidth <= availableWidth && desiredHeight <= availableHeightBottom) { this.Width = Math.Min(availableWidth, desiredWidth) + (Items.Count > 1 ? ItemNumberWidth : 0) + 10 + 4; this.Height = Math.Max(desiredHeight, 25) + 4; this.FindControl <ScrollViewer>("MethodDescriptionContainer").Content = content; this.FindControl <ScrollViewer>("MethodDescriptionContainer").Width = Math.Min(availableWidth, desiredWidth) + 10; this.FindControl <ScrollViewer>("MethodParametersContainer").Height = content.Height; this.FindControl <ScrollViewer>("MethodParametersContainer").Content = parameterContents; this.FindControl <ScrollViewer>("MethodParametersContainer").Width = Math.Min(availableWidth, desiredWidth) + 10; this.FindControl <ScrollViewer>("MethodParametersContainer").Height = parameterContentsHeight; this.RenderTransform = new TranslateTransform() { X = Math.Min(RenderPosition.X, this.Parent.Bounds.Width - 22 - this.Width), Y = RenderPosition.Y }; this.IsOnTop = false; this.IsVisible = true; } else if (desiredWidth <= availableWidth && desiredHeight <= availableHeightTop) { this.Width = Math.Min(availableWidth, desiredWidth) + (Items.Count > 1 ? ItemNumberWidth : 0) + 10 + 4; this.Height = Math.Max(desiredHeight, 25) + 4; this.FindControl <ScrollViewer>("MethodDescriptionContainer").Content = content; this.FindControl <ScrollViewer>("MethodDescriptionContainer").Width = Math.Min(availableWidth, desiredWidth) + 10; this.FindControl <ScrollViewer>("MethodParametersContainer").Height = content.Height; this.FindControl <ScrollViewer>("MethodParametersContainer").Content = parameterContents; this.FindControl <ScrollViewer>("MethodParametersContainer").Width = Math.Min(availableWidth, desiredWidth) + 10; this.FindControl <ScrollViewer>("MethodParametersContainer").Height = parameterContentsHeight; this.RenderTransform = new TranslateTransform() { X = Math.Min(RenderPosition.X, this.Parent.Bounds.Width - 22 - this.Width), Y = RenderPosition.Y - CharacterHeight - this.Height }; this.IsOnTop = true; this.IsVisible = true; } else if (content.Width <= availableWidth && content.Height <= availableHeightBottom) { this.Width = Math.Min(availableWidth, content.Width) + (Items.Count > 1 ? ItemNumberWidth : 0) + 10 + 4; this.Height = Math.Max(content.Height, 25) + 4; this.FindControl <ScrollViewer>("MethodDescriptionContainer").Content = content; this.FindControl <ScrollViewer>("MethodDescriptionContainer").Width = Math.Min(availableWidth, content.Width) + 10; this.FindControl <ScrollViewer>("MethodParametersContainer").Height = content.Height; this.FindControl <ScrollViewer>("MethodParametersContainer").Content = null; this.FindControl <ScrollViewer>("MethodParametersContainer").Height = 0; this.FindControl <ScrollViewer>("MethodParametersContainer").IsVisible = false; this.RenderTransform = new TranslateTransform() { X = Math.Min(RenderPosition.X, this.Parent.Bounds.Width - 22 - this.Width), Y = RenderPosition.Y }; this.IsOnTop = false; this.IsVisible = true; } else if (content.Width <= availableWidth && content.Height <= availableHeightTop) { this.Width = Math.Min(availableWidth, content.Width) + (Items.Count > 1 ? ItemNumberWidth : 0) + 10 + 4; this.Height = Math.Max(content.Height, 25) + 4; this.FindControl <ScrollViewer>("MethodDescriptionContainer").Content = content; this.FindControl <ScrollViewer>("MethodDescriptionContainer").Width = Math.Min(availableWidth, content.Width) + 10; this.FindControl <ScrollViewer>("MethodParametersContainer").Height = content.Height; this.FindControl <ScrollViewer>("MethodParametersContainer").Content = null; this.FindControl <ScrollViewer>("MethodParametersContainer").Height = 0; this.FindControl <ScrollViewer>("MethodParametersContainer").IsVisible = false; this.RenderTransform = new TranslateTransform() { X = Math.Min(RenderPosition.X, this.Parent.Bounds.Width - 22 - this.Width), Y = RenderPosition.Y - CharacterHeight - this.Height }; this.IsOnTop = true; this.IsVisible = true; } else { this.IsVisible = false; } }