Example #1
0
        private void AddInvertedLineEllipse(ISheet contentSheet, IBlock contentBlock, IBlock selectedBlock, SheetOptions options, double x, double y, double width, double height)
        {
            // create ellipse
            var ellipse = _blockFactory.CreateEllipse(options.LineThickness / options.Zoom, x, y, width, height, false, ItemColors.Black, ItemColors.Transparent);

            contentBlock.Ellipses.Add(ellipse);
            contentSheet.Add(ellipse);
        }
Example #2
0
        public XPoint Deserialize(ISheet sheet, XBlock parent, ItemPoint pointItem, double thickness)
        {
            var point = _blockFactory.CreatePoint(thickness, pointItem.X, pointItem.Y, false);

            point.Id = pointItem.Id;

            parent.Points.Add(point);
            sheet.Add(point);

            return(point);
        }
Example #3
0
        public XLine Deserialize(ISheet sheet, XBlock parent, ItemLine lineItem, double thickness)
        {
            var line = _blockFactory.CreateLine(thickness, lineItem.X1, lineItem.Y1, lineItem.X2, lineItem.Y2, lineItem.Stroke);

            line.Id      = lineItem.Id;
            line.StartId = lineItem.StartId;
            line.EndId   = lineItem.EndId;

            parent.Lines.Add(line);
            sheet.Add(line);

            return(line);
        }
Example #4
0
        public static void Import(this IRawSheetImporterPage page, RawSheetImporter importer, SheetConvertingContext context, ISheet sheet)
        {
            var idColumnName = page.GetCell(0, 0);

            if (idColumnName != nameof(ISheetRow.Id))
            {
                context.Logger.LogError("First column \"{ColumnName}\" must be named \"Id\"", idColumnName);
                return;
            }

            ISheetRow sheetRow = null;

            for (int pageRow = 1; !page.IsEmptyRow(pageRow); ++pageRow)
            {
                var rowId = page.GetCell(0, pageRow);

                if (!string.IsNullOrEmpty(rowId))
                {
                    using (context.Logger.BeginScope(rowId))
                    {
                        sheetRow = Activator.CreateInstance(sheet.RowType) as ISheetRow;

                        page.ImportToObject(importer, context, sheetRow, pageRow);

                        if (sheet.Contains(sheetRow.Id))
                        {
                            context.Logger.LogError("Already has row with id \"{RowId}\"", sheetRow.Id);
                            sheetRow = null;
                        }
                        else
                        {
                            sheet.Add(sheetRow);
                        }
                    }
                }

                if (sheetRow is ISheetRowArray sheetRowArray)
                {
                    using (context.Logger.BeginScope(sheetRow.Id))
                        using (context.Logger.BeginScope(sheetRowArray.Arr.Count))
                        {
                            var sheetElem = Activator.CreateInstance(sheetRowArray.ElemType);

                            page.ImportToObject(importer, context, sheetElem, pageRow);

                            sheetRowArray.Arr.Add(sheetElem);
                        }
                }
            }
        }
Example #5
0
        public void CreateText(ISheet sheet, IList <XText> texts, string content, double x, double y, double width, double height, int halign, int valign, double size, ArgbColor foreground)
        {
            var text = _blockFactory.CreateText(content, x, y, width, height, halign, valign, size, ArgbColors.Transparent, foreground);

            if (texts != null)
            {
                texts.Add(text);
            }

            if (sheet != null)
            {
                sheet.Add(text);
            }
        }
Example #6
0
        public void CreateLine(ISheet sheet, IList <XLine> lines, double thickness, double x1, double y1, double x2, double y2, ArgbColor stroke)
        {
            var line = _blockFactory.CreateLine(thickness, x1, y1, x2, y2, stroke);

            if (lines != null)
            {
                lines.Add(line);
            }

            if (sheet != null)
            {
                sheet.Add(line);
            }
        }
Example #7
0
        public XImage Deserialize(ISheet sheet, XBlock parent, ItemImage imageItem)
        {
            var image = _blockFactory.CreateImage(imageItem.X,
                                                  imageItem.Y,
                                                  imageItem.Width,
                                                  imageItem.Height,
                                                  imageItem.Data);

            image.Id = imageItem.Id;

            parent.Images.Add(image);
            sheet.Add(image);

            return(image);
        }
Example #8
0
        public XText Deserialize(ISheet sheet, XBlock parent, ItemText textItem)
        {
            var text = _blockFactory.CreateText(textItem.Text,
                                                textItem.X, textItem.Y,
                                                textItem.Width, textItem.Height,
                                                textItem.HAlign,
                                                textItem.VAlign,
                                                textItem.Size,
                                                textItem.Backgroud,
                                                textItem.Foreground);

            text.Id = textItem.Id;

            parent.Texts.Add(text);
            sheet.Add(text);

            return(text);
        }
Example #9
0
        public XEllipse Deserialize(ISheet sheet, XBlock parent, ItemEllipse ellipseItem, double thickness)
        {
            var ellipse = _blockFactory.CreateEllipse(thickness,
                                                      ellipseItem.X,
                                                      ellipseItem.Y,
                                                      ellipseItem.Width,
                                                      ellipseItem.Height,
                                                      ellipseItem.IsFilled,
                                                      ellipseItem.Stroke,
                                                      ellipseItem.Fill);

            ellipse.Id = ellipseItem.Id;

            parent.Ellipses.Add(ellipse);
            sheet.Add(ellipse);

            return(ellipse);
        }
Example #10
0
        public XRectangle Deserialize(ISheet sheet, XBlock parent, ItemRectangle rectangleItem, double thickness)
        {
            var rectangle = _blockFactory.CreateRectangle(thickness,
                                                          rectangleItem.X,
                                                          rectangleItem.Y,
                                                          rectangleItem.Width,
                                                          rectangleItem.Height,
                                                          rectangleItem.IsFilled,
                                                          rectangleItem.Stroke,
                                                          rectangleItem.Fill);

            rectangle.Id = rectangleItem.Id;

            parent.Rectangles.Add(rectangle);
            sheet.Add(rectangle);

            return(rectangle);
        }