/// <summary> /// Initializes a new instance of the <see cref="ScanCompletedEventArgs"/> class. /// </summary> /// <param name="cancelled"> /// Whether the scan was cancelled. /// </param> /// <param name="exception"> /// The exception. /// </param> /// <param name="errorInformation"> /// The error information. /// </param> /// <param name="scannedSource"> /// The scanned Source. /// </param> public ScanCompletedEventArgs(bool cancelled, Exception exception, string errorInformation, Source scannedSource) { this.Successful = !cancelled && exception == null && string.IsNullOrEmpty(errorInformation) && scannedSource != null && scannedSource.Titles != null && scannedSource.Titles.Count > 0; this.Cancelled = cancelled; this.Exception = exception; this.ErrorInformation = errorInformation; this.ScannedSource = scannedSource; }
/// <summary> /// Scan Completed Event Handler /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The EventArgs. /// </param> private void InstanceScanCompleted(object sender, System.EventArgs e) { try { bool cancelled = this.isCancelled; this.isCancelled = false; // TODO -> Might be a better place to fix this. string path = this.currentSourceScanPath; if (this.currentSourceScanPath.Contains("\"")) { path = this.currentSourceScanPath.Trim('\"'); } // Process into internal structures. Source sourceData = null; if (this.instance?.Titles != null) { sourceData = new Source(path, this.ConvertTitles(this.instance.Titles), null); } this.IsScanning = false; if (this.postScanOperation != null) { try { this.postScanOperation(true, sourceData); } catch (Exception exc) { Debug.WriteLine(exc); } this.postScanOperation = null; // Reset this.ServiceLogMessage("Scan Finished for Queue Edit ..."); } else { this.ScanCompleted?.Invoke( this, new ScanCompletedEventArgs(cancelled, null, string.Empty, sourceData)); this.ServiceLogMessage("Scan Finished ..."); } } finally { this.IsScanning = false; var handBrakeInstance = this.instance; if (handBrakeInstance != null) { handBrakeInstance.ScanProgress -= this.InstanceScanProgress; handBrakeInstance.ScanCompleted -= this.InstanceScanCompleted; } } }
/// <summary> /// Scan Completed Event Handler /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The EventArgs. /// </param> private void InstanceScanCompleted(object sender, System.EventArgs e) { this.ServiceLogMessage("Scan Finished ..."); // Write the log file out before we start processing incase we crash. try { if (this.scanLog != null) { this.scanLog.Flush(); } } catch (Exception exc) { Debug.WriteLine(exc); } HandBrakeUtils.MessageLogged -= this.HandBrakeInstanceMessageLogged; HandBrakeUtils.ErrorLogged -= this.HandBrakeInstanceErrorLogged; // TODO -> Might be a better place to fix this. string path = this.currentSourceScanPath; if (this.currentSourceScanPath.Contains("\"")) { path = this.currentSourceScanPath.Trim('\"'); } // Process into internal structures. Source sourceData = null; if (this.instance != null && this.instance.Titles != null) { sourceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path }; } this.IsScanning = false; if (this.postScanOperation != null) { try { this.postScanOperation(true, sourceData); } catch (Exception exc) { Debug.WriteLine(exc); } this.postScanOperation = null; // Reset } else { if (this.ScanCompleted != null) this.ScanCompleted(this, new ScanCompletedEventArgs(false, null, string.Empty, sourceData)); } }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.Task = task; }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.Task = task; this.NotifyOfPropertyChange(() => this.Task); if (preset != null) { this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers; } this.sourceChaptersList = title.Chapters; this.SetSourceChapters(title.Chapters); }
/// <summary> /// The setup. /// </summary> /// <param name="scannedSource"> /// The scanned source. /// </param> /// <param name="srcName"> /// The src Name. /// </param> /// <param name="addAction"> /// The add Action. /// </param> /// <param name="preset"> /// The preset. /// </param> public void Setup(Source scannedSource, string srcName, Action<IEnumerable<SelectionTitle>> addAction, Preset preset) { this.TitleList.Clear(); this.addToQueue = addAction; if (scannedSource != null) { IEnumerable<Title> titles = orderedByTitle ? scannedSource.Titles : scannedSource.Titles.OrderByDescending(o => o.Duration).ToList(); foreach (Title item in titles) { SelectionTitle title = new SelectionTitle(item, srcName) { IsSelected = true }; TitleList.Add(title); } } if (preset != null) { this.CurrentPreset = string.Format(ResourcesUI.QueueSelection_UsingPreset, preset.Name); } this.NotifyOfPropertyChange(() => this.IsAutoNamingEnabled); }
/// <summary> /// Set the Source Title /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.SourceTracks = title.AudioTracks; // Only reset the audio tracks if we have none, or if the task is null. if (this.Task == null) { this.SetPreset(preset, task); } // If there are no source tracks, clear the list, otherwise try to Auto-Select the correct tracks if (this.SourceTracks == null || !this.SourceTracks.Any()) { this.Task.AudioTracks.Clear(); } else { this.SetupTracks(); } // Force UI Updates this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.currentTitle = title; this.Task = task; this.scannedSource = source; if (title != null) { // Set cached info this.sourceParValues = title.ParVal; this.sourceResolution = title.Resolution; // Update the cropping values, preffering those in the presets. if (!preset.Task.HasCropping) { this.Task.Cropping.Top = title.AutoCropDimensions.Top; this.Task.Cropping.Bottom = title.AutoCropDimensions.Bottom; this.Task.Cropping.Left = title.AutoCropDimensions.Left; this.Task.Cropping.Right = title.AutoCropDimensions.Right; this.IsCustomCrop = false; } else { this.Task.Cropping.Left = preset.Task.Cropping.Left; this.Task.Cropping.Right = preset.Task.Cropping.Right; this.Task.Cropping.Top = preset.Task.Cropping.Top; this.Task.Cropping.Bottom = preset.Task.Cropping.Bottom; this.IsCustomCrop = true; } if (preset.PictureSettingsMode == PresetPictureSettingsMode.None) { // We have no instructions, so simply set it to the source. this.Task.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight); this.MaintainAspectRatio = true; } else { // Set the Max Width / Height available to the user controls if (this.sourceResolution.Width < this.MaxWidth) { this.MaxWidth = this.sourceResolution.Width; } else if (this.sourceResolution.Width > this.MaxWidth) { this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width; } if (this.sourceResolution.Height < this.MaxHeight) { this.MaxHeight = this.sourceResolution.Height; } else if (this.sourceResolution.Height > this.MaxHeight) { this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height; } // Set the Width, and Maintain Aspect ratio. That should calc the Height for us. if (this.SelectedAnamorphicMode == Anamorphic.None) { this.Task.Width = preset.Task.Width ?? (this.MaxWidth - this.CropLeft - this.CropRight); // Note: This will be auto-corrected in the property if it's too large. } else { this.Task.Width = preset.Task.Width ?? this.MaxWidth; int cropHeight = this.Task.Cropping.Top + this.Task.Cropping.Bottom; this.Task.Height = (preset.Task.Height ?? this.MaxHeight) - cropHeight; } // If our height is too large, let it downscale the width for us by setting the height to the lower value. if (!this.MaintainAspectRatio && this.Height > this.MaxHeight) { this.Task.Height = this.MaxHeight; } } // Set Screen Controls this.SourceInfo = string.Format( "{0}x{1}, PAR: {2}/{3}", title.Resolution.Width, title.Resolution.Height, title.ParVal.Width, title.ParVal.Height); this.RecaulcatePictureSettingsProperties(ChangedPictureField.Width); } this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Setup the window after a scan. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="selectedTitle"> /// The selected title. /// </param> /// <param name="currentPreset"> /// The Current preset /// </param> /// <param name="encodeTask"> /// The task. /// </param> public void SetSource(Source source, Title selectedTitle, Preset currentPreset, EncodeTask encodeTask) { this.Task = encodeTask; }
/// <summary> /// Scan Completed Event Handler /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The EventArgs. /// </param> private void InstanceScanCompleted(object sender, System.EventArgs e) { this.ServiceLogMessage("Scan Finished ..."); bool cancelled = this.isCancelled; this.isCancelled = false; // TODO -> Might be a better place to fix this. string path = this.currentSourceScanPath; if (this.currentSourceScanPath.Contains("\"")) { path = this.currentSourceScanPath.Trim('\"'); } // Process into internal structures. Source sourceData = null; if (this.instance?.Titles != null) { sourceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path }; } this.IsScanning = false; if (this.postScanOperation != null) { try { this.postScanOperation(true, sourceData); } catch (Exception exc) { Debug.WriteLine(exc); } this.postScanOperation = null; // Reset } else { this.ScanCompleted?.Invoke(this, new ScanCompletedEventArgs(cancelled, null, string.Empty, sourceData)); } }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.Task = task; this.NotifyOfPropertyChange(() => this.AdvancedOptionsString); }
/// <summary> /// The update preview frame. /// </summary> /// <param name="task"> /// The task. /// </param> /// <param name="scannedSource"> /// The scanned Source. /// </param> public void UpdatePreviewFrame(EncodeTask task, Source scannedSource) { this.Task = task; this.UpdatePreviewFrame(); this.DisplayName = Resources.StaticPreviewViewModel_Title; this.Title = Resources.Preview; this.ScannedSource = scannedSource; }
/// <summary> /// Update all the UI Components to allow the user to edit their previous settings. /// </summary> /// <param name="successful"> /// The successful. /// </param> /// <param name="scannedSource"> /// The scanned Source. /// </param> private void QueueEditAction(bool successful, Source scannedSource) { /* TODO Fix this. */ Execute.OnUIThread(() => { // Copy all the Scan data into the UI scannedSource.CopyTo(this.ScannedSource); this.NotifyOfPropertyChange(() => this.ScannedSource); this.NotifyOfPropertyChange(() => this.ScannedSource.Titles); // Select the Users Title this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault(); this.CurrentTask = new EncodeTask(queueEditTask); this.NotifyOfPropertyChange(() => this.CurrentTask); this.HasSource = true; // Update the Main Window this.NotifyOfPropertyChange(() => this.Destination); this.NotifyOfPropertyChange(() => this.SelectedStartPoint); this.NotifyOfPropertyChange(() => this.SelectedEndPoint); this.NotifyOfPropertyChange(() => this.SelectedAngle); this.NotifyOfPropertyChange(() => this.SelectedPointToPoint); this.NotifyOfPropertyChange(() => this.SelectedOutputFormat); this.NotifyOfPropertyChange(() => IsMkv); // Update the Tab Controls this.PictureSettingsViewModel.UpdateTask(this.CurrentTask); this.VideoViewModel.UpdateTask(this.CurrentTask); this.FiltersViewModel.UpdateTask(this.CurrentTask); this.AudioViewModel.UpdateTask(this.CurrentTask); this.SubtitleViewModel.UpdateTask(this.CurrentTask); this.ChaptersViewModel.UpdateTask(this.CurrentTask); this.AdvancedViewModel.UpdateTask(this.CurrentTask); // Cleanup this.ShowStatusWindow = false; this.SourceLabel = this.SourceName; this.StatusLabel = Resources.Main_ScanCompleted; }); }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.SourceTracks.Clear(); this.SourceTracks.Add(ForeignAudioSearchTrack); foreach (Subtitle subtitle in title.Subtitles) { this.SourceTracks.Add(subtitle); } this.Task = task; this.NotifyOfPropertyChange(() => this.Task); this.AutomaticSubtitleSelection(); }
/// <summary> /// Copy this Source to another Source Model /// </summary> /// <param name="source"> /// The source. /// </param> public void CopyTo(Source source) { source.Titles = this.Titles; source.ScanPath = this.ScanPath; }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.X264ViewModel.SetSource(source, title, preset, task); }