--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <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);
+ }
+ }
+ }
+}
<Compile Include="EventArgs\SettingChangedEventArgs.cs" />\r
<Compile Include="EventArgs\TabStatusEventArgs.cs" />\r
<Compile Include="Exceptions\GeneralApplicationException.cs" />\r
+ <Compile Include="Extensions\ListExtensions.cs" />\r
<Compile Include="Extensions\StringExtensions.cs" />\r
<Compile Include="Helpers\TreeViewHelper.cs" />\r
<Compile Include="Helpers\LogManager.cs" />\r
<Resource Include="Views\Images\file.png" />\r
</ItemGroup>\r
<ItemGroup>\r
- <BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">\r
+ <BootstrapperPackage Include=".NETFramework,Version=v4.7.1">\r
<Visible>False</Visible>\r
- <ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>\r
+ <ProductName>Microsoft .NET Framework 4.7.1 %28x86 and x64%29</ProductName>\r
<Install>true</Install>\r
</BootstrapperPackage>\r
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">\r
<ProductName>.NET Framework 3.5 SP1</ProductName>\r
<Install>false</Install>\r
</BootstrapperPackage>\r
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">\r
- <Visible>False</Visible>\r
- <ProductName>Windows Installer 3.1</ProductName>\r
- <Install>true</Install>\r
- </BootstrapperPackage>\r
</ItemGroup>\r
<ItemGroup>\r
<Resource Include="Views\Images\folder32.png" />\r
namespace HandBrakeWPF.Services.Queue.Interfaces\r
{\r
using System;\r
+ using System.Collections.ObjectModel;\r
using System.ComponentModel;\r
\r
using HandBrakeWPF.Services.Queue.Model;\r
/// <summary>\r
/// Gets The current queue.\r
/// </summary>\r
- BindingList<QueueTask> Queue { get; }\r
+ ObservableCollection<QueueTask> Queue { get; }\r
\r
#endregion\r
\r
{\r
using System;\r
using System.Collections.Generic;\r
+ using System.Collections.ObjectModel;\r
using System.ComponentModel;\r
using System.IO;\r
using System.Linq;\r
#region Constants and Fields\r
private static readonly object QueueLock = new object();\r
private readonly IUserSettingService userSettingService;\r
- private readonly BindingList<QueueTask> queue = new BindingList<QueueTask>();\r
+ private readonly ObservableCollection<QueueTask> queue = new ObservableCollection<QueueTask>();\r
private readonly string queueFile;\r
private bool clearCompleted;\r
\r
/// <summary>\r
/// Gets The current queue.\r
/// </summary>\r
- public BindingList<QueueTask> Queue\r
+ public ObservableCollection<QueueTask> Queue\r
{\r
get\r
{\r
{\r
using System;\r
using System.Collections.Generic;\r
+ using System.Collections.ObjectModel;\r
using System.ComponentModel;\r
using System.Diagnostics;\r
using System.IO;\r
using Caliburn.Micro;\r
\r
using HandBrakeWPF.EventArgs;\r
+ using HandBrakeWPF.Extensions;\r
using HandBrakeWPF.Properties;\r
using HandBrakeWPF.Services.Interfaces;\r
using HandBrakeWPF.Services.Queue.Interfaces;\r
/// <summary>\r
/// Gets the queue tasks.\r
/// </summary>\r
- public BindingList<QueueTask> QueueTasks\r
+ public ObservableCollection<QueueTask> QueueTasks\r
{\r
get\r
{\r
\r
public void MoveUp()\r
{\r
- this.errorService.ShowMessageBox("Not Implemented yet. You can drag / drop re-organise the queue for now.", "Coming Soon!", MessageBoxButton.OK, MessageBoxImage.Information);\r
+ Dictionary<int, QueueTask> tasks = new Dictionary<int, QueueTask>();\r
+ foreach (var item in this.SelectedItems)\r
+ {\r
+ tasks.Add(this.QueueTasks.IndexOf(item), item);\r
+ }\r
+\r
+ foreach (var item in tasks.OrderBy(s => s.Key))\r
+ {\r
+ this.QueueTasks.MoveUp(item.Value);\r
+ }\r
}\r
\r
public void MoveDown()\r
{\r
- this.errorService.ShowMessageBox("Not Implemented yet. You can drag / drop re-organise the queue for now.", "Coming Soon!", MessageBoxButton.OK, MessageBoxImage.Information);\r
+ Dictionary<int, QueueTask> tasks = new Dictionary<int, QueueTask>();\r
+ foreach (var item in this.SelectedItems)\r
+ {\r
+ tasks.Add(this.QueueTasks.IndexOf(item), item);\r
+ }\r
+\r
+ foreach (var item in tasks.OrderByDescending(s => s.Key))\r
+ {\r
+ this.QueueTasks.MoveDown(item.Value);\r
+ }\r
}\r
\r
#endregion\r