This one is for radiobuttons (and groupboxes).
Basically save it as a macronumber file of your choosing (such as M10002.txt) and run it via the mdi.
5x Radio Buttons will popup on a form, with a "Post G-Code" button.
2 of the radiobuttons are within a Groupbox and 3 are on the form
The groupbox allows you to group the radiobuttons as only one radiobutton can be selected at any one time..... unless you place them in a groupbox..... which allows you to then add them in groups
you can run any code and it will post the gcode to the Codeview window.
- Code: Select all
// ## RadioButton Wizard Example, M10002
//Set up the form for Wizard
MyForm = new Form();
MyForm.Size = new System.Drawing.Size(1200, 750);
MyForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
MyForm.Text = " UCCNC xxxxx Wizard vx.xxxxx ";
//((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
//Define the objects on the form
//
// radioButton1
//
radioButton1.AutoSize = true;
radioButton1.Checked = true;
radioButton1.Font = new System.Drawing.Font("Arial Narrow", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
radioButton1.Location = new System.Drawing.Point(24, 36);
radioButton1.Name = "radioButton1";
radioButton1.Size = new System.Drawing.Size(101, 24);
radioButton1.TabIndex = 0;
radioButton1.TabStop = true;
radioButton1.Text = "radioButton1";
radioButton1.UseVisualStyleBackColor = true;
//
// radioButton2
//
radioButton2.AutoSize = true;
radioButton2.Font = new System.Drawing.Font("Arial Narrow", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
radioButton2.Location = new System.Drawing.Point(24, 70);
radioButton2.Name = "radioButton2";
radioButton2.Size = new System.Drawing.Size(101, 24);
radioButton2.TabIndex = 1;
radioButton2.Text = "radioButton2";
radioButton2.UseVisualStyleBackColor = true;
//
// groupBox1
//
groupBox1.Controls.Add(this.radioButton1);
groupBox1.Controls.Add(this.radioButton2);
groupBox1.Font = new System.Drawing.Font("Arial Narrow", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
groupBox1.Location = new System.Drawing.Point(25, 48);
groupBox1.Name = "groupBox1";
groupBox1.Size = new System.Drawing.Size(223, 118);
groupBox1.TabIndex = 2;
groupBox1.TabStop = false;
groupBox1.Text = "groupBox1";
//
// radioButton3
//
radioButton3.AutoSize = true;
radioButton3.Checked = true;
radioButton3.Font = new System.Drawing.Font("Arial Narrow", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
radioButton3.Location = new System.Drawing.Point(302, 63);
radioButton3.Name = "radioButton3";
radioButton3.Size = new System.Drawing.Size(101, 24);
radioButton3.TabIndex = 3;
radioButton3.TabStop = true;
radioButton3.Text = "radioButton3";
radioButton3.UseVisualStyleBackColor = true;
//
// radioButton4
//
radioButton4.AutoSize = true;
radioButton4.Font = new System.Drawing.Font("Arial Narrow", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
radioButton4.Location = new System.Drawing.Point(302, 98);
radioButton4.Name = "radioButton4";
radioButton4.Size = new System.Drawing.Size(101, 24);
radioButton4.TabIndex = 4;
radioButton4.Text = "radioButton4";
radioButton4.UseVisualStyleBackColor = true;
//
// radioButton5
//
radioButton5.AutoSize = true;
radioButton5.Font = new System.Drawing.Font("Arial Narrow", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
radioButton5.Location = new System.Drawing.Point(302, 132);
radioButton5.Name = "radioButton5";
radioButton5.Size = new System.Drawing.Size(101, 24);
radioButton5.TabIndex = 5;
radioButton5.Text = "radioButton5";
radioButton5.UseVisualStyleBackColor = true;
//
// postGcode - BUTTON
//
postGcode.Location = new System.Drawing.Point(222, 653);
postGcode.Name = "postGcode";
postGcode.Size = new System.Drawing.Size(302, 37);
postGcode.TabIndex = 20;
postGcode.Text = "Post Gcode";
postGcode.UseVisualStyleBackColor = true;
postGcode.Click += new EventHandler(postGcode_Click);
//
//
// Define the Event Handler (VERY IMPORTANT)
// Wizard Form
//
MyForm.Controls.Add(postGcode);
MyForm.Controls.Add(radioButton5); // Radio Button 5
MyForm.Controls.Add(radioButton4); // Radio Button 4
MyForm.Controls.Add(radioButton3); // Radio Button 3
MyForm.Controls.Add(groupBox1); // Group Box 1
MyForm.ShowDialog();
//*************** Starting of the Events Section *****************************
#Events
Form MyForm; //This is a global variable, a Windows Form
// DEFINE all of the elements of the Form HERE (VERY IMPORTANT)
RadioButton radioButton1 = new RadioButton();
RadioButton radioButton2 = new RadioButton();
GroupBox groupBox1 = new GroupBox();
RadioButton radioButton3 = new RadioButton();
RadioButton radioButton4 = new RadioButton();
RadioButton radioButton5 = new RadioButton();
Button postGcode= new Button();
// ADD EVENTS BELOW HERE:
void postGcode_Click(object sender, EventArgs e)
{
string Gcode = "";
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// STARTUP / LINITIALISATION SECTION
Gcode = (Gcode + " ( TEST CODE ) " ) + Environment.NewLine;
Gcode = (Gcode + " " ) + Environment.NewLine;
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// BODY SECTION
Gcode = (Gcode + " ( radioButton1 " + radioButton1.Checked + " ) ") + Environment.NewLine;
Gcode = (Gcode + " ( radioButton2 " + radioButton2.Checked + " ) ") + Environment.NewLine;
Gcode = (Gcode + " ( radioButton3 " + radioButton3.Checked + " ) ") + Environment.NewLine;
Gcode = (Gcode + " ( radioButton4 " + radioButton4.Checked + " ) ") + Environment.NewLine;
Gcode = (Gcode + " ( radioButton5 " + radioButton5.Checked + " ) ") + Environment.NewLine;
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//FINISHING SECTION
Gcode = (Gcode + ("M30")) + Environment.NewLine;
System.IO.File.WriteAllText(Application.StartupPath + @"/Example_codes/Test.tap" , Gcode );
// Load and Run File
exec.Loadfile(Application.StartupPath + @"/Example_codes/Test.tap");
exec.Callbutton(402);
// Close the Wizard
MyForm.Close();
}
Happy coding