// Called if the respective button is clicked in the player or main form public static void SwitchPlaybackScreen() { Screen mainFormScreen = Screen.FromControl(MainForm); Screen playerFormScreen = Screen.FromControl(PlayerForm); int oldIndex = 0; int newIndex = 0; for (int i = 0; i < Screen.AllScreens.Length; i++) { if (Screen.AllScreens[i].Equals(playerFormScreen)) { oldIndex = i; newIndex = (i == Screen.AllScreens.Length - 1 ? 0 : i + 1); break; } } PlayerForm.WindowState = FormWindowState.Normal; PlayerForm.Location = Screen.AllScreens[newIndex].Bounds.Location; PlayerForm.WindowState = FormWindowState.Maximized; lastPlayerFormScreen = Screen.AllScreens[newIndex]; if (Screen.AllScreens[newIndex].Equals(mainFormScreen)) { int dx = MainForm.Location.X - mainFormScreen.Bounds.X; int dy = MainForm.Location.Y - mainFormScreen.Bounds.Y; MainForm.Location = Screen.AllScreens[oldIndex].Bounds.Location; MainForm.Location = new Point(MainForm.Location.X + dx, MainForm.Location.Y + dy); } PlayerForm.ReCenterControls(); }