Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Async/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/Style/ExcelGradientFill.cs @ 11642

Last change on this file since 11642 was 9580, checked in by sforsten, 12 years ago

#1730:

  • added SymbolicDataAnalysisExpressionExcelFormatter
  • changed modifiers in SymbolicExpressionTreeChart of methods SaveImageAsBitmap and SaveImageAsEmf to public
  • added menu item ExportSymbolicSolutionToExcelMenuItem to export a symbolic solution to an excel file
  • added EPPlus-3.1.3 to ExtLibs
File size: 7.8 KB
Line 
1/*******************************************************************************
2 * You may amend and distribute as you like, but don't remove this header!
3 *
4 * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets.
5 * See http://www.codeplex.com/EPPlus for details.
6 *
7 * Copyright (C) 2011  Jan Källman
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
17 * See the GNU Lesser General Public License for more details.
18 *
19 * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
20 * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
21 *
22 * All code and executables are provided "as is" with no warranty either express or implied.
23 * The author accepts no liability for any damage or loss of business that this product may cause.
24 *
25 * Code change notes:
26 *
27 * Author             Change            Date
28 * ******************************************************************************
29 * Jan Källman                    Initial Release           2009-10-01
30 * Jan Källman    License changed GPL-->LGPL 2011-12-16
31 *******************************************************************************/
32using System;
33using System.Collections.Generic;
34using System.Text;
35using OfficeOpenXml.Style.XmlAccess;
36using System.Globalization;
37
38namespace OfficeOpenXml.Style
39{
40    /// <summary>
41    /// The background fill of a cell
42    /// </summary>
43    public class ExcelGradientFill : StyleBase
44    {
45        internal ExcelGradientFill(ExcelStyles styles, OfficeOpenXml.XmlHelper.ChangedEventHandler ChangedEvent, int PositionID, string address, int index) :
46            base(styles, ChangedEvent, PositionID, address)
47
48        {
49            Index = index;
50        }
51        /// <summary>
52        /// Angle of the linear gradient
53        /// </summary>
54        public double Degree
55        {
56            get
57            {
58                return ((ExcelGradientFillXml)_styles.Fills[Index]).Degree;
59            }
60            set
61            {
62                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.GradientFill, eStyleProperty.GradientDegree, value, _positionID, _address));
63            }
64        }
65        /// <summary>
66        /// Linear or Path gradient
67        /// </summary>
68        public ExcelFillGradientType Type
69        {
70            get
71            {
72                return ((ExcelGradientFillXml)_styles.Fills[Index]).Type;
73            }
74            set
75            {
76                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.GradientFill, eStyleProperty.GradientType, value, _positionID, _address));
77            }
78        }
79        /// <summary>
80        /// Specifies in percentage format(from the top to the bottom) the position of the top edge of the inner rectangle (color 1). For top, 0 means the top edge of the inner rectangle is on the top edge of the cell, and 1 means it is on the bottom edge of the cell. (applies to From Corner and From Center gradients).
81        /// </summary>
82        public double Top
83        {
84            get
85            {
86                return ((ExcelGradientFillXml)_styles.Fills[Index]).Top;
87            }
88            set
89            {
90                if (value < 0 | value > 1)
91                {
92                    throw (new ArgumentOutOfRangeException("Value must be between 0 and 1"));
93                }
94                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.GradientFill, eStyleProperty.GradientTop, value, _positionID, _address));
95            }
96        }
97        /// <summary>
98        /// Specifies in percentage format (from the top to the bottom) the position of the bottom edge of the inner rectangle (color 1). For bottom, 0 means the bottom edge of the inner rectangle is on the top edge of the cell, and 1 means it is on the bottom edge of the cell.
99        /// </summary>
100        public double Bottom
101        {
102            get
103            {
104                return ((ExcelGradientFillXml)_styles.Fills[Index]).Bottom;
105            }
106            set
107            {
108                if (value < 0 | value > 1)
109                {
110                    throw (new ArgumentOutOfRangeException("Value must be between 0 and 1"));
111                }
112                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.GradientFill, eStyleProperty.GradientBottom, value, _positionID, _address));
113            }
114        }
115        /// <summary>
116        /// Specifies in percentage format (from the left to the right) the position of the left edge of the inner rectangle (color 1). For left, 0 means the left edge of the inner rectangle is on the left edge of the cell, and 1 means it is on the right edge of the cell. (applies to From Corner and From Center gradients).
117        /// </summary>
118        public double Left
119        {
120            get
121            {
122                return ((ExcelGradientFillXml)_styles.Fills[Index]).Left;
123            }
124            set
125            {
126                if (value < 0 | value > 1)
127                {
128                    throw (new ArgumentOutOfRangeException("Value must be between 0 and 1"));
129                }
130                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.GradientFill, eStyleProperty.GradientLeft, value, _positionID, _address));
131            }
132        }
133        /// <summary>
134        /// Specifies in percentage format (from the left to the right) the position of the right edge of the inner rectangle (color 1). For right, 0 means the right edge of the inner rectangle is on the left edge of the cell, and 1 means it is on the right edge of the cell. (applies to From Corner and From Center gradients).
135        /// </summary>
136        public double Right
137        {
138            get
139            {
140                return ((ExcelGradientFillXml)_styles.Fills[Index]).Right;
141            }
142            set
143            {
144                if (value < 0 | value > 1)
145                {
146                    throw (new ArgumentOutOfRangeException("Value must be between 0 and 1"));
147                }
148                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.GradientFill, eStyleProperty.GradientRight, value, _positionID, _address));
149            }
150        }
151        ExcelColor _gradientColor1 = null;
152        /// <summary>
153        /// Gradient Color 1
154        /// </summary>
155        public ExcelColor Color1
156        {
157            get
158            {
159                if (_gradientColor1 == null)
160                {
161                    _gradientColor1 = new ExcelColor(_styles, _ChangedEvent, _positionID, _address, eStyleClass.FillGradientColor1, this);
162                }
163                return _gradientColor1;
164
165            }
166        }
167        ExcelColor _gradientColor2 = null;
168        /// <summary>
169        /// Gradient Color 2
170        /// </summary>
171        public ExcelColor Color2
172        {
173            get
174            {
175                if (_gradientColor2 == null)
176                {
177                    _gradientColor2 = new ExcelColor(_styles, _ChangedEvent, _positionID, _address, eStyleClass.FillGradientColor2, this);
178                }
179                return _gradientColor2;
180
181            }
182        }
183        internal override string Id
184        {
185            get { return Degree.ToString() + Type + Color1.Id + Color2.Id + Top.ToString() + Bottom.ToString() + Left.ToString() + Right.ToString(); }
186        }
187    }
188}
Note: See TracBrowser for help on using the repository browser.