Browse Source

Merge branch 'master' of https://github.com/Perspex/Perspex

pull/448/head
Steven Kirk 11 years ago
parent
commit
e1b42e8fdd
  1. 4
      src/Perspex.Controls/PlacementMode.cs
  2. 11
      src/Perspex.Controls/Primitives/Popup.cs

4
src/Perspex.Controls/PlacementMode.cs

@ -23,6 +23,6 @@ namespace Perspex.Controls
/// <summary> /// <summary>
/// The popup is placed at the top right of its target. /// The popup is placed at the top right of its target.
/// </summary> /// </summary>
Right, Right
} }
} }

11
src/Perspex.Controls/Primitives/Popup.cs

@ -2,13 +2,13 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using System.Linq;
using Perspex.Input; using Perspex.Input;
using Perspex.Interactivity; using Perspex.Interactivity;
using Perspex.LogicalTree;
using Perspex.Metadata; using Perspex.Metadata;
using Perspex.Rendering; using Perspex.Rendering;
using Perspex.VisualTree; using Perspex.VisualTree;
using Perspex.LogicalTree;
using System.Linq;
namespace Perspex.Controls.Primitives namespace Perspex.Controls.Primitives
{ {
@ -270,7 +270,7 @@ namespace Perspex.Controls.Primitives
/// Gets the position for the popup based on the placement properties. /// Gets the position for the popup based on the placement properties.
/// </summary> /// </summary>
/// <returns>The popup's position in screen coordinates.</returns> /// <returns>The popup's position in screen coordinates.</returns>
private Point GetPosition() protected virtual Point GetPosition()
{ {
var zero = default(Point); var zero = default(Point);
var target = PlacementTarget ?? this.GetVisualParent<Control>(); var target = PlacementTarget ?? this.GetVisualParent<Control>();
@ -279,10 +279,13 @@ namespace Perspex.Controls.Primitives
{ {
case PlacementMode.Pointer: case PlacementMode.Pointer:
return MouseDevice.Instance.Position; return MouseDevice.Instance.Position;
case PlacementMode.Bottom: case PlacementMode.Bottom:
return target?.PointToScreen(new Point(0, target.Bounds.Height)) ?? zero; return target?.PointToScreen(new Point(0, target.Bounds.Height)) ?? zero;
case PlacementMode.Right: case PlacementMode.Right:
return target?.PointToScreen(new Point(target.Bounds.Width, 0)) ?? zero; return target?.PointToScreen(new Point(target.Bounds.Width, 0)) ?? zero;
default: default:
throw new InvalidOperationException("Invalid value for Popup.PlacementMode"); throw new InvalidOperationException("Invalid value for Popup.PlacementMode");
} }
@ -310,4 +313,4 @@ namespace Perspex.Controls.Primitives
} }
} }
} }
} }
Loading…
Cancel
Save