using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GcDevicePc
{
    public partial class LMessageBox : Form
    {
        public LMessageBox()
        {
            InitializeComponent();

        }

        public LMessageBox(Point fp,Size fs, bool isup, string Title, string Tips, MessageBoxPosition mbp)
        {
            InitializeComponent();
            
            switch (mbp)
            {
                case MessageBoxPosition.MBP_BottomLeft:
                    this.StartPosition = FormStartPosition.Manual; //窗体的位置由Location属性决定
                    this.Location = (Point)new Size(fp.X, fp.Y + fs.Height - this.Height);
                    break;
                case MessageBoxPosition.MBP_Center:
                    this.StartPosition = FormStartPosition.Manual; //窗体的位置由Location属性决定
                    this.Location = (Point)new Size(fp.X + (fs.Width / 2) - this.Width, fp.Y + (fs.Height / 2) - this.Height);
                    break;
                case MessageBoxPosition.MBP_BottomRight:
                    this.StartPosition = FormStartPosition.Manual; //窗体的位置由Location属性决定
                    this.Location = (Point)new Size(fp.X+ fs.Width- this.Width, fp.Y + fs.Height - this.Height);
                    break;
                default:
                    break;
            }

            this.TopMost = isup;

            if (!string.IsNullOrEmpty(Title))
            {
                this.Text = Title;
            }

            if (!string.IsNullOrEmpty(Tips))
            {
                TipsText = Tips;
            }
        }
        private string TipsText { get; set; }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            int x = ((this.Width - label1.Width)/2);
            int y = label1.Location.Y;
            label1.Location = new System.Drawing.Point(x, y);

        }

        public enum MessageBoxType
        {
            MBT_NoButton,
            MBT_ButtonOK,
            MBT_ButtonOKCancel,
            MBT_ButtonYesNo
        }

        public enum MessageBoxPosition
        {
            MBP_BottomLeft,
            MBP_Center,
            MBP_BottomRight
        }

        private void LMessageBox_Load(object sender, EventArgs e)
        {
            label1.Text = TipsText;
            OnResize(e);
        }
    }
}
