/// <summary> /// Initializes a new instance of the <see cref="ConsoleRenderer"/> class. /// </summary> /// <param name="borderStyleFactory">Style that will be used for drawing border.</param> public ConsoleRenderer(IStyleFactory borderStyleFactory) { this.borderStyleFactory = borderStyleFactory; this.styles = new Dictionary<string, IStyle>() { { GlobalConstants.GridBorderStyle, this.borderStyleFactory.Get(BorderStyleType.Solid) } }; }
public void SetStyle(IStyleFactory style) { _styleManager.Clear(); _styleManager.ChangeBackground(style.GetBackground()); _styleManager.ChangeButtonStyle(style.GetButtonStyle()); _styleManager.ChangeTextBoxStyle(style.GetTextBoxStyle()); PlayStopSound(GeneralObject._backgroundPlayer, playingCommand.play, style.GetMusic(), PlayingType.loop); }
public static IEnumerable <Section> SplitToSections( this Pack.MainDocumentPart mainDocument, IStyleFactory styleFactory) { var sections = mainDocument.Document.Body .SplitToSectionsCore(mainDocument, styleFactory) .ToArray(); return(sections); }
public Label() { _text = "AAAABBBBBCCCCCC"; _bitmapFactory = new BitmapFactory(); _charFactory = new CharFactory(); _styleFactory = new StyleFactory(); Update(); }
public Section( SectionProperties properties, IEnumerable <SectionContent> sectionContents, IImageAccessor imageAccessor, IStyleFactory styleFactory) { _properties = properties; _imageAccessor = imageAccessor; _contents = sectionContents.ToArray(); _styleFactory = styleFactory; }
public static PageContextElement CreateElement( this OpenXmlCompositeElement openXmlComposite, IImageAccessor imageAccessor, IStyleFactory styleFactory) { return(openXmlComposite switch { Word.Paragraph p => Paragraphs.Builders.ParagraphFactory.Create(p, imageAccessor, styleFactory), Word.Table t => Tables.Builders.TableFactory.Create(t, imageAccessor, styleFactory), _ => throw new RendererException("Unhandled element") });
public static IEnumerable <PageContextElement> CreatePageElements( this IEnumerable <OpenXmlCompositeElement> openXmlComposites, IImageAccessor imageAccessor, IStyleFactory styleFactory) { return(openXmlComposites .Select(xml => { var e = xml.CreateElement(imageAccessor, styleFactory); return e; })); }
private static IEnumerable <SectionContent> SplitToSectionContents( this IEnumerable <OpenXml.OpenXmlCompositeElement> xmlElements, ColumnsConfiguration columnsConfiguration, IImageAccessor imageAccessor, IStyleFactory styleFactory) { var sectionContents = new List <SectionContent>(); var stack = xmlElements.ToStack(); var contentElements = new List <OpenXml.OpenXmlCompositeElement>(); while (stack.Count > 0) { var e = stack.Pop(); switch (e) { case Word.Paragraph p: { var(begin, @break, end) = p.SplitByNextBreak(); if (@break == SectionContentBreak.None) { contentElements.Add(p); } else { if (end != null) { stack.Push(end); } contentElements.Add(begin); var childElements = contentElements.CreatePageElements(imageAccessor, styleFactory); sectionContents.Add(new SectionContent(childElements, columnsConfiguration, @break)); contentElements.Clear(); } } break; default: contentElements.Add(e); break; } } if (contentElements.Count > 0) { var childElements = contentElements.CreatePageElements(imageAccessor, styleFactory); sectionContents.Add(new SectionContent(childElements, columnsConfiguration, SectionContentBreak.None)); } return(sectionContents); }
public static Cell From( Word.TableCell wordCell, GridPosition gridPosition, IImageAccessor imageAccessor, IStyleFactory styleFactory) { var childs = wordCell .RenderableChildren() .CreatePageElements(imageAccessor, styleFactory) .ToArray(); var borderStyle = wordCell.GetBorderStyle(); return(new Cell(childs, gridPosition, borderStyle)); }
public static FooterBase CreateFooter( this Word.Footer wordFooter, PageMargin pageMargin, IImageAccessor imageAccessor, IStyleFactory styleFactory) { if (wordFooter == null) { return(new NoFooter(pageMargin)); } var childElements = wordFooter.RenderableChildren().CreatePageElements(imageAccessor, styleFactory); return(new Footer(childElements, pageMargin)); }
public QuestionStyleVisitor( IDomainItemLocator domainItemLocator, IStyledOutputItemFactory styledOutputItemFactory, IStyleFactory styleFactory) { m_domainItemLocator = domainItemLocator; m_styledOutputItemFactory = styledOutputItemFactory; m_styleFactory = styleFactory; StyleStacks.Add(typeof(IntegerQuestionType), new StyleStack(m_styleFactory.CreateIntegerBaseStyle())); StyleStacks.Add(typeof(DecimalQuestionType), new StyleStack(m_styleFactory.CreateDecimalBaseStyle())); StyleStacks.Add(typeof(DateQuestionType), new StyleStack(m_styleFactory.CreateDateBaseStyle())); StyleStacks.Add(typeof(StringQuestionType), new StyleStack(m_styleFactory.CreateStringBaseStyle())); StyleStacks.Add(typeof(BooleanQuestionType), new StyleStack(m_styleFactory.CreateBoolBaseStyle())); }
public void Fill(IStyleFactory factory) { Set<IShapeStyle> added = new Set<IShapeStyle>(); ListStyles.BeginUpdate(); ListStyles.Items.Clear(); foreach (IShapeStyle style in factory) { if (!added.Contains(style)) { ListStyles.Items.Add(style); added.Add(style); } } ListStyles.EndUpdate(); PropertiesStyle.SelectedObject = null; }
private static Section CreateSection( this IReadOnlyCollection <OpenXml.OpenXmlCompositeElement> xmlElements, Word.SectionProperties wordSectionProperties, Pack.MainDocumentPart mainDocumentPart, HeaderFooterConfiguration headerFooterConfiguration, bool isFirst, IStyleFactory styleFactory) { var imageAccessor = new ImageAccessor(mainDocumentPart); var sectionProperties = wordSectionProperties.CreateSectionProperties(mainDocumentPart, isFirst, headerFooterConfiguration); var columnsConfiguration = wordSectionProperties.CreateColumnsConfiguration(sectionProperties.PageConfiguration, sectionProperties.Margin); var sectionContents = xmlElements.SplitToSectionContents(columnsConfiguration, imageAccessor, styleFactory); var sd = new Section(sectionProperties, sectionContents, imageAccessor, styleFactory); return(sd); }
public void Fill(IStyleFactory factory) { Set <IShapeStyle> added = new Set <IShapeStyle>(); ListStyles.BeginUpdate(); ListStyles.Items.Clear(); foreach (IShapeStyle style in factory) { if (!added.Contains(style)) { ListStyles.Items.Add(style); added.Add(style); } } ListStyles.EndUpdate(); PropertiesStyle.SelectedObject = null; }
public static IEnumerable <Cell> InitializeCells( this Word.Table table, IImageAccessor imageAccessor, IStyleFactory styleFactory) { var spans = table.PrepareCellSpans(); var cells = table .Rows() .SelectMany((row, index) => { var rowCells = row.InitializeCells(index, spans, imageAccessor, styleFactory); return(rowCells); }) .Where(c => !c.GridPosition.IsRowMergedCell) .ToArray(); return(cells); }
private static IEnumerable <Cell> InitializeCells( this Word.TableRow row, int rowIndex, List <GridSpanInfo[]> spans, IImageAccessor imageAccessor, IStyleFactory styleFactory) { var cells = row .Cells() .Select((cell, index) => { var gridPosition = GetCellGridPosition(rowIndex, index, spans); var c = Cell.From(cell, gridPosition, imageAccessor, styleFactory); return(c); }) .ToArray(); return(cells); }
public static LineElement CreateField( this ICollection <Word.Run> runs, IStyleFactory styleFactory) { var style = styleFactory.EffectiveTextStyle(runs.First().RunProperties); var run = runs .Skip(1) .First(); var fieldCode = run .ChildsOfType <Word.FieldCode>() .Single(); var text = fieldCode.Text; var field = text.CreateField(style); field.Update(PageVariables.Empty); return(field); }
private static IEnumerable <Section> SplitToSectionsCore( this Word.Body body, Pack.MainDocumentPart mainDocumentPart, IStyleFactory styleFactory) { var sections = new List <Section>(); var sectionElements = new List <OpenXml.OpenXmlCompositeElement>(); var headerFooterConfiguration = HeaderFooterConfiguration.Empty; Word.SectionProperties wordSectionProperties; foreach (var e in body.RenderableChildren()) { sectionElements.Add(e); if (!(e is Word.Paragraph paragraph)) { continue; } wordSectionProperties = paragraph.GetSectionProperties(); if (wordSectionProperties == null) { continue; } var section = sectionElements.CreateSection(wordSectionProperties, mainDocumentPart, headerFooterConfiguration, sections.Count == 0, styleFactory); headerFooterConfiguration = section.HeaderFooterConfiguration; sections.Add(section); sectionElements.Clear(); } wordSectionProperties = body .ChildsOfType <Word.SectionProperties>() .Single(); var lastSection = sectionElements.CreateSection(wordSectionProperties, mainDocumentPart, headerFooterConfiguration, sections.Count == 0, styleFactory); sections.Add(lastSection); return(sections); }
private static IEnumerable <LineElement> CreateParagraphElements( this Word.Run run, IImageAccessor imageAccessor, IStyleFactory styleAccessor) { var textStyle = styleAccessor.EffectiveTextStyle(run.RunProperties); var elements = run .ChildElements .Where(c => c is Word.Text || c is Word.TabChar || c is Word.Drawing || c is Word.Break || c is Word.CarriageReturn) .SelectMany(c => { return(c switch { Word.Text t => t.SplitTextToElements(textStyle), Word.TabChar t => new LineElement[] { new TabElement(textStyle) }, Word.Drawing d => d.CreateInlineDrawing(imageAccessor), Word.CarriageReturn _ => new LineElement[] { new NewLineElement(textStyle) }, Word.Break b => b.CreateBreakElement(textStyle), _ => throw new RendererException("unprocessed child") }); })
public static IEnumerable <LineElement> CreateParagraphElements( this Word.Paragraph paragraph, IImageAccessor imageAccessor, IStyleFactory styleFactory) { var runs = paragraph .SelectRuns() .ToStack(); var elements = new List <LineElement>(); while (runs.Count > 0) { var run = runs.Pop(); if (run.IsFieldStart()) { var fieldRuns = new List <Word.Run> { run }; do { run = runs.Pop(); fieldRuns.Add(run); } while (!run.IsFieldEnd()); var field = fieldRuns.CreateField(styleFactory); elements.Add(field); } else { var runElements = run.CreateParagraphElements(imageAccessor, styleFactory); elements.AddRange(runElements); } } return(elements.Union(new[] { ParagraphCharElement.Create(styleFactory.TextStyle) })); }
public static Table Create(Word.Table wordTable, IImageAccessor imageAccessor, IStyleFactory styleFactory) { var grid = wordTable.InitializeGrid(); var cells = wordTable .InitializeCells(imageAccessor, styleFactory.ForTable(wordTable.Properties())) .OrderBy(c => c.GridPosition.Row) .ThenBy(c => c.GridPosition.Column) .ToArray(); var tableBorder = wordTable .Properties() .TableBorders .GetBorder(); return(new Table(cells, grid, tableBorder)); }
public Document(WordprocessingDocument docx) { _docx = docx; _styleAccessor = StyleFactory.Default(docx.MainDocumentPart); }
public DocumentVectorSource(IStyleFactory styleFactory, INRCDictionary dictionary, AnomalyVectorType anomalyVectorType) { this.styleFactory = styleFactory ?? throw new ArgumentNullException(nameof(styleFactory)); this.dictionary = dictionary ?? throw new ArgumentNullException(nameof(dictionary)); this.anomalyVectorType = anomalyVectorType; }
public StyleCache(IStyleFactory factory) { _factory = factory; }
public static Paragraph Create(Word.Paragraph paragraph, IImageAccessor imageAccessor, IStyleFactory styleFactory) { var paragraphStyleFactory = styleFactory.ForParagraph(paragraph.ParagraphProperties); var fixedDrawings = paragraph .CreateFixedDrawingElements(imageAccessor) .OrderBy(d => d.OffsetFromParent.Y) .ToArray(); var elements = paragraph .CreateParagraphElements(imageAccessor, paragraphStyleFactory); return(new Paragraph(elements, fixedDrawings, paragraphStyleFactory)); }
public PdfCreator(IStyleFactory styleFactory, IParagraphFactory paragraphFactory) { StyleFactory = styleFactory; ParagraphFactory = paragraphFactory; }
public Paragraph(IEnumerable <LineElement> elements, IEnumerable <FixedDrawing> fixedDrawings, IStyleFactory styleFactory) { _unprocessedElements = elements.ToStack(); _fixedDrawings = fixedDrawings.ToArray(); _styleFactory = styleFactory; }