프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ZoomAndPan / ZoomAndPanControl_ScrollInfo.cs @ f65e6c02

이력 | 보기 | 이력해설 | 다운로드 (3.86 KB)

1

2
using System.Windows;
3
using System.Windows.Controls;
4
using System.Windows.Controls.Primitives;
5
using System.Windows.Media;
6

    
7
namespace ZoomAndPan
8
{
9
    public partial class ZoomAndPanControl : IScrollInfo
10
    {
11
        public ScrollViewer ScrollOwner
12
        {
13
            get
14
            {
15
                return scrollOwner;
16
            }
17
            set
18
            {
19
                scrollOwner = value;
20
            }
21
        }
22

    
23
        public double ViewportWidth
24
        {
25
            get
26
            {
27
                return viewport.Width;
28
            }
29
        }
30

    
31
        public double ViewportHeight
32
        {
33
            get
34
            {
35
                return viewport.Height;
36
            }
37
        }
38

    
39
        public bool CanHorizontallyScroll
40
        {
41
            get { return canHorizontallyScroll; }
42

    
43
            set { canHorizontallyScroll = value; }
44
        }
45

    
46
        public bool CanVerticallyScroll
47
        {
48

    
49
            get { return canVerticallyScroll; }
50
            set { canVerticallyScroll = value; }
51
        }
52

    
53
        public double ExtentHeight
54
        {
55
            get
56
            {
57
                return unScaledExtent.Height * ContentScale;
58
            }
59
        }
60

    
61
        public double ExtentWidth
62
        {
63
            get { return unScaledExtent.Width * ContentScale; }
64
        }
65

    
66
        public double VerticalOffset
67
        {
68
            get { return ContentOffsetY * ContentScale; }
69
        }
70

    
71
        public double HorizontalOffset
72
        {
73
            get { return ContentOffsetX * ContentScale; }
74
        }
75

    
76
        public void LineDown()
77
        {
78
            ContentOffsetY += (ContentViewportHeight / 10);
79
        }
80

    
81
        public void LineLeft()
82
        {
83
            ContentOffsetX -= (ContentViewportWidth / 10);
84
        }
85

    
86
        public void LineRight()
87
        {
88
            ContentOffsetX += (ContentViewportWidth / 10);
89
        }
90

    
91
        public void LineUp()
92
        {
93
            ContentOffsetY -= (ContentViewportHeight / 10);
94
        }
95

    
96
        public void MouseWheelDown()
97
        {
98
            if (IsMouseWheelScrollingEnabled)
99
            {
100
                LineDown();
101
            }
102
        }
103

    
104
        public void MouseWheelLeft()
105
        {
106
            if (IsMouseWheelScrollingEnabled)
107
            {
108
                LineLeft();
109
            }
110
        }
111

    
112
        public void MouseWheelRight()
113
        {
114
            if (IsMouseWheelScrollingEnabled)
115
            {
116
                LineRight();
117
            }
118
        }
119

    
120
        public void MouseWheelUp()
121
        {
122
            if (IsMouseWheelScrollingEnabled)
123
            {
124
                LineUp();
125
            }
126
        }
127

    
128
        public void PageDown()
129
        {
130
            ContentOffsetY += ContentViewportHeight;
131
        }
132

    
133
        public void PageLeft()
134
        {
135
            ContentOffsetX -= ContentViewportWidth;
136
        }
137

    
138
        public void PageRight()
139
        {
140
            ContentOffsetX += ContentViewportWidth;
141
        }
142

    
143
        public void PageUp()
144
        {
145
            ContentOffsetY -= ContentViewportHeight;
146
        }
147

    
148
        public void SetHorizontalOffset(double offset)
149
        {
150
            if (disableScrollOffsetSync)
151
                return;
152

    
153
            try
154
            {
155
                disableScrollOffsetSync = true;
156

    
157
                ContentOffsetX = offset / ContentScale;
158
            }
159
            finally
160
            {
161
                disableScrollOffsetSync = false;
162
            }
163
        }
164

    
165
        public void SetVerticalOffset(double offset)
166
        {
167
            if (disableScrollOffsetSync)
168
                return;
169
            try
170
            {
171
                disableScrollOffsetSync = true;
172
                ContentOffsetY = offset / ContentScale;
173
            }
174
            finally
175
            {
176
                disableScrollOffsetSync = false;
177
            }
178
        }
179

    
180
        public Rect MakeVisible(Visual visual, Rect rectangle)
181
        {
182
            return rectangle;
183
        }
184

    
185
    }
186
}
클립보드 이미지 추가 (최대 크기: 500 MB)