From 1aadfe267e451acfbc900590a53cd9df87fe50ff Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 20 Jul 2012 13:24:52 +0000 Subject: WinGui: Array of fixes and changes - Change Font rendering to "Display" mode to see if folks prefer it. If not it can be reverted back. - Fixes to Queue Edit for the Audio/Subs panel. These should now populate correctly. - Thrown the Drive detector onto a background thread as it seems the windows drive management service can get "stuck" and block the app from starting while it waits. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4867 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrake.ApplicationServices/Parsing/Audio.cs | 65 ++++++++++++++++++++++ .../Parsing/Subtitle.cs | 65 ++++++++++++++++++++++ win/CS/HandBrakeWPF/Services/DriveDetectService.cs | 48 +++++++++------- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 15 +++++ .../HandBrakeWPF/ViewModels/SubtitlesViewModel.cs | 1 + win/CS/HandBrakeWPF/Views/AdvancedView.xaml | 11 ++-- win/CS/HandBrakeWPF/Views/MainView.xaml | 1 + win/CS/HandBrakeWPF/Views/ShellView.xaml | 1 + win/CS/HandBrakeWPF/Views/Styles/Styles.xaml | 17 ++++++ win/CS/HandBrakeWPF/Views/VideoView.xaml | 2 +- 10 files changed, 199 insertions(+), 27 deletions(-) (limited to 'win/CS') diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs index 0e65a3502..b78ca5ad8 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs @@ -112,5 +112,70 @@ namespace HandBrake.ApplicationServices.Parsing return string.Format("{0} {1} ({2}) ({3})", this.TrackNumber, this.Language, this.Format, this.Description); } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The System.Boolean. + /// + public bool Equals(Audio other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.Format, this.Format); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// + /// true if the specified is equal to the current ; otherwise, false. + /// + /// The to compare with the current . 2 + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != typeof(Audio)) + { + return false; + } + return Equals((Audio)obj); + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + /// 2 + public override int GetHashCode() + { + unchecked + { + int result = this.TrackNumber; + result = (result * 397) ^ (this.Language != null ? this.Language.GetHashCode() : 0); + result = (result * 397) ^ (this.LanguageCode != null ? this.LanguageCode.GetHashCode() : 0); + result = (result * 397) ^ (this.Format != null ? this.Format.GetHashCode() : 0); + return result; + } + } } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs index 6548f3aaf..20deeae1b 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs @@ -175,5 +175,70 @@ namespace HandBrake.ApplicationServices.Parsing { return this.SubtitleType == SubtitleType.ForeignAudioSearch ? "Foreign Audio Scan" : string.Format("{0} {1} ({2})", this.TrackNumber, this.Language, this.TypeString); } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The System.Boolean. + /// + public bool Equals(Subtitle other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.SubtitleType, this.SubtitleType); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// + /// true if the specified is equal to the current ; otherwise, false. + /// + /// The to compare with the current . 2 + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != typeof(Subtitle)) + { + return false; + } + return Equals((Subtitle)obj); + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + /// 2 + public override int GetHashCode() + { + unchecked + { + int result = this.TrackNumber; + result = (result * 397) ^ (this.Language != null ? this.Language.GetHashCode() : 0); + result = (result * 397) ^ (this.LanguageCode != null ? this.LanguageCode.GetHashCode() : 0); + result = (result * 397) ^ this.SubtitleType.GetHashCode(); + return result; + } + } } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/DriveDetectService.cs b/win/CS/HandBrakeWPF/Services/DriveDetectService.cs index 7f1b3f9b9..3a4ef5113 100644 --- a/win/CS/HandBrakeWPF/Services/DriveDetectService.cs +++ b/win/CS/HandBrakeWPF/Services/DriveDetectService.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.Services { using System; using System.Management; + using System.Threading; using HandBrakeWPF.Services.Interfaces; @@ -37,28 +38,32 @@ namespace HandBrakeWPF.Services /// public void StartDetection(Action action) { - this.detectionAction = action; + ThreadPool.QueueUserWorkItem( + delegate + { + this.detectionAction = action; - var options = new ConnectionOptions { EnablePrivileges = true }; - var scope = new ManagementScope(@"root\CIMV2", options); + var options = new ConnectionOptions { EnablePrivileges = true }; + var scope = new ManagementScope(@"root\CIMV2", options); - try - { - var query = new WqlEventQuery - { - EventClassName = "__InstanceModificationEvent", - WithinInterval = TimeSpan.FromSeconds(1), - Condition = @"TargetInstance ISA 'Win32_LogicalDisk' and TargetInstance.DriveType = 5" // DriveType - 5: CDROM - }; + try + { + var query = new WqlEventQuery + { + EventClassName = "__InstanceModificationEvent", + WithinInterval = TimeSpan.FromSeconds(1), + Condition = @"TargetInstance ISA 'Win32_LogicalDisk' and TargetInstance.DriveType = 5" // DriveType - 5: CDROM + }; - this.watcher = new ManagementEventWatcher(scope, query); - this.watcher.EventArrived += this.WatcherEventArrived; - this.watcher.Start(); - } - catch (Exception e) - { - Console.WriteLine(e.Message); - } + this.watcher = new ManagementEventWatcher(scope, query); + this.watcher.EventArrived += this.WatcherEventArrived; + this.watcher.Start(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + }); } /// @@ -66,7 +71,10 @@ namespace HandBrakeWPF.Services /// public void Close() { - this.watcher.Stop(); + if (watcher != null) + { + this.watcher.Stop(); + } } /// diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index aea8461bc..c1df4b8be 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1114,6 +1114,21 @@ namespace HandBrakeWPF.ViewModels MessageBoxImage.Information); } + /// + /// The debug scan log. + /// + public void DebugScanLog() + { + VistaOpenFileDialog dialog = new VistaOpenFileDialog(); + + dialog.ShowDialog(); + + if (File.Exists(dialog.FileName)) + { + this.scanService.DebugScanLog(dialog.FileName); + } + } + #endregion #region Main Window Public Methods diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index 5950bc448..d5e949809 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -262,6 +262,7 @@ namespace HandBrakeWPF.ViewModels { this.Task = task; this.NotifyOfPropertyChange(() => this.Task.SubtitleTracks); + this.NotifyOfPropertyChange(() => this.Task); } /// diff --git a/win/CS/HandBrakeWPF/Views/AdvancedView.xaml b/win/CS/HandBrakeWPF/Views/AdvancedView.xaml index bea0cb814..e30a0fcd2 100644 --- a/win/CS/HandBrakeWPF/Views/AdvancedView.xaml +++ b/win/CS/HandBrakeWPF/Views/AdvancedView.xaml @@ -18,13 +18,15 @@ - + + @@ -274,13 +276,10 @@ -