using System;
using System.Drawing;
using Decal.Adapter.Support;
using Decal.Interop.Controls;

namespace Decal.Adapter.Wrappers;

public class ProgressWrapper : ControlWrapperBase<ProgressClass>
{
	private EventHandler<ControlEventArgs> evtDestroy;

	private string alignment;

	private Color borderColor;

	private int borderWidth;

	private bool drawText;

	private Color faceColor;

	private Color fillColor;

	private int maxValue;

	private string preText;

	private string postText;

	private Color textColor;

	public string Alignment
	{
		get
		{
			return alignment;
		}
		set
		{
			alignment = value;
			base.Control.Alignment = value;
		}
	}

	public Color BorderColor
	{
		get
		{
			return borderColor;
		}
		set
		{
			borderColor = value;
			base.Control.BorderColor = Util.ColorToBGR(value);
		}
	}

	public int BorderWidth
	{
		get
		{
			return borderWidth;
		}
		set
		{
			borderWidth = value;
			base.Control.BorderWidth = value;
		}
	}

	public bool DrawText
	{
		get
		{
			return drawText;
		}
		set
		{
			drawText = value;
			base.Control.DecalDrawText = value;
		}
	}

	public Color FaceColor
	{
		get
		{
			return faceColor;
		}
		set
		{
			faceColor = value;
			base.Control.FaceColor = Util.ColorToBGR(value);
		}
	}

	public Color FillColor
	{
		get
		{
			return fillColor;
		}
		set
		{
			fillColor = value;
			base.Control.FillColor = Util.ColorToBGR(value);
		}
	}

	public int MaxValue
	{
		get
		{
			return maxValue;
		}
		set
		{
			maxValue = value;
			base.Control.MaxValue = value;
		}
	}

	public string PostText
	{
		get
		{
			return postText;
		}
		set
		{
			postText = value;
			base.Control.PostText = value;
		}
	}

	public string PreText
	{
		get
		{
			return preText;
		}
		set
		{
			preText = value;
			base.Control.PreText = value;
		}
	}

	public Color TextColor
	{
		get
		{
			return textColor;
		}
		set
		{
			textColor = value;
			base.Control.TextColor = Util.ColorToBGR(value);
		}
	}

	public int Value
	{
		get
		{
			return base.Control.Value;
		}
		set
		{
			base.Control.Value = value;
		}
	}

	public event EventHandler<ControlEventArgs> Destroy
	{
		add
		{
			if (evtDestroy == null)
			{
				base.Control.Destroy += DestroyEvent;
			}
			evtDestroy = (EventHandler<ControlEventArgs>)Delegate.Combine(evtDestroy, value);
		}
		remove
		{
			evtDestroy = (EventHandler<ControlEventArgs>)Delegate.Remove(evtDestroy, value);
			if (evtDestroy == null)
			{
				base.Control.Destroy -= DestroyEvent;
			}
		}
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && evtDestroy != null)
		{
			evtDestroy = (EventHandler<ControlEventArgs>)Delegate.Remove(evtDestroy, evtDestroy);
			base.Control.Destroy -= DestroyEvent;
		}
		base.Dispose(disposing);
	}

	private void DestroyEvent(int ID)
	{
		if (evtDestroy != null)
		{
			evtDestroy(this, new ControlEventArgs(ID));
		}
	}
}
