Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorModel/DocumentStructure/SvgWindow.cs @ 13918

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

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

File size: 4.0 KB
Line 
1using System;
2using System.IO;
3using System.Xml;
4
5using SharpVectors.Dom.Stylesheets;
6
7namespace SharpVectors.Dom.Svg
8{
9    public abstract class SvgWindow : ISvgWindow
10    {
11        #region Private fields
12
13        private long innerWidth;
14        private long innerHeight;
15        private SvgDocument document;
16        private SvgWindow parentWindow;
17
18        private ISvgRenderer renderer;
19
20        #endregion
21
22        #region Contructors and Destructor
23
24        protected SvgWindow(long innerWidth, long innerHeight, ISvgRenderer renderer)
25        {
26            this.renderer = renderer;
27            if (this.renderer != null)
28            {
29                this.renderer.Window = this;
30            }
31
32            this.innerWidth  = innerWidth;
33            this.innerHeight = innerHeight;
34        }
35
36        protected SvgWindow(SvgWindow parentWindow, long innerWidth, long innerHeight)
37            : this(innerWidth, innerHeight, parentWindow.Renderer)
38        {
39            this.parentWindow = parentWindow;
40        }
41
42        #endregion
43
44        #region Public properties
45       
46        public SvgWindow ParentWindow
47        {
48            get
49            {
50                return parentWindow;
51            }
52        }
53       
54        public ISvgRenderer Renderer
55        {
56            get { return renderer; }
57            set { renderer = value; }
58        }
59
60        public abstract DirectoryInfo WorkingDir
61        {
62            get;
63        }
64       
65        #endregion
66
67        #region Public Methods
68
69        /// <summary>
70        /// Create and assign an empty SvgDocument to this window.  This is needed only in situations where the library user needs to create an SVG DOM tree outside of the usual LoadSvgDocument mechanism.
71        /// </summary>
72        public SvgDocument CreateEmptySvgDocument()
73        {
74            return document = new SvgDocument(this);
75        }
76
77        #endregion
78
79        #region ISvgWindow Members
80
81        public virtual long InnerWidth
82        {
83            get
84            {
85                return innerWidth;
86            }
87            set
88            {
89                this.innerWidth = value;
90            }
91        }
92
93        public virtual long InnerHeight
94        {
95            get
96            {
97                return innerHeight;
98            }
99            set
100            {
101                this.innerHeight = value;
102            }
103        }
104
105        public XmlDocumentFragment ParseXML(string source, XmlDocument document)
106        {
107            XmlDocumentFragment frag = document.CreateDocumentFragment();
108            frag.InnerXml = source;
109            return frag;
110        }
111
112        public string PrintNode(XmlNode node)
113        {
114            return node.OuterXml;
115        }
116
117        public IStyleSheet DefaultStyleSheet
118        {
119            get
120            {
121                return null;
122            }
123        }
124
125        public ISvgDocument Document
126        {
127            get
128            {
129                return document;
130            }
131            set
132            {
133                document = (SvgDocument)value;
134            }
135        }
136
137        public abstract void Alert(string message);
138
139        public abstract SvgWindow CreateOwnedWindow(long innerWidth, long innerHeight);
140
141        public abstract string Source
142        {
143            get;
144            set;
145        }
146
147        /// <summary>
148        /// This is expected to be called by the host
149        /// </summary>
150        /// <param name="width">The new width of the control</param>
151        /// <param name="height">The new height of the control</param>
152        public virtual void Resize(int innerWidth, int innerHeight)
153        {
154            this.innerWidth  = innerWidth;
155            this.innerHeight = innerHeight;
156
157            if (Document != null && Document.RootElement != null)
158                (Document.RootElement as SvgSvgElement).Resize();
159        }
160
161        #endregion
162    }
163}
Note: See TracBrowser for help on using the repository browser.