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

namespace SixGroup_Knowledge.PopView
{

    public partial class ConfirmForm : Form
    {

        public static Boolean isOk = false;
        //获得屏幕的宽和高
        private int winWidth = Screen.PrimaryScreen.Bounds.Width;
        private int winHeight = Screen.PrimaryScreen.Bounds.Height;

        protected static ConfirmForm self = null;
        public ConfirmCallBack callBack = null;
        public static ConfirmForm getInstance()
        {
            if (self == null)
                self = new ConfirmForm();
            return self;
        }

        
        protected ConfirmForm()
        {
            InitializeComponent();
            isOk = false;
            this.timer1.Enabled = true;
            callBack = null;
        }

        private void p_ok_Click(object sender, EventArgs e)
        {
            isOk = true;
            if (callBack != null)
                callBack.ok();
            this.Close();
        }

        private void p_cancel_Click(object sender, EventArgs e)
        {
            isOk = false;
            if (callBack != null)
                callBack.cancel();
            this.Close();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if(this.Location.X>(int)(winWidth/2)-this.Width)
                this.timer1.Enabled=false;

            this.Location = new Point(this.Location.X+20,this.Location.Y);

        }

        private void ConfirmForm_Load(object sender, EventArgs e)
        {
            this.Location = new Point(0,(int)(winHeight/2));
        }

        private void ConfirmForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            isOk = false;
            self = null;
        }
        public void setTitle(string title)
        {
            this.title_text.Text = title;
        }
    }
    public interface ConfirmCallBack
    {
        void ok();
        void cancel();
    }
}
