From 43c5f5a6736c2c074adda7e71450704a6ac09f8b Mon Sep 17 00:00:00 2001 From: Curtis Wensley Date: Thu, 8 Aug 2019 16:04:09 -0700 Subject: [PATCH 1/2] Wpf/WinForms: Fix initial draw of viewport in some cases. - Only subscribe to Paint to update the view (like before) - Don't override Eto's Control.Shown or SizeChanged event registration, it caused the view to be redrawn many multiple times (and broke those events). - Update the context during OnPaint() instead of calling OnResize to do the same as it has unintended side effects e.g. causes the view not to show initially. - Set the background of the WPF control to ControlBrush so it doesn't show unpainted areas when resizing. --- Eto.OpenTK.WinForms/WinGLUserControl.cs | 7 +++--- Eto.OpenTK.Wpf/WpfWinGLSurfaceHandler.cs | 32 ++++++------------------ 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/Eto.OpenTK.WinForms/WinGLUserControl.cs b/Eto.OpenTK.WinForms/WinGLUserControl.cs index 4f8b2c9..3a67d08 100644 --- a/Eto.OpenTK.WinForms/WinGLUserControl.cs +++ b/Eto.OpenTK.WinForms/WinGLUserControl.cs @@ -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); } /// diff --git a/Eto.OpenTK.Wpf/WpfWinGLSurfaceHandler.cs b/Eto.OpenTK.Wpf/WpfWinGLSurfaceHandler.cs index 9e7aae3..77f6bad 100644 --- a/Eto.OpenTK.Wpf/WpfWinGLSurfaceHandler.cs +++ b/Eto.OpenTK.Wpf/WpfWinGLSurfaceHandler.cs @@ -17,6 +17,8 @@ public class WpfWinGLSurfaceHandler : WindowsFormsHostHandler 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(); @@ -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: From 8c85263539ed2f5e62a778c6e6d00e9a7d67cb4c Mon Sep 17 00:00:00 2001 From: Curtis Wensley Date: Thu, 8 Aug 2019 16:04:54 -0700 Subject: [PATCH 2/2] Update CI to 1.2 --- azure-pipelines.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ff56c43..9df82ea 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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