object CreateTooltip(IType type)
		{
			var ambience = AmbienceService.GetCurrentAmbience();
			ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.ShowDeclaringType | ConversionFlags.UseFullyQualifiedTypeNames;
			string header;
			if (type is ITypeDefinition)
				header = ambience.ConvertEntity((ITypeDefinition)type);
			else
				header = ambience.ConvertType(type);
			
			ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList;
			DocumentationUIBuilder b = new DocumentationUIBuilder(ambience);
			b.AddCodeBlock(header, keepLargeMargin: true);
			
			ITypeDefinition entity = type.GetDefinition();
			if (entity != null) {
				var documentation = XmlDocumentationElement.Get(entity);
				if (documentation != null) {
					foreach (var child in documentation.Children) {
						b.AddDocumentationElement(child);
					}
				}
			}
			return new FlowDocumentTooltip(b.CreateFlowDocument());
		}
Exemplo n.º 2
0
        FlowDocumentScrollViewer GenerateHeader()
        {
            AlAmbience ambience = new AlAmbience();

            ambience.ConversionFlags = ConversionFlags.StandardConversionFlags;
            var stringBuilder = new StringBuilder();
            var formatter     = new ParameterHighlightingOutputFormatter(stringBuilder, highlightedParameterIndex);

            ambience.ConvertSymbol(Method, formatter, AlFormattingPolicies.Instance.GlobalOptions.OptionsContainer.GetEffectiveOptions());

            var documentation = XmlDocumentationElement.Get(Method);

            ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList;

            DocumentationUIBuilder b = new DocumentationUIBuilder(ambience);
            string parameterName     = null;

            if (Method.Parameters.Count > highlightedParameterIndex)
            {
                parameterName = Method.Parameters[highlightedParameterIndex].Name;
            }
            b.AddSignatureBlock(stringBuilder.ToString(), formatter.parameterStartOffset, formatter.parameterLength, parameterName);

            DocumentationUIBuilder b2 = new DocumentationUIBuilder(ambience);

            b2.ParameterName     = parameterName;
            b2.ShowAllParameters = false;

            if (documentation != null)
            {
                foreach (var child in documentation.Children)
                {
                    b2.AddDocumentationElement(child);
                }
            }

            content = new FlowDocumentScrollViewer {
                Document = b2.CreateFlowDocument(),
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto
            };

            var flowDocument = b.CreateFlowDocument();

            flowDocument.PagePadding = new Thickness(0);             // default is NOT Thickness(0), but Thickness(Auto), which adds unnecessary space

            return(new FlowDocumentScrollViewer {
                Document = flowDocument,
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto
            });
        }