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.Filters;
using ImageBlockz.Operations.Edit;
using ImageBlockz.Api;
using ImageBlockz.Core;

namespace ImageBlockz.Operations.Controls
{
    public partial class ColorMappingControl : OperationControl
    {
        private ImageBlockz.Operations.Filters.ColorMapping colorMapping;

        public ColorMappingControl()
            : base(typeof(ImageBlockz.Operations.Filters.ColorMapping).FullName)
        {
            IsPreview = true;

            InitializeComponent();
        }

        public override IOperation GetOperation()
        {
            colorMapping.CmType = comboBox.Items[comboBox.SelectedIndex].ToString();
            return colorMapping;
        }

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

            if (operation is ImageBlockz.Operations.Filters.ColorMapping == false)
            {
                throw new ArgumentException("operation", "Argument operation is not instance of "
                    + typeof(ImageBlockz.Operations.Filters.ColorMapping).FullName);
            }

            colorMapping = (ImageBlockz.Operations.Filters.ColorMapping) operation;
        }

        public override bool OnOK()
        {
            colorMapping.CmType = comboBox.Items[comboBox.SelectedIndex].ToString();

            return true;
        }
    }
}
