示例#1
0
        public DocumentationGenerator Download(DocumentType docType,
                                               string fileName,
                                               VideoForUser video)
        {
            DocumentationGenerator documentGenerator = DocumentationGenerator.Create(_domain, _fontPath, docType, fileName);

            var fields = new List <string> {
                "Отрывок текста"
            };

            if (video.HasAnyTranslation)
            {
                fields.Add("Перевод");
            }
            var tableData = new TableData(fields.Count, false);

            tableData.AddHeader(fields);
            foreach (var sentence in video.Sentences)
            {
                fields = new List <string> {
                    sentence.Item1
                };
                if (video.HasTranslation(sentence))
                {
                    fields.Add(sentence.Item2);
                }
                tableData.AddRow(fields);
            }

            documentGenerator.AddHeader(string.Format("Текст из видео «{0}»", video.Title));
            documentGenerator.AddTable(tableData);

            return(documentGenerator);
        }
示例#2
0
        public DocumentationGenerator Download(DocumentType docType,
                                               string fileName,
                                               Dictionary <KnowledgeDataType, List <GeneratedKnowledgeItem> >
                                               generatedItems)
        {
            DocumentationGenerator documentGenerator = DocumentationGenerator.Create(_domain, _fontPath, docType,
                                                                                     fileName);

            var tables = new Dictionary <string, TableData>();

            foreach (KnowledgeDataType knowledgeDataType in generatedItems.Keys)
            {
                var tableData = new TableData(2, true);

                string tableHeader = GetTableHeader(knowledgeDataType);
                if (!string.IsNullOrEmpty(tableHeader))
                {
                    tableData.AddHeader(tableHeader, "Перевод");

                    string subHeader = GetHeader(knowledgeDataType);
                    tables.Add(subHeader, tableData);
                }

                List <GeneratedKnowledgeItem> items = generatedItems[knowledgeDataType];
                foreach (GeneratedKnowledgeItem item in items)
                {
                    var sourceTranslation = (SourceWithTranslation)item.ParsedData;
                    tableData.AddRow(sourceTranslation.Source.Text, sourceTranslation.Translation.Text);
                }
            }

            if (string.IsNullOrEmpty(Header))
            {
                Header = "Генератор знаний";
            }

            documentGenerator.AddHeader(Header, false);
            foreach (var pair in tables)
            {
                documentGenerator.AddHeader(pair.Key);
                documentGenerator.AddTable(pair.Value);
            }

            return(documentGenerator);
        }
        public DocumentationGenerator Download(DocumentType docType, string fileName, ComparisonForUser comparisonForUser)
        {
            string header = comparisonForUser.Title;
            DocumentationGenerator documentGenerator = DocumentationGenerator.Create(_domain, _fontPath, docType, fileName);

            documentGenerator.AddHeader(header, false);
            if (comparisonForUser.HasDescription)
            {
                documentGenerator.AddParagraph(TextFormatter.AppendCharIfNeed(comparisonForUser.Description));
            }
            foreach (ComparisonItemForUser item in comparisonForUser.Items)
            {
                string title = item.Title;
                if (item.HasTranslatedTitle)
                {
                    title += " – " + item.TitleTranslated;
                }
                documentGenerator.AddSubheader(title);
                documentGenerator.AddParagraph(item.GetRuleHeader());
                int ruleNumber = 1;
                foreach (ComparisonRuleForUser rule in item.Rules)
                {
                    string ruleDescription = TextFormatter.AppendCharIfNeed(rule.Description);
                    if (!item.IsOneRule)
                    {
                        ruleDescription = ruleNumber + ". " + ruleDescription;
                        ruleNumber++;
                    }
                    documentGenerator.AddParagraph(ruleDescription);
                    if (EnumerableValidator.IsNotEmpty(rule.Examples))
                    {
                        foreach (ComparisonRuleExampleForUser example in @rule.Examples)
                        {
                            documentGenerator.AddParagraph(example.Example.Source.Text + " – "
                                                           + example.Example.Translation.Text,
                                                           new TextFormat {
                                CountLeftPaddings = 1
                            });
                            if (!string.IsNullOrWhiteSpace(example.Description))
                            {
                                documentGenerator.AddParagraph("Пояснение к примеру: "
                                                               + TextFormatter.AppendCharIfNeed(example.Description),
                                                               new TextFormat {
                                    IsItalic = true, CountLeftPaddings = 1
                                });
                            }
                        }
                    }
                }
            }

            return(documentGenerator);
        }
        public DocumentationGenerator Download(DocumentType docType,
                                               string fileName,
                                               RepresentationForUser representationForUser)
        {
            DocumentationGenerator documentGenerator = DocumentationGenerator.Create(_domain, _fontPath, docType, fileName);

            var tableData = new TableData(2, true);

            tableData.AddHeader("Слово", "Перевод");
            foreach (RepresentationAreaForUser area in representationForUser.Areas)
            {
                tableData.AddRow(area.Source.Text, area.Translation.Text);
            }

            documentGenerator.AddHeader(string.Format("Визуальный словарь на тему «{0}»", representationForUser.Title));
            documentGenerator.AddTable(tableData);

            return(documentGenerator);
        }
示例#5
0
        public DocumentationGenerator Download(DocumentType docType,
                                               string fileName,
                                               List <SourceWithTranslation> elemsWithTranslations)
        {
            DocumentationGenerator documentGenerator = DocumentationGenerator.Create(_domain, _fontPath, docType,
                                                                                     fileName);

            var tableData = new TableData(2, true);

            tableData.AddHeader(TableHeader, "Перевод");
            foreach (SourceWithTranslation elem in elemsWithTranslations)
            {
                tableData.AddRow(elem.Source.Text, elem.Translation.Text);
            }

            documentGenerator.AddHeader(Header);
            documentGenerator.AddTable(tableData);

            return(documentGenerator);
        }
示例#6
0
        public DocumentationGenerator Download(DocumentType docType,
                                               string fileName,
                                               List <SourceWithTranslation> words)
        {
            DocumentationGenerator documentGenerator = DocumentationGenerator.Create(_domain, _fontPath, docType, fileName);

            var tableData = new TableData(2, true);

            tableData.AddHeader("Слово", "Перевод");
            foreach (SourceWithTranslation word in words)
            {
                tableData.AddRow(word.Source.Text, word.Translation.Text);
            }

            if (string.IsNullOrEmpty(Header))
            {
                Header = "Минилекс Гуннемарка";
            }

            documentGenerator.AddHeader(Header);
            documentGenerator.AddTable(tableData);

            return(documentGenerator);
        }