using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;


namespace ImageBlockz.Api
{
#if DEBUG
    ///<summary>Implement graphical user interface for chosen operations.</summary>
    public class OperationControl : UserControl
#else
    ///<summary>Implement graphical user interface for chosen operations.</summary>
    public abstract class OperationControl : UserControl
#endif
    {
        private IOperation operation;
        private string operationName;

#if DEBUG
        /**
         * This constructor is only for form designer!!!
         */
        /// <summary>
        /// Constructor that initializes control with its operation.
        /// </summary>
        public OperationControl()
        {
        }
#endif

        /// <summary>
        /// Constructor that initializes control with its operation.
        /// </summary>
        /// <param name="operationName">Operation full name. Contains name and full path.</param>
        public OperationControl(string operationName)
        {
            this.operationName = operationName;
        }

        /// <summary>
        /// Gets or Sets <see cref="Bitmap"/>.
        /// </summary>
        public Bitmap Bmp
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or Sets <see cref="bool"/> value, that determines whether preview of operation will be allowed.
        /// </summary>
        public bool IsPreview
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or Sets <see cref="bool"/> value, that determines whether control is open first time.
        /// </summary>
        public bool IsNew
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or Sets <see cref="string"/> path to the operation in menu.
        /// </summary>
        public string MenuPath
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or Sets <see cref="bool"/> value, that determines whether preview of operation will be allowed.
        /// </summary>
        public string OperationName
        {
            get
            {
                return operationName;
            }
        }

        /// <summary>
        /// Set valid operation of type <see cref="IOperation"/> to this <see cref="OperationControl"/> 
        /// </summary>
        /// <param name="operation">Operation of type <see cref="IOperation"/>.</param>
        public virtual void SetOperation(IOperation operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException("operation", "Must set valid operation");
            }

            this.operation = operation;
        }

        /// <summary>
        ///  Set operation operation of type <see cref="IOperation"/> from this <see cref="OperationControl"/> 
        /// </summary>
        /// <returns>Operation of type <see cref="IOperation"/>.</returns>
        public virtual IOperation GetOperation()
        {
            return operation;
        }

        /// <summary>
        /// Determine, what will be processed after OperationDialog confirmation. 
        /// </summary>
        /// <returns>Confirmation about success (True) or failure (False).</returns>
        public virtual bool OnOK()
        {
            return false;
        }

        /// <summary>
        /// Determine, what will be processed after OperationDialog cancellation. 
        /// </summary>
        public virtual void OnCancel()
        {
            
        }

        /// <summary>
        /// Determines what data will be displayed when displaying the <see cref="OperationControl"/>.
        /// </summary>
        public virtual void ShowData()
        {
            
        }
    }
}
