/// <summary> /// Show full-sized preview of snapshot. /// </summary> private void pictureBoxImage_Click(object sender, EventArgs e) { if (previewWorkerVars == null) { return; } string snapshotFile = previewWorkerVars.MediaDir + Path.DirectorySeparatorChar + ConstantSettings.TempImageFilename; if (File.Exists(snapshotFile)) { DialogPreviewSnapshot dlg = new DialogPreviewSnapshot(); dlg.Snapshot = UtilsSnapshot.getImageFromFile(snapshotFile); dlg.ShowDialog(); } }
/// <summary> /// Update the image preview. /// </summary> private void updateImagePreview(InfoCombined selectedComb) { if (selectedComb == null) { return; } // Update the snapshot if (Settings.Instance.VideoClips.Files.Length > 0 && checkBoxSnapshotPreview.Checked) { string videoFileName = Settings.Instance.VideoClips.Files[comboBoxEpisode.SelectedIndex]; DateTime midTime = UtilsSubs.getMidpointTime(selectedComb.Subs1.StartTime, selectedComb.Subs1.EndTime); string outFile = previewWorkerVars.MediaDir + Path.DirectorySeparatorChar + ConstantSettings.TempImageFilename; try { File.Delete(outFile); } catch { // File is locked return; } UtilsSnapshot.takeSnapshotFromVideo(videoFileName, midTime, Settings.Instance.Snapshots.Size, Settings.Instance.Snapshots.Crop, outFile); if (File.Exists(outFile)) { Image image = UtilsSnapshot.getImageFromFile(outFile); image = UtilsSnapshot.fitImageToSize(image, new Size(pictureBoxImage.Width, pictureBoxImage.Height)); pictureBoxImage.Image = image; } } }
/// <summary> /// Update the Subs1 and Subs2 text boxes with the provided combined info. /// </summary> private void updateTextPreview(InfoCombined selectedComb) { if (selectedComb == null) { return; } if (selectedComb.Active) { this.textBoxSubs1.BackColor = activeColor; this.textBoxSubs2.BackColor = activeColor; this.pictureBoxSubs1.BackColor = activeColor; this.pictureBoxSubs2.BackColor = activeColor; this.panelSubs1.BackColor = activeColor; this.panelSubs2.BackColor = activeColor; } else { this.textBoxSubs1.BackColor = inactiveColor; this.textBoxSubs2.BackColor = inactiveColor; this.pictureBoxSubs1.BackColor = inactiveColor; this.pictureBoxSubs2.BackColor = inactiveColor; this.panelSubs1.BackColor = inactiveColor; this.panelSubs2.BackColor = inactiveColor; } // Disable subs2 textbox if there aren't any subs2 files this.textBoxSubs2.Enabled = (Settings.Instance.Subs[1].Files.Length != 0); this.pictureBoxSubs2.Enabled = (Settings.Instance.Subs[1].Files.Length != 0); this.panelSubs2.Enabled = (Settings.Instance.Subs[1].Files.Length != 0); if (selectedComb.Subs1.Text.EndsWith("png" + ConstantSettings.SrsVobsubFilenameSuffix)) { this.textBoxSubs1.Visible = false; this.pictureBoxSubs1.Visible = true; try { // Multiple vobsub image can be shown in a single line, so extract each image // and concatenate them before displaying. List <string> vobsubImages = UtilsSubs.extractVobsubFilesFromText(selectedComb.Subs1.Text); List <Image> vobSubImages = new List <Image>(); foreach (string vobsubImage in vobsubImages) { Image image = UtilsSnapshot.getImageFromFile(previewWorkerVars.MediaDir + Path.DirectorySeparatorChar + vobsubImage); vobSubImages.Add(image); } if (vobSubImages.Count != 0) { Image image; if (vobSubImages.Count == 0) { image = vobSubImages[0]; } else { image = UtilsSnapshot.concatImages(vobSubImages); } this.pictureBoxSubs1.Image = image; } } catch { // Don't care } } else { this.textBoxSubs1.Visible = true; this.pictureBoxSubs1.Visible = false; this.textBoxSubs1.Text = selectedComb.Subs1.Text; } if (Settings.Instance.Subs[1].Files.Length != 0) { if (selectedComb.Subs2.Text.EndsWith("png" + ConstantSettings.SrsVobsubFilenameSuffix)) { this.textBoxSubs2.Visible = false; this.pictureBoxSubs2.Visible = true; try { // Multiple vobsub image can be shown in a single line, so extract each image // and concatenate them before displaying. List <string> vobsubImages = UtilsSubs.extractVobsubFilesFromText(selectedComb.Subs2.Text); List <Image> vobSubImages = new List <Image>(); foreach (string vobsubImage in vobsubImages) { Image image = UtilsSnapshot.getImageFromFile(previewWorkerVars.MediaDir + Path.DirectorySeparatorChar + vobsubImage); vobSubImages.Add(image); } if (vobSubImages.Count != 0) { Image image; if (vobSubImages.Count == 0) { image = vobSubImages[0]; } else { image = UtilsSnapshot.concatImages(vobSubImages); } this.pictureBoxSubs2.Image = image; } } catch { } } else { this.textBoxSubs2.Visible = true; this.pictureBoxSubs2.Visible = false; this.textBoxSubs2.Text = selectedComb.Subs2.Text; } } else { this.textBoxSubs2.Visible = true; this.pictureBoxSubs2.Visible = false; this.textBoxSubs2.Text = ""; } }