Browse Source

Fix: FormLocationHelper has set wrong window location when opening a dialog from another dialog.

pull/664/head
Andreas Weizel 11 years ago
parent
commit
f3a38a329e
  1. 7
      src/Main/Base/Project/Src/Gui/FormLocationHelper.cs

7
src/Main/Base/Project/Src/Gui/FormLocationHelper.cs

@ -53,11 +53,11 @@ namespace ICSharpCode.SharpDevelop.Gui
public static void ApplyWindow(Window window, string propertyName, bool isResizable) public static void ApplyWindow(Window window, string propertyName, bool isResizable)
{ {
window.WindowStartupLocation = WindowStartupLocation.Manual; window.WindowStartupLocation = WindowStartupLocation.Manual;
var ownerLocation = GetOwnerLocation(window);
if (isResizable) { if (isResizable) {
Rect bounds = PropertyService.Get(propertyName, GetDefaultBounds(window));
bounds.Offset(ownerLocation.X, ownerLocation.Y);
window.SourceInitialized += delegate { window.SourceInitialized += delegate {
var ownerLocation = GetOwnerLocation(window);
Rect bounds = PropertyService.Get(propertyName, GetDefaultBounds(window));
bounds.Offset(ownerLocation.X, ownerLocation.Y);
bounds = Validate(bounds.TransformToDevice(window).ToSystemDrawing()) bounds = Validate(bounds.TransformToDevice(window).ToSystemDrawing())
.ToWpf().TransformFromDevice(window); .ToWpf().TransformFromDevice(window);
window.Left = bounds.X; window.Left = bounds.X;
@ -67,6 +67,7 @@ namespace ICSharpCode.SharpDevelop.Gui
}; };
} else { } else {
window.SourceInitialized += delegate { window.SourceInitialized += delegate {
var ownerLocation = GetOwnerLocation(window);
Size size = new Size(window.ActualWidth, window.ActualHeight); Size size = new Size(window.ActualWidth, window.ActualHeight);
Point location = PropertyService.Get(propertyName, GetDefaultLocation(window)); Point location = PropertyService.Get(propertyName, GetDefaultLocation(window));
location.Offset(ownerLocation.X, ownerLocation.Y); location.Offset(ownerLocation.X, ownerLocation.Y);

Loading…
Cancel
Save