diff options
author | sr55 <[email protected]> | 2013-09-03 17:01:14 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-09-03 17:01:14 +0000 |
commit | 2a344e45c4ed8f98e872066aa506512063d5ae51 (patch) | |
tree | 24ef953c10805458513d225eef58c2388e5c67ed /win | |
parent | bcb1dcedb04fabcde6475daa2d8c9bf01c128139 (diff) |
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
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs | 3 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Model/SourceMenuItem.cs | 22 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 9 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml | 27 |
4 files changed, 42 insertions, 19 deletions
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;
/// <summary>
@@ -37,11 +36,6 @@ namespace HandBrakeWPF.Model public ICommand Command { get; set; }
/// <summary>
- /// Gets or sets the image.
- /// </summary>
- public Image Image { get; set; }
-
- /// <summary>
/// Gets or sets the children.
/// </summary>
public ObservableCollection<SourceMenuItem> Children { get; set; }
@@ -52,6 +46,22 @@ namespace HandBrakeWPF.Model public bool IsDrive { get; set; }
/// <summary>
+ /// Gets or sets a value indicating whether is open folder.
+ /// </summary>
+ public bool IsOpenFolder { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating whether is open file.
+ /// </summary>
+ public bool IsOpenFile
+ {
+ get
+ {
+ return !this.IsOpenFolder && (this.Children == null || this.Children.Count == 0);
+ }
+ }
+
+ /// <summary>
/// Gets or sets the tag.
/// </summary>
public object Tag { get; set; }
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 @@ </i:EventTrigger>
</i:Interaction.Triggers>
- <UserControl.Resources>
+ <UserControl.Resources>
<Style TargetType="Button">
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Padding" Value="5,1" />
@@ -204,14 +205,30 @@ />
</StackPanel>
</MenuItem.Header>
+ <MenuItem.Resources>
+ <Image x:Key="Movie" x:Shared="False" MaxWidth="16" SnapsToDevicePixels="True" Source="Images/Movies.png" />
+ <Image x:Key="Folder" x:Shared="False" MaxWidth="16" SnapsToDevicePixels="True" Source="Images/folder.png" />
+ <Image x:Key="Disc" x:Shared="False" MaxWidth="16" SnapsToDevicePixels="True" Source="Images/disc_small.png" />
+ </MenuItem.Resources>
<MenuItem.ItemContainerStyle>
- <Style TargetType="{x:Type MenuItem}">
+ <Style TargetType="{x:Type MenuItem}" x:Shared="True">
<Setter Property="Header" Value="{Binding Text}" />
<Setter Property="Command" Value="{Binding Command}"/>
<Setter Property="ItemsSource" Value="{Binding Children}" />
- <Setter Property="Icon" Value="{Binding Image}" />
<Setter Property="InputGestureText" Value="{Binding InputGestureText}" />
<Setter Property="Tag" Value="{Binding}" />
+
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Path=IsDisc}" Value="true">
+ <Setter Property="Icon" Value="{StaticResource Disc}"/>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Path=IsOpenFolder}" Value="true">
+ <Setter Property="Icon" Value="{StaticResource Folder}"/>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Path=IsOpenFile}" Value="true">
+ <Setter Property="Icon" Value="{StaticResource Movie}"/>
+ </DataTrigger>
+ </Style.Triggers>
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
@@ -472,7 +489,7 @@ <MenuItem Header="Open this Directory" Micro:Message.Attach="[Event Click] = [Action OpenDestinationDirectory]" />
</ContextMenu>
</TextBox.ContextMenu>
- </TextBox>
+ </TextBox>
<Button Name="DestinationBrowser"
Grid.Column="2"
Margin="8,0,0,0"
@@ -566,7 +583,7 @@ Header="Presets"
Margin="0,0,0,5"
Visibility="{Binding IsPresetPanelShowing, Converter={StaticResource boolToVisConverter}}">
-
+
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
|