Free cookie consent management tool by TermsFeed Policy Generator

source: branches/LogResidualEvaluator/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/Drawing/ExcelDrawingBorder.cs @ 10204

Last change on this file since 10204 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.6 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-12-22
30 * Jan Källman    License changed GPL-->LGPL 2011-12-16
31 *******************************************************************************/
32using System;
33using System.Collections.Generic;
34using System.Text;
35using System.Xml;
36using System.Drawing;
37
38namespace OfficeOpenXml.Drawing
39{
40    /// <summary>
41    /// Type of Line cap
42    /// </summary>
43    public enum eLineCap
44    {
45        Flat,   //flat
46        Round,  //rnd
47        Square  //Sq
48    }
49    /// <summary>
50    /// Line style.
51    /// </summary>
52    public enum eLineStyle
53    {
54        Dash,
55        DashDot,
56        Dot,
57        LongDash,
58        LongDashDot,
59        LongDashDotDot,
60        Solid,
61        SystemDash,
62        SystemDashDot,
63        SystemDashDotDot,
64        SystemDot
65    }
66    /// <summary>
67    /// Border for drawings
68    /// </summary>   
69    public sealed class ExcelDrawingBorder : XmlHelper
70    {
71        string _linePath;
72        internal ExcelDrawingBorder(XmlNamespaceManager nameSpaceManager, XmlNode topNode, string linePath) :
73            base(nameSpaceManager, topNode)
74        {
75            SchemaNodeOrder = new string[] { "chart","tickLblPos", "spPr", "txPr","crossAx", "printSettings", "showVal", "showCatName", "showSerName", "showPercent", "separator", "showLeaderLines", "noFill", "solidFill", "blipFill", "gradFill", "noFill", "pattFill", "prstDash" };
76            _linePath = linePath;   
77            _lineStylePath = string.Format(_lineStylePath, linePath);
78            _lineCapPath = string.Format(_lineCapPath, linePath);
79            _lineWidth = string.Format(_lineWidth, linePath);
80        }
81        #region "Public properties"
82        ExcelDrawingFill _fill = null;
83        /// <summary>
84        /// Fill
85        /// </summary>
86        public ExcelDrawingFill Fill
87        {
88            get
89            {
90                if (_fill == null)
91                {
92                    _fill = new ExcelDrawingFill(NameSpaceManager, TopNode, _linePath);
93                }
94                return _fill;
95            }
96        }
97        string _lineStylePath = "{0}/a:prstDash/@val";
98        /// <summary>
99        /// Linestyle
100        /// </summary>
101        public eLineStyle LineStyle
102        {
103            get
104            {
105                return TranslateLineStyle(GetXmlNodeString(_lineStylePath));
106            }
107            set
108            {
109                CreateNode(_linePath, false);
110                SetXmlNodeString(_lineStylePath, TranslateLineStyleText(value));
111            }
112        }
113        string _lineCapPath = "{0}/@cap";
114        /// <summary>
115        /// Linecap
116        /// </summary>
117        public eLineCap LineCap
118        {
119            get
120            {
121                return TranslateLineCap(GetXmlNodeString(_lineCapPath));
122            }
123            set
124            {
125                CreateNode(_linePath, false);
126                SetXmlNodeString(_lineCapPath, TranslateLineCapText(value));
127            }
128        }
129        string _lineWidth = "{0}/@w";
130        /// <summary>
131        /// Width in pixels
132        /// </summary>
133        public int Width
134        {
135            get
136            {
137                return GetXmlNodeInt(_lineWidth) / 12700;
138            }
139            set
140            {
141                SetXmlNodeString(_lineWidth, (value * 12700).ToString());
142            }
143        }
144        #endregion
145        #region "Translate Enum functions"
146        private string TranslateLineStyleText(eLineStyle value)
147        {
148            string text=value.ToString();
149            switch (value)
150            {
151                case eLineStyle.Dash:
152                case eLineStyle.Dot:
153                case eLineStyle.DashDot:
154                case eLineStyle.Solid:
155                    return text.Substring(0,1).ToLower() + text.Substring(1,text.Length-1); //First to Lower case.
156                case eLineStyle.LongDash:
157                case eLineStyle.LongDashDot:
158                case eLineStyle.LongDashDotDot:
159                    return "lg" + text.Substring(4, text.Length - 4);
160                case eLineStyle.SystemDash:
161                case eLineStyle.SystemDashDot:
162                case eLineStyle.SystemDashDotDot:
163                case eLineStyle.SystemDot:
164                    return "sys" + text.Substring(6, text.Length - 6);
165                default:
166                    throw(new Exception("Invalid Linestyle"));
167            }
168        }
169        private eLineStyle TranslateLineStyle(string text)
170        {
171            switch (text)
172            {
173                case "dash":
174                case "dot":
175                case "dashDot":
176                case "solid":
177                    return (eLineStyle)Enum.Parse(typeof(eLineStyle), text, true);
178                case "lgDash":
179                case "lgDashDot":
180                case "lgDashDotDot":
181                    return (eLineStyle)Enum.Parse(typeof(eLineStyle), "Long" + text.Substring(2, text.Length - 2));
182                case "sysDash":
183                case "sysDashDot":
184                case "sysDashDotDot":
185                case "sysDot":
186                    return (eLineStyle)Enum.Parse(typeof(eLineStyle), "System" + text.Substring(3, text.Length - 3));
187                default:
188                    throw (new Exception("Invalid Linestyle"));
189            }
190        }
191        private string TranslateLineCapText(eLineCap value)
192        {
193            switch (value)
194            {
195                case eLineCap.Round:
196                    return "rnd";
197                case eLineCap.Square:
198                    return "sq";
199                default:
200                    return "flat";
201            }
202        }
203        private eLineCap TranslateLineCap(string text)
204        {
205            switch (text)
206            {
207                case "rnd":
208                    return eLineCap.Round;
209                case "sq":
210                    return eLineCap.Square;
211                default:
212                    return eLineCap.Flat;
213            }
214        }
215        #endregion
216
217       
218        //public ExcelDrawingFont Font
219        //{
220        //    get
221        //    {
222           
223        //    }
224        //}
225    }
226}
Note: See TracBrowser for help on using the repository browser.