/// <summary> /// Initializes a new instance of the <see cref="NotificationService"/> class. /// </summary> /// <param name="encodeService"> /// The encode Service. /// </param> /// <param name="queueProcessor"> /// The queue Processor. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public NotificationService(IEncodeServiceWrapper encodeService, IQueueProcessor queueProcessor, IUserSettingService userSettingService) { this.userSettingService = userSettingService; encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted; queueProcessor.QueueCompleted += this.QueueProcessorQueueCompleted; GrowlCommunicator.Register(); }
/// <summary> /// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.SubtitlesViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public SubtitlesViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.SubtitleTracks = new ObservableCollection<SubtitleTrack>(); Langauges = LanguageUtilities.MapLanguages().Keys; CharacterCodes = CharCodesUtilities.GetCharacterCodes(); }
/// <summary> /// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.SubtitlesViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public SubtitlesViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask(); this.Langauges = LanguageUtilities.MapLanguages().Keys; this.CharacterCodes = CharCodesUtilities.GetCharacterCodes(); }
/// <summary> /// Initializes a new instance of the <see cref="ScanService"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public ScanService(IUserSettingService userSettingService) { this.userSettingService = userSettingService; this.logBuffer = new StringBuilder(); header = GeneralUtilities.CreateCliLogHeader(); }
/// <summary> /// Initializes a new instance of the <see cref="Encode"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public Encode(IUserSettingService userSettingService) : base(userSettingService) { this.userSettingService = userSettingService; this.EncodeStarted += this.EncodeEncodeStarted; GrowlCommunicator.Register(); }
/// <summary> /// Initializes a new instance of the <see cref="QueueProcessor"/> class. /// </summary> /// <param name="encodeService"> /// The encode Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <exception cref="ArgumentNullException"> /// Services are not setup /// </exception> public QueueProcessor(IEncodeServiceWrapper encodeService, IUserSettingService userSettingService) { this.userSettingService = userSettingService; this.EncodeService = encodeService; // If this is the first instance, just use the main queue file, otherwise add the instance id to the filename. this.queueFile = string.Format("hb_queue_recovery{0}.xml", GeneralUtilities.ProcessId); }
/// <summary> /// Initializes a new instance of the <see cref="AudioViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask(); this.SampleRates = new ObservableCollection<string> { "Auto", "48", "44.1", "32", "24", "22.05", "16", "12", "11.025", "8" }; this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList(); this.AudioMixdowns = EnumHelper<Mixdown>.GetEnumList(); this.SourceTracks = new List<Audio>(); }
/// <summary> /// Initializes a new instance of the <see cref="QueueSelectionViewModel"/> class. /// </summary> /// <param name="errorService"> /// The Error Service /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public QueueSelectionViewModel(IErrorService errorService, IUserSettingService userSettingService) { this.errorService = errorService; this.userSettingService = userSettingService; this.Title = Resources.QueueSelectionViewModel_AddToQueue; this.TitleList = new BindingList<SelectionTitle>(); this.OrderedByTitle = true; }
/// <summary> /// Initializes a new instance of the <see cref="LibEncode"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public LibEncode(IUserSettingService userSettingService) : base(userSettingService) { this.userSettingService = userSettingService; HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged; HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged; }
/// <summary> /// Initializes a new instance of the <see cref="VideoViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public VideoViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask { VideoEncoder = VideoEncoder.X264 }; this.userSettingService = userSettingService; this.QualityMin = 0; this.QualityMax = 51; this.IsConstantQuantity = true; this.VideoEncoders = EnumHelper<VideoEncoder>.GetEnumList(); }
/// <summary> /// Initializes a new instance of the <see cref="AudioViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask(); this.SampleRates = new ObservableCollection<string> { "Auto", "48", "44.1", "32", "24", "22.05" }; this.AudioBitrates = this.GetAppropiateBitrates(AudioEncoder.ffaac, Mixdown.DolbyProLogicII); this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList(); this.AudioMixdowns = EnumHelper<Mixdown>.GetEnumList(); this.SourceTracks = new List<Audio>(); }
/// <summary> /// Initializes a new instance of the <see cref="PrePostActionService"/> class. /// </summary> /// <param name="queueProcessor"> /// The queue processor. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService) { this.queueProcessor = queueProcessor; this.userSettingService = userSettingService; this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted; this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted; this.queueProcessor.EncodeService.EncodeStarted += EncodeService_EncodeStarted; }
/// <summary> /// Initializes a new instance of the <see cref="QueueViewModel"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <param name="queueProcessor"> /// The Queue Processor Service /// </param> /// <param name="errorService"> /// The Error Service /// </param> public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService) { this.userSettingService = userSettingService; this.queueProcessor = queueProcessor; this.errorService = errorService; this.Title = "Queue"; this.JobsPending = "No encodes pending"; this.JobStatus = "There are no jobs currently encoding"; }
/// <summary> /// Initializes a new instance of the <see cref="EncodeBase"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public EncodeBase(IUserSettingService userSettingService) { this.userSettingService = userSettingService; this.logBuffer = new StringBuilder(); header = GeneralUtilities.CreateCliLogHeader(); this.LogIndex = 0; }
/// <summary> /// Initializes a new instance of the <see cref="EncodeBase"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public EncodeBase(IUserSettingService userSettingService) { this.userSettingService = userSettingService; this.logBuffer = new StringBuilder(); header = GeneralUtilities.CreateCliLogHeader( userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild)); }
/// <summary> /// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.SubtitlesViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public SubtitlesViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask(); this.Langauges = LanguageUtilities.MapLanguages().Keys; this.CharacterCodes = CharCodesUtilities.GetCharacterCodes(); this.ForeignAudioSearchTrack = new Subtitle { SubtitleType = SubtitleType.ForeignAudioSearch, Language = "Foreign Audio Search (Bitmap)" }; this.SourceTracks = new List<Subtitle> { this.ForeignAudioSearchTrack }; }
/// <summary> /// Initializes a new instance of the <see cref="AdvancedViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public AdvancedViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { X264Presets = EnumHelper<x264Preset>.GetEnumList(); X264Profiles = EnumHelper<x264Profile>.GetEnumList(); X264Tunes = EnumHelper<x264Tune>.GetEnumList(); this.x264Preset = x264Preset.None; this.x264Profile = x264Profile.None; this.x264Tune = x264Tune.None; }
/// <summary> /// Initializes a new instance of the <see cref="AudioDefaultsViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public AudioDefaultsViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList(); this.AudioBehaviours = new AudioBehaviours(); this.SelectedAvailableToMove = new BindingList<string>(); this.SelectedLangaugesToMove = new BindingList<string>(); this.AvailableLanguages = new BindingList<string>(); this.SetupLanguages(null); }
/// <summary> /// Initializes a new instance of the <see cref="PresetService"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PresetService(IUserSettingService userSettingService) { this.userSettingService = userSettingService; // If the preset file doesn't exist. Create it. if (!File.Exists(this.builtInPresetFile)) { this.UpdateBuiltInPresets(); } this.LoadPresets(); }
/// <summary> /// Initializes a new instance of the <see cref="QueueViewModel"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <param name="queueProcessor"> /// The Queue Processor Service /// </param> /// <param name="errorService"> /// The Error Service /// </param> public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService) { this.userSettingService = userSettingService; this.queueProcessor = queueProcessor; this.errorService = errorService; this.Title = Resources.QueueViewModel_Queue; this.JobsPending = Resources.QueueViewModel_NoEncodesPending; this.JobStatus = Resources.QueueViewModel_NoJobsPending; this.SelectedItems = new BindingList<QueueTask>(); this.DisplayName = "Queue"; this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction); }
/// <summary> /// Initializes a new instance of the <see cref="PreviewViewModel"/> class. /// </summary> /// <param name="encodeService"> /// The encode Service. /// </param> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PreviewViewModel(IEncodeServiceWrapper encodeService, IErrorService errorService, IUserSettingService userSettingService) { this.encodeService = encodeService; this.errorService = errorService; this.userSettingService = userSettingService; this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.StartAt = 1; this.Duration = 30; UseSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer); }
/// <summary> /// Initializes a new instance of the <see cref="LibEncode"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <param name="handBrakeInstance"> /// The hand Brake Instance. /// </param> public LibEncode(IUserSettingService userSettingService, IHandBrakeInstance handBrakeInstance) : base(userSettingService) { this.userSettingService = userSettingService; // Setup the HandBrake Instance this.instance = handBrakeInstance; this.instance.EncodeCompleted += this.InstanceEncodeCompleted; this.instance.EncodeProgress += this.InstanceEncodeProgress; HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged; HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged; }
/// <summary> /// Parse the StreamReader output into a List of Titles /// </summary> /// <param name="output"> /// The output. /// </param> /// <param name="userSettingService"> </param> /// <returns> /// A DVD object which contains a list of title inforamtion /// </returns> public static Source Parse(StreamReader output, IUserSettingService userSettingService) { var thisDVD = new Source(); while (!output.EndOfStream) { if ((char) output.Peek() == '+') thisDVD.Titles.AddRange(Title.ParseList(output.ReadToEnd(), userSettingService)); else output.ReadLine(); } return thisDVD; }
/// <summary> /// Initializes a new instance of the <see cref="AudioViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask(); this.SampleRates = new ObservableCollection<string> { "Auto", "48", "44.1", "32", "24", "22.05", "16", "12", "11.025", "8" }; this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList(); this.AudioMixdowns = EnumHelper<Mixdown>.GetEnumList(); this.SourceTracks = new List<Audio>(); this.AudioBehaviours = new AudioBehaviours(); this.SelectedAvailableToMove = new BindingList<string>(); this.SelectedLangaugesToMove = new BindingList<string>(); this.AvailableLanguages = new BindingList<string>(); this.SetupLanguages(null); }
/// <summary> /// Initializes a new instance of the <see cref="AudioViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.windowManager = windowManager; this.Task = new EncodeTask(); this.AudioDefaultsViewModel = new AudioDefaultsViewModel(this.Task); this.SampleRates = new ObservableCollection<string> { "Auto" }; foreach (var item in HandBrakeEncoderHelpers.AudioSampleRates) { this.SampleRates.Add(item.Name); } this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList(); this.SourceTracks = new List<Audio>(); }
/// <summary> /// Initializes a new instance of the <see cref="IsolatedEncodeService"/> class. /// </summary> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public IsolatedEncodeService(IErrorService errorService, IUserSettingService userSettingService) : base(errorService, userSettingService) { try { if (this.CanConnect()) { this.Connect(); } } catch (Exception exception) { errorService.ShowError( "Unable to connect to scan worker process.", "Try restarting HandBrake", exception); } }
/// <summary> /// Initializes a new instance of the <see cref="VideoViewModel"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <param name="advancedEncoderOptionsCommand"> /// The advanced Encoder Options Command. /// </param> public VideoViewModel(IUserSettingService userSettingService) { this.Task = new EncodeTask { VideoEncoder = VideoEncoder.X264 }; this.userSettingService = userSettingService; this.QualityMin = 0; this.QualityMax = 51; this.IsConstantQuantity = true; this.VideoEncoders = EnumHelper<VideoEncoder>.GetEnumList(); this.VideoProfiles = new BindingList<VideoProfile>(); this.VideoTunes = new BindingList<VideoTune>(); this.VideoPresets = new BindingList<VideoPreset>(); this.VideoLevels = new BindingList<VideoLevel>(); this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged; }
/// <summary> /// Initializes a new instance of the <see cref="LibScan"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <param name="handBrakeInstance"> /// The hand Brake Instance. /// </param> public LibScan(IUserSettingService userSettingService, IHandBrakeInstance handBrakeInstance) { logging = new StringBuilder(); header = GeneralUtilities.CreateCliLogHeader( userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild)); instance = handBrakeInstance; instance.Initialize(1); instance.ScanProgress += this.InstanceScanProgress; instance.ScanCompleted += this.InstanceScanCompleted; HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged; HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged; }
/// <summary> /// Initializes a new instance of the <see cref="QueueProcessor"/> class. /// </summary> /// <param name="queueManager"> /// The queue manager. /// </param> /// <param name="encodeService"> /// The encode Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <exception cref="ArgumentNullException"> /// Services are not setup /// </exception> public QueueProcessor(IQueueManager queueManager, IEncode encodeService, IUserSettingService userSettingService) { this.userSettingService = userSettingService; this.QueueManager = queueManager; this.EncodeService = encodeService; if (this.QueueManager == null) { throw new ArgumentNullException("queueManager"); } if (this.QueueManager == null) { throw new ArgumentNullException("queueManager"); } }
/// <summary> /// Initializes a new instance of the <see cref="PreviewViewModel"/> class. /// </summary> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PreviewViewModel(IErrorService errorService, IUserSettingService userSettingService) { // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point this.encodeService = new EncodeServiceWrapper(userSettingService); this.errorService = errorService; this.userSettingService = userSettingService; this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.StartAt = 1; this.Duration = 30; this.CanPlay = true; UseSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer); this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration); }
/// <summary> /// Initializes a new instance of the <see cref="FiltersViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public FiltersViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.CurrentTask = new EncodeTask(); this.DeblockValue = 4; // OFF this.IsDeinterlaceMode = true; }
public PresetService(IErrorService errorService, IUserSettingService userSettingService, ILog logService) { this.log = logService; this.errorService = errorService; this.userSettingService = userSettingService; }
/// <summary> /// Initializes a new instance of the <see cref="ChaptersViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public ChaptersViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask(); }
/// <summary> /// Initializes a new instance of the <see cref="UpdateService"/> class. /// </summary> /// <param name="userSettingService"> /// The user setting service. /// </param> public UpdateService(IUserSettingService userSettingService) { this.userSettingService = userSettingService; }
/// <summary> /// Override the startup behavior to handle files dropped on the app icon. /// </summary> /// <param name="e"> /// The StartupEventArgs. /// </param> protected override void OnStartup(StartupEventArgs e) { // We don't support Windows XP / 2003 / 2003 R2 / Vista / 2008 OperatingSystem os = Environment.OSVersion; if (((os.Platform == PlatformID.Win32NT) && (os.Version.Major == 5)) || ((os.Platform == PlatformID.Win32NT) && (os.Version.Major == 6 && os.Version.Minor < 1))) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsVersionWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (!Environment.Is64BitOperatingSystem) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsBitnessWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.Equals("--reset"))) { HandBrakeApp.ResetToDefaults(); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.StartsWith("--recover-queue-ids"))) { string command = e.Args.FirstOrDefault(f => f.StartsWith("--recover-queue-ids")); if (!string.IsNullOrEmpty(command)) { command = command.Replace("--recover-queue-ids=", string.Empty); List <string> processIds = command.Split(',').ToList(); StartupOptions.QueueRecoveryIds = processIds; } } if (e.Args.Any(f => f.Equals("--auto-start-queue"))) { StartupOptions.AutoRestartQueue = true; } // Portable Mode if (Portable.IsPortable()) { if (!Portable.Initialise()) { Application.Current.Shutdown(); return; } } // Setup the UI Language IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); string culture = userSettingService.GetUserSetting <string>(UserSettingConstants.UiLanguage); if (!string.IsNullOrEmpty(culture)) { InterfaceLanguage language = InterfaceLanguageUtilities.FindInterfaceLanguage(culture); if (language != null) { CultureInfo ci = new CultureInfo(language.Culture); Thread.CurrentThread.CurrentUICulture = ci; } } DarkThemeMode useDarkTheme = (DarkThemeMode)userSettingService.GetUserSetting <int>(UserSettingConstants.DarkThemeMode); if (SystemInfo.IsWindows10()) { ResourceDictionary darkTheme = new ResourceDictionary(); switch (useDarkTheme) { case DarkThemeMode.System: if (SystemInfo.IsAppsUsingDarkTheme()) { darkTheme.Source = new Uri("Themes/Dark.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(darkTheme); } break; case DarkThemeMode.Dark: darkTheme.Source = new Uri("Themes/Dark.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(darkTheme); break; default: break; } } // NO-Hardware Mode bool noHardware = e.Args.Any(f => f.Equals("--no-hardware")) || (Portable.IsPortable() && !Portable.IsHardwareEnabled()); // Initialise the Engine HandBrakeWPF.Helpers.LogManager.Init(); try { HandBrakeInstanceManager.Init(noHardware); } catch (Exception exception) { if (!noHardware) { MessageBox.Show(HandBrakeWPF.Properties.Resources.Startup_InitFailed, HandBrakeWPF.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } throw exception; } // Initialise the GUI base.OnStartup(e); // If we have a file dropped on the icon, try scanning it. string[] args = e.Args; if (args.Any() && (File.Exists(args[0]) || Directory.Exists(args[0]))) { IMainViewModel mvm = IoC.Get <IMainViewModel>(); mvm.StartScan(args[0], 0); } }
private static string CheckAndHandleFilenameCollisions(string autoNamePath, string destinationFilename, EncodeTask task, IUserSettingService userSettingService) { AutonameFileCollisionBehaviour behaviour = (AutonameFileCollisionBehaviour)userSettingService.GetUserSetting <int>(UserSettingConstants.AutonameFileCollisionBehaviour); string prefix = string.Empty, postfix = string.Empty; switch (behaviour) { case AutonameFileCollisionBehaviour.Postfix: postfix = userSettingService.GetUserSetting <string>(UserSettingConstants.AutonameFilePrePostString); break; case AutonameFileCollisionBehaviour.Prefix: prefix = userSettingService.GetUserSetting <string>(UserSettingConstants.AutonameFilePrePostString); break; } string extension = Path.GetExtension(destinationFilename); string filenameWithoutExt = Path.GetFileNameWithoutExtension(destinationFilename); if (behaviour != AutonameFileCollisionBehaviour.AppendNumber) { if (autoNamePath?.ToLower() == task.Source?.ToLower()) { autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), prefix + filenameWithoutExt + postfix + extension); int counter = 0; while (File.Exists(autoNamePath)) { counter = counter + 1; string appendedNumber = string.Format("({0})", counter); autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), prefix + filenameWithoutExt + postfix + appendedNumber + extension); } } } else { int counter = 0; while (File.Exists(autoNamePath)) { counter = counter + 1; string appendedNumber = string.Format("({0})", counter); autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), filenameWithoutExt + appendedNumber + extension); } } return(autoNamePath); }
/// <summary> /// Initializes a new instance of the <see cref="PreviewViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="encodeService"> /// The encode Service. /// </param> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PreviewViewModel(IWindowManager windowManager, IEncode encodeService, IErrorService errorService, IUserSettingService userSettingService) { this.encodeService = encodeService; this.errorService = errorService; this.userSettingService = userSettingService; this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.StartAt = 1; this.Duration = 30; UseSystemDefaultPlayer = userSettingService.GetUserSetting <bool>(UserSettingConstants.DefaultPlayer); }
/// <summary> /// Override the startup behavior to handle files dropped on the app icon. /// </summary> /// <param name="e"> /// The StartupEventArgs. /// </param> protected override void OnStartup(StartupEventArgs e) { // We don't support Windows earlier than 10. if (!SystemInfo.IsWindows10OrLater()) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsVersionWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (!Environment.Is64BitOperatingSystem) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsBitnessWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.Equals("--reset"))) { HandBrakeApp.ResetToDefaults(); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.StartsWith("--recover-queue-ids"))) { string command = e.Args.FirstOrDefault(f => f.StartsWith("--recover-queue-ids")); if (!string.IsNullOrEmpty(command)) { command = command.Replace("--recover-queue-ids=", string.Empty); List <string> processIds = command.Split(',').ToList(); StartupOptions.QueueRecoveryIds = processIds; } } if (e.Args.Any(f => f.Equals("--auto-start-queue"))) { StartupOptions.AutoRestartQueue = true; } // Portable Mode if (Portable.IsPortable()) { if (!Portable.Initialise()) { Application.Current.Shutdown(); return; } } // Setup the UI Language IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); string culture = userSettingService.GetUserSetting <string>(UserSettingConstants.UiLanguage); if (!string.IsNullOrEmpty(culture)) { InterfaceLanguage language = InterfaceLanguageUtilities.FindInterfaceLanguage(culture); if (language != null) { CultureInfo ci = new CultureInfo(language.Culture); Thread.CurrentThread.CurrentUICulture = ci; } } int runCounter = userSettingService.GetUserSetting <int>(UserSettingConstants.RunCounter); // Software Rendering if (e.Args.Any(f => f.Equals("--force-software-rendering")) || Portable.IsForcingSoftwareRendering() || userSettingService.GetUserSetting <bool>(UserSettingConstants.ForceSoftwareRendering)) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } // Check if the user would like to check for updates AFTER the first run, but only once. if (runCounter == 1) { CheckForUpdateCheckPermission(userSettingService); } // Increment the counter so we can change startup behavior for the above warning and update check question. userSettingService.SetUserSetting(UserSettingConstants.RunCounter, runCounter + 1); // Only display once. // App Theme DarkThemeMode useDarkTheme = (DarkThemeMode)userSettingService.GetUserSetting <int>(UserSettingConstants.DarkThemeMode); ResourceDictionary dark = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Blue.xaml") }; ResourceDictionary light = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml") }; Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Generic.xaml", UriKind.Relative) }); bool themed = false; switch (useDarkTheme) { case DarkThemeMode.System: if (SystemParameters.HighContrast) { break; } if (SystemInfo.IsAppsUsingDarkTheme()) { Application.Current.Resources.MergedDictionaries.Add(dark); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Dark.xaml", UriKind.Relative) }); } else { Application.Current.Resources.MergedDictionaries.Add(light); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Light.xaml", UriKind.Relative) }); } themed = true; break; case DarkThemeMode.Dark: Application.Current.Resources.MergedDictionaries.Add(dark); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Dark.xaml", UriKind.Relative) }); themed = true; break; case DarkThemeMode.Light: Application.Current.Resources.MergedDictionaries.Add(light); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Light.xaml", UriKind.Relative) }); themed = true; break; } Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Views/Styles/Styles.xaml", UriKind.Relative) }); if (themed) { Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Views/Styles/ThemedStyles.xaml", UriKind.Relative) }); } // NO-Hardware Mode bool noHardware = e.Args.Any(f => f.Equals("--no-hardware")) || (Portable.IsPortable() && !Portable.IsHardwareEnabled()); // Initialise the Engine HandBrakeWPF.Helpers.LogManager.Init(); try { HandBrakeInstanceManager.Init(noHardware); } catch (Exception) { if (!noHardware) { MessageBox.Show(HandBrakeWPF.Properties.Resources.Startup_InitFailed, HandBrakeWPF.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } throw; } // Initialise the GUI base.OnStartup(e); // If we have a file dropped on the icon, try scanning it. string[] args = e.Args; if (args.Any() && (File.Exists(args[0]) || Directory.Exists(args[0]))) { IMainViewModel mvm = IoC.Get <IMainViewModel>(); mvm.StartScan(args[0], 0); } }
public QueueResourceService(IUserSettingService userSettingService) { this.userSettingService = userSettingService; this.userSettingService.SettingChanged += this.UserSettingService_SettingChanged; }
public EncodeTaskFactory(IUserSettingService userSettingService) { this.userSettingService = userSettingService; }
/// <summary> /// Gets a list of Video encoders OR returns the string name of an encoder depending on the input. /// </summary> /// <param name="values"> /// The values. /// </param> /// <param name="targetType"> /// The target type. /// </param> /// <param name="parameter"> /// The parameter. /// </param> /// <param name="culture"> /// The culture. /// </param> /// <returns> /// IEnumberable VideoEncoder or String encoder name. /// </returns> public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Count() >= 2) { IUserSettingService userSettingService = values[2] as IUserSettingService; bool isQsvEnabled = false, isVceEnabled = false, isNvencEnabled = false; if (userSettingService != null) { isQsvEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncEncoding); isVceEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableVceEncoder); isNvencEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableNvencEncoder); } List <VideoEncoder> encoders = EnumHelper <VideoEncoder> .GetEnumList().ToList(); EncodeTask task = values[1] as EncodeTask; if (HandBrakeEncoderHelpers.VideoEncoders.All(a => a.ShortName != EnumHelper <VideoEncoder> .GetShortName(VideoEncoder.X264_10))) { encoders.Remove(VideoEncoder.X264_10); } if (HandBrakeEncoderHelpers.VideoEncoders.All(a => a.ShortName != EnumHelper <VideoEncoder> .GetShortName(VideoEncoder.X265_10))) { encoders.Remove(VideoEncoder.X265_10); } if (HandBrakeEncoderHelpers.VideoEncoders.All(a => a.ShortName != EnumHelper <VideoEncoder> .GetShortName(VideoEncoder.X265_12))) { encoders.Remove(VideoEncoder.X265_12); } if (task != null && task.OutputFormat == OutputFormat.Mp4) { encoders.Remove(VideoEncoder.Theora); encoders.Remove(VideoEncoder.VP8); encoders.Remove(VideoEncoder.VP9); } else if (task != null && task.OutputFormat == OutputFormat.WebM) { encoders.RemoveAll(ve => !(ve.Equals(VideoEncoder.VP9) || ve.Equals(VideoEncoder.VP8))); } if (!isQsvEnabled || !SystemInfo.IsQsvAvailableH264) { encoders.Remove(VideoEncoder.QuickSync); } if (!isQsvEnabled || !SystemInfo.IsQsvAvailableH265) { encoders.Remove(VideoEncoder.QuickSyncH265); encoders.Remove(VideoEncoder.QuickSyncH26510b); } else if (!SystemInfo.IsQsvAvailableH26510bit) { encoders.Remove(VideoEncoder.QuickSyncH26510b); } if (!isVceEnabled || !SystemInfo.IsVceH264Available) { encoders.Remove(VideoEncoder.VceH264); } if (!isVceEnabled || !SystemInfo.IsVceH265Available) { encoders.Remove(VideoEncoder.VceH265); } if (!isNvencEnabled || !SystemInfo.IsNVEncH264Available) { encoders.Remove(VideoEncoder.NvencH264); } if (!isNvencEnabled || !SystemInfo.IsNVEncH265Available) { encoders.Remove(VideoEncoder.NvencH265); } return(EnumHelper <VideoEncoder> .GetEnumDisplayValuesSubset(encoders)); } if (values[0].GetType() == typeof(VideoEncoder)) { return(EnumHelper <VideoEncoder> .GetDisplay((VideoEncoder)values[0])); } return(null); }
public RemoteInstance(ILog logService, IUserSettingService userSettingService, IPortService portService) { this.logService = logService; this.userSettingService = userSettingService; this.portService = portService; }
/// <summary> /// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.SubtitlesViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public SubtitlesViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.SubtitleTracks = new ObservableCollection <SubtitleTrack>(); }
public PresetsMenuConverter() { this.userSettingService = IoC.Get <IUserSettingService>(); }
private static string GenerateDestinationFileName(EncodeTask task, IUserSettingService userSettingService, string sourceName, string dvdTitle, string combinedChapterTag, string createDate, string createTime) { string destinationFilename; if (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNameFormat) != string.Empty) { destinationFilename = userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNameFormat); destinationFilename = destinationFilename .RegexReplace(Constants.Source, sourceName) .RegexReplace(Constants.Title, dvdTitle) .RegexReplace(Constants.Chapters, combinedChapterTag) .RegexReplace(Constants.Date, DateTime.Now.Date.ToShortDateString().Replace('/', '-')) .RegexReplace(Constants.Time, DateTime.Now.ToString("HH-mm")) .RegexReplace(Constants.CretaionDate, createDate) .RegexReplace(Constants.CreationTime, createTime); if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality) { destinationFilename = destinationFilename.Replace(Constants.Quality, task.Quality.ToString()); destinationFilename = destinationFilename.Replace(Constants.Bitrate, string.Empty); } else { destinationFilename = destinationFilename.Replace( Constants.Bitrate, task.VideoBitrate.ToString()); destinationFilename = destinationFilename.Replace(Constants.Quality, string.Empty); } } else { destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag; } /* * File Extension */ if (task.OutputFormat == OutputFormat.Mp4) { switch ((Mp4Behaviour)userSettingService.GetUserSetting <int>(UserSettingConstants.UseM4v)) { case Mp4Behaviour.Auto: // Automatic destinationFilename += task.IncludeChapterMarkers || MP4Helper.RequiresM4v(task) ? ".m4v" : ".mp4"; break; case Mp4Behaviour.MP4: // Always MP4 destinationFilename += ".mp4"; break; case Mp4Behaviour.M4V: // Always M4V destinationFilename += ".m4v"; break; } } else if (task.OutputFormat == OutputFormat.Mkv) { destinationFilename += ".mkv"; } else if (task.OutputFormat == OutputFormat.WebM) { destinationFilename += ".webm"; } return(destinationFilename); }
/// <summary> /// Initializes a new instance of the <see cref="AutoNameHelper"/> class. /// </summary> /// <param name="userSetting"> /// The user Setting. /// </param> public AutoNameHelper(IUserSettingService userSetting) { userSettingService = userSetting; }
/// <summary> /// Function which generates the filename and path automatically based on /// the Source Name, DVD title and DVD Chapters /// </summary> public static string AutoName(EncodeTask task, string sourceOrLabelName, Preset presetName) { IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); if (task.Destination == null) { task.Destination = string.Empty; } if (task.Title != 0) { // Get the Source Name and remove any invalid characters string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty)); // Remove Underscores if (userSettingService.GetUserSetting <bool>(UserSettingConstants.AutoNameRemoveUnderscore)) { sourceName = sourceName.Replace("_", " "); } if (userSettingService.GetUserSetting <bool>(UserSettingConstants.RemovePunctuation)) { sourceName = sourceName.Replace("-", string.Empty); sourceName = sourceName.Replace(",", string.Empty); sourceName = sourceName.Replace(".", string.Empty); } // Switch to "Title Case" if (userSettingService.GetUserSetting <bool>(UserSettingConstants.AutoNameTitleCase)) { sourceName = sourceName.ToTitleCase(); } // Get the Selected Title Number string dvdTitle = task.Title.ToString(); // Get the Chapter Start and Chapter End Numbers string chapterStart = task.StartPoint.ToString(); string chapterFinish = task.EndPoint.ToString(); string combinedChapterTag = chapterStart; if (chapterFinish != chapterStart && chapterFinish != string.Empty) { combinedChapterTag = chapterStart + "-" + chapterFinish; } // Local method to check if we have a creation time in the meta data. If not, fall back to source file creation time. DateTime obtainCreateDateObject() { var rd = task.MetaData.ReleaseDate; if (DateTime.TryParse(rd, out var d)) { return(d); } try { return(File.GetCreationTime(task.Source)); } catch (Exception e) { if (e is UnauthorizedAccessException || e is PathTooLongException || e is NotSupportedException) { // Suspect the most likely concerns trying to grab the creation date in which we would want to swallow exception. return(default(DateTime)); } throw e; } } var creationDateTime = obtainCreateDateObject(); string createDate = creationDateTime.Date.ToShortDateString().Replace('/', '-'); string createTime = creationDateTime.ToString("HH-mm"); /* * Generate the full path and filename */ string destinationFilename = GenerateDestinationFileName(task, userSettingService, sourceName, dvdTitle, combinedChapterTag, createDate, createTime); string autoNamePath = GetAutonamePath(userSettingService, task, destinationFilename); autoNamePath = CheckAndHandleFilenameCollisions(autoNamePath, destinationFilename, task, userSettingService); return(autoNamePath); } return(string.Empty); }
/// <summary> /// Initializes a new instance of the <see cref="FiltersViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public FiltersViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.CurrentTask = new EncodeTask(); this.DeblockValue = 4; // OFF this.SelectedDeinterlaceFilter = DeinterlaceFilter.Off; }
/// <summary> /// Initializes a new instance of the <see cref="MetaDataViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window Manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public MetaDataViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.task = new EncodeTask(); }
public SettingsController(IUserSettingService service) { _service = service; }
public LibScan(ILog logService, IUserSettingService userSettingService) { this.log = logService; this.userSettingService = userSettingService; this.IsScanning = false; }
/// <summary> /// Initializes a new instance of the <see cref="AdvancedViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public AdvancedViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask(); this.UpdateUIFromAdvancedOptions(); }
/// <summary> /// The check cli version. /// </summary> public static void CheckCLIVersion() { IErrorService errorService = IoC.Get <IErrorService>(); IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); string line; // 0 = SVN Build / Version // 1 = Build Date // Get the SHA1 Hash of HandBrakeCLI byte[] hash; using (Stream stream = File.OpenRead("HandBrakeCLI.exe")) { hash = SHA1.Create().ComputeHash(stream); } string base64Hash = Convert.ToBase64String(hash); // Compare the hash with the last known hash. If it's the same, return. if (userSettingService.GetUserSetting <string>(ASUserSettingConstants.HandBrakeExeHash) == base64Hash) { return; } // It's not the same, so start the CLI to get it's version data. Process cliProcess = new Process(); ProcessStartInfo handBrakeCli = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0") { UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true, CreateNoWindow = true }; cliProcess.StartInfo = handBrakeCli; try { cliProcess.Start(); // Retrieve standard output and report back to parent thread until the process is complete bool success = false; TextReader stdOutput = cliProcess.StandardError; while ((line = stdOutput.ReadLine()) != null) { Match m = Regex.Match(line, @"HandBrake ([svnM0-9.]*) \(([0-9]*)\)"); Match platform = Regex.Match(line, @"- ([A-Za-z0-9\s ]*) -"); if (m.Success) { string version = m.Groups[1].Success ? m.Groups[1].Value : string.Empty; string build = m.Groups[2].Success ? m.Groups[2].Value : string.Empty; int buildValue; int.TryParse(build, out buildValue); userSettingService.SetUserSetting(ASUserSettingConstants.HandBrakeBuild, buildValue); userSettingService.SetUserSetting(ASUserSettingConstants.HandBrakeVersion, version); success = true; } if (platform.Success) { userSettingService.SetUserSetting( ASUserSettingConstants.HandBrakePlatform, platform.Value.Replace("-", string.Empty).Trim()); } } while (!cliProcess.HasExited) { if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds. { Process cli = Process.GetProcessById(cliProcess.Id); if (!cli.HasExited) { cli.Kill(); } } } if (success) { userSettingService.SetUserSetting(ASUserSettingConstants.HandBrakeExeHash, base64Hash); } } catch (Exception e) { userSettingService.SetUserSetting(ASUserSettingConstants.HandBrakeBuild, 0); userSettingService.SetUserSetting(ASUserSettingConstants.HandBrakePlatform, string.Empty); userSettingService.SetUserSetting(ASUserSettingConstants.HandBrakeVersion, string.Empty); userSettingService.SetUserSetting(ASUserSettingConstants.HandBrakeExeHash, string.Empty); errorService.ShowError( "Unable to Initialise HandBrake. This error is unrecoverable.", " Try restarting.", e); } }
public ActiveJob(QueueTask task, IHbFunctionsProvider hbFunctionsProvider, IUserSettingService userSettingService, ILogInstanceManager logInstanceManager, int jobId, IPortService portService) { this.job = task; this.encodeService = new LibEncode(hbFunctionsProvider, userSettingService, logInstanceManager, jobId, portService); }
/// <summary> /// Gets a list of Video encoders OR returns the string name of an encoder depending on the input. /// </summary> /// <param name="values"> /// The values. /// </param> /// <param name="targetType"> /// The target type. /// </param> /// <param name="parameter"> /// The parameter. /// </param> /// <param name="culture"> /// The culture. /// </param> /// <returns> /// IEnumerable VideoEncoder or String encoder name. /// </returns> public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Count() >= 2) { IUserSettingService userSettingService = values[2] as IUserSettingService; bool isQsvEnabled = false, isVceEnabled = false, isNvencEnabled = false; if (userSettingService != null) { isQsvEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncEncoding); isVceEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableVceEncoder); isNvencEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableNvencEncoder); } List <VideoEncoder> allEncoders = values[0] as List <VideoEncoder>; EncodeTask task = values[1] as EncodeTask; if (task == null || allEncoders == null) { return(null); } List <VideoEncoder> returnEncoders = new List <VideoEncoder>(allEncoders); foreach (var encoder in allEncoders) { HBVideoEncoder foundEncoder = HandBrakeEncoderHelpers.GetVideoEncoder(EnumHelper <VideoEncoder> .GetShortName(encoder)); if (foundEncoder == null) { returnEncoders.Remove(encoder); continue; } if (task.OutputFormat == OutputFormat.Mp4 && !foundEncoder.SupportsMP4) { returnEncoders.Remove(encoder); } if (task.OutputFormat == OutputFormat.Mkv && !foundEncoder.SupportsMKV) { returnEncoders.Remove(encoder); } if (task.OutputFormat == OutputFormat.WebM && !foundEncoder.SupportsWebM) { returnEncoders.Remove(encoder); } if (!isQsvEnabled && VideoEncoderHelpers.IsQuickSync(encoder)) { returnEncoders.Remove(encoder); } if (!isVceEnabled && VideoEncoderHelpers.IsVCN(encoder)) { returnEncoders.Remove(encoder); } if (!isNvencEnabled && VideoEncoderHelpers.IsNVEnc(encoder)) { returnEncoders.Remove(encoder); } } return(EnumHelper <VideoEncoder> .GetEnumDisplayValuesSubset(returnEncoders)); } if (values[0].GetType() == typeof(VideoEncoder)) { return(EnumHelper <VideoEncoder> .GetDisplay((VideoEncoder)values[0])); } return(null); }
public LogService(IUserSettingService userSettingService) { HandBrakeUtils.MessageLogged += this.HandBrakeUtils_MessageLogged; HandBrakeUtils.ErrorLogged += this.HandBrakeUtils_ErrorLogged; }
public SummaryViewModel(IScan scanService, IUserSettingService userSettingService) { this.scanService = scanService; this.userSettingService = userSettingService; }
/// <summary> /// Function which generates the filename and path automatically based on /// the Source Name, DVD title and DVD Chapters /// </summary> /// <param name="task"> /// The task. /// </param> /// <param name="sourceOrLabelName"> /// The Source or Label Name /// </param> /// <returns> /// The Generated FileName /// </returns> public static string AutoName(EncodeTask task, string sourceOrLabelName) { IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); if (task.Destination == null) { task.Destination = string.Empty; } string autoNamePath = string.Empty; if (task.Title != 0) // TODO check. { // Get the Source Name and remove any invalid characters string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty)); // Remove Underscores if (userSettingService.GetUserSetting <bool>(UserSettingConstants.AutoNameRemoveUnderscore)) { sourceName = sourceName.Replace("_", " "); } // Switch to "Title Case" if (userSettingService.GetUserSetting <bool>(UserSettingConstants.AutoNameTitleCase)) { sourceName = sourceName.ToTitleCase(); } // Get the Selected Title Number string dvdTitle = task.Title.ToString(); // Get the Chapter Start and Chapter End Numbers string chapterStart = task.StartPoint.ToString(); string chapterFinish = task.EndPoint.ToString(); string combinedChapterTag = chapterStart; if (chapterFinish != chapterStart && chapterFinish != string.Empty) { combinedChapterTag = chapterStart + "-" + chapterFinish; } /* * File Name */ string destinationFilename; if (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNameFormat) != string.Empty) { destinationFilename = userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNameFormat); destinationFilename = destinationFilename.Replace("{source}", sourceName) .Replace("{title}", dvdTitle) .Replace("{chapters}", combinedChapterTag) .Replace("{date}", DateTime.Now.Date.ToShortDateString().Replace('/', '-')); } else { destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag; } /* * File Extension */ if (task.OutputFormat == OutputFormat.Mp4 || task.OutputFormat == OutputFormat.M4V) { switch (userSettingService.GetUserSetting <int>(UserSettingConstants.UseM4v)) { case 0: // Automatic destinationFilename += task.IncludeChapterMarkers || task.RequiresM4v ? ".m4v" : ".mp4"; break; case 1: // Always MP4 destinationFilename += ".mp4"; break; case 2: // Always M4V destinationFilename += ".m4v"; break; } } else if (task.OutputFormat == OutputFormat.Mkv) { destinationFilename += ".mkv"; } /* * File Destination Path */ // If there is an auto name path, use it... if (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") && !string.IsNullOrEmpty(task.Source)) { string savedPath = userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim().Replace("{source_path}\\", string.Empty).Replace("{source_path}", string.Empty); string directory = Directory.Exists(task.Source) ? task.Source : Path.GetDirectoryName(task.Source); string requestedPath = Path.Combine(directory, savedPath); autoNamePath = Path.Combine(requestedPath, destinationFilename); if (autoNamePath == task.Source) { // Append out_ to files that already exist or is the source file autoNamePath = Path.Combine(Path.GetDirectoryName(task.Source), "output_" + destinationFilename); } } else if (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") && !string.IsNullOrEmpty(task.Source)) { // Second Case: We have a Path, with "{source_folder}" in it, therefore we need to replace it with the folder name from the source. string path = Path.GetDirectoryName(task.Source); if (!string.IsNullOrEmpty(path)) { string[] filesArray = path.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); string sourceFolder = filesArray[filesArray.Length - 1]; autoNamePath = Path.Combine(userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Replace("{source_folder_name}", sourceFolder), destinationFilename); } } else if (!task.Destination.Contains(Path.DirectorySeparatorChar.ToString())) { // Third case: If the destination box doesn't already contain a path, make one. if (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim() != string.Empty && userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim() != "Click 'Browse' to set the default location") { autoNamePath = Path.Combine(userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath), destinationFilename); } else // ...otherwise, output to the source directory { autoNamePath = null; } } else // Otherwise, use the path that is already there. { // Use the path and change the file extension to match the previous destination autoNamePath = Path.Combine(Path.GetDirectoryName(task.Destination), destinationFilename); } } return(autoNamePath); }
public static IEncodeInstance GetEncodeInstance(int verbosity, HBConfiguration configuration, ILog logService, IUserSettingService userSettingService, IPortService portService) { lock (ProcessingLock) { if (!HandBrakeUtils.IsInitialised()) { throw new Exception("Please call Init before Using!"); } IEncodeInstance newInstance; if (userSettingService.GetUserSetting <bool>(UserSettingConstants.ProcessIsolationEnabled) && Portable.IsProcessIsolationEnabled()) { newInstance = new RemoteInstance(logService, userSettingService, portService); } else { if (encodeInstance != null && !encodeInstance.IsRemoteInstance) { encodeInstance.Dispose(); encodeInstance = null; } newInstance = new HandBrakeInstance(); HandBrakeUtils.SetDvdNav( !userSettingService.GetUserSetting <bool>(UserSettingConstants.DisableLibDvdNav)); encodeInstance = newInstance; } newInstance.Initialize(verbosity, noHardware); return(newInstance); } }
private int intelGpuCounter = -1; // Always default to the first card when allocating. public QueueResourceService(IUserSettingService userSettingService) { this.userSettingService = userSettingService; }