Skip to content

Commit

Permalink
Merge pull request #32 from picoe/curtis/wpf-fix-drawing
Browse files Browse the repository at this point in the history
Wpf/WinForms: Fix initial draw of viewport in some cases.
  • Loading branch information
cwensley authored Aug 8, 2019
2 parents 1944fef + 8c85263 commit 5f47a3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
7 changes: 4 additions & 3 deletions Eto.OpenTK.WinForms/WinGLUserControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ protected override void OnHandleDestroyed(EventArgs e)
protected override void OnPaint(PaintEventArgs e)
{
EnsureValidHandle();
if (context != null)
{
context.Update(windowInfo);
}

base.OnPaint(e);

// prompt view to update when it is repainted
OnResize(EventArgs.Empty);
}

/// <summary>
Expand Down
32 changes: 8 additions & 24 deletions Eto.OpenTK.Wpf/WpfWinGLSurfaceHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class WpfWinGLSurfaceHandler : WindowsFormsHostHandler<WinGLUserControl,
public void CreateWithParams(GraphicsMode mode, int major, int minor, GraphicsContextFlags flags)
{
WinFormsControl = new WinGLUserControl(mode, major, minor, flags);
Control.Focusable = true;
Control.Background = System.Windows.SystemColors.ControlBrush;
}

protected override void Initialize()
Expand All @@ -25,29 +27,15 @@ protected override void Initialize()
HandleEvent(GLSurface.GLDrawEvent);
}

public bool IsInitialized
{
get { return Control.IsInitialized; }
}
public bool IsInitialized => WinFormsControl.IsInitialized;

public void MakeCurrent()
{
WinFormsControl.MakeCurrent();
}
public void MakeCurrent() => WinFormsControl.MakeCurrent();

public void SwapBuffers()
{
WinFormsControl.SwapBuffers();
}

public void updateViewHandler(object sender, EventArgs e)
{
updateView();
}
public void SwapBuffers() => WinFormsControl.SwapBuffers();

public void updateView()
public void UpdateView()
{
if (!Control.IsInitialized)
if (!WinFormsControl.IsInitialized)
return;

MakeCurrent();
Expand All @@ -68,12 +56,8 @@ public override void AttachEvent(string id)
WinFormsControl.ShuttingDown += (sender, e) => Callback.OnShuttingDown(Widget, e);
break;

case GLSurface.ShownEvent:
case GLSurface.SizeChangedEvent:
case GLSurface.GLDrawEvent:
WinFormsControl.SizeChanged += updateViewHandler;
WinFormsControl.Paint += updateViewHandler;
//Control.Resize += (sender, e) => Callback.OnDraw(Widget, EventArgs.Empty);
WinFormsControl.Paint += (sender, e) => UpdateView();
break;

default:
Expand Down
5 changes: 2 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
variables:
variables:
solution: 'Eto.OpenTK.sln'
build.version: '0.1.0-ci-$(Build.BuildNumber)'
build.version: '0.1.2-ci-$(Build.BuildNumber)'
build.configuration: 'Release'
build.arguments: /restore /t:Build;Pack /p:BuildVersion=$(build.version) /p:BuildBranch=$(Build.SourceBranch)


trigger:
- master
Expand Down

0 comments on commit 5f47a3c

Please sign in to comment.