using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ImageBlockz.Operations;
using ImageBlockz.Operations.Edit;
using ImageBlockz.Api;
using ImageBlockz.Core;

namespace ImageBlockz.Operations.Controls
{
    public partial class RotateControl : OperationControl
    {
        private ImageBlockz.Operations.Edit.Rotate rotate;

        public RotateControl()
            : base(typeof(ImageBlockz.Operations.Edit.Rotate).FullName)
        {
            IsPreview = false;

            InitializeComponent();
        }

        public override void SetOperation(IOperation operation)
        {
            base.SetOperation(operation);

            if (operation is ImageBlockz.Operations.Edit.Rotate)
            {
                rotate = (ImageBlockz.Operations.Edit.Rotate) GetOperation();
            }
        }

        public override bool OnOK()
        {
            if (dbAngle.IsOK() == false)
            { 
                return false; 
            }

            rotate.Angle =  dbAngle.GetValue();

            return true;
        }

        public override void ShowData()
        {
            dbAngle.SetDigitBox(DigitBox.ValueType.Int, -360, +360, 0);

            if (IsNew)
            {
                dbAngle.Value = 0;
            }
            else
            {
                dbAngle.Value = rotate.Angle;
            }
            
        }

        private void dbAngle_Load(object sender, EventArgs e)
        {

        }

        private void digitBox1_Load(object sender, EventArgs e)
        {

        }
    }
}
