diff options
Diffstat (limited to 'win')
5 files changed, 110 insertions, 13 deletions
diff --git a/win/CS/HandBrakeWPF/Extensions/ListExtensions.cs b/win/CS/HandBrakeWPF/Extensions/ListExtensions.cs new file mode 100644 index 000000000..b45b778a0 --- /dev/null +++ b/win/CS/HandBrakeWPF/Extensions/ListExtensions.cs @@ -0,0 +1,79 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="ListExtensions.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> +// IList Extensions +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Extensions +{ + using System; + using System.Collections; + + public static class ListExtensions + { + public static void Swap<T>(this IList list, int firstIndex, int secondIndex) + { + if (list == null) + { + throw new ArgumentNullException("List was null"); + } + + if (firstIndex > list.Count - 1) + { + throw new IndexOutOfRangeException("First Index: " + firstIndex); + } + + if (firstIndex > list.Count - 1 || secondIndex < 0) + { + throw new IndexOutOfRangeException("Second Index: " + secondIndex); + } + + T temp = (T)list[firstIndex]; + list[firstIndex] = list[secondIndex]; + list[secondIndex] = temp; + } + + public static void MoveUp<T>(this IList list, T item) + { + if (list == null) + { + throw new ArgumentNullException("List was null"); + } + + if (item == null) + { + throw new ArgumentNullException("Item was null"); + } + + int index = list.IndexOf(item); + + if (index > 0) + { + list.Swap<T>(index, index - 1); + } + } + + public static void MoveDown<T>(this IList list, T item) + { + if (list == null) + { + throw new ArgumentNullException("List was null"); + } + + if (item == null) + { + throw new ArgumentNullException("Item was null"); + } + + int index = list.IndexOf(item); + + if (index >= 0) + { + list.Swap<T>(index, index + 1); + } + } + } +} diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 2e4860bef..b47ed425c 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -149,6 +149,7 @@ <Compile Include="EventArgs\SettingChangedEventArgs.cs" />
<Compile Include="EventArgs\TabStatusEventArgs.cs" />
<Compile Include="Exceptions\GeneralApplicationException.cs" />
+ <Compile Include="Extensions\ListExtensions.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Helpers\TreeViewHelper.cs" />
<Compile Include="Helpers\LogManager.cs" />
@@ -681,9 +682,9 @@ <Resource Include="Views\Images\file.png" />
</ItemGroup>
<ItemGroup>
- <BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
+ <BootstrapperPackage Include=".NETFramework,Version=v4.7.1">
<Visible>False</Visible>
- <ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
+ <ProductName>Microsoft .NET Framework 4.7.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
@@ -696,11 +697,6 @@ <ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Views\Images\folder32.png" />
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs index 33dc42fe2..90723c7a8 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.Services.Queue.Interfaces
{
using System;
+ using System.Collections.ObjectModel;
using System.ComponentModel;
using HandBrakeWPF.Services.Queue.Model;
@@ -77,7 +78,7 @@ namespace HandBrakeWPF.Services.Queue.Interfaces /// <summary>
/// Gets The current queue.
/// </summary>
- BindingList<QueueTask> Queue { get; }
+ ObservableCollection<QueueTask> Queue { get; }
#endregion
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs index 5e4726bcb..ec0867f2a 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.Services.Queue {
using System;
using System.Collections.Generic;
+ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
@@ -46,7 +47,7 @@ namespace HandBrakeWPF.Services.Queue #region Constants and Fields
private static readonly object QueueLock = new object();
private readonly IUserSettingService userSettingService;
- private readonly BindingList<QueueTask> queue = new BindingList<QueueTask>();
+ private readonly ObservableCollection<QueueTask> queue = new ObservableCollection<QueueTask>();
private readonly string queueFile;
private bool clearCompleted;
@@ -174,7 +175,7 @@ namespace HandBrakeWPF.Services.Queue /// <summary>
/// Gets The current queue.
/// </summary>
- public BindingList<QueueTask> Queue
+ public ObservableCollection<QueueTask> Queue
{
get
{
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index ee5dfb583..0b4e954a5 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.ViewModels {
using System;
using System.Collections.Generic;
+ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
@@ -21,6 +22,7 @@ namespace HandBrakeWPF.ViewModels using Caliburn.Micro;
using HandBrakeWPF.EventArgs;
+ using HandBrakeWPF.Extensions;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Queue.Interfaces;
@@ -162,7 +164,7 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Gets the queue tasks.
/// </summary>
- public BindingList<QueueTask> QueueTasks
+ public ObservableCollection<QueueTask> QueueTasks
{
get
{
@@ -615,12 +617,30 @@ namespace HandBrakeWPF.ViewModels public void MoveUp()
{
- this.errorService.ShowMessageBox("Not Implemented yet. You can drag / drop re-organise the queue for now.", "Coming Soon!", MessageBoxButton.OK, MessageBoxImage.Information);
+ Dictionary<int, QueueTask> tasks = new Dictionary<int, QueueTask>();
+ foreach (var item in this.SelectedItems)
+ {
+ tasks.Add(this.QueueTasks.IndexOf(item), item);
+ }
+
+ foreach (var item in tasks.OrderBy(s => s.Key))
+ {
+ this.QueueTasks.MoveUp(item.Value);
+ }
}
public void MoveDown()
{
- this.errorService.ShowMessageBox("Not Implemented yet. You can drag / drop re-organise the queue for now.", "Coming Soon!", MessageBoxButton.OK, MessageBoxImage.Information);
+ Dictionary<int, QueueTask> tasks = new Dictionary<int, QueueTask>();
+ foreach (var item in this.SelectedItems)
+ {
+ tasks.Add(this.QueueTasks.IndexOf(item), item);
+ }
+
+ foreach (var item in tasks.OrderByDescending(s => s.Key))
+ {
+ this.QueueTasks.MoveDown(item.Value);
+ }
}
#endregion
|