From 2a344e45c4ed8f98e872066aa506512063d5ae51 Mon Sep 17 00:00:00 2001 From: sr55 Date: Tue, 3 Sep 2013 17:01:14 +0000 Subject: WinGui: Change the implementation of the Source Menu Image handling. Hopefully this might workaround a crash some people are seeing in the .NET BitmapDecoder object. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5765 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrakeWPF/AttachedProperties/DriveMenu.cs | 3 --- win/CS/HandBrakeWPF/Model/SourceMenuItem.cs | 22 +++++++++++++----- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 9 ++++---- win/CS/HandBrakeWPF/Views/MainView.xaml | 27 ++++++++++++++++++---- 4 files changed, 42 insertions(+), 19 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs b/win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs index 8c12ca820..ffe8fe634 100644 --- a/win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs +++ b/win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs @@ -12,10 +12,8 @@ namespace HandBrakeWPF.AttachedProperties using System; using System.Collections.Generic; using System.Linq; - using System.Threading; using System.Windows; using System.Windows.Controls; - using System.Windows.Media.Imaging; using HandBrake.ApplicationServices.Exceptions; using HandBrake.ApplicationServices.Utilities; @@ -119,7 +117,6 @@ namespace HandBrakeWPF.AttachedProperties let driveInformation = item select new SourceMenuItem { - Image = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/disc_small.png")), Width = 16, Height = 16 }, Text = string.Format("{0} ({1})", item.RootDirectory, item.VolumeLabel), Command = new SourceMenuCommand(() => mvm.ProcessDrive(driveInformation)), Tag = item, diff --git a/win/CS/HandBrakeWPF/Model/SourceMenuItem.cs b/win/CS/HandBrakeWPF/Model/SourceMenuItem.cs index 4be52964e..00cb2e28f 100644 --- a/win/CS/HandBrakeWPF/Model/SourceMenuItem.cs +++ b/win/CS/HandBrakeWPF/Model/SourceMenuItem.cs @@ -10,7 +10,6 @@ namespace HandBrakeWPF.Model { using System.Collections.ObjectModel; - using System.Windows.Controls; using System.Windows.Input; /// @@ -36,11 +35,6 @@ namespace HandBrakeWPF.Model /// public ICommand Command { get; set; } - /// - /// Gets or sets the image. - /// - public Image Image { get; set; } - /// /// Gets or sets the children. /// @@ -51,6 +45,22 @@ namespace HandBrakeWPF.Model /// public bool IsDrive { get; set; } + /// + /// Gets or sets a value indicating whether is open folder. + /// + public bool IsOpenFolder { get; set; } + + /// + /// Gets a value indicating whether is open file. + /// + public bool IsOpenFile + { + get + { + return !this.IsOpenFolder && (this.Children == null || this.Children.Count == 0); + } + } + /// /// Gets or sets the tag. /// diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 614964700..dce7e524b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -2032,7 +2032,7 @@ namespace HandBrakeWPF.ViewModels SourceMenuItem folderScan = new SourceMenuItem { - Image = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/folder.png")), Width = 16, Height = 16 }, + IsOpenFolder = true, Text = "Open Folder", Command = new SourceMenuCommand(this.FolderScan), IsDrive = false, @@ -2040,7 +2040,7 @@ namespace HandBrakeWPF.ViewModels }; SourceMenuItem fileScan = new SourceMenuItem { - Image = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/Movies.png")), Width = 16, Height = 16 }, + IsOpenFolder = false, Text = "Open File", Command = new SourceMenuCommand(this.FileScan), IsDrive = false, @@ -2050,14 +2050,14 @@ namespace HandBrakeWPF.ViewModels SourceMenuItem titleSpecific = new SourceMenuItem { Text = "Title Specific Scan" }; SourceMenuItem folderScanTitle = new SourceMenuItem { - Image = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/folder.png")), Width = 16, Height = 16 }, + IsOpenFolder = true, Text = "Open Folder", Command = new SourceMenuCommand(this.FolderScanTitleSpecific), IsDrive = false }; SourceMenuItem fileScanTitle = new SourceMenuItem { - Image = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/Movies.png")), Width = 16, Height = 16 }, + IsOpenFolder = false, Text = "Open File", Command = new SourceMenuCommand(this.FileScanTitleSpecific), IsDrive = false @@ -2076,7 +2076,6 @@ namespace HandBrakeWPF.ViewModels select new SourceMenuItem { - Image = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/disc_small.png")), Width = 16, Height = 16 }, Text = string.Format("{0} ({1})", item.RootDirectory, item.VolumeLabel), Command = new SourceMenuCommand(() => this.ProcessDrive(driveInformation)), Tag = item, diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index c9d87f870..cb1fa7582 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -6,6 +6,7 @@ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" xmlns:attachedProperties="clr-namespace:HandBrakeWPF.AttachedProperties" + xmlns:handBrakeWpf="clr-namespace:HandBrakeWPF" AllowDrop="True" FontSize="11" Micro:Message.Attach="[Event Loaded] = [Action Load]" @@ -21,7 +22,7 @@ - + @@ -472,7 +489,7 @@ - +