public static Point GetMiddlePoint(this IPositionAware model)
        {
            IResizable resizable = model as IResizable;

            if (resizable != null)
            {
                return(new Point(model.Left + (resizable.Width / 2), model.Top + (resizable.Height / 2)));
            }
            else
            {
                return(new Point(model.Left, model.Top));
            }
        }
Exemple #2
0
 /// <summary>
 /// Instantly snap the camera to the position of an object
 /// </summary>
 /// <param name="obj">The object to snap to</param>
 public void SnapTo(IPositionAware obj)
 {
     SnapTo(obj.Position);
 }
Exemple #3
0
 /// <summary>
 /// Gradually move the camera to a position
 /// </summary>
 /// <param name="position">The object to move to</param>
 public void MoveTo(IPositionAware obj)
 {
     MoveTo(obj.Position);
 }
Exemple #4
0
 /// <summary>
 /// Follow an object
 /// </summary>
 /// <param name="position">The object to follow</param>
 public void Follow(IPositionAware obj)
 {
     this.followObject = obj;
     this.Mode = CameraMode.Follow;
 }
 /// <summary>
 /// Update model's Left and Top based on offset.
 /// </summary>
 /// <param name="model"></param>
 /// <param name="offset"></param>
 public static void OffsetPosition(this IPositionAware model, Vector offset)
 {
     model.Left += offset.X;
     model.Top  += offset.Y;
 }
 public static void SetPosition(this IPositionAware model, Point position)
 {
     model.Left = position.X;
     model.Top  = position.Y;
 }