private void MyFormConnection_Closed(object sender, EventArgs e) { MyFormConnection = new FormConnection(); if (Global.connection_use == 1) { if (Global.Status == 1) { Connection_status.Value = 100; connectStatus_text.Text = "Connecting"; connectStatus_text.ForeColor = Color.Green; } } else { if (Global.Status == 1) { Connection_status.Value = 100; connectStatus_text.Text = "Connecting"; connectStatus_text.ForeColor = Color.Green; } backgroundWorker1.RunWorkerAsync(); // Start receiving data in background //backgroundWorker2.WorkerSupportsCancellation = true; // Ability to cancel this thread } pictureBox5.Image = Properties.Resources.CONNECT_BUTTON_NORMAL; }
private void pictureBox5_Click(object sender, EventArgs e) { Pic_Normal_All(5); pictureBox5.Image = Properties.Resources.CONNECT_BUTTON_CLICKED; connect_btn_status = 1; form_close_all(5); MyFormConnection = new FormConnection(); MyFormConnection.TopLevel = false; MyFormConnection.AutoScroll = true; User_Control.Controls.Add(MyFormConnection); MyFormConnection.Show(); MyFormConnection.FormClosed += MyFormConnection_Closed; MyFormConnection.FormClosing += MyFormConnection_Closing; }