Exemplo n.º 1
0
        public static void htmlToTextBlockText(System.Windows.Controls.TextBlock textBlock, string html)
        {
            try
            {
                textBlock.Text = "";
                string xaml = HtmlToXamlConverter.ConvertHtmlToXaml(html, false);
                System.Windows.Documents.InlineCollection xamlLines =
                    (
                        (System.Windows.Documents.Paragraph)(
                            (System.Windows.Documents.Section)System.Windows.Markup.XamlReader.Parse(xaml)
                            ).Blocks.FirstBlock
                    ).Inlines;

                System.Windows.Documents.Inline[] newLines = new System.Windows.Documents.Inline[xamlLines.Count];
                xamlLines.CopyTo(newLines, 0);

                foreach (var item in newLines)
                {
                    textBlock.Inlines.Add(item);
                }
            }
            catch (Exception)
            {
                System.Diagnostics.Debugger.Break();
            }
        }
        public static void Add(this System.Windows.Documents.InlineCollection inlines, InlineCollectionItem item)
        {
            switch (item.TypeIndex)
            {
            case 1: inlines.Add(item.T1Value); break;

            case 2: inlines.Add(item.T2Value); break;

            case 3: inlines.Add(item.T3Value); break;
            }
        }
Exemplo n.º 3
0
 void AddTypeArguments(System.Windows.Documents.InlineCollection text, ImmutableArray <ITypeParameterSymbol> arguments)
 {
     text.Add("<");
     for (int i = 0; i < arguments.Length; i++)
     {
         if (i > 0)
         {
             text.Add(", ");
         }
         text.Add(arguments[i].Name.Render(TypeParameter));
     }
     text.Add(">");
 }
Exemplo n.º 4
0
        private double?Measure(System.Windows.Documents.InlineCollection inlines)
        {
            double totalWidth = 0;

            foreach (var inline in inlines)
            {
                var width = Measure(inline);

                if (width.HasValue)
                {
                    totalWidth = Math.Max(totalWidth, width.Value);
                }
                else
                {
                    return(null);
                }
            }
            return(totalWidth);
        }
 public static void AddIfNotNull(this System.Windows.Documents.InlineCollection inlineCollection, System.Windows.Documents.Inline inline)
 {
 }
Exemplo n.º 6
0
        internal void ToUIText(System.Windows.Documents.InlineCollection text, ISymbol symbol, string alias)
        {
            switch (symbol.Kind)
            {
            case SymbolKind.ArrayType:
                ToUIText(text, (symbol as IArrayTypeSymbol).ElementType, alias);
                if (alias == null)
                {
                    text.Add("[]");
                }
                return;

            case SymbolKind.Event: text.Add(symbol.Render(alias, Delegate)); return;

            case SymbolKind.Field:
                text.Add(symbol.Render(alias, (symbol as IFieldSymbol).IsConst ? Const : Field));
                return;

            case SymbolKind.Method:
                text.Add(symbol.Render(alias, Method));
                var method = symbol as IMethodSymbol;
                if (method.IsGenericMethod)
                {
                    var arguments = method.TypeParameters;
                    AddTypeArguments(text, arguments);
                }
                return;

            case SymbolKind.NamedType:
                var type = symbol as INamedTypeSymbol;
                switch (type.TypeKind)
                {
                case TypeKind.Class:
                    text.Add(symbol.Render(alias, Class)); break;

                case TypeKind.Delegate:
                    text.Add(symbol.Render(alias, Delegate)); break;

                case TypeKind.Dynamic:
                    text.Add(symbol.Render(alias ?? symbol.Name, Keyword)); return;

                case TypeKind.Enum:
                    text.Add(symbol.Render(alias, Enum)); return;

                case TypeKind.Interface:
                    text.Add(symbol.Render(alias, Interface)); break;

                case TypeKind.Struct:
                    text.Add(symbol.Render(alias, Struct)); break;

                case TypeKind.TypeParameter:
                    text.Add(symbol.Render(alias ?? symbol.Name, TypeParameter)); return;

                default:
                    text.Add(symbol.MetadataName.Render(Class)); return;
                }
                if (type.IsGenericType)
                {
                    var arguments = type.TypeParameters;
                    AddTypeArguments(text, arguments);
                }
                return;

            case SymbolKind.Namespace: text.Add(symbol.Name.Render(Namespace)); return;

            case SymbolKind.Parameter: text.Add(symbol.Name.Render(Parameter)); return;

            case SymbolKind.Property: text.Add(symbol.Render(alias, Property)); return;

            case SymbolKind.TypeParameter: text.Add(symbol.Name.Render(TypeParameter)); return;

            default: text.Add(symbol.Name); return;
            }
        }