|
11 | 11 |
|
12 | 12 | namespace Eto.Wpf.Forms.Controls
|
13 | 13 | {
|
14 |
| - public class DrawableHandler : WpfPanel<swc.Canvas, Drawable, Drawable.ICallback>, Drawable.IHandler |
| 14 | + public class DrawableHandler : DrawableHandler<swc.Canvas, Drawable, Drawable.ICallback> { } |
| 15 | + |
| 16 | + public class DrawableHandler<TControl, TWidget, TCallback> : WpfPanel<TControl, TWidget, TCallback>, Drawable.IHandler |
| 17 | + where TControl : swc.Canvas |
| 18 | + where TWidget : Drawable |
| 19 | + where TCallback : Drawable.ICallback |
15 | 20 | {
|
16 | 21 | bool tiled;
|
17 | 22 | sw.FrameworkElement content;
|
@@ -51,9 +56,9 @@ public Size TileSize
|
51 | 56 | }
|
52 | 57 | }
|
53 | 58 |
|
54 |
| - class EtoMainCanvas : swc.Canvas |
| 59 | + public class EtoMainCanvas : swc.Canvas |
55 | 60 | {
|
56 |
| - public DrawableHandler Handler { get; set; } |
| 61 | + public DrawableHandler<TControl, TWidget, TCallback> Handler { get; set; } |
57 | 62 |
|
58 | 63 | protected override void OnMouseDown(sw.Input.MouseButtonEventArgs e)
|
59 | 64 | {
|
@@ -111,7 +116,7 @@ protected override sw.Size ArrangeOverride(sw.Size arrangeSize)
|
111 | 116 | class EtoTile : sw.FrameworkElement
|
112 | 117 | {
|
113 | 118 | Rectangle bounds;
|
114 |
| - public DrawableHandler Handler { get; set; } |
| 119 | + public DrawableHandler<TControl, TWidget, TCallback> Handler { get; set; } |
115 | 120 |
|
116 | 121 | public Rectangle Bounds
|
117 | 122 | {
|
@@ -163,18 +168,26 @@ public override void OnUnLoad(EventArgs e)
|
163 | 168 | UnRegisterScrollable();
|
164 | 169 | }
|
165 | 170 |
|
166 |
| - public void Create() |
| 171 | + protected override TControl CreateControl() |
167 | 172 | {
|
168 |
| - Control = new EtoMainCanvas |
| 173 | + return new EtoMainCanvas |
169 | 174 | {
|
170 | 175 | Handler = this,
|
171 | 176 | SnapsToDevicePixels = true,
|
172 | 177 | FocusVisualStyle = null,
|
173 | 178 | Background = swm.Brushes.Transparent
|
174 |
| - }; |
| 179 | + } as TControl; |
| 180 | + } |
| 181 | + |
| 182 | + protected override void Initialize() |
| 183 | + { |
| 184 | + base.Initialize(); |
| 185 | + |
175 | 186 | Control.Loaded += Control_Loaded;
|
176 | 187 | }
|
177 | 188 |
|
| 189 | + public void Create() { } |
| 190 | + |
178 | 191 | public void Create(bool largeCanvas)
|
179 | 192 | {
|
180 | 193 | AllowTiling = largeCanvas;
|
|
0 commit comments