/// <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) }
     };
 }
Пример #2
0
        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);
        }
Пример #3
0
        public static IEnumerable <Section> SplitToSections(
            this Pack.MainDocumentPart mainDocument,
            IStyleFactory styleFactory)
        {
            var sections = mainDocument.Document.Body
                           .SplitToSectionsCore(mainDocument, styleFactory)
                           .ToArray();

            return(sections);
        }
Пример #4
0
        public Label()
        {
            _text = "AAAABBBBBCCCCCC";

            _bitmapFactory = new BitmapFactory();
            _charFactory = new CharFactory();
            _styleFactory = new StyleFactory();

            Update();
        }
Пример #5
0
        public Label()
        {
            _text = "AAAABBBBBCCCCCC";

            _bitmapFactory = new BitmapFactory();
            _charFactory   = new CharFactory();
            _styleFactory  = new StyleFactory();

            Update();
        }
Пример #6
0
 public Section(
     SectionProperties properties,
     IEnumerable <SectionContent> sectionContents,
     IImageAccessor imageAccessor,
     IStyleFactory styleFactory)
 {
     _properties    = properties;
     _imageAccessor = imageAccessor;
     _contents      = sectionContents.ToArray();
     _styleFactory  = styleFactory;
 }
Пример #7
0
 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")
     });
Пример #8
0
 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;
     }));
 }
Пример #9
0
        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);
        }
Пример #10
0
        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));
        }
Пример #11
0
        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));
        }
Пример #12
0
        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()));
        }
Пример #13
0
 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;
 }
Пример #14
0
        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;
        }
Пример #16
0
        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);
        }
Пример #17
0
        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);
        }
Пример #18
0
        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);
        }
Пример #19
0
        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);
        }
Пример #20
0
        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")
                });
            })
Пример #21
0
        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) }));
        }
Пример #22
0
        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));
        }
Пример #23
0
 public Document(WordprocessingDocument docx)
 {
     _docx          = docx;
     _styleAccessor = StyleFactory.Default(docx.MainDocumentPart);
 }
Пример #24
0
 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;
 }
Пример #25
0
 public StyleCache(IStyleFactory factory)
 {
     _factory = factory;
 }
Пример #26
0
        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));
        }
Пример #27
0
 public PdfCreator(IStyleFactory styleFactory, IParagraphFactory paragraphFactory)
 {
     StyleFactory     = styleFactory;
     ParagraphFactory = paragraphFactory;
 }
Пример #28
0
 public Paragraph(IEnumerable <LineElement> elements, IEnumerable <FixedDrawing> fixedDrawings, IStyleFactory styleFactory)
 {
     _unprocessedElements = elements.ToStack();
     _fixedDrawings       = fixedDrawings.ToArray();
     _styleFactory        = styleFactory;
 }