Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/Style/ExcelFont.cs @ 10355

Last change on this file since 10355 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.7 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 System.Drawing;
36
37namespace OfficeOpenXml.Style
38{
39    /// <summary>
40    /// Cell style Font
41    /// </summary>
42    public sealed class ExcelFont : StyleBase
43    {
44        internal ExcelFont(ExcelStyles styles, OfficeOpenXml.XmlHelper.ChangedEventHandler ChangedEvent, int PositionID, string address, int index) :
45            base(styles, ChangedEvent, PositionID, address)
46
47        {
48            Index = index;
49        }
50        /// <summary>
51        /// The name of the font
52        /// </summary>
53        public string Name
54        {
55            get
56            {
57                return _styles.Fonts[Index].Name;
58            }
59            set
60            {
61                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.Name, value, _positionID, _address));
62            }
63        }
64        /// <summary>
65        /// The Size of the font
66        /// </summary>
67        public float Size
68        {
69            get
70            {
71                return _styles.Fonts[Index].Size;
72            }
73            set
74            {
75                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.Size, value, _positionID, _address));
76            }
77        }
78        /// <summary>
79        /// Font family
80        /// </summary>
81        public int Family
82        {
83            get
84            {
85                return _styles.Fonts[Index].Family;
86            }
87            set
88            {
89                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.Family, value, _positionID, _address));
90            }
91        }
92        /// <summary>
93        /// Cell color
94        /// </summary>
95        public ExcelColor Color
96        {
97            get
98            {
99                return new ExcelColor(_styles, _ChangedEvent, _positionID, _address, eStyleClass.Font, this);
100            }
101        }
102        /// <summary>
103        /// Scheme
104        /// </summary>
105        public string Scheme
106        {
107            get
108            {
109                return _styles.Fonts[Index].Scheme;
110            }
111            set
112            {
113                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.Scheme, value, _positionID, _address));
114            }
115        }
116        /// <summary>
117        /// Font-bold
118        /// </summary>
119        public bool Bold
120        {
121            get
122            {
123                return _styles.Fonts[Index].Bold;
124            }
125            set
126            {
127                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.Bold, value, _positionID, _address));
128            }
129        }
130        /// <summary>
131        /// Font-italic
132        /// </summary>
133        public bool Italic
134        {
135            get
136            {
137                return _styles.Fonts[Index].Italic;
138            }
139            set
140            {
141                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.Italic, value, _positionID, _address));
142            }
143        }
144        /// <summary>
145        /// Font-Strikeout
146        /// </summary>
147        public bool Strike
148        {
149            get
150            {
151                return _styles.Fonts[Index].Strike;
152            }
153            set
154            {
155                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.Strike, value, _positionID, _address));
156            }
157        }
158        /// <summary>
159        /// Font-Underline
160        /// </summary>
161        public bool UnderLine
162        {
163            get
164            {
165                return _styles.Fonts[Index].UnderLine;
166            }
167            set
168            {
169                if (value)
170                {
171                    UnderLineType = ExcelUnderLineType.Single;
172                }
173                else
174                {
175                    UnderLineType = ExcelUnderLineType.None;
176                }
177                //_ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.UnderlineType, value, _positionID, _address));
178            }
179        }
180        public ExcelUnderLineType UnderLineType
181        {
182            get
183            {
184                return _styles.Fonts[Index].UnderLineType;
185            }
186            set
187            {
188                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.UnderlineType, value, _positionID, _address));
189            }
190        }
191        /// <summary>
192        /// Font-Vertical Align
193        /// </summary>
194        public ExcelVerticalAlignmentFont VerticalAlign
195        {
196            get
197            {
198                if (_styles.Fonts[Index].VerticalAlign == "")
199                {
200                    return ExcelVerticalAlignmentFont.None;
201                }
202                else
203                {
204                    return (ExcelVerticalAlignmentFont)Enum.Parse(typeof(ExcelVerticalAlignmentFont), _styles.Fonts[Index].VerticalAlign, true);
205                }
206            }
207            set
208            {
209                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Font, eStyleProperty.VerticalAlign, value, _positionID, _address));
210            }
211        }
212        /// <summary>
213        /// Set the font from a Font object
214        /// </summary>
215        /// <param name="Font"></param>
216        public void SetFromFont(Font Font)
217        {
218            Name = Font.Name;
219            //Family=fnt.FontFamily.;
220            Size = (int)Font.Size;
221            Strike = Font.Strikeout;
222            Bold = Font.Bold;
223            UnderLine = Font.Underline;
224            Italic = Font.Italic;
225        }
226
227        internal override string Id
228        {
229            get
230            {
231                return Name + Size.ToString() + Family.ToString() + Scheme.ToString() + Bold.ToString()[0] + Italic.ToString()[0] + Strike.ToString()[0] + UnderLine.ToString()[0] + VerticalAlign;
232            }
233        }
234    }
235}
Note: See TracBrowser for help on using the repository browser.