﻿using System.Collections.Generic;
using System.Drawing;
using SFML.Graphics;
using SFML.Window;

namespace GuiTestingCon
{
    public abstract class ScreenObject
    {
        private Rectangle _RectPosition = new Rectangle();
        private Vector2 _VectPosition = new Vector2();
        private bool _IsVisisble = true;
        private bool _Focused = false;
        private bool _IsDraggable = true;
        private int _Z = 0;
        private ScreenManager screenmanager;
        private Dictionary<string, GuiObject> _GuiObjects = new Dictionary<string, GuiObject>();
        private Sprite _Sprite;
        private Dictionary<string, SFML.Graphics.Image> _Images = new Dictionary<string, SFML.Graphics.Image>();

        public abstract void Draw();

        public Dictionary<string, GuiObject> Controls
        {
            get { return _GuiObjects; }
        }

        public Dictionary<string, SFML.Graphics.Image> Images
        {
            get { return _Images; }
        }

        public Sprite sprite
        {
            get { return _Sprite; }
            set
            {
                _Sprite = value;
            }
        }

        public ScreenManager Screen
        {
            get { return screenmanager; }
            set { screenmanager = value; }
        }

        public void AddControl(GuiObject obj)
        {
            obj.Screen = this;
            _GuiObjects.Add(obj.Name, obj);
        }

        public void RemoveControl(string Name)
        {
            _GuiObjects.Remove(Name);
        }

        public void RemoveControls()
        {
            this._GuiObjects.Clear();
        }

        public Rectangle ScreenRect
        {
            get { return _RectPosition; }
            set
            {
                _RectPosition = value;
                _VectPosition.X = value.X;
                _VectPosition.Y = value.Y;
            }
        }

        public Vector2 Position
        {
            get { return _VectPosition; }
            set
            {
                _VectPosition = value;
                _RectPosition.X = (int)value.X;
                _RectPosition.Y = (int)value.Y;
            }
        }

        public float PositionY
        {
            get { return _VectPosition.Y; }
            set
            {
                _VectPosition.Y = value;
                _RectPosition.Y = (int)value;
            }
        }

        public float PositionX
        {
            get { return _VectPosition.X; }
            set
            {
                _VectPosition.X = value;
                _RectPosition.X = (int)value;
            }
        }

        public bool Visible
        {
            get { return _IsVisisble; }
            set { _IsVisisble = value; }
        }

        public bool Draggable
        {
            get { return _IsDraggable; }
            set { _IsDraggable = value; }
        }

        public bool Focused
        {
            get { return _Focused; }
            set { _Focused = value; }
        }

        public int Z
        {
            get { return _Z; }
            set { _Z = value; }
        }

        public virtual void KeyReleased(object sender, KeyEventArgs e) { }

        public virtual void KeyPressed(object sender, KeyEventArgs e) { }

        public virtual void MouseButtonReleased(object sender, MouseButtonEventArgs e) { }

        public virtual void MouseButtonPressed(object sender, MouseButtonEventArgs e) { }

        public virtual void TextEntered(object sender, TextEventArgs e) { }

        public virtual void MouseWheelMoved(object sender, MouseWheelEventArgs e) { }
    }
}