using System;
using UIKit;
using CoreGraphics;

namespace Shared
{
	/// <summary>
	/// 弹窗
	/// </summary>
	public class Dialog
	{
		Button tempButton;
		FrameLayout mainFrameLayout;
		/// <summary>
		/// 弹窗构造函数
		/// </summary>
		public Dialog()
		{
			Application.MainPage.AddChidren(tempButton = new Button { Visible = false, Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, BackgroundColor = 0x88323232 });
			Application.MainPage.AddChidren(mainFrameLayout = new FrameLayout { Visible = false, });
            //mainFrameLayout.MouseUpEventHandler += (sender, e) => { 
            //};
		}
		/// <summary>
		/// 背景颜色
		/// </summary>
		/// <value>The color of the background.</value>
		public uint BackgroundColor
		{
			get
			{
				return mainFrameLayout.BackgroundColor;
			}
			set
			{
                mainFrameLayout.BackgroundColor = value;
			}
		}

		/// <summary>
		/// 圆角大小
		/// </summary>
		/// <value>The corner.</value>
		public uint Radius
        {
            get
            {
                return mainFrameLayout.Radius;
            }
            set
            {
                mainFrameLayout.Radius = value;
            }
        }

		/// <summary>
		/// 边框线大小
		/// </summary>
		/// <value>The width of the border.</value>
		public uint BorderWidth
		{
			get
			{
                return mainFrameLayout.BorderWidth;
			}
			set
			{
                mainFrameLayout.BorderWidth = value;
			}
		}

		/// <summary>
		/// 增加子控件
		/// </summary>
		/// <param name="view">View.</param>
		public void AddChidren(View view)
		{
			mainFrameLayout.AddChidren(view);
		}

		/// <summary>
		/// 背景图片路径
		/// </summary>
		/// <value>The background image path.</value>
		public string BackgroundImagePath
		{
			get
			{
				return mainFrameLayout.BackgroundImagePath;
			}
			set
			{
				mainFrameLayout.BackgroundImagePath = value;
			}
		}

		/// <summary>
		/// 宽度
		/// </summary>
		/// <value>The width.</value>
		public int Width
		{
			get
			{
				return mainFrameLayout.Width;
			}
			set
			{
				mainFrameLayout.Width = value;
			}
		}

		/// <summary>
		/// 高宽
		/// </summary>
		/// <value>The height.</value>
		public int Height
		{
			get
			{
				return mainFrameLayout.Height;
			}
			set
			{
				mainFrameLayout.Height = value;
			}
		}

		/// <summary>
		/// X
		/// </summary>
		/// <value>The height.</value>
		public int X
		{
			get
			{
				return mainFrameLayout.X;
			}
			set
			{
				mainFrameLayout.X = value;
			}
		}

		/// <summary>
		/// Y
		/// </summary>
		/// <value>The height.</value>
		public int Y
		{
			get
			{
				return mainFrameLayout.Y;
			}
			set
			{
				mainFrameLayout.Y = value;
			}
		}

		/// <summary>
		/// 显示当前的界面
		/// </summary>
		public void Show()
		{
			tempButton.Visible = true;
			mainFrameLayout.Visible = true;
			mainFrameLayout.Gravity = Gravity.Center;
			tempButton.BringToFront();
			mainFrameLayout.BringToFront();
		}

		/// <summary>
		/// 关闭当前的界面,释放资源
		/// </summary>
		public void Close()
		{
			tempButton.RemoveFromParent();
			mainFrameLayout.RemoveFromParent();
		}
	}
}