Пример #1
0
        public LayoutContext(List <string> tokens, ContentLayoutOptions layoutOptions)
        {
            Require.ArgumentNotNull(tokens, nameof(tokens));
            Require.ArgumentNotNull(layoutOptions, nameof(layoutOptions));

            this.tokens  = tokens;
            this.options = layoutOptions;
        }
        /// <summary>
        /// Creates an IContentLayout object for the specified text.
        /// </summary>
        /// <param name="text">The text to layout. If localizeText is true, this text will be used
        /// as a key in the lookup table for the current language.</param>
        /// <param name="contentLayoutOptions">Options for content layout.</param>
        /// <param name="localizeText">If true, the text will be localized. Defaults to true.</param>
        /// <returns></returns>
        public IContentLayout LayoutContent(
            string text,
            ContentLayoutOptions contentLayoutOptions,
            bool localizeText = true)
        {
            if (localizeText)
            {
                text = textRepo.Lookup(text);
            }

            return(baseEngine.LayoutContent(text, contentLayoutOptions));
        }
Пример #3
0
        public IContentLayout LayoutContent(string text, ContentLayoutOptions layoutOptions)
        {
            layoutOptions.Font = layoutOptions.Font ?? LookupFont(layoutOptions.FontLookup);

            var tokens  = tokenizer.Tokenize(text);
            var context = new LayoutContext(tokens, layoutOptions);

            while (context.AnyTokensLeft)
            {
                ProcessToken(context, context.ReadNextToken());
            }

            return(context.Layout);
        }