using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
using System.Windows.Media;



namespace CartographerLibrary
{
    /// <summary>
    /// Rectangle object properties.
    /// </summary>
    public class PropertiesGraphicsTableBlock : PropertiesGraphicsBase
    {
        private double left;
        private double top;
        private double right;
        private double bottom;
        private double lineWidth;
        private Color objectColor;

        public PropertiesGraphicsTableBlock()
        {

        }

        public PropertiesGraphicsTableBlock(GraphicsTableBlock rectangle)
        {
            if (rectangle == null)
            {
                throw new ArgumentNullException("rectangle");
            }

            left = rectangle.Left;
            top = rectangle.Top;
            right = rectangle.Right;
            bottom = rectangle.Bottom;

            lineWidth = rectangle.LineWidth;
            objectColor = rectangle.ObjectColor;
            actualScale = rectangle.ActualScale;
            ID = rectangle.Id;
            selected = rectangle.IsSelected;
        }

        public override GraphicsBase CreateGraphics()
        {
            GraphicsBase b = new GraphicsTableBlock(left, top, right, bottom, lineWidth, objectColor, actualScale);

            // GraphicsBase contains new ID generated by constructor.
            // This is OK if this instance is loaded from XML file.
            // But if this instance is part of commands history,
            // it contains ID which should be set in GraphicsBase.
            // This rule is applied to all SerializedGraphicsBase-derived
            // classes.

            if (this.ID != 0)       // from command history, not from file
            {
                b.Id = this.ID;
                b.IsSelected = this.selected;
            }

            return b;

        }

        #region Properties

        /// <summary>
        /// Left bounding rectangle side, X
        /// </summary>
        public double Left
        {
            get { return left; }
            set { left = value; }
        }

        /// <summary>
        /// Top bounding rectangle side, Y
        /// </summary>
        public double Top
        {
            get { return top; }
            set { top = value; }
        }

        /// <summary>
        /// Right bounding rectangle side, X
        /// </summary>
        public double Right
        {
            get { return right; }
            set { right = value; }
        }

        /// <summary>
        /// Bottom bounding rectangle side, Y
        /// </summary>
        public double Bottom
        {
            get { return bottom; }
            set { bottom = value; }
        }


        /// <summary>
        /// Line Width
        /// </summary>
        public double LineWidth
        {
            get { return lineWidth; }
            set { lineWidth = value; }
        }

        /// <summary>
        /// Color
        /// </summary>
        public Color ObjectColor
        {
            get { return objectColor; }
            set { objectColor = value; }
        }

        #endregion Properties

    }
}
