[New Utility]Mouse Without Borders

* Integrate Mouse Without Borders into PowerToys

---------

Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
This commit is contained in:
Andrey Nekrasov
2023-05-15 23:32:26 +01:00
committed by Jaime Bernardo
parent a0b9af039d
commit 29eebe16a4
304 changed files with 37234 additions and 133 deletions

View File

@@ -0,0 +1,58 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.PowerToys.Settings.UI.Helpers
{
#pragma warning disable SA1649 // File name should match first type name
public class IndexedItem<T>
#pragma warning restore SA1649 // File name should match first type name
{
public T Item { get; set; }
public int Index { get; set; }
public IndexedItem(T item, int index)
{
Item = item;
Index = index;
}
}
#pragma warning disable SA1402 // File may only contain a single type
public class IndexedObservableCollection<T> : ObservableCollection<IndexedItem<T>>
#pragma warning restore SA1402 // File may only contain a single type
{
public IndexedObservableCollection(IEnumerable<T> items)
{
int index = 0;
foreach (var item in items)
{
Add(new IndexedItem<T>(item, index++));
}
}
public IEnumerable<T> ToEnumerable()
{
return this.Select(x => x.Item);
}
public void Swap(int index1, int index2)
{
var temp = this[index1];
this[index1] = this[index2];
this[index2] = temp;
// Update the original index of the items
this[index1].Index = index1;
this[index2].Index = index2;
}
}
}