private void Initialize(XLCell cell)
        {
            Author    = cell.Worksheet.Author;
            Container = this;
            Anchor    = XLDrawingAnchor.MoveAndSizeWithCells;
            Style     = new XLDrawingStyle();
            Int32  pRow       = cell.Address.RowNumber;
            Double pRowOffset = 0;

            if (pRow > 1)
            {
                pRow--;
                double prevHeight = cell.CellAbove().WorksheetRow().Height;
                if (prevHeight > 7)
                {
                    pRowOffset = prevHeight - 7;
                }
            }
            Position = new XLDrawingPosition
            {
                Column       = cell.Address.ColumnNumber + 1,
                ColumnOffset = 2,
                Row          = pRow,
                RowOffset    = pRowOffset
            };

            ZOrder = cell.Worksheet.ZOrder++;
            Style
            .Margins.SetLeft(0.1)
            .Margins.SetRight(0.1)
            .Margins.SetTop(0.05)
            .Margins.SetBottom(0.05)
            .Margins.SetAutomatic()
            .Size.SetHeight(59.25)
            .Size.SetWidth(19.2)
            .ColorsAndLines.SetLineColor(XLColor.Black)
            .ColorsAndLines.SetFillColor(XLColor.FromArgb(255, 255, 225))
            .ColorsAndLines.SetLineDash(XLDashStyle.Solid)
            .ColorsAndLines.SetLineStyle(XLLineStyle.Single)
            .ColorsAndLines.SetLineWeight(0.75)
            .ColorsAndLines.SetFillTransparency(1)
            .ColorsAndLines.SetLineTransparency(1)
            .Alignment.SetHorizontal(XLDrawingHorizontalAlignment.Left)
            .Alignment.SetVertical(XLDrawingVerticalAlignment.Top)
            .Alignment.SetDirection(XLDrawingTextDirection.Context)
            .Alignment.SetOrientation(XLDrawingTextOrientation.LeftToRight)
            .Properties.SetPositioning(XLDrawingAnchor.Absolute)
            .Protection.SetLocked()
            .Protection.SetLockText();

            _cell   = cell;
            ShapeId = cell.Worksheet.Workbook.ShapeIdManager.GetNext();
        }
示例#2
0
 public XLDrawing()
 {
     Style    = new XLDrawingStyle();
     Position = new XLDrawingPosition();
 }
示例#3
0
        private void Initialize(XLCell cell, IXLDrawingStyle style = null, int?shapeId = null)
        {
            style   = style ?? XLDrawingStyle.DefaultCommentStyle;
            shapeId = shapeId ?? cell.Worksheet.Workbook.ShapeIdManager.GetNext();

            Author    = cell.Worksheet.Author;
            Container = this;
            Anchor    = XLDrawingAnchor.MoveAndSizeWithCells;
            Style     = new XLDrawingStyle();
            Int32  previousRowNumber = cell.Address.RowNumber;
            Double previousRowOffset = 0;

            if (previousRowNumber > 1)
            {
                previousRowNumber--;

                if (cell.Worksheet.Internals.RowsCollection.TryGetValue(previousRowNumber, out XLRow previousRow))
                {
                    previousRowOffset = Math.Max(0, previousRow.Height - 7);
                }
                else
                {
                    previousRowOffset = Math.Max(0, cell.Worksheet.RowHeight - 7);
                }
            }

            Position = new XLDrawingPosition
            {
                Column       = cell.Address.ColumnNumber + 1,
                ColumnOffset = 2,
                Row          = previousRowNumber,
                RowOffset    = previousRowOffset
            };

            ZOrder = cell.Worksheet.ZOrder++;
            Style
            .Margins.SetLeft(style.Margins.Left)
            .Margins.SetRight(style.Margins.Right)
            .Margins.SetTop(style.Margins.Top)
            .Margins.SetBottom(style.Margins.Bottom)
            .Margins.SetAutomatic(style.Margins.Automatic)
            .Size.SetHeight(style.Size.Height)
            .Size.SetWidth(style.Size.Width)
            .ColorsAndLines.SetLineColor(style.ColorsAndLines.LineColor)
            .ColorsAndLines.SetFillColor(style.ColorsAndLines.FillColor)
            .ColorsAndLines.SetLineDash(style.ColorsAndLines.LineDash)
            .ColorsAndLines.SetLineStyle(style.ColorsAndLines.LineStyle)
            .ColorsAndLines.SetLineWeight(style.ColorsAndLines.LineWeight)
            .ColorsAndLines.SetFillTransparency(style.ColorsAndLines.FillTransparency)
            .ColorsAndLines.SetLineTransparency(style.ColorsAndLines.LineTransparency)
            .Alignment.SetHorizontal(style.Alignment.Horizontal)
            .Alignment.SetVertical(style.Alignment.Vertical)
            .Alignment.SetDirection(style.Alignment.Direction)
            .Alignment.SetOrientation(style.Alignment.Orientation)
            .Alignment.SetAutomaticSize(style.Alignment.AutomaticSize)
            .Properties.SetPositioning(style.Properties.Positioning)
            .Protection.SetLocked(style.Protection.Locked)
            .Protection.SetLockText(style.Protection.LockText);

            _cell   = cell;
            ShapeId = shapeId.Value;
        }