using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Xml;
using ImageBlockz.Operations.InOut;
using ImageBlockz.Api;
using ImageBlockz.Core;
using AForge.Imaging.Filters;

namespace ImageBlockz.Operations.Edit
{
    public class Negative : AbstractOperation
    {
        public static readonly string OperationName = typeof(Negative).FullName;

        public Negative()
            : base(OperationType.Filter, OperationName)
        {
        
        }

        public Negative(float angle)
            : this()
        {
            Angle = angle;
        }

        public float Angle
        {
            set;
            get;
        }

        public override Bitmap Do(Bitmap bmp)
        {
            Invert filter = new Invert();
            return filter.Apply(bmp);
        }

        public override XmlNode ToXml(XmlDocument xmlDoc)
        {
            XmlElement rotate = xmlDoc.CreateElement(OperationName);
            XmlElement angle = XmlOperation.FloatToXml("angle", Angle, xmlDoc);
            
            rotate.AppendChild(angle);

            return rotate;
        }

        public override void FromXml(XmlNode node)
        {
            Angle = XmlOperation.FloatFromXml(node["angle"]);
        }

        public override string GetFormattedName()
        {
            return "Rotate";
        }


        public override string GetInfo()
        {
            return "Angle: " + Angle.ToString() + " degress";
        }
    }
}
