بالطبع، سأقوم بتصميم نموذج (Form) بلغة C# ويندوز فورمز Windows Forms يحتوي على العناصر المطلوبة:
csharp
using System;
using System.Windows.Forms;
namespace ColorJobSelector
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeControls();
}
private GroupBox groupBoxColor;
private GroupBox groupBoxJob;
private Button btnShow;
private RadioButton[] colorRadios;
private RadioButton[] jobRadios;
private void InitializeControls()
{
// إعداد الفورم
this.Text = "Form1";
this.Width = 350;
this.Height = 300;
// مجموعة الألوان
groupBoxColor = new GroupBox();
groupBoxColor.Text = "Select your Color";
groupBoxColor.Width = 150;
groupBoxColor.Height = 140;
groupBoxColor.Top = 10;
groupBoxColor.Left = 10;
string[] colors = { "Red", "Blue", "Green", "Black", "White", "Orange" };
colorRadios = new RadioButton[colors.Length];
for(int i=0; i < colors.Length; i++)
{
colorRadios[i] = new RadioButton();
colorRadios[i].Text = colors[i];
colorRadios[i].Left = 10;
colorRadios[i].Top = 20 + i * 20;
groupBoxColor.Controls.Add(colorRadios[i]);
}
// مجموعة الوظائف
groupBoxJob = new GroupBox();
groupBoxJob.Text = "Select your job";
groupBoxJob.Width = 150;
groupBoxJob.Height = 120;
groupBoxJob.Top = 10;
groupBoxJob.Left = groupBoxColor.Right + 10;
string[] jobs = { "Teacher", "Doctor", "Developer", "Journalist" };
jobRadios = new RadioButton[jobs.Length];
for (int i = 0; i < jobs.Length; i++)
{
jobRadios[i] = new RadioButton();
jobRadios[i].Text = jobs[i];
jobRadios[i].Left = 10;
jobRadios[i].Top = 20 + i * 25;
groupBoxJob.Controls.Add(jobRadios[i]);
}
// زر العرض
btnShow = new Button();
btnShow.Text = "Show";
btnShow.Width = 100;
btnShow.Height = 30;
btnShow.Top = groupBoxColor.Bottom + 20;
btnShow.Left = (this.ClientSize.Width - btnShow.Width) / 2;
btnShow.Click += BtnShow_Click;
// إضافة العناصر للنموذج
this.Controls.Add(groupBoxColor);
this.Controls.Add(groupBoxJob);
this.Controls.Add(btnShow);
}
private void BtnShow_Click(object sender, EventArgs e)
{
string selectedColor = null;
foreach(var rb in colorRadios)
{
if (rb.Checked)
{
selectedColor = rb.Text;
break;
}
}
string selectedJob = null;
foreach(var rb in jobRadios)
{
if (rb.Checked)
{
selectedJob = rb.Text;
break;
}
}
if(string.IsNullOrEmpty(selectedColor) || string.IsNullOrEmpty(selectedJob))
{
MessageBox.Show("Please select both a color and a job.", "Incomplete selection", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string message = $"your Color {selectedColor} and your job {selectedJob}";
MessageBox.Show(message, "Selection", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
إذا أردت ملف تصميم منفصل Designer.cs، يمكنني توفيره أيضاً.