using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel; namespace RecoursiveConstructor_Image_Text { public partial class Form1 : Form { private UserControl1[] arrUC; UserControl1 firstUC, secondUC; private int arrUser_size = 2; static private Form1 Cat_Form, Dog_Form; private static Random formRand = new Random(); private void Form1_FormClosing(object sender, FormClosingEventArgs e) { Application.Exit(); } int GetBrightness(Color c) { return (int)(0.299 * c.R + 0.587 * c.G + 0.114 * c.B); } public Form1(int counter) { InitializeComponent(); this.AutoScaleMode = AutoScaleMode.Dpi; this.WindowState = FormWindowState.Normal; arrUC = new UserControl1[arrUser_size]; bool firstRound = false; for (int i = 0; i < arrUser_size; i++) { if (!firstRound) { arrUC[i] = new UserControl1(formRand); arrUC[i].Location = new Point(0, 30 + 120 * i + 50); arrUC[i].event_FromUC += new delegate_MyEventHadler(Form_event_FromUC); this.Controls.Add(arrUC[i]); firstRound = true; } else { arrUC[i] = new UserControl1(formRand); arrUC[i].Location = new Point(0, 30 + 120 * i + 70); arrUC[i].event_FromUC += new delegate_MyEventHadler(Form_event_FromUC); this.Controls.Add(arrUC[i]); } } if (counter == 2) { Cat_Form = this; Form1 temp = new Form1(1); temp.Show(); } if (counter == 1) { this.Text = "Dog"; Dog_Form = this; if (formRand.Next(2) == 0) { Cat_Form.Min_Max_label.Text = "Min"; Dog_Form.Min_Max_label.Text = "Max"; } else { Cat_Form.Min_Max_label.Text = "Max"; Dog_Form.Min_Max_label.Text = "Min"; } if (formRand.Next(2) == 0) { Cat_Form.Image_Text_label.Text = "Image"; Cat_Form.bySize_byBrightness_label.Text = "bySize"; Dog_Form.Image_Text_label.Text = "Text"; Dog_Form.bySize_byBrightness_label.Text = "byBrightness"; } else { Dog_Form.Image_Text_label.Text = "Image"; Dog_Form.bySize_byBrightness_label.Text = "bySize"; Cat_Form.Image_Text_label.Text = "Text"; Cat_Form.bySize_byBrightness_label.Text = "byBrightness"; } } } private Label cloneLbl(Label l) { Label cur = new Label(); cur.Text = l.Text; cur.Image = l.Image; cur.Font = l.Font; cur.Tag = l.Tag; cur.Size = l.Size; cur.BackColor = l.BackColor; cur.ForeColor = l.ForeColor; cur.TextAlign = l.TextAlign; cur.Name = l.Name; return cur; } private void Form_event_FromUC(object sender, myEventArgs e) { //List