i have been working on a spindle warm up timer which is now fully working.
id like to have it pop up a form (like the extra button form) but with a few leds and text fields on it which i can then populate from my macroloop.
is this possible?
// Path is relative to UCCNC.EXE
path = Application.StartupPath + @"\Flashscreen\BMP\";
ledON = path + "LEDon.png";
ledOFF = path + "LEDoff.png";
myForm = new Form();
myForm.SuspendLayout();
myForm.ClientSize = new System.Drawing.Size(400, 200); // Min width: 140!
myForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
myForm.ControlBox = false;
myForm.MaximizeBox = false;
myForm.MinimizeBox = false;
myForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
myLabel = new Label();
myLabel.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (byte)238);
myLabel.Location = new System.Drawing.Point(12, 20);
myLabel.Size = new System.Drawing.Size((int)(myForm.ClientSize.Width - 24), 22);
myLabel.Text = "Activate the probe input at least once!";
myLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
myPBox = new PictureBox();
myPBox.Size = new System.Drawing.Size(40, 40);
myPBox.Location = new System.Drawing.Point((int)(myForm.ClientSize.Width / 2 - myPBox.Size.Width / 2), myForm.ClientSize.Height - myPBox.Size.Height - 100);
myPBox.ImageLocation = ledOFF;
myPBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
myButton1 = new Button();
myButton1.Size = new System.Drawing.Size(90, 23);
myButton1.Location = new System.Drawing.Point((int)(myForm.ClientSize.Width / 2 - myButton1.Size.Width / 2), myForm.ClientSize.Height - 80);
myButton1.TabIndex = 0;
myButton1.Text = "Proceed";
myButton1.Enabled = false;
myButton1.Click += new System.EventHandler(myButton1_Click);
myButton2 = new Button();
myButton2.Size = new System.Drawing.Size(90, 23);
myButton2.Location = new System.Drawing.Point((int)(myForm.ClientSize.Width / 2 - myButton2.Size.Width / 2), myForm.ClientSize.Height - 40);
myButton2.TabIndex = 0;
myButton2.Text = "Cancel";
myButton2.Click += new System.EventHandler(myButton2_Click);
myTimer = new System.Windows.Forms.Timer();
myTimer.Enabled = true;
myTimer.Interval = 50;
myTimer.Tick += new System.EventHandler(myTimer_Tick);
myForm.Controls.Add(myLabel);
myForm.Controls.Add(myPBox);
myForm.Controls.Add(myButton1);
myForm.Controls.Add(myButton2);
myForm.ResumeLayout(false);
myForm.BringToFront();
myForm.ShowDialog(exec.mainform);
if (proceed)
{
// Proceed was pressed, your code here!
exec.AddStatusmessage("Test completed.")
}
#Events
string path;
string ledON;
string ledOFF;
Form myForm;
Label myLabel;
PictureBox myPBox;
Button myButton1;
Button myButton2;
System.Windows.Forms.Timer myTimer;
bool lastProbeLEDState = false;
bool wasActive = false;
bool proceed = false;
private void myTimer_Tick(object sender, EventArgs e)
{
bool probeState = exec.GetLED(37); // Probe LED
if (probeState != lastProbeLEDState)
{
if (probeState)
wasActive = true;
else
if (wasActive) myButton1.Enabled = true;
lastProbeLEDState = probeState;
if (probeState)
myPBox.ImageLocation = ledON;
else
myPBox.ImageLocation = ledOFF;
}
}
private void myButton1_Click(object sender, EventArgs e)
{
proceed = true;
myForm.Close();
}
private void myButton2_Click(object sender, EventArgs e)
{
proceed = false;
exec.Callbutton(130);
myForm.Close();
}
myLabel.Text = "Z = " + AS3.Getfield(228);
Users browsing this forum: No registered users and 0 guests