using Microsoft.Xna.Framework;
using MonoGame.FourEngine.Attributes;
using MonoGame.FourEngine.Services;
using System;

namespace MonoGame.FourEngine.Services
{
    [Service]
    public interface IPointerControl
    {
        void Update(TimeSpan deltaTime);
        Point Position { get; }
        Point PreviousPosition { get; }
        bool IsPrimaryPressed { get; }
        bool WasPrimaryPressed { get; }
        bool HasPrimaryClicked { get; }
        bool IsSecondaryPressed { get; }
        bool WasSecondaryPressed { get; }
        bool HasSecondaryClicked { get; }
        bool IsTouchMode { get; }
        CancelableEventArgs PrimaryClickCancellable { get; }
        CancelableEventArgs SecondaryClickCancellable { get; }
    }

    public class PointerControlCopy : IPointerControl
    {
        public Point Position { get; set; }
        public Point PreviousPosition { get; set; }
        public bool IsPrimaryPressed { get; set; }
        public bool WasPrimaryPressed { get; set; }
        public bool HasPrimaryClicked { get; set; }
        public bool IsSecondaryPressed { get; set; }
        public bool WasSecondaryPressed { get; set; }
        public bool HasSecondaryClicked { get; set; }
        public bool IsTouchMode { get; set; }
        public CancelableEventArgs PrimaryClickCancellable { get; set; }
        public CancelableEventArgs SecondaryClickCancellable { get; set; }

        public void Update(TimeSpan deltaTime)
        {
        }
    }
}

namespace MonoGame.FourEngine
{
    public static class IPointerControlExt
    {
        public static PointerControlCopy Clone(this IPointerControl c)
            => new PointerControlCopy
            {
                Position = c.Position,
                PreviousPosition = c.PreviousPosition,
                IsPrimaryPressed = c.IsPrimaryPressed,
                WasPrimaryPressed = c.WasPrimaryPressed,
                HasPrimaryClicked = c.HasPrimaryClicked,
                IsSecondaryPressed = c.IsSecondaryPressed,
                WasSecondaryPressed = c.WasSecondaryPressed,
                HasSecondaryClicked = c.HasSecondaryClicked,
                IsTouchMode = c.IsTouchMode,
                PrimaryClickCancellable = c.PrimaryClickCancellable,
                SecondaryClickCancellable = c.SecondaryClickCancellable
            };
    }
}