Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ExportSymbolicDataAnalysisSolutions/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/Style/Dxf/DxfStyleBase.cs @ 9580

Last change on this file since 9580 was 9580, checked in by sforsten, 11 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: 3.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Xml;
6
7namespace OfficeOpenXml.Style.Dxf
8{
9    public abstract class DxfStyleBase<T>
10    {
11        protected ExcelStyles _styles;
12        internal DxfStyleBase(ExcelStyles styles)
13        {
14            _styles = styles;
15            AllowChange = false; //Don't touch this value in the styles.xml (by default). When Dxfs is fully implemented this can be removed.
16        }
17        protected internal abstract string Id { get; }
18        protected internal abstract bool HasValue{get;}
19        protected internal abstract void CreateNodes(XmlHelper helper, string path);
20        protected internal abstract T Clone();
21        protected void SetValueColor(XmlHelper helper,string path, ExcelDxfColor color)
22        {
23            if (color != null && color.HasValue)
24            {
25                if (color.Color != null)
26                {
27                    SetValue(helper, path + "/@rgb", color.Color.Value.ToArgb().ToString("x"));
28                }
29                else if (color.Auto != null)
30                {
31                    SetValueBool(helper, path + "/@auto", color.Auto);
32                }
33                else if (color.Theme != null)
34                {
35                    SetValue(helper, path + "/@theme", color.Theme);
36                }
37                else if (color.Index != null)
38                {
39                    SetValue(helper, path + "/@indexed", color.Index);
40                }
41                if (color.Tint != null)
42                {
43                    SetValue(helper, path + "/@tint", color.Tint);
44                }
45            }
46        }
47        /// <summary>
48        /// Same as SetValue but will set first char to lower case.
49        /// </summary>
50        /// <param name="helper"></param>
51        /// <param name="path"></param>
52        /// <param name="v"></param>
53        protected void SetValueEnum(XmlHelper helper, string path, Enum v)
54        {
55            if (v == null)
56            {
57                helper.DeleteNode(path);
58            }
59            else
60            {
61                var s = v.ToString();
62                s = s.Substring(0, 1).ToLower() + s.Substring(1);
63                helper.SetXmlNodeString(path, s);
64            }
65        }
66        protected void SetValue(XmlHelper helper, string path, object v)
67        {
68            if (v == null)
69            {
70                helper.DeleteNode(path);
71            }
72            else
73            {
74                helper.SetXmlNodeString(path, v.ToString());
75            }
76        }
77        protected void SetValueBool(XmlHelper helper, string path, bool? v)
78        {
79            if (v == null)
80            {
81                helper.DeleteNode(path);
82            }
83            else
84            {
85                helper.SetXmlNodeBool(path, (bool)v);
86            }
87        }
88        protected internal string GetAsString(object v)
89        {
90            return (v ?? "").ToString();
91        }
92        /// <summary>
93        /// Is this value allowed to be changed?
94        /// </summary>
95        protected internal bool AllowChange { get; set; }
96    }
97}
Note: See TracBrowser for help on using the repository browser.