summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-10-30 21:53:10 +0000
committersr55 <[email protected]>2011-10-30 21:53:10 +0000
commit1fae5640fafcc3a4613eba99dcbb56f3e98430ae (patch)
treedca397ee63a4e9983899f639db50bad352dc3650 /win
parent8b8ebd1f417c6ef65ab431a36fad0bbf0e2daf58 (diff)
WinGui: (WPF) Further work on the new Options window. Just UI/Cosmetic code to finish now.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4330 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj5
-rw-r--r--win/CS/HandBrakeWPF/Helpers/ListBoxHelper.cs93
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs166
-rw-r--r--win/CS/HandBrakeWPF/Views/Images/arrow_down.pngbin0 -> 625 bytes
-rw-r--r--win/CS/HandBrakeWPF/Views/Images/arrow_left.pngbin0 -> 654 bytes
-rw-r--r--win/CS/HandBrakeWPF/Views/Images/arrow_right.pngbin0 -> 793 bytes
-rw-r--r--win/CS/HandBrakeWPF/Views/Images/arrow_up.pngbin0 -> 669 bytes
-rw-r--r--win/CS/HandBrakeWPF/Views/OptionsView.xaml24
8 files changed, 228 insertions, 60 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index f94cf2a28..c600cd1a4 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -75,6 +75,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Factories\ViewModelFactory.cs" />
+ <Compile Include="Helpers\ListBoxHelper.cs" />
<Compile Include="Startup\CastleBootstrapper.cs" />
<Compile Include="Startup\MefBootstrapper.cs" />
<Compile Include="UserSettingConstants.cs" />
@@ -231,6 +232,10 @@
<Content Include="defaultsettings.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
+ <Resource Include="Views\Images\arrow_down.png" />
+ <Resource Include="Views\Images\arrow_left.png" />
+ <Resource Include="Views\Images\arrow_right.png" />
+ <Resource Include="Views\Images\arrow_up.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Views\Images\ActivityWindow.png" />
diff --git a/win/CS/HandBrakeWPF/Helpers/ListBoxHelper.cs b/win/CS/HandBrakeWPF/Helpers/ListBoxHelper.cs
new file mode 100644
index 000000000..ee24b3bbe
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Helpers/ListBoxHelper.cs
@@ -0,0 +1,93 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ListBoxHelper.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// A Helper for the ListBox control to provide SelectedItems functionality.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Helpers
+{
+ using System.Collections;
+ using System.Windows;
+ using System.Windows.Controls;
+
+ /// <summary>
+ /// A Helper for the ListBox control to provide SelectedItems functionality.
+ /// </summary>
+ public class ListBoxHelper
+ {
+ /// <summary>
+ /// SelectedItems Attached Dependency Property
+ /// </summary>
+ public static readonly DependencyProperty SelectedItemsProperty =
+ DependencyProperty.RegisterAttached("SelectedItems", typeof(IList), typeof(ListBoxHelper), new FrameworkPropertyMetadata(null, OnSelectedItemsChanged));
+
+ /// <summary>
+ /// Gets the SelectedItems property. This dependency property
+ /// indicates ....
+ /// </summary>
+ /// <param name="item">
+ /// The item.
+ /// </param>
+ /// <returns>
+ /// The get selected items.
+ /// </returns>
+ public static IList GetSelectedItems(DependencyObject item)
+ {
+ return (IList)item.GetValue(SelectedItemsProperty);
+ }
+
+ /// <summary>
+ /// Sets the SelectedItems property. This dependency property
+ /// indicates ....
+ /// </summary>
+ /// <param name="item">
+ /// The item.
+ /// </param>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ public static void SetSelectedItems(DependencyObject item, IList value)
+ {
+ item.SetValue(SelectedItemsProperty, value);
+ }
+
+ /// <summary>
+ /// Handles changes to the SelectedItems property.
+ /// </summary>
+ /// <param name="item">
+ /// The item.
+ /// </param>
+ /// <param name="e">
+ /// The DependencyPropertyChangedEventArgs.
+ /// </param>
+ private static void OnSelectedItemsChanged(DependencyObject item, DependencyPropertyChangedEventArgs e)
+ {
+ ListBox listBox = item as ListBox;
+ if (listBox != null)
+ {
+ ResetSelectedItems(listBox);
+ listBox.SelectionChanged += delegate { ResetSelectedItems(listBox); };
+ }
+ }
+
+ /// <summary>
+ /// Reset Selected Items
+ /// </summary>
+ /// <param name="listBox">
+ /// The list box.
+ /// </param>
+ private static void ResetSelectedItems(ListBox listBox)
+ {
+ IList selectedItems = GetSelectedItems(listBox);
+ selectedItems.Clear();
+ if (listBox.SelectedItems != null)
+ {
+ foreach (var item in listBox.SelectedItems)
+ selectedItems.Add(item);
+ }
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index 68a4ecf5d..9af9590f3 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -675,6 +675,40 @@ namespace HandBrakeWPF.ViewModels
#region Audio and Subtitles
/// <summary>
+ /// Gets or sets preferredLanguages.
+ /// </summary>
+ public BindingList<string> PreferredLanguages
+ {
+ get
+ {
+ return this.preferredLanguages;
+ }
+
+ set
+ {
+ this.preferredLanguages = value;
+ this.NotifyOfPropertyChange("preferredLanguages");
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets SelectedPreferreedLangauge.
+ /// </summary>
+ public string SelectedPreferredLangauge
+ {
+ get
+ {
+ return this.selectedPreferredLangauge;
+ }
+
+ set
+ {
+ this.selectedPreferredLangauge = value;
+ this.NotifyOfPropertyChange("SelectedPreferreedLangauge");
+ }
+ }
+
+ /// <summary>
/// Gets or sets AvailableLanguages.
/// </summary>
public BindingList<string> AvailableLanguages
@@ -692,6 +726,32 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Gets or sets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedLangauges
+ {
+ get
+ {
+ return this.selectedLangauges;
+ }
+ set
+ {
+ this.selectedLangauges = value;
+ this.NotifyOfPropertyChange("SelectedLangauges");
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedAvailableToMove { get; set; }
+
+ /// <summary>
+ /// Gets or sets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedLangaugesToMove { get; set; }
+
+ /// <summary>
/// Gets or sets AddAudioModeOptions.
/// </summary>
public BindingList<string> AddAudioModeOptions
@@ -793,55 +853,6 @@ namespace HandBrakeWPF.ViewModels
}
}
- /// <summary>
- /// Gets or sets preferredLanguages.
- /// </summary>
- public BindingList<string> PreferredLanguages
- {
- get
- {
- return this.preferredLanguages;
- }
-
- set
- {
- this.preferredLanguages = value;
- this.NotifyOfPropertyChange("preferredLanguages");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedLangauges.
- /// </summary>
- public BindingList<string> SelectedLangauges
- {
- get
- {
- return this.selectedLangauges;
- }
- set
- {
- this.selectedLangauges = value;
- this.NotifyOfPropertyChange("SelectedLangauges");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedPreferreedLangauge.
- /// </summary>
- public string SelectedPreferredLangauge
- {
- get
- {
- return this.selectedPreferredLangauge;
- }
-
- set
- {
- this.selectedPreferredLangauge = value;
- this.NotifyOfPropertyChange("SelectedPreferreedLangauge");
- }
- }
#endregion
#region System and Logging
@@ -1297,6 +1308,9 @@ namespace HandBrakeWPF.ViewModels
// Audio and Subtitles Tab
// #############################
+ this.SelectedAvailableToMove = new BindingList<string>();
+ this.SelectedLangaugesToMove = new BindingList<string>();
+
IDictionary<string, string> langList = LanguageUtilities.MapLanguages();
foreach (string selectedItem in this.userSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages))
@@ -1447,7 +1461,15 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void LanguageMoveLeft()
{
- // TODO
+ if (this.AvailableLanguages.Count > 0)
+ {
+ List<string> copiedList = SelectedAvailableToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.AvailableLanguages.Remove(item);
+ this.SelectedLangauges.Add(item);
+ }
+ }
}
/// <summary>
@@ -1455,7 +1477,15 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void LanguageMoveRight()
{
- // TODO
+ if (this.SelectedLangauges.Count > 0)
+ {
+ List<string> copiedList = SelectedLangaugesToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.SelectedLangauges.Remove(item);
+ this.AvailableLanguages.Add(item);
+ }
+ }
}
/// <summary>
@@ -1463,6 +1493,11 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void LanguageClearAll()
{
+ foreach (string item in this.SelectedLangauges)
+ {
+ this.AvailableLanguages.Add(item);
+ }
+
this.SelectedLangauges.Clear();
}
@@ -1471,7 +1506,19 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void LanguageMoveUp()
{
- // TODO
+ List<string> langauges = this.SelectedLangauges.ToList();
+ foreach (string item in langauges)
+ {
+ if (this.SelectedLangaugesToMove.Contains(item))
+ {
+ int index = this.SelectedLangauges.IndexOf(item);
+ if (index != 0)
+ {
+ this.SelectedLangauges.Remove(item);
+ this.SelectedLangauges.Insert(index - 1, item);
+ }
+ }
+ }
}
/// <summary>
@@ -1479,7 +1526,20 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void LanguageMoveDown()
{
- // TODO
+ List<string> langauges = this.SelectedLangauges.ToList();
+ int count = this.SelectedLangauges.Count;
+ foreach (string item in langauges)
+ {
+ if (this.SelectedLangaugesToMove.Contains(item))
+ {
+ int index = this.SelectedLangauges.IndexOf(item);
+ if ((index + 1) != count)
+ {
+ this.SelectedLangauges.Remove(item);
+ this.SelectedLangauges.Insert(index + 1, item);
+ }
+ }
+ }
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Views/Images/arrow_down.png b/win/CS/HandBrakeWPF/Views/Images/arrow_down.png
new file mode 100644
index 000000000..9a8de4f4a
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Views/Images/arrow_down.png
Binary files differ
diff --git a/win/CS/HandBrakeWPF/Views/Images/arrow_left.png b/win/CS/HandBrakeWPF/Views/Images/arrow_left.png
new file mode 100644
index 000000000..713030f29
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Views/Images/arrow_left.png
Binary files differ
diff --git a/win/CS/HandBrakeWPF/Views/Images/arrow_right.png b/win/CS/HandBrakeWPF/Views/Images/arrow_right.png
new file mode 100644
index 000000000..a270c5479
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Views/Images/arrow_right.png
Binary files differ
diff --git a/win/CS/HandBrakeWPF/Views/Images/arrow_up.png b/win/CS/HandBrakeWPF/Views/Images/arrow_up.png
new file mode 100644
index 000000000..530daed53
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Views/Images/arrow_up.png
Binary files differ
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
index 8f3d155bd..36df30219 100644
--- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml
+++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
@@ -1,7 +1,7 @@
<Window x:Class="HandBrakeWPF.Views.OptionsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cal="http://www.caliburnproject.org"
- Title="OptionsView" MinWidth="620" MinHeight="550" Width="620" Height="550">
+ xmlns:Helpers="clr-namespace:HandBrakeWPF.Helpers" Title="OptionsView" MinWidth="620" MinHeight="550" Width="620" Height="550">
<Window.Resources>
<Style TargetType="Button">
@@ -186,26 +186,36 @@
<StackPanel Orientation="Vertical" Grid.Column="0">
<TextBlock Text="Available Langauges" Margin="0,0,0,5"/>
- <ListBox Name="availableLanguages" ItemsSource="{Binding AvailableLanguages}" SelectionMode="Multiple" Height="140"></ListBox>
+ <ListBox Name="availableLanguages" ItemsSource="{Binding AvailableLanguages}" Helpers:ListBoxHelper.SelectedItems="{Binding SelectedAvailableToMove}"
+ SelectionMode="Extended" Width="140" Height="160"></ListBox>
</StackPanel>
<DockPanel Grid.Column="1" Margin="10,0,10,0">
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
- <Button Content="Move Left" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveLeft]" Width="60" />
- <Button Content="Move Right" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveRight]" Width="60" />
+ <Button VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveLeft]" Width="60" >
+ <Image Source="Images/arrow_right.png" Width="24" Height="24" />
+ </Button>
+ <Button VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveRight]" Width="60" >
+ <Image Source="Images/arrow_left.png" Width="24" Height="24" />
+ </Button>
<Button Content="Clear" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageClearAll]" Width="60" />
</StackPanel>
</DockPanel>
<StackPanel Orientation="Vertical" Grid.Column="2">
<TextBlock Text="Selected Langauges" Margin="0,0,0,5"/>
- <ListBox Name="selectedLangauges" ItemsSource="{Binding SelectedLangauges}" SelectionMode="Multiple" Height="140" />
+ <ListBox Name="selectedLangauges" ItemsSource="{Binding SelectedLangauges}" Helpers:ListBoxHelper.SelectedItems="{Binding SelectedLangaugesToMove}"
+ SelectionMode="Extended" Width="140" Height="160" />
</StackPanel>
<DockPanel Grid.Column="3" Margin="10,0,10,0">
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
- <Button Content="Move Up" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveUp]" Width="60" />
- <Button Content="Move Down" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveDown]" Width="60" />
+ <Button VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveUp]" >
+ <Image Source="Images/arrow_up.png" Width="16" Height="16" />
+ </Button>
+ <Button VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveDown]" >
+ <Image Source="Images/arrow_down.png" Width="16" Height="16" />
+ </Button>
</StackPanel>
</DockPanel>