mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-09 22:15:00 +03:00
Add ProDataGrid (#10347)
* Bump Avalonia.Desktop from 12.1.2 to 12.1.4 --- updated-dependencies: - dependency-name: Avalonia.Desktop dependency-version: 12.1.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Remove Avalonia.Controls.DataGrid * Add ProDataGrid Feature --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
This commit is contained in:
@@ -540,6 +540,67 @@ public static class ConfigHandler
|
||||
return await Task.FromResult(0);
|
||||
}
|
||||
|
||||
public static Task<int> MoveServersTo(
|
||||
Config config,
|
||||
IReadOnlyList<string> orderedProfileIds,
|
||||
IReadOnlyList<int> sourceIndices,
|
||||
int insertIndex)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(orderedProfileIds);
|
||||
ArgumentNullException.ThrowIfNull(sourceIndices);
|
||||
|
||||
if (orderedProfileIds.Count == 0 ||
|
||||
sourceIndices.Count == 0 ||
|
||||
insertIndex < 0 ||
|
||||
insertIndex > orderedProfileIds.Count)
|
||||
{
|
||||
return Task.FromResult(-1);
|
||||
}
|
||||
|
||||
int[] movingIndices = sourceIndices
|
||||
.Distinct()
|
||||
.OrderBy(index => index)
|
||||
.ToArray();
|
||||
|
||||
if (movingIndices.Length != sourceIndices.Count ||
|
||||
movingIndices.Any(index =>
|
||||
index < 0 || index >= orderedProfileIds.Count))
|
||||
{
|
||||
return Task.FromResult(-1);
|
||||
}
|
||||
|
||||
var movingIndexSet = movingIndices.ToHashSet();
|
||||
|
||||
var movingIds = movingIndices
|
||||
.Select(index => orderedProfileIds[index])
|
||||
.ToList();
|
||||
|
||||
var remainingIds = orderedProfileIds
|
||||
.Where((_, index) => !movingIndexSet.Contains(index))
|
||||
.ToList();
|
||||
|
||||
if (insertIndex > remainingIds.Count)
|
||||
{
|
||||
return Task.FromResult(-1);
|
||||
}
|
||||
|
||||
remainingIds.InsertRange(insertIndex, movingIds);
|
||||
|
||||
if (remainingIds.Count != orderedProfileIds.Count)
|
||||
{
|
||||
return Task.FromResult(-1);
|
||||
}
|
||||
|
||||
for (var index = 0; index < remainingIds.Count; index++)
|
||||
{
|
||||
ProfileExManager.Instance.SetSort(
|
||||
remainingIds[index],
|
||||
(index + 1) * 10);
|
||||
}
|
||||
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a custom server configuration from a file
|
||||
/// Copies the configuration file to the app's config directory
|
||||
|
||||
Generated
+9
@@ -978,6 +978,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Columns 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuColumns {
|
||||
get {
|
||||
return ResourceManager.GetString("menuColumns", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Close Connection 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -1905,4 +1905,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<data name="menuAddMasqueServer" xml:space="preserve">
|
||||
<value>Add [MASQUE]</value>
|
||||
</data>
|
||||
<data name="menuColumns" xml:space="preserve">
|
||||
<value>Columns</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1897,4 +1897,7 @@
|
||||
<data name="menuAddMasqueServer" xml:space="preserve">
|
||||
<value>添加 [MASQUE]</value>
|
||||
</data>
|
||||
<data name="menuColumns" xml:space="preserve">
|
||||
<value>列</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -702,6 +702,33 @@ public partial class ProfilesViewModel : MyReactiveObject
|
||||
}
|
||||
}
|
||||
|
||||
public async Task MoveServersTo(
|
||||
IReadOnlyList<int> sourceIndices,
|
||||
int insertIndex)
|
||||
{
|
||||
if (sourceIndices.Count == 0 ||
|
||||
insertIndex < 0 ||
|
||||
insertIndex > ProfileItems.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var orderedProfileIds = ProfileItems
|
||||
.Select(item => item.IndexId)
|
||||
.ToList();
|
||||
|
||||
var result = await ConfigHandler.MoveServersTo(
|
||||
_config,
|
||||
orderedProfileIds,
|
||||
sourceIndices,
|
||||
insertIndex);
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
await RefreshServers();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ServerSpeedtest(ESpeedActionType actionType)
|
||||
{
|
||||
List<ProfileItem>? lstSelected;
|
||||
|
||||
Reference in New Issue
Block a user