protected void BackgroundWorkerBuildGalleryImages_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { List <VideoInfo> videoInfos = null; // First, handle the case where an exception was thrown. if (e.Error != null) { MyLog.Add(e.Error.ToString()); subFormProgress.Text(e.Error.Message); } else if (e.Cancelled) { // Next, handle the case where the user canceled the operation. // Note that due to a race condition in the DoWork event handler, the Cancelled // flag may not have been set, even though CancelAsync was called. subFormProgress.Text("Canceled"); } else { // Finally, handle the case where the operation succeeded. videoInfos = (List <VideoInfo>)e.Result; subFormProgress.Text("Ready"); subFormProgress.Value(0); } // bubble the event up var handler = backgroundWorkerBuildGalleryImages_RunWorkerCompleted; if (handler != null) { handler(videoInfos, e); } }
public void LoadVideoForm(ListViewItem selectedItem) { VideoInfo selectedVideoInfo = (VideoInfo)selectedItem.Tag; if (selectedVideoInfo != null) { subFormVideoForm.AddAccessToSubForms(subFormFileList, subFormProgress); subFormVideoForm.SetForm(selectedVideoInfo); subFormVideoImage.SetImages(selectedVideoInfo); subFormFileList.SetList(selectedVideoInfo); } else { subFormProgress.Text("Unable to load info for video"); } listView.Focus(); }
public void RunCalcStats(object sender, RunWorkerCompletedEventArgs e) { MyLog.Add("Setting Stats"); subFormProgress.Value(0); subFormProgress.Text("Setting Stats.."); if (!CalcVideoInfoStats.Load()) { stopwatchCalcStats = Stopwatch.StartNew(); // stopped when background worker completed calcVideoInfoStats.Calc(ListVideoInfo.GetList()); } else { LoadVideos_Completed(sender, e); } }
protected void BackgroundWorkerRunFile_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { VideoItemFileInfo resultsVideoItemFileInfo = null; // First, handle the case where an exception was thrown. if (e.Error != null) { MyLog.Add(e.Error.ToString()); subFormProgress.Text(e.Error.Message); } else if (e.Cancelled) { // Next, handle the case where the user canceled the operation. // Note that due to a race condition in the DoWork event handler, the Cancelled // flag may not have been set, even though CancelAsync was called. subFormProgress.Text("Canceled"); } else { // Finally, handle the case where the operation succeeded. resultsVideoItemFileInfo = (VideoItemFileInfo)e.Result; if (resultsVideoItemFileInfo != null) { MyLog.Add("Played: " + resultsVideoItemFileInfo.videoItemFile.Name + " for " + resultsVideoItemFileInfo.elapsed + "s"); } else { MyLog.Add("Played: no results: " + e.ToString()); } long elapsed = resultsVideoItemFileInfo.elapsed; // kinda simple check to make sure updating video that was played if (subFormVideoForm.selectedVideoInfo.files != null && subFormVideoForm.selectedVideoInfo.files.video != null && resultsVideoItemFileInfo.videoItemFile != null && subFormVideoForm.selectedVideoInfo.files.video.Name == resultsVideoItemFileInfo.videoItemFile.Name) { subFormProgress.Text("Done playing.."); // MyLog.Add("elapsed:"+elapsed+" watchedAfter:" + (Config.settings.watchedAfter)); // if played for more than X minutes, assumed "watched" if (Config.settings.markWatched && elapsed > Config.settings.watchedAfter) { subFormProgress.Value(90); subFormProgress.Text("Updating watched.."); subFormVideoForm.SetWatched(); subFormVideoForm.SaveForm(); } subFormProgress.Value(0); subFormProgress.Text("Ready"); } subFormProgress.Value(0); subFormProgress.Text("Ready"); } // bubble the event up EventHandler <VideoItemFileInfo> handler = this.playFile_Completed; if (handler != null) { MessageBox.Show("bubble"); handler(this, resultsVideoItemFileInfo); } }