private static void LoadInSpecificTarget(ScreenManagerKernel manager, int targetScreen, CameraSummary summary) { AbstractScreen screen = manager.GetScreenAt(targetScreen); if (screen is CaptureScreen) { CaptureScreen captureScreen = screen as CaptureScreen; captureScreen.LoadCamera(summary); manager.UpdateCaptureBuffers(); manager.OrganizeScreens(); manager.OrganizeCommonControls(); manager.OrganizeMenus(); } else if (screen is PlayerScreen) { // Loading a camera onto a video should never close the video. // We only load the camera if there is room to create a new capture screen, otherwise we do nothing. if (manager.ScreenCount == 1) { manager.AddCaptureScreen(); LoadInSpecificTarget(manager, 1, summary); } } }
public void Execute() { // We keep the list ordered. [0] = left. AbstractScreen temp = m_ScreenManagerKernel.screenList[0]; m_ScreenManagerKernel.screenList[0] = m_ScreenManagerKernel.screenList[1]; m_ScreenManagerKernel.screenList[1] = temp; // Show new disposition. ScreenManagerUserInterface smui = m_ScreenManagerKernel.UI as ScreenManagerUserInterface; if (smui != null) { smui.splitScreens.Panel1.Controls.Clear(); smui.splitScreens.Panel2.Controls.Clear(); smui.splitScreens.Panel1.Controls.Add(m_ScreenManagerKernel.screenList[0].UI); smui.splitScreens.Panel2.Controls.Add(m_ScreenManagerKernel.screenList[1].UI); } // the following lines are placed here so they also get called at unexecute. m_ScreenManagerKernel.OrganizeMenus(); m_ScreenManagerKernel.UpdateStatusBar(); m_ScreenManagerKernel.SwapSync(); m_ScreenManagerKernel.SetSyncPoint(true); }
private static void LoadInSpecificTarget(ScreenManagerKernel manager, int targetScreen, string path, ScreenDescriptionPlayback screenDescription) { AbstractScreen screen = manager.GetScreenAt(targetScreen); if (screen is CaptureScreen) { // Loading a video onto a capture screen should not close the capture screen. // If there is room to add a second screen, we add a playback screen and load the video there, otherwise, we don't do anything. if (manager.ScreenCount == 1) { manager.AddPlayerScreen(); manager.UpdateCaptureBuffers(); LoadInSpecificTarget(manager, 1, path, screenDescription); } } else if (screen is PlayerScreen) { PlayerScreen playerScreen = screen as PlayerScreen; bool confirmed = manager.BeforeReplacingPlayerContent(targetScreen); if (!confirmed) { return; } LoadVideo(playerScreen, path, screenDescription); if (playerScreen.FrameServer.Loaded) { NotificationCenter.RaiseFileOpened(null, path); PreferencesManager.FileExplorerPreferences.AddRecentFile(path); PreferencesManager.Save(); } manager.OrganizeScreens(); manager.OrganizeCommonControls(); manager.OrganizeMenus(); manager.UpdateStatusBar(); } }
/// <summary> /// Execution de la commande /// Si ok, enregistrement du path dans l'historique. /// </summary> public void Execute() { //----------------------------------------------------------------------------------------------- // Principes d'ouverture. // // 1. Si il n'y a qu'un seul écran, on ouvre sur place. // On part du principe que l'utilisateur peut se placer en mode DualScreen s'il le souhaite. // Sinon on doit demander si il veut charger sur place ou pas... // Si c'est un écran Capture -> idem. // On offre de plus la possibilité d'annuler l'action au cas où. // // 2. Si il y a deux players, dont au moins un vide, on ouvre dans le premier vide trouvé. // // 3. Si il y a deux players plein, on pose à droite. // // 4+ Variations à définir... // 4. Si il y a 1 player plein et un capture vide, on ouvre dans le player. //----------------------------------------------------------------------------------------------- ICommand clm; CommandManager cm = CommandManager.Instance(); ICommand css = new CommandShowScreens(screenManagerKernel); if (ForceScreen != -1) { // Position d'écran forcée: Vérifier s'il y a des choses à enregistrer. PlayerScreen ps = (PlayerScreen)screenManagerKernel.screenList[ForceScreen - 1]; bool bLoad = true; if (ps.FrameServer.Metadata.IsDirty) { DialogResult dr = ConfirmDirty(); if (dr == DialogResult.Yes) { // Launch the save dialog. // Note: if we cancel this one, we will go on without saving... screenManagerKernel.mnuSaveOnClick(null, EventArgs.Empty); } else if (dr == DialogResult.Cancel) { // Cancel the load. bLoad = false; screenManagerKernel.CancelLastCommand = true; } // else (DialogResult.No) => Do nothing. } if (bLoad) { // Utiliser l'écran, qu'il soit vide ou plein. clm = new CommandLoadMovie(ps, filePath); CommandManager.LaunchCommand(clm); //Si on a pu charger la vidéo, sauver dans l'historique if (ps.FrameServer.VideoFile.Loaded) { SaveFileToHistory(filePath); } } } else { switch (screenManagerKernel.screenList.Count) { case 0: { // Ajouter le premier écran ICommand caps = new CommandAddPlayerScreen(screenManagerKernel, false); CommandManager.LaunchCommand(caps); // Charger la vidéo dedans PlayerScreen ps = screenManagerKernel.screenList[0] as PlayerScreen; if (ps != null) { clm = new CommandLoadMovie(ps, filePath); CommandManager.LaunchCommand(clm); //Si on a pu charger la vidéo, sauver dans l'historique if (ps.FrameServer.VideoFile.Loaded) { SaveFileToHistory(filePath); } //Afficher l'écran qu'on vient de le créer. CommandManager.LaunchCommand(css); } break; } case 1: { PlayerScreen ps = screenManagerKernel.screenList[0] as PlayerScreen; if (ps != null) { bool bLoad = true; if (ps.FrameServer.Metadata.IsDirty) { DialogResult dr = ConfirmDirty(); if (dr == DialogResult.Yes) { // Launch the save dialog. // Note: if we cancel this one, we will go on without saving... screenManagerKernel.mnuSaveOnClick(null, EventArgs.Empty); } else if (dr == DialogResult.Cancel) { // Cancel the load. bLoad = false; screenManagerKernel.CancelLastCommand = true; } // else (DialogResult.No) => Do nothing. } if (bLoad) { clm = new CommandLoadMovie(ps, filePath); CommandManager.LaunchCommand(clm); //Si on a pu charger la vidéo, sauver dans l'historique if (ps.FrameServer.VideoFile.Loaded) { SaveFileToHistory(filePath); } } } else { // Only screen is a capture screen and we try to play a video. // In that case we create a new player screen and load the video in it. ICommand caps = new CommandAddPlayerScreen(screenManagerKernel, false); CommandManager.LaunchCommand(caps); // Reset the buffer before the video is loaded. screenManagerKernel.UpdateCaptureBuffers(); // load video. PlayerScreen newScreen = (screenManagerKernel.screenList.Count > 0) ? (screenManagerKernel.screenList[1] as PlayerScreen) : null; if (newScreen != null) { clm = new CommandLoadMovie(newScreen, filePath); CommandManager.LaunchCommand(clm); //video loaded finely, save in history. if (newScreen.FrameServer.VideoFile.Loaded) { SaveFileToHistory(filePath); } // Display screens. CommandManager.LaunchCommand(css); } } break; } case 2: { //Chercher un écran vide. int iEmptyScreen = -1; PlayerScreen ps0 = screenManagerKernel.screenList[0] as PlayerScreen; PlayerScreen ps1 = screenManagerKernel.screenList[1] as PlayerScreen; if (ps0 != null && ps0.FrameServer.VideoFile.Loaded == false) { iEmptyScreen = 0; } else if (ps1 != null && ps1.FrameServer.VideoFile.Loaded == false) { iEmptyScreen = 1; } if (iEmptyScreen >= 0) { // On a trouvé un écran vide, charger la vidéo dedans. clm = new CommandLoadMovie((PlayerScreen)screenManagerKernel.screenList[iEmptyScreen], filePath); CommandManager.LaunchCommand(clm); //Si on a pu charger la vidéo, sauver dans l'historique if (((PlayerScreen)screenManagerKernel.screenList[iEmptyScreen]).FrameServer.VideoFile.Loaded) { SaveFileToHistory(filePath); } //-------------------------------------------- // Sur échec, on ne modifie pas l'écran actif. // normalement c'est toujours l'autre écran. //-------------------------------------------- } else { // On a pas trouvé d'écran vide... // Par défaut : toujours à droite. // (étant donné que l'utilisateur à la possibilité d'annuler l'opération // et de revenir à l'ancienne vidéo facilement, autant éviter une boîte de dialogue.) PlayerScreen ps = screenManagerKernel.screenList[1] as PlayerScreen; if (ps != null) { bool bLoad = true; if (ps.FrameServer.Metadata.IsDirty) { DialogResult dr = ConfirmDirty(); if (dr == DialogResult.Yes) { // Launch the save dialog. // Note: if we cancel this one, we will go on without saving... screenManagerKernel.mnuSaveOnClick(null, EventArgs.Empty); } else if (dr == DialogResult.Cancel) { // Cancel the load. bLoad = false; screenManagerKernel.CancelLastCommand = true; } // else (DialogResult.No) => Do nothing. } if (bLoad) { clm = new CommandLoadMovie(ps, filePath); CommandManager.LaunchCommand(clm); //Si on a pu charger la vidéo, sauver dans l'historique if (ps.FrameServer.VideoFile.Loaded) { SaveFileToHistory(filePath); } else { //---------------------------------------------------------------------------- // Echec de chargement, vérifier si on ne vient pas d'invalider l'écran actif. //---------------------------------------------------------------------------- if (screenManagerKernel.m_ActiveScreen == ps) { screenManagerKernel.Screen_SetActiveScreen(screenManagerKernel.screenList[0]); } } } } } // Vérifier qu'on a un écran actif. // sinon, positionner le premier comme actif. break; } default: break; } } screenManagerKernel.OrganizeCommonControls(); screenManagerKernel.OrganizeMenus(); screenManagerKernel.UpdateStatusBar(); }
private static void LoadInSpecificTarget(ScreenManagerKernel manager, int targetScreen, string path, ScreenDescriptionPlayback screenDescription) { AbstractScreen screen = manager.GetScreenAt(targetScreen); if (screen is CaptureScreen) { // Loading a video onto a capture screen should not close the capture screen. // If there is room to add a second screen, we add a playback screen and load the video there, otherwise, we don't do anything. if (manager.ScreenCount == 1) { manager.AddPlayerScreen(); manager.UpdateCaptureBuffers(); LoadInSpecificTarget(manager, 1, path, screenDescription); } } else if (screen is PlayerScreen) { PlayerScreen playerScreen = screen as PlayerScreen; if (playerScreen.IsWaitingForIdle) { // The player screen will yield its thread after having loaded the first frame and come back later. // We must not launch a new video while it's waiting. log.ErrorFormat("Player screen is currently busy loading the previous video. Aborting load."); return; } bool confirmed = manager.BeforeReplacingPlayerContent(targetScreen); if (!confirmed) { return; } LoadVideo(playerScreen, path, screenDescription); bool prefsNeedSaving = false; if (screenDescription != null && screenDescription.IsReplayWatcher) { PreferencesManager.FileExplorerPreferences.AddRecentWatcher(path); PreferencesManager.FileExplorerPreferences.LastReplayFolder = path; prefsNeedSaving = true; } if (playerScreen.FrameServer.Loaded) { NotificationCenter.RaiseFileOpened(null, path); if (screenDescription != null && screenDescription.IsReplayWatcher) { // At this point we have lost the actual file that was loaded. The path here still contaiins the special '*' to indicate the watched folder. // The actual file is the latest file in the folder this was computed right before loading. string actualPath = FilesystemHelper.GetMostRecentFile(Path.GetDirectoryName(path)); PreferencesManager.FileExplorerPreferences.AddRecentFile(actualPath); } else { PreferencesManager.FileExplorerPreferences.AddRecentFile(path); } prefsNeedSaving = true; } if (prefsNeedSaving) { PreferencesManager.Save(); } manager.OrganizeScreens(); manager.OrganizeCommonControls(); manager.OrganizeMenus(); manager.UpdateStatusBar(); } }