Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of the virtual method CreateControl on wpf DrawableHandler #2458

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/Eto.Wpf/Forms/Controls/DrawableHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

namespace Eto.Wpf.Forms.Controls
{
public class DrawableHandler : WpfPanel<swc.Canvas, Drawable, Drawable.ICallback>, Drawable.IHandler
public class DrawableHandler : DrawableHandler<swc.Canvas, Drawable, Drawable.ICallback> { }

public class DrawableHandler<TControl, TWidget, TCallback> : WpfPanel<TControl, TWidget, TCallback>, Drawable.IHandler
where TControl : swc.Canvas
where TWidget : Drawable
where TCallback : Drawable.ICallback
{
bool tiled;
sw.FrameworkElement content;
Expand Down Expand Up @@ -51,9 +56,9 @@ public Size TileSize
}
}

class EtoMainCanvas : swc.Canvas
public class EtoMainCanvas : swc.Canvas
{
public DrawableHandler Handler { get; set; }
public DrawableHandler<TControl, TWidget, TCallback> Handler { get; set; }

protected override void OnMouseDown(sw.Input.MouseButtonEventArgs e)
{
Expand Down Expand Up @@ -111,7 +116,7 @@ protected override sw.Size ArrangeOverride(sw.Size arrangeSize)
class EtoTile : sw.FrameworkElement
{
Rectangle bounds;
public DrawableHandler Handler { get; set; }
public DrawableHandler<TControl, TWidget, TCallback> Handler { get; set; }

public Rectangle Bounds
{
Expand Down Expand Up @@ -163,18 +168,26 @@ public override void OnUnLoad(EventArgs e)
UnRegisterScrollable();
}

public void Create()
protected override TControl CreateControl()
{
Control = new EtoMainCanvas
return new EtoMainCanvas
{
Handler = this,
SnapsToDevicePixels = true,
FocusVisualStyle = null,
Background = swm.Brushes.Transparent
};
} as TControl;
}

protected override void Initialize()
{
base.Initialize();

Control.Loaded += Control_Loaded;
}

public void Create() { }

public void Create(bool largeCanvas)
{
AllowTiling = largeCanvas;
Expand Down