private void DoSave(String _FilePath, Metadata _Metadata, double _fPlaybackFrameInterval, Int64 _iSelStart, Int64 _iSelEnd, bool _bFlushDrawings, bool _bKeyframesOnly, bool _bPausedVideo, DelegateGetOutputBitmap _DelegateOutputBitmap) { // Save video. // We use a bgWorker and a Progress Bar. // Memorize the parameters, they will be used later in bgWorkerSave_DoWork. // Note: _iSelStart, _iSelEnd, _Metadata, should ultimately be taken from the local members. m_iSaveStart = _iSelStart; m_iSaveEnd = _iSelEnd; m_SaveMetadata = _Metadata; m_SaveFile = _FilePath; m_fSaveFramesInterval = _fPlaybackFrameInterval; m_bSaveFlushDrawings = _bFlushDrawings; m_bSaveKeyframesOnly = _bKeyframesOnly; m_bSavePausedVideo = _bPausedVideo; m_SaveDelegateOutputBitmap = _DelegateOutputBitmap; // Instanciate and configure the bgWorker. BackgroundWorker bgWorkerSave = new BackgroundWorker(); bgWorkerSave.WorkerReportsProgress = true; bgWorkerSave.WorkerSupportsCancellation = true; bgWorkerSave.DoWork += new DoWorkEventHandler(bgWorkerSave_DoWork); bgWorkerSave.ProgressChanged += new ProgressChangedEventHandler(bgWorkerSave_ProgressChanged); bgWorkerSave.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWorkerSave_RunWorkerCompleted); // Attach the bgWorker to the VideoFile object so it can report progress. m_VideoFile.BgWorker = bgWorkerSave; // Create the progress bar and launch the worker. m_FormProgressBar = new formProgressBar(true); m_FormProgressBar.Cancel = Cancel_Asked; bgWorkerSave.RunWorkerAsync(); m_FormProgressBar.ShowDialog(); }
protected void StartProcessing() { // This method is called by concrete filters to start applying the filter. // It should be called whenever the filter takes time to process. m_FormProgressBar = new formProgressBar(false); m_BackgroundWorker.RunWorkerAsync(); m_FormProgressBar.ShowDialog(); }
public void Export(CommonTimeline commonTimeline, PlayerScreen leftPlayer, PlayerScreen rightPlayer, bool merging) { this.commonTimeline = commonTimeline; this.leftPlayer = leftPlayer; this.rightPlayer = rightPlayer; this.merging = merging; // During saving we move through the common timeline by a time unit based on framerate and high speed factor, but not based on user custom slow motion factor. // For the framerate saved in the file metadata we take user custom slow motion into account and not high speed factor. fileFrameInterval = Math.Max(leftPlayer.FrameInterval, rightPlayer.FrameInterval); fileFrameInterval = Math.Max(fileFrameInterval, 10); dualSaveFileName = GetFilename(leftPlayer, rightPlayer); if (string.IsNullOrEmpty(dualSaveFileName)) { return; } dualSaveCancelled = false; // Instanciate and configure the bgWorker. bgWorkerDualSave = new BackgroundWorker(); bgWorkerDualSave.WorkerReportsProgress = true; bgWorkerDualSave.WorkerSupportsCancellation = true; bgWorkerDualSave.DoWork += bgWorkerDualSave_DoWork; bgWorkerDualSave.ProgressChanged += bgWorkerDualSave_ProgressChanged; bgWorkerDualSave.RunWorkerCompleted += bgWorkerDualSave_RunWorkerCompleted; // Make sure none of the screen will try to update itself. // Otherwise it will cause access to the other screen image (in case of merge), which can cause a crash. leftPlayer.DualSaveInProgress = true; rightPlayer.DualSaveInProgress = true; dualSaveProgressBar = new formProgressBar(true); dualSaveProgressBar.Cancel = dualSave_CancelAsked; // The worker thread runs in the background while the UI thread is in the progress bar dialog. // We only continue after these two lines once the video has been saved or the saving cancelled. bgWorkerDualSave.RunWorkerAsync(); dualSaveProgressBar.ShowDialog(); if (dualSaveCancelled) { DeleteTemporaryFile(dualSaveFileName); } leftPlayer.DualSaveInProgress = false; rightPlayer.DualSaveInProgress = false; }
protected void StartProcessing() { // Spawn a new thread for the computation, and a modal dialog for progress bar. // This function is not mandatory, if the effect is really quick, // a VideoFilter may proceed within Activate() directly. BackgroundWorker worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.DoWork += Process; worker.ProgressChanged += bgWorker_ProgressChanged; worker.RunWorkerCompleted += bgWorker_RunWorkerCompleted; worker.RunWorkerAsync(); formProgressBar = new formProgressBar(false); formProgressBar.ShowDialog(); }
private void DoSave(string filePath, double frameInterval, bool flushDrawings, bool keyframesOnly, bool pausedVideo, ImageRetriever imageRetriever) { SavingSettings s = new SavingSettings(); s.Section = videoReader.WorkingZone; s.File = filePath; s.InputFrameInterval = frameInterval; s.FlushDrawings = flushDrawings; s.KeyframesOnly = keyframesOnly; s.PausedVideo = pausedVideo; s.ImageRetriever = imageRetriever; formProgressBar = new formProgressBar(true); formProgressBar.Cancel = Cancel_Asked; bgWorkerSave.RunWorkerAsync(s); formProgressBar.ShowDialog(); }