diff --git a/src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs b/src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs
index 14bd084a37..ed853a4353 100644
--- a/src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs
+++ b/src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs
@@ -137,6 +137,8 @@ namespace Perspex.Android.Platform.SkiaPlatform
//Not supported
}
+ public Point Position { get; set; }
+
public IDisposable ShowDialog()
{
throw new NotImplementedException();
diff --git a/src/Gtk/Perspex.Gtk/PopupImpl.cs b/src/Gtk/Perspex.Gtk/PopupImpl.cs
index 8e432e2448..63e34460b4 100644
--- a/src/Gtk/Perspex.Gtk/PopupImpl.cs
+++ b/src/Gtk/Perspex.Gtk/PopupImpl.cs
@@ -12,10 +12,5 @@ namespace Perspex.Gtk
: base(WindowType.Popup)
{
}
-
- public void SetPosition(Point p)
- {
- Move((int)p.X, (int)p.Y);
- }
}
}
diff --git a/src/Gtk/Perspex.Gtk/WindowImpl.cs b/src/Gtk/Perspex.Gtk/WindowImpl.cs
index 01054ae50b..0435a052ba 100644
--- a/src/Gtk/Perspex.Gtk/WindowImpl.cs
+++ b/src/Gtk/Perspex.Gtk/WindowImpl.cs
@@ -179,6 +179,20 @@ namespace Perspex.Gtk
BeginResizeDrag((Gdk.WindowEdge) (int) edge, 1, x, y, 0);
}
+ public Point Position
+ {
+ get
+ {
+ int x, y;
+ GetPosition(out x, out y);
+ return new Point(x, y);
+ }
+ set
+ {
+ Move((int)value.X, (int)value.Y);
+ }
+ }
+
public IDisposable ShowDialog()
{
Modal = true;
diff --git a/src/Perspex.Controls/Platform/IPopupImpl.cs b/src/Perspex.Controls/Platform/IPopupImpl.cs
index 495b16409c..5cbdafb9f9 100644
--- a/src/Perspex.Controls/Platform/IPopupImpl.cs
+++ b/src/Perspex.Controls/Platform/IPopupImpl.cs
@@ -8,15 +8,6 @@ namespace Perspex.Platform
///
public interface IPopupImpl : ITopLevelImpl
{
- ///
- /// Sets the position of the popup.
- ///
- /// The position, in screen coordinates.
- void SetPosition(Point p);
- ///
- /// Hides the popup.
- ///
- void Hide();
}
}
diff --git a/src/Perspex.Controls/Platform/ITopLevelImpl.cs b/src/Perspex.Controls/Platform/ITopLevelImpl.cs
index 0a11566c5a..7c80b951a5 100644
--- a/src/Perspex.Controls/Platform/ITopLevelImpl.cs
+++ b/src/Perspex.Controls/Platform/ITopLevelImpl.cs
@@ -89,6 +89,11 @@ namespace Perspex.Platform
/// Shows the toplevel.
///
void Show();
+
+ ///
+ /// Hides the window.
+ ///
+ void Hide();
///
/// Starts moving a window with left button being held. Should be called from left mouse button press event handler.
@@ -100,5 +105,7 @@ namespace Perspex.Platform
/// Should be called from left mouse button press event handler
///
void BeginResizeDrag(WindowEdge edge);
+
+ Point Position { get; set; }
}
}
diff --git a/src/Perspex.Controls/Platform/IWindowImpl.cs b/src/Perspex.Controls/Platform/IWindowImpl.cs
index e27d94b41e..cb266a9153 100644
--- a/src/Perspex.Controls/Platform/IWindowImpl.cs
+++ b/src/Perspex.Controls/Platform/IWindowImpl.cs
@@ -29,11 +29,6 @@ namespace Perspex.Platform
///
IDisposable ShowDialog();
- ///
- /// Hides the window.
- ///
- void Hide();
-
///
/// Enables of disables system window decorations (title bar, buttons, etc)
///
diff --git a/src/Perspex.Controls/Platform/PlatformManager.cs b/src/Perspex.Controls/Platform/PlatformManager.cs
index fc582ab45d..6cec6cfadf 100644
--- a/src/Perspex.Controls/Platform/PlatformManager.cs
+++ b/src/Perspex.Controls/Platform/PlatformManager.cs
@@ -155,11 +155,6 @@ namespace Perspex.Controls.Platform
set { _tl.Deactivated = value; }
}
- public void SetPosition(Point p)
- {
- _popup.SetPosition(p*ScalingFactor);
- }
-
public void Dispose() => _tl.Dispose();
public IPlatformHandle Handle => _tl.Handle;
@@ -177,6 +172,12 @@ namespace Perspex.Controls.Platform
public void BeginMoveDrag() => _tl.BeginMoveDrag();
public void BeginResizeDrag(WindowEdge edge) => _tl.BeginResizeDrag(edge);
+ public Point Position
+ {
+ get { return _tl.Position; }
+ set { _tl.Position = value; }
+ }
+
public IDisposable ShowDialog() => _window.ShowDialog();
public void Hide() => _popup.Hide();
diff --git a/src/Perspex.Controls/Primitives/Popup.cs b/src/Perspex.Controls/Primitives/Popup.cs
index e3f4183a1a..c074d26874 100644
--- a/src/Perspex.Controls/Primitives/Popup.cs
+++ b/src/Perspex.Controls/Primitives/Popup.cs
@@ -169,7 +169,7 @@ namespace Perspex.Controls.Primitives
((ISetLogicalParent)_popupRoot).SetParent(this);
}
- _popupRoot.SetPosition(GetPosition());
+ _popupRoot.Position = GetPosition();
_popupRoot.AddHandler(PointerPressedEvent, MaybeClose, RoutingStrategies.Bubble, true);
if (_topLevel != null)
diff --git a/src/Perspex.Controls/Primitives/PopupRoot.cs b/src/Perspex.Controls/Primitives/PopupRoot.cs
index b69af20c3f..9abf981642 100644
--- a/src/Perspex.Controls/Primitives/PopupRoot.cs
+++ b/src/Perspex.Controls/Primitives/PopupRoot.cs
@@ -65,15 +65,6 @@ namespace Perspex.Controls.Primitives
///
IVisual IHostedVisualTreeRoot.Host => Parent;
- ///
- /// Sets the position of the popup in screen coordinates.
- ///
- /// The position.
- public void SetPosition(Point p)
- {
- PlatformImpl.SetPosition(p);
- }
-
///
/// Hides the popup.
///
diff --git a/src/Perspex.Controls/ToolTip.cs b/src/Perspex.Controls/ToolTip.cs
index 8be91f237b..559db90ff3 100644
--- a/src/Perspex.Controls/ToolTip.cs
+++ b/src/Perspex.Controls/ToolTip.cs
@@ -118,7 +118,7 @@ namespace Perspex.Controls
var position = control.PointToScreen(cp ?? new Point(0, 0)) + new Vector(0, 22);
((ToolTip)s_popup.Content).Content = GetTip(control);
- s_popup.SetPosition(position);
+ s_popup.Position = position;
s_popup.Show();
s_current = control;
diff --git a/src/Perspex.Controls/TopLevel.cs b/src/Perspex.Controls/TopLevel.cs
index 12311df1c9..f167c62770 100644
--- a/src/Perspex.Controls/TopLevel.cs
+++ b/src/Perspex.Controls/TopLevel.cs
@@ -375,5 +375,11 @@ namespace Perspex.Controls
/// Should be called from left mouse button press event handler
///
public void BeginResizeDrag(WindowEdge edge) => PlatformImpl.BeginResizeDrag(edge);
+
+ public Point Position
+ {
+ get { return PlatformImpl.Position; }
+ set { PlatformImpl.Position = value; }
+ }
}
}
diff --git a/src/Windows/Perspex.Win32/PopupImpl.cs b/src/Windows/Perspex.Win32/PopupImpl.cs
index 8161df4c65..2d73da88b0 100644
--- a/src/Windows/Perspex.Win32/PopupImpl.cs
+++ b/src/Windows/Perspex.Win32/PopupImpl.cs
@@ -9,18 +9,6 @@ namespace Perspex.Win32
{
public class PopupImpl : WindowImpl, IPopupImpl
{
- public void SetPosition(Point p)
- {
- UnmanagedMethods.SetWindowPos(
- Handle.Handle,
- IntPtr.Zero,
- (int)p.X,
- (int)p.Y,
- 0,
- 0,
- UnmanagedMethods.SetWindowPosFlags.SWP_NOSIZE | UnmanagedMethods.SetWindowPosFlags.SWP_NOACTIVATE);
- }
-
public override void Show()
{
UnmanagedMethods.ShowWindow(Handle.Handle, UnmanagedMethods.ShowWindowCommand.ShowNoActivate);
diff --git a/src/Windows/Perspex.Win32/WindowImpl.cs b/src/Windows/Perspex.Win32/WindowImpl.cs
index ca1a2ae9c6..49383c10e3 100644
--- a/src/Windows/Perspex.Win32/WindowImpl.cs
+++ b/src/Windows/Perspex.Win32/WindowImpl.cs
@@ -247,6 +247,28 @@ namespace Perspex.Win32
new IntPtr((int) EdgeDic[edge]), IntPtr.Zero);
}
+ public Point Position
+ {
+ get
+ {
+ UnmanagedMethods.RECT rc;
+ UnmanagedMethods.GetWindowRect(_hwnd, out rc);
+ return new Point(rc.left, rc.top);
+ }
+ set
+ {
+ UnmanagedMethods.SetWindowPos(
+ Handle.Handle,
+ IntPtr.Zero,
+ (int) value.X,
+ (int) value.Y,
+ 0,
+ 0,
+ UnmanagedMethods.SetWindowPosFlags.SWP_NOSIZE | UnmanagedMethods.SetWindowPosFlags.SWP_NOACTIVATE);
+
+ }
+ }
+
public virtual IDisposable ShowDialog()
{
var disabled = s_instances.Where(x => x != this && x.IsEnabled).ToList();
diff --git a/src/iOS/Perspex.iOS/PerspexView.cs b/src/iOS/Perspex.iOS/PerspexView.cs
index 92b2fac730..fca1e28a1c 100644
--- a/src/iOS/Perspex.iOS/PerspexView.cs
+++ b/src/iOS/Perspex.iOS/PerspexView.cs
@@ -118,6 +118,8 @@ namespace Perspex.iOS
//Not supported
}
+ public Point Position { get; set; }
+
public Size MaxClientSize => Bounds.Size.ToPerspex();
public void SetTitle(string title)
{