private void webcamToolStripMenuItem3_Click(object sender, EventArgs e) { foreach (Client c in GetSelectedClients()) { var frmRw = FrmWebcam.CreateNewOrGetExisting(c); frmRw.Show(); frmRw.Focus(); } }
/// <summary> /// Creates a new webcam form for the client or gets the current open form, if there exists one already. /// </summary> /// <param name="client">The client used for the webcam form.</param> /// <returns> /// Returns a new webcam form for the client if there is none currently open, otherwise creates a new one. /// </returns> public static FrmWebcam CreateNewOrGetExisting(Client client) { if (OpenedForms.ContainsKey(client)) { return(OpenedForms[client]); } FrmWebcam r = new FrmWebcam(client); r.Disposed += (sender, args) => OpenedForms.Remove(client); OpenedForms.Add(client, r); return(r); }