Browse Source

Designer positioning fixes

pull/346/head
Nikita Tsukanov 11 years ago
parent
commit
2e7f3091c8
  1. 6
      src/Windows/Perspex.Designer/AppHost/WindowHost.cs
  2. 14
      src/Windows/Perspex.Designer/PerspexDesigner.xaml.cs

6
src/Windows/Perspex.Designer/AppHost/WindowHost.cs

@ -25,6 +25,8 @@ namespace Perspex.Designer.AppHost
SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true);
Controls.Add(_windowHost); Controls.Add(_windowHost);
_windowHost.Anchor = AnchorStyles.None; _windowHost.Anchor = AnchorStyles.None;
if (!supportScroll)
_windowHost.Visible = false;
_timer.Tick += delegate _timer.Tick += delegate
{ {
ReloadSettings(); ReloadSettings();
@ -98,7 +100,7 @@ namespace Perspex.Designer.AppHost
_hWnd = hWnd; _hWnd = hWnd;
if (_hWnd != IntPtr.Zero) if (_hWnd != IntPtr.Zero)
{ {
WinApi.SetParent(hWnd, _windowHost.Handle); WinApi.SetParent(hWnd, _supportScroll ? _windowHost.Handle : Handle);
FixWindow(); FixWindow();
} }
} }
@ -127,8 +129,6 @@ namespace Perspex.Designer.AppHost
} }
else else
{ {
_windowHost.Width = Width;
_windowHost.Height = Height;
WinApi.MoveWindow(_hWnd, 0, 0, Width, Height, true); WinApi.MoveWindow(_hWnd, 0, 0, Width, Height, true);
} }
} }

14
src/Windows/Perspex.Designer/PerspexDesigner.xaml.cs

@ -73,14 +73,16 @@ namespace Perspex.Designer
{ {
if (e.PropertyName == nameof(ProcessHost.WindowHandle)) if (e.PropertyName == nameof(ProcessHost.WindowHandle))
{ {
if (NativeContainer.Child == null) if (NativeContainer.Child != null)
{ {
NativeContainer.Child = new WindowHost(false); var child = NativeContainer.Child;
} NativeContainer.Child = null;
{ child.Dispose();
var wndHost = ((WindowHost) NativeContainer.Child);
wndHost.SetWindow(_host.WindowHandle);
} }
NativeContainer.Child = new WindowHost(false);
var wndHost = ((WindowHost) NativeContainer.Child);
wndHost.SetWindow(_host.WindowHandle);
} }
} }

Loading…
Cancel
Save