Exemplo n.º 1
0
        internal A.Outline ToOutline()
        {
            var ol = new A.Outline();

            if (UseNoLine)
            {
                ol.Append(new A.NoFill());
            }
            if (UseSolidLine)
            {
                if (SolidColor.IsRgbColorModelHex)
                {
                    ol.Append(new A.SolidFill {
                        RgbColorModelHex = SolidColor.ToRgbColorModelHex()
                    });
                }
                else
                {
                    ol.Append(new A.SolidFill {
                        SchemeColor = SolidColor.ToSchemeColor()
                    });
                }
            }
            if (UseGradientLine)
            {
                ol.Append(GradientColor.ToGradientFill());
            }

            if (HasDashType)
            {
                ol.Append(new A.PresetDash {
                    Val = DashType
                });
            }

            if (HasJoinType)
            {
                switch (JoinType)
                {
                case SLLineJoinValues.Round:
                    ol.Append(new A.Round());
                    break;

                case SLLineJoinValues.Bevel:
                    ol.Append(new A.Bevel());
                    break;

                case SLLineJoinValues.Miter:
                    // 800000 was the default Excel gave
                    ol.Append(new A.Miter {
                        Limit = 800000
                    });
                    break;
                }
            }

            if (HeadEndType != null)
            {
                ol.Append(GetHeadEnd());
            }
            if (TailEndType != null)
            {
                ol.Append(GetTailEnd());
            }

            if (HasWidth)
            {
                ol.Width = Convert.ToInt32(Width * SLConstants.PointToEMU);
            }
            if (HasCapType)
            {
                ol.CapType = CapType;
            }
            if (HasCompoundLineType)
            {
                ol.CompoundLineType = CompoundLineType;
            }
            if (Alignment != null)
            {
                ol.Alignment = Alignment.Value;
            }

            return(ol);
        }
Exemplo n.º 2
0
        internal OpenXmlElement ToFill()
        {
            OpenXmlElement oxe = new A.NoFill();

            if (Type == SLFillType.NoFill)
            {
                return(new A.NoFill());
            }
            if (Type == SLFillType.SolidFill)
            {
                var sf = new A.SolidFill();
                if (SolidColor.IsRgbColorModelHex)
                {
                    sf.RgbColorModelHex = SolidColor.ToRgbColorModelHex();
                }
                else
                {
                    sf.SchemeColor = SolidColor.ToSchemeColor();
                }
                return(sf);
            }
            if (Type == SLFillType.GradientFill)
            {
                return(GradientColor.ToGradientFill());
            }
            if (Type == SLFillType.BlipFill)
            {
                var bf = new A.BlipFill();
                if (BlipDpi != null)
                {
                    bf.Dpi = BlipDpi.Value;
                }
                if (BlipRotateWithShape != null)
                {
                    bf.RotateWithShape = BlipRotateWithShape.Value;
                }

                bf.Blip       = new A.Blip();
                bf.Blip.Embed = BlipRelationshipID;
                if (BlipTransparency > 0m)
                {
                    bf.Blip.Append(new A.AlphaModulationFixed {
                        Amount = SLDrawingTool.CalculateAlpha(BlipTransparency)
                    });
                }
                bf.Append(new A.SourceRectangle());
                if (BlipTile)
                {
                    bf.Append(new A.Tile
                    {
                        HorizontalOffset = SLDrawingTool.CalculateCoordinate(BlipOffsetX),
                        VerticalOffset   = SLDrawingTool.CalculateCoordinate(BlipOffsetY),
                        HorizontalRatio  = SLDrawingTool.CalculatePercentage(BlipScaleX),
                        VerticalRatio    = SLDrawingTool.CalculatePercentage(BlipScaleY),
                        Flip             = BlipMirrorType,
                        Alignment        = BlipAlignment
                    });
                }
                else
                {
                    bf.Append(new A.Stretch
                    {
                        FillRectangle = new A.FillRectangle
                        {
                            Left   = SLDrawingTool.CalculatePercentage(BlipLeftOffset),
                            Top    = SLDrawingTool.CalculatePercentage(BlipTopOffset),
                            Right  = SLDrawingTool.CalculatePercentage(BlipRightOffset),
                            Bottom = SLDrawingTool.CalculatePercentage(BlipBottomOffset)
                        }
                    });
                }
                return(bf);
            }
            if (Type == SLFillType.PatternFill)
            {
                var pf = new A.PatternFill();
                pf.Preset = A.PresetPatternValues.Trellis;

                pf.ForegroundColor = new A.ForegroundColor();
                if (PatternForegroundColor.IsRgbColorModelHex)
                {
                    pf.ForegroundColor.RgbColorModelHex = PatternForegroundColor.ToRgbColorModelHex();
                }
                else
                {
                    pf.ForegroundColor.SchemeColor = PatternForegroundColor.ToSchemeColor();
                }

                pf.BackgroundColor = new A.BackgroundColor();
                if (PatternBackgroundColor.IsRgbColorModelHex)
                {
                    pf.BackgroundColor.RgbColorModelHex = PatternBackgroundColor.ToRgbColorModelHex();
                }
                else
                {
                    pf.BackgroundColor.SchemeColor = PatternBackgroundColor.ToSchemeColor();
                }

                return(pf);
            }

            return(oxe);
        }