1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Windows;
|
---|
6 | using System.Windows.Media;
|
---|
7 | using System.ComponentModel;
|
---|
8 |
|
---|
9 | namespace Microsoft.Research.DynamicDataDisplay.Charts
|
---|
10 | {
|
---|
11 | public partial class ViewportPanel
|
---|
12 | {
|
---|
13 | #region Properties
|
---|
14 |
|
---|
15 | #region ViewportBounds
|
---|
16 |
|
---|
17 | [AttachedPropertyBrowsableForChildren]
|
---|
18 | public static DataRect GetViewportBounds(DependencyObject obj)
|
---|
19 | {
|
---|
20 | return (DataRect)obj.GetValue(ViewportBoundsProperty);
|
---|
21 | }
|
---|
22 |
|
---|
23 | public static void SetViewportBounds(DependencyObject obj, DataRect value)
|
---|
24 | {
|
---|
25 | obj.SetValue(ViewportBoundsProperty, value);
|
---|
26 | }
|
---|
27 |
|
---|
28 | public static readonly DependencyProperty ViewportBoundsProperty = DependencyProperty.RegisterAttached(
|
---|
29 | "ViewportBounds",
|
---|
30 | typeof(DataRect),
|
---|
31 | typeof(ViewportPanel),
|
---|
32 | new FrameworkPropertyMetadata(DataRect.Empty, OnLayoutPropertyChanged));
|
---|
33 |
|
---|
34 | #endregion
|
---|
35 |
|
---|
36 | #region X
|
---|
37 |
|
---|
38 | [AttachedPropertyBrowsableForChildren]
|
---|
39 | public static double GetX(DependencyObject obj)
|
---|
40 | {
|
---|
41 | return (double)obj.GetValue(XProperty);
|
---|
42 | }
|
---|
43 |
|
---|
44 | public static void SetX(DependencyObject obj, double value)
|
---|
45 | {
|
---|
46 | obj.SetValue(XProperty, value);
|
---|
47 | }
|
---|
48 |
|
---|
49 | public static readonly DependencyProperty XProperty = DependencyProperty.RegisterAttached(
|
---|
50 | "X",
|
---|
51 | typeof(double),
|
---|
52 | typeof(ViewportPanel),
|
---|
53 | new FrameworkPropertyMetadata(Double.NaN, OnLayoutPropertyChanged));
|
---|
54 |
|
---|
55 | #endregion
|
---|
56 |
|
---|
57 | #region Y
|
---|
58 |
|
---|
59 | [AttachedPropertyBrowsableForChildren]
|
---|
60 | public static double GetY(DependencyObject obj)
|
---|
61 | {
|
---|
62 | return (double)obj.GetValue(YProperty);
|
---|
63 | }
|
---|
64 |
|
---|
65 | public static void SetY(DependencyObject obj, double value)
|
---|
66 | {
|
---|
67 | obj.SetValue(YProperty, value);
|
---|
68 | }
|
---|
69 |
|
---|
70 | public static readonly DependencyProperty YProperty = DependencyProperty.RegisterAttached(
|
---|
71 | "Y",
|
---|
72 | typeof(double),
|
---|
73 | typeof(ViewportPanel),
|
---|
74 | new FrameworkPropertyMetadata(Double.NaN, OnLayoutPropertyChanged));
|
---|
75 |
|
---|
76 | #endregion
|
---|
77 |
|
---|
78 | #region ViewportWidth
|
---|
79 |
|
---|
80 | [AttachedPropertyBrowsableForChildren]
|
---|
81 | public static double GetViewportWidth(DependencyObject obj)
|
---|
82 | {
|
---|
83 | return (double)obj.GetValue(ViewportWidthProperty);
|
---|
84 | }
|
---|
85 |
|
---|
86 | public static void SetViewportWidth(DependencyObject obj, double value)
|
---|
87 | {
|
---|
88 | obj.SetValue(ViewportWidthProperty, value);
|
---|
89 | }
|
---|
90 |
|
---|
91 | public static readonly DependencyProperty ViewportWidthProperty = DependencyProperty.RegisterAttached(
|
---|
92 | "ViewportWidth",
|
---|
93 | typeof(double),
|
---|
94 | typeof(ViewportPanel),
|
---|
95 | new FrameworkPropertyMetadata(Double.NaN, OnLayoutPropertyChanged));
|
---|
96 |
|
---|
97 | #endregion
|
---|
98 |
|
---|
99 | #region ViewportHeight
|
---|
100 |
|
---|
101 | [AttachedPropertyBrowsableForChildren]
|
---|
102 | public static double GetViewportHeight(DependencyObject obj)
|
---|
103 | {
|
---|
104 | return (double)obj.GetValue(ViewportHeightProperty);
|
---|
105 | }
|
---|
106 |
|
---|
107 | public static void SetViewportHeight(DependencyObject obj, double value)
|
---|
108 | {
|
---|
109 | obj.SetValue(ViewportHeightProperty, value);
|
---|
110 | }
|
---|
111 |
|
---|
112 | public static readonly DependencyProperty ViewportHeightProperty = DependencyProperty.RegisterAttached(
|
---|
113 | "ViewportHeight",
|
---|
114 | typeof(double),
|
---|
115 | typeof(ViewportPanel),
|
---|
116 | new FrameworkPropertyMetadata(Double.NaN, OnLayoutPropertyChanged));
|
---|
117 |
|
---|
118 | #endregion
|
---|
119 |
|
---|
120 | #region ScreenOffsetX
|
---|
121 |
|
---|
122 | [AttachedPropertyBrowsableForChildren]
|
---|
123 | public static double GetScreenOffsetX(DependencyObject obj)
|
---|
124 | {
|
---|
125 | return (double)obj.GetValue(ScreenOffsetXProperty);
|
---|
126 | }
|
---|
127 |
|
---|
128 | public static void SetScreenOffsetX(DependencyObject obj, double value)
|
---|
129 | {
|
---|
130 | obj.SetValue(ScreenOffsetXProperty, value);
|
---|
131 | }
|
---|
132 |
|
---|
133 | public static readonly DependencyProperty ScreenOffsetXProperty = DependencyProperty.RegisterAttached(
|
---|
134 | "ScreenOffsetX",
|
---|
135 | typeof(double),
|
---|
136 | typeof(ViewportPanel),
|
---|
137 | new FrameworkPropertyMetadata(Double.NaN, OnLayoutPropertyChanged));
|
---|
138 |
|
---|
139 | #endregion
|
---|
140 |
|
---|
141 | #region ScreenOffsetY
|
---|
142 |
|
---|
143 | [AttachedPropertyBrowsableForChildren]
|
---|
144 | public static double GetScreenOffsetY(DependencyObject obj)
|
---|
145 | {
|
---|
146 | return (double)obj.GetValue(ScreenOffsetYProperty);
|
---|
147 | }
|
---|
148 |
|
---|
149 | public static void SetScreenOffsetY(DependencyObject obj, double value)
|
---|
150 | {
|
---|
151 | obj.SetValue(ScreenOffsetYProperty, value);
|
---|
152 | }
|
---|
153 |
|
---|
154 | public static readonly DependencyProperty ScreenOffsetYProperty = DependencyProperty.RegisterAttached(
|
---|
155 | "ScreenOffsetY",
|
---|
156 | typeof(double),
|
---|
157 | typeof(ViewportPanel),
|
---|
158 | new FrameworkPropertyMetadata(Double.NaN, OnLayoutPropertyChanged));
|
---|
159 |
|
---|
160 | #endregion
|
---|
161 |
|
---|
162 | #region HorizontalAlignment
|
---|
163 |
|
---|
164 | [AttachedPropertyBrowsableForChildren]
|
---|
165 | public static HorizontalAlignment GetViewportHorizontalAlignment(DependencyObject obj)
|
---|
166 | {
|
---|
167 | return (HorizontalAlignment)obj.GetValue(ViewportHorizontalAlignmentProperty);
|
---|
168 | }
|
---|
169 |
|
---|
170 | public static void SetViewportHorizontalAlignment(DependencyObject obj, HorizontalAlignment value)
|
---|
171 | {
|
---|
172 | obj.SetValue(ViewportHorizontalAlignmentProperty, value);
|
---|
173 | }
|
---|
174 |
|
---|
175 | public static readonly DependencyProperty ViewportHorizontalAlignmentProperty = DependencyProperty.RegisterAttached(
|
---|
176 | "ViewportHorizontalAlignment",
|
---|
177 | typeof(HorizontalAlignment),
|
---|
178 | typeof(ViewportPanel),
|
---|
179 | new FrameworkPropertyMetadata(HorizontalAlignment.Center, OnLayoutPropertyChanged));
|
---|
180 |
|
---|
181 | #endregion
|
---|
182 |
|
---|
183 | #region VerticalAlignment
|
---|
184 |
|
---|
185 | [AttachedPropertyBrowsableForChildren]
|
---|
186 | public static VerticalAlignment GetViewportVerticalAlignment(DependencyObject obj)
|
---|
187 | {
|
---|
188 | return (VerticalAlignment)obj.GetValue(ViewportVerticalAlignmentProperty);
|
---|
189 | }
|
---|
190 |
|
---|
191 | public static void SetViewportVerticalAlignment(DependencyObject obj, VerticalAlignment value)
|
---|
192 | {
|
---|
193 | obj.SetValue(ViewportVerticalAlignmentProperty, value);
|
---|
194 | }
|
---|
195 |
|
---|
196 | public static readonly DependencyProperty ViewportVerticalAlignmentProperty = DependencyProperty.RegisterAttached(
|
---|
197 | "ViewportVerticalAlignment",
|
---|
198 | typeof(VerticalAlignment),
|
---|
199 | typeof(ViewportPanel),
|
---|
200 | new FrameworkPropertyMetadata(VerticalAlignment.Center, OnLayoutPropertyChanged));
|
---|
201 |
|
---|
202 | #endregion
|
---|
203 |
|
---|
204 | #region ActualViewportBounds
|
---|
205 |
|
---|
206 | public static DataRect GetActualViewportBounds(DependencyObject obj)
|
---|
207 | {
|
---|
208 | return (DataRect)obj.GetValue(ActualViewportBoundsProperty);
|
---|
209 | }
|
---|
210 |
|
---|
211 | public static void SetActualViewportBounds(DependencyObject obj, DataRect value)
|
---|
212 | {
|
---|
213 | obj.SetValue(ActualViewportBoundsProperty, value);
|
---|
214 | }
|
---|
215 |
|
---|
216 | public static readonly DependencyProperty ActualViewportBoundsProperty = DependencyProperty.RegisterAttached(
|
---|
217 | "ActualViewportBounds",
|
---|
218 | typeof(DataRect),
|
---|
219 | typeof(ViewportPanel),
|
---|
220 | new FrameworkPropertyMetadata(DataRect.Empty));
|
---|
221 |
|
---|
222 | #endregion
|
---|
223 |
|
---|
224 | #region PrevActualViewportBounds
|
---|
225 |
|
---|
226 | [EditorBrowsable(EditorBrowsableState.Never)]
|
---|
227 | public static DataRect GetPrevActualViewportBounds(DependencyObject obj)
|
---|
228 | {
|
---|
229 | return (DataRect)obj.GetValue(PrevActualViewportBoundsProperty);
|
---|
230 | }
|
---|
231 |
|
---|
232 | public static void SetPrevActualViewportBounds(DependencyObject obj, DataRect value)
|
---|
233 | {
|
---|
234 | obj.SetValue(PrevActualViewportBoundsProperty, value);
|
---|
235 | }
|
---|
236 |
|
---|
237 | public static readonly DependencyProperty PrevActualViewportBoundsProperty = DependencyProperty.RegisterAttached(
|
---|
238 | "PrevActualViewportBounds",
|
---|
239 | typeof(DataRect),
|
---|
240 | typeof(ViewportPanel),
|
---|
241 | new FrameworkPropertyMetadata(DataRect.Empty));
|
---|
242 |
|
---|
243 | #endregion
|
---|
244 |
|
---|
245 | #region MinScreenWidth
|
---|
246 |
|
---|
247 | public static double GetMinScreenWidth(DependencyObject obj)
|
---|
248 | {
|
---|
249 | return (double)obj.GetValue(MinScreenWidthProperty);
|
---|
250 | }
|
---|
251 |
|
---|
252 | public static void SetMinScreenWidth(DependencyObject obj, double value)
|
---|
253 | {
|
---|
254 | obj.SetValue(MinScreenWidthProperty, value);
|
---|
255 | }
|
---|
256 |
|
---|
257 | public static readonly DependencyProperty MinScreenWidthProperty = DependencyProperty.RegisterAttached(
|
---|
258 | "MinScreenWidth",
|
---|
259 | typeof(double),
|
---|
260 | typeof(ViewportPanel),
|
---|
261 | new FrameworkPropertyMetadata(Double.NaN, OnLayoutPropertyChanged));
|
---|
262 |
|
---|
263 | #endregion // end of MinScreenWidth
|
---|
264 |
|
---|
265 | protected static void OnLayoutPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
---|
266 | {
|
---|
267 | FrameworkElement uiElement = d as FrameworkElement;
|
---|
268 | if (uiElement != null)
|
---|
269 | {
|
---|
270 | ViewportPanel panel = VisualTreeHelper.GetParent(uiElement) as ViewportPanel;
|
---|
271 | if (panel != null)
|
---|
272 | {
|
---|
273 | // invalidating not self arrange, but calling Arrange method of only that uiElement which has changed position
|
---|
274 | panel.InvalidatePosition(uiElement);
|
---|
275 | }
|
---|
276 | }
|
---|
277 | }
|
---|
278 |
|
---|
279 | #region IsMarkersHost
|
---|
280 |
|
---|
281 | public bool IsMarkersHost
|
---|
282 | {
|
---|
283 | get { return (bool)GetValue(IsMarkersHostProperty); }
|
---|
284 | set { SetValue(IsMarkersHostProperty, value); }
|
---|
285 | }
|
---|
286 |
|
---|
287 | public static readonly DependencyProperty IsMarkersHostProperty = DependencyProperty.Register(
|
---|
288 | "IsMarkersHost",
|
---|
289 | typeof(bool),
|
---|
290 | typeof(ViewportPanel),
|
---|
291 | new FrameworkPropertyMetadata(false));
|
---|
292 |
|
---|
293 | #endregion // end of IsMarkersHost
|
---|
294 |
|
---|
295 | #endregion
|
---|
296 | }
|
---|
297 | }
|
---|