Ejemplo n.º 1
0
        private static Block BuildGrammarDetail(GrammarDetail detail)
        {
            Section section = new Section();

            //Grammar Synopsis
            section.Blocks.Add(new Paragraph()
            {
                Inlines =
                {
                    new Run(detail.Synopsis)
                    {
                        Foreground = Brushes.Red,
                        FontSize   = 20,
                    }
                }
            });

            //Grammar Attribute
            section.Blocks.Add(BuildAttribute("Ý nghĩa: ", detail.Mean));
            section.Blocks.Add(BuildAttribute("Giải thích: ", detail.Explain));
            section.Blocks.Add(new Paragraph()
            {
                Foreground = Brushes.Gray,
                FontSize   = 14,
                Inlines    = { new Run("Ví dụ:") }
            });

            //Grammar Examples
            var examplesBlock = BuilderHelper.BuildJaViExamples(detail.Examples);

            examplesBlock.Margin = new Thickness(15, 10, 0, 0);
            section.Blocks.Add(examplesBlock);
            section.Blocks.Add(BuildAttribute("Ghi chú: ", detail.Note));
            return(section);
        }
Ejemplo n.º 2
0
        private static Block BuildWordMean(string sMeans)
        {
            if (string.IsNullOrWhiteSpace(sMeans))
            {
                return(null);
            }
            var means = JsonConvert.DeserializeObject <WordMean[]>(sMeans);
            //build list mean
            List list = new List()
            {
                MarkerStyle = TextMarkerStyle.Decimal,
                Padding     = new Thickness(20, 0, 0, 0)
            };


            foreach (var mean in means)
            {
                ListItem item = new ListItem();

                //add mean
                item.Blocks.Add(new Paragraph()
                {
                    Inlines =
                    {
                        new Run(mean.Kind == null?"":$"({mean.Kind})"),
                        new Run(mean.Mean)
                    }
                });

                //add example
                if (mean.Examples != null && mean.Examples.Count > 0)
                {
                    var examples = BuilderHelper.BuildJaViExamples(mean.Examples.ToArray());
                    examples.Padding = new Thickness(10, 0, 0, 0);
                    item.Blocks.Add(examples);
                }

                //paragragh.Inlines.Add(new LineBreak());
                //TODO add sub list
                //

                list.ListItems.Add(item);
            }
            return(list);
        }