Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorRenderingGdi/Gdi/GdiRenderingBase.cs @ 13777

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

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

File size: 2.5 KB
Line 
1// <developer>kevin@kevlindev.com</developer>
2// <completed>0</completed>
3
4using System;
5using System.Drawing;
6
7using SharpVectors.Dom.Svg;
8
9namespace SharpVectors.Renderers.Gdi
10{
11    /// <summary>     
12    /// Defines the interface required for a rendering node to interact with the renderer and the SVG DOM
13    /// </summary>
14    public abstract class GdiRenderingBase : IDisposable
15    {
16        #region Private Fields
17
18        protected SvgElement element;
19        protected SvgRectF screenRegion;
20
21        #endregion
22
23        #region Constructors and Destructor
24
25        protected GdiRenderingBase(SvgElement element)
26        {
27            this.element      = element;
28            this.screenRegion = SvgRectF.Empty;
29        }
30
31        ~GdiRenderingBase()
32        {
33            this.Dispose(false);
34        }
35
36        #endregion
37
38        #region Public Properties
39
40        public SvgElement Element
41        {
42            get { return element; }
43        }
44
45        public SvgRectF ScreenRegion
46        {
47            get { return screenRegion; }
48            set { screenRegion = value; }
49        }
50
51        public virtual bool IsRecursive
52        {
53            get
54            {
55                return false;
56            }
57        }
58
59        #endregion
60
61        #region Public Methods
62
63        public virtual bool NeedRender(GdiGraphicsRenderer renderer)
64        {
65            // We make this assumption so that the first pass is still fast
66            // That way we don't have to calculate the screen regions
67            // Before a full rendering
68            if (screenRegion == SvgRectF.Empty)
69                return true;
70            if (renderer.InvalidRect == SvgRectF.Empty)
71                return true;
72            if (renderer.InvalidRect.Intersects(screenRegion))
73                // TODO: Eventually add a full path check here?
74                return true;
75
76            return false;
77        }
78
79        // define empty handlers by default
80        public virtual void BeforeRender(GdiGraphicsRenderer renderer) { }
81        public virtual void Render(GdiGraphicsRenderer renderer) { }
82        public virtual void AfterRender(GdiGraphicsRenderer renderer) { }
83
84        #endregion
85
86        #region IDisposable Members
87
88        public void Dispose()
89        {
90            this.Dispose(true);
91            GC.SuppressFinalize(this);
92        }
93
94        protected virtual void Dispose(bool disposing)
95        {
96        }
97
98        #endregion
99    }
100}
101
102
Note: See TracBrowser for help on using the repository browser.