bool checkButton = AS3.Getbuttonstate (20003);

InitializeGUI ();
dr = new DialogResult ();

if (checkButton)
{
	btnYES.Visible = false;
	btnNO.Visible = false;
	btnOK.Visible = true;
	textBoxStatus.Clear ();
	textBoxStatus.AppendText ("Il pulsante puo essere usato solo una volta all'avvio del programma quando il led rimane rosso!");
	System.Media.SystemSounds.Exclamation.Play();
	dr = myForm.ShowDialog (exec.mainform);
		if (dr == DialogResult.OK)
		{
			myForm.Close();
						
		}
	
	
	return;
}


AS3.Setfield(Convert.ToDouble(exec.Readkey ("GP Proto CNC", "X_palp", "0")), 3001);
AS3.Validatefield (3001);
AS3.Setfield(Convert.ToDouble(exec.Readkey ("GP Proto CNC", "Y_palp", "0")), 3002);
AS3.Validatefield (3002);
AS3.Setfield(Convert.ToDouble(exec.Readkey ("GP Proto CNC", "X_UT1", "0")), 3003);
AS3.Validatefield (3003);
AS3.Setfield(Convert.ToDouble(exec.Readkey ("GP Proto CNC", "Y_UT1", "0")), 3004);
AS3.Validatefield (3004);
AS3.Setfield(Convert.ToDouble(exec.Readkey ("GP Proto CNC", "ToolDown", "0")), 3005);
AS3.Validatefield (3005);
AS3.Setfield(Convert.ToDouble(exec.Readkey ("GP Proto CNC", "UTpres", "0")), 3006);
AS3.Validatefield (3006);
AS3.Setfield(Convert.ToDouble(exec.Readkey ("GP Proto CNC", "Zprobe", "0")), 3007);
AS3.Validatefield (3007);
exec.Setcurrenttool (Convert.ToInt32 (exec.Readkey ("GP Proto CNC", "CurrentTool", "0")));


#Events

Form myForm;
Button btnYES;
Button btnNO;
Button btnOK;
TextBox textBoxStatus;
PictureBox pictureBoxUI;
DialogResult dr;

public Point mouseLocation;

private void pictureBoxUI_MouseDown(object sender, MouseEventArgs e)
{
	mouseLocation = new Point(-e.X, -e.Y);
}

private void pictureBoxUI_MouseMove(object sender, MouseEventArgs e)
{
	if (e.Button == MouseButtons.Left)
	{
		Point mousePos = Control.MousePosition;
		mousePos.Offset(mouseLocation.X, mouseLocation.Y);
		myForm.Location = mousePos;
	}
}

private void InitializeGUI ()
{
btnYES = new Button ();
btnYES.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(164)))), ((int)(((byte)(211)))), ((int)(((byte)(118)))));
btnYES.DialogResult = System.Windows.Forms.DialogResult.Yes;
btnYES.FlatAppearance.BorderSize = 0;
btnYES.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
btnYES.Font = new System.Drawing.Font("Aero Matics", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
btnYES.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(52)))), ((int)(((byte)(63)))));
btnYES.Location = new System.Drawing.Point(236, 112);
btnYES.Size = new System.Drawing.Size(70, 22);
btnYES.TabIndex = 1;
btnYES.Text = "YES";
btnYES.UseVisualStyleBackColor = false;

btnNO = new Button ();
btnNO.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(164)))), ((int)(((byte)(211)))), ((int)(((byte)(118)))));
btnNO.DialogResult = System.Windows.Forms.DialogResult.No;
btnNO.FlatAppearance.BorderSize = 0;
btnNO.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
btnNO.Font = new System.Drawing.Font("Aero Matics", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
btnNO.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(52)))), ((int)(((byte)(63)))));
btnNO.Location = new System.Drawing.Point(315, 112);
btnNO.Size = new System.Drawing.Size(70, 22);
btnNO.TabIndex = 2;
btnNO.Text = "NO";
btnNO.UseVisualStyleBackColor = false;

btnOK = new Button ();
btnOK.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(164)))), ((int)(((byte)(211)))), ((int)(((byte)(118)))));
btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
btnOK.FlatAppearance.BorderSize = 0;
btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
btnOK.Font = new System.Drawing.Font("Aero Matics", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
btnOK.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(52)))), ((int)(((byte)(63)))));
btnOK.Location = new System.Drawing.Point(315, 112);
btnOK.Size = new System.Drawing.Size(70, 22);
btnOK.TabIndex = 3;
btnOK.Text = "OK";
btnOK.UseVisualStyleBackColor = false;

textBoxStatus = new TextBox (); 
textBoxStatus.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(52)))), ((int)(((byte)(63)))));
textBoxStatus.BorderStyle = System.Windows.Forms.BorderStyle.None;
textBoxStatus.Font = new System.Drawing.Font("Aero Matics", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
textBoxStatus.ForeColor = System.Drawing.Color.LightGray;
textBoxStatus.Location = new System.Drawing.Point(83, 39);
textBoxStatus.Multiline = true;
textBoxStatus.ReadOnly = true;
textBoxStatus.Size = new System.Drawing.Size(302, 54);
textBoxStatus.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
textBoxStatus.TabIndex = 4;
textBoxStatus.TabStop = false;

pictureBoxUI = new PictureBox ();
pictureBoxUI.BackColor = System.Drawing.Color.Transparent;
pictureBoxUI.BackgroundImage = System.Drawing.Image.FromFile (Application.StartupPath + @"\Flashscreen\BMP\Bluescreenset\MessageBox.png");
pictureBoxUI.Location = new System.Drawing.Point(0, 0);
pictureBoxUI.Size = new System.Drawing.Size(400, 150);
pictureBoxUI.Controls.Add(btnYES);
pictureBoxUI.Controls.Add(btnNO);
pictureBoxUI.Controls.Add(btnOK);
pictureBoxUI.Controls.Add(textBoxStatus);
pictureBoxUI.TabIndex = 0;
pictureBoxUI.MouseDown += new System.Windows.Forms.MouseEventHandler(pictureBoxUI_MouseDown);
pictureBoxUI.MouseMove += new System.Windows.Forms.MouseEventHandler(pictureBoxUI_MouseMove);

myForm = new Form ();
myForm.BackColor = System.Drawing.Color.DarkRed;
myForm.ClientSize = new System.Drawing.Size(400, 150);
myForm.Controls.Add(pictureBoxUI);
myForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
myForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
myForm.TransparencyKey = System.Drawing.Color.DarkRed;
myForm.TopMost = true;
}