Beispiel #1
0
 /// <summary>
 /// Set a custom gradient fill. Used in conjunction with AppendGradientStop().
 /// </summary>
 /// <param name="GradientType">The gradient fill type. Default value is Linear.</param>
 /// <param name="Degree">The angle in the direction from which the first color starts. The end color is at 180 degrees from this angle. 0 degrees means start from left, 90 degrees from the top, 180 degrees from the right and 270 degrees from below.</param>
 /// <param name="Left">Specifies position of the first color at the left edge, ranging from 0.0 to 1.0. A 0.0 means the position is on the left edge of the cell, and 1.0 means it's on the right edge.</param>
 /// <param name="Right">Specifies position of the first color at the right edge, ranging from 0.0 to 1.0. A 0.0 means the position is on the left edge of the cell, and 1.0 means it's on the right edge.</param>
 /// <param name="Top">Specifies position of the first color at the top edge, ranging from 0.0 to 1.0. A 0.0 means the position is on the top edge of the cell, and 1.0 means it's on the bottom edge.</param>
 /// <param name="Bottom">Specifies position of the first color at the bottom edge, ranging 0.0 to 1.0. A 0.0 means the position is on the top edge of the cell, and 1.0 means it's on the bottom edge.</param>
 public void SetCustomGradient(GradientValues GradientType, double? Degree, double? Left, double? Right, double? Top, double? Bottom)
 {
     HasBeenAssignedValues = true;
     UsePatternFill = false;
     this.gfReal.SetCustomGradient(GradientType, Degree, Left, Right, Top, Bottom);
 }
Beispiel #2
0
 /// <summary>
 /// Set a custom gradient fill. Used in conjunction with AppendGradientStop().
 /// </summary>
 /// <param name="GradientType">The gradient fill type. Default value is Linear.</param>
 /// <param name="Degree">The angle in the direction from which the first color starts. The end color is at 180 degrees from this angle. 0 degrees means start from left, 90 degrees from the top, 180 degrees from the right and 270 degrees from below.</param>
 /// <param name="Left">Specifies position of the first color at the left edge, ranging from 0.0 to 1.0. A 0.0 means the position is on the left edge of the cell, and 1.0 means it's on the right edge.</param>
 /// <param name="Right">Specifies position of the first color at the right edge, ranging from 0.0 to 1.0. A 0.0 means the position is on the left edge of the cell, and 1.0 means it's on the right edge.</param>
 /// <param name="Top">Specifies position of the first color at the top edge, ranging from 0.0 to 1.0. A 0.0 means the position is on the top edge of the cell, and 1.0 means it's on the bottom edge.</param>
 /// <param name="Bottom">Specifies position of the first color at the bottom edge, ranging 0.0 to 1.0. A 0.0 means the position is on the top edge of the cell, and 1.0 means it's on the bottom edge.</param>
 public void SetCustomGradient(GradientValues GradientType, double? Degree, double? Left, double? Right, double? Top, double? Bottom)
 {
     this.Type = GradientType;
     if (Degree != null) this.Degree = Degree.Value;
     if (Left != null) this.Left = Left.Value;
     if (Right != null) this.Right = Right.Value;
     if (Top != null) this.Top = Top.Value;
     if (Bottom != null) this.Bottom = Bottom.Value;
 }
Beispiel #3
0
        /// <summary>
        /// Form SLGradientFill from DocumentFormat.OpenXml.Spreadsheet.GradientFill class.
        /// </summary>
        /// <param name="gradientFill">The source DocumentFormat.OpenXml.Spreadsheet.GradientFill class.</param>
        public void FromGradientFill(GradientFill gradientFill)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(gradientFill))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(GradientStop))
                    {
                        listGradientStops.Add((GradientStop)oxr.LoadCurrentElement().CloneNode(true));
                    }
                }
            }

            if (gradientFill.Type != null)
            {
                this.Type = gradientFill.Type.Value;
            }

            if (gradientFill.Degree != null)
            {
                this.Degree = gradientFill.Degree.Value;
            }

            if (gradientFill.Left != null)
            {
                this.Left = gradientFill.Left.Value;
            }

            if (gradientFill.Right != null)
            {
                this.Right = gradientFill.Right.Value;
            }

            if (gradientFill.Top != null)
            {
                this.Top = gradientFill.Top.Value;
            }

            if (gradientFill.Bottom != null)
            {
                this.Bottom = gradientFill.Bottom.Value;
            }
        }
Beispiel #4
0
 private void SetAllNull()
 {
     this.listGradientStops = new List<GradientStop>();
     this.vType = GradientValues.Linear;
     this.HasType = false;
     this.Degree = null;
     this.Left = null;
     this.Right = null;
     this.Top = null;
     this.Bottom = null;
 }
Beispiel #5
0
        private void SetGradientFill(SLGradientShadingStyleValues ShadingStyle, SLColor Color1, SLColor Color2)
        {
            GradientStop gs;

            switch (ShadingStyle)
            {
                case SLGradientShadingStyleValues.Horizontal1:
                    this.Degree = 90;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Horizontal2:
                    this.Degree = 270;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Horizontal3:
                    this.Degree = 90;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 0.5;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Vertical1:
                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Vertical2:
                    this.Degree = 180;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Vertical3:
                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 0.5;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalUp1:
                    this.Degree = 45;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalUp2:
                    this.Degree = 225;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalUp3:
                    this.Degree = 45;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 0.5;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalDown1:
                    this.Degree = 135;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalDown2:
                    this.Degree = 315;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalDown3:
                    this.Degree = 135;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 0.5;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Corner1:
                    this.Type = GradientValues.Path;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Corner2:
                    this.Type = GradientValues.Path;
                    this.Left = 1;
                    this.Right = 1;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Corner3:
                    this.Type = GradientValues.Path;
                    this.Top = 1;
                    this.Bottom = 1;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Corner4:
                    this.Type = GradientValues.Path;
                    this.Left = 1;
                    this.Right = 1;
                    this.Top = 1;
                    this.Bottom = 1;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.FromCenter:
                    this.Type = GradientValues.Path;
                    this.Left = 0.5;
                    this.Right = 0.5;
                    this.Top = 0.5;
                    this.Bottom = 0.5;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
            }
        }