From 38708b351ba85863d00ee8a345179cd3b5ca6c82 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 31 Aug 2011 17:26:47 +0200 Subject: [PATCH] fix SD-1859 - Crash when opening Goto Dialog --- .../Base/Project/Src/Gui/FormLocationHelper.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/FormLocationHelper.cs b/src/Main/Base/Project/Src/Gui/FormLocationHelper.cs index 00d900c4b1..03159a79fd 100644 --- a/src/Main/Base/Project/Src/Gui/FormLocationHelper.cs +++ b/src/Main/Base/Project/Src/Gui/FormLocationHelper.cs @@ -41,7 +41,10 @@ namespace ICSharpCode.SharpDevelop.Gui if (isResizable) { Rect bounds = PropertyService.Get(propertyName, GetDefaultBounds(window)); bounds.Offset(ownerLocation.X, ownerLocation.Y); - bounds = Validate(bounds.TransformToDevice(window).ToSystemDrawing()).ToWpf().TransformFromDevice(window); + window.SourceInitialized += delegate { + bounds = Validate(bounds.TransformToDevice(window).ToSystemDrawing()) + .ToWpf().TransformFromDevice(window); + }; window.Left = bounds.X; window.Top = bounds.Y; window.Width = bounds.Width; @@ -50,9 +53,12 @@ namespace ICSharpCode.SharpDevelop.Gui Size size = new Size(window.ActualWidth, window.ActualHeight); Point location = PropertyService.Get(propertyName, GetDefaultLocation(window)); location.Offset(ownerLocation.X, ownerLocation.Y); - var bounds = Validate(new Rect(location, size).TransformToDevice(window).ToSystemDrawing()).ToWpf().TransformFromDevice(window); - window.Left = bounds.X; - window.Top = bounds.Y; + window.SourceInitialized += delegate { + var bounds = Validate(new Rect(location, size).TransformToDevice(window).ToSystemDrawing()) + .ToWpf().TransformFromDevice(window); + window.Left = bounds.X; + window.Top = bounds.Y; + }; } window.Closing += delegate { var relativeToOwner = GetLocationRelativeToOwner(window);