DebugRenderer.cs 3.06 KB
Newer Older
Eric Domke's avatar
Eric Domke committed
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Svg;
using System.Drawing.Drawing2D;
using System.Drawing;

namespace SVGViewer
{
    class DebugRenderer : ISvgRenderer
    {
        private Region _clip = new Region();
        private Matrix _transform = new Matrix();
        private Stack<ISvgBoundable> _boundables = new Stack<ISvgBoundable>();

        public void SetBoundable(ISvgBoundable boundable)
        {
            _boundables.Push(boundable);
        }
        public ISvgBoundable GetBoundable()
        {
            return _boundables.Peek();
        }
        public ISvgBoundable PopBoundable()
        {
            return _boundables.Pop();
        }


        public float DpiY
        {
            get { return 96; }
        }

        public void DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit graphicsUnit)
        {
            
        }
        public void DrawImageUnscaled(Image image, Point location)
        {
            
        }
        public void DrawPath(Pen pen, GraphicsPath path)
        {
            var newPath = (GraphicsPath)path.Clone();
            newPath.Transform(_transform);

        }
        public void FillPath(Brush brush, GraphicsPath path)
        {
            var newPath = (GraphicsPath)path.Clone();
            newPath.Transform(_transform);
        }
        public Region GetClip()
        {
            return _clip;
        }
        public void RotateTransform(float fAngle, MatrixOrder order = MatrixOrder.Append)
        {
            _transform.Rotate(fAngle, order);
        }
        public void ScaleTransform(float sx, float sy, MatrixOrder order = MatrixOrder.Append)
        {
            _transform.Scale(sx, sy, order);
        }
        public void SetClip(Region region, CombineMode combineMode = CombineMode.Replace)
        {
            switch (combineMode)
            {
                case CombineMode.Intersect:
                    _clip.Intersect(region);
                    break;
                case CombineMode.Complement:
                    _clip.Complement(region);
                    break;
                case CombineMode.Exclude:
                    _clip.Exclude(region);
                    break;
                case CombineMode.Union:
                    _clip.Union(region);
                    break;
                case CombineMode.Xor:
                    _clip.Xor(region);
                    break;
                default:
                    _clip = region;
                    break;
            }
        }
        public void TranslateTransform(float dx, float dy, MatrixOrder order = MatrixOrder.Append)
        {
            _transform.Translate(dx, dy, order);
        }



        public SmoothingMode SmoothingMode
        {
            get { return SmoothingMode.Default; }
            set { /* Do Nothing */ }
        }

        public Matrix Transform
        {
            get { return _transform; }
            set { _transform = value; }
        }

        public void Dispose()
        {
            
        }
    }
}