summaryrefslogtreecommitdiffstats
path: root/DHTMLX.Export.PDF/SchedulerMonth.cs
blob: e23bc88f954c3dc60ed9769c306ff11b3bcca633 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Xml;

namespace DHTMLX.Export.PDF.Scheduler
{
    public class SchedulerMonth
    {
        private string _monthName;
        private string[,] _rows;

        public void Parse(XmlNode parent)
        {
            _monthName = parent.Attributes["label"].Value;
            var parsRows = XMLParser.GetElementsByTagName(parent, "row");
            var cols = XMLParser.GetElementsByTagName(parent, "column");

            if ((parsRows.Count != 0) && (cols.Count != 0))
            {
                _rows = new string[parsRows.Count + 1, 7];
                for (var i = 0; i < cols.Count; i++)
                {
                    _rows[0, i] = cols[i].FirstChild.Value;
                }
                for (var i = 1; i <= parsRows.Count; i++)
                {
                    var values = parsRows[i - 1].FirstChild.Value.Split(new[] { "|" }, StringSplitOptions.None);
                    for (var j = 0; j < values.Length; j++)
                    {
                        _rows[i, j] = values[j];
                    }
                }
            }
        }

        public string GetLabel()
        {
            return _monthName;
        }

        public string[,] GetRows()
        {
            return _rows;
        }

        public string[,] GetOnlyDays()
        {
            var days = new string[_rows.GetLength(0) - 1, 7];


            for (var i = 1; i < _rows.GetLength(0); i++)
            {
                for (var j = 0; j < 7; j++)
                {
                    days[i - 1, j] = _rows[i, j];
                }
            }
            return days;
        }
    }
}