Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorModel/BasicTypes/SvgLengthList.cs @ 12762

Last change on this file since 12762 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 2.1 KB
Line 
1// <developer>niklas@protocol7.com</developer>
2// <developer>kevin@kevlindev.com.com</developer>
3// <completed>100</completed>
4
5using System;
6using System.Text.RegularExpressions;
7
8namespace SharpVectors.Dom.Svg
9{
10    /// <summary>
11    /// This interface defines a list of SvgLength objects
12    /// </summary>
13    public sealed class SvgLengthList : SvgList<ISvgLength>, ISvgLengthList
14  {
15        #region Fields
16        private SvgElement ownerElement;
17        private SvgLengthDirection direction;
18    private string propertyName;
19        #endregion
20
21        #region Constructors
22        public SvgLengthList()
23        {
24        }
25
26        public SvgLengthList(string listString)
27        {
28            this.FromString(listString);
29        }
30
31        public SvgLengthList(string propertyName, string listString, SvgElement ownerElement, SvgLengthDirection direction)
32        {
33      this.propertyName = propertyName;
34      this.ownerElement = ownerElement;
35      this.direction = direction;
36
37      this.FromString(listString);
38        }
39        #endregion
40
41        public void FromString(string listString)
42        {
43            // remove existing list items
44            Clear();
45
46            if ( listString != null )
47            {
48                // remove leading and trailing whitespace
49                // NOTE: Need to check if .NET whitespace = SVG (XML) whitespace
50                listString = listString.Trim();
51
52                if ( listString.Length > 0 )
53                {
54                    Regex delim = new Regex(@"\s+,?\s*|,\s*");
55                    foreach ( string item in delim.Split(listString) )
56                    {
57                        // the following test is needed to catch consecutive commas
58                        // for example, "one,two,,three"
59                        if ( item.Length == 0 )
60                            throw new DomException(DomExceptionType.SyntaxErr);
61
62                        AppendItem(new SvgLength(ownerElement, propertyName,
63                            direction, item, String.Empty));
64                    }
65                }
66            }
67        }
68  }
69}
Note: See TracBrowser for help on using the repository browser.