mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 20:09:12 +00:00
Compare commits
2 commits
6653ea12b7
...
53a99e3f79
Author | SHA1 | Date | |
---|---|---|---|
![]() |
53a99e3f79 | ||
![]() |
e7f04f55c2 |
6 changed files with 48 additions and 103 deletions
|
@ -1,50 +0,0 @@
|
|||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ServiceLib.Common
|
||||
{
|
||||
public static class QueryableExtension
|
||||
{
|
||||
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> query, string propertyName)
|
||||
{
|
||||
return _OrderBy<T>(query, propertyName, false);
|
||||
}
|
||||
|
||||
public static IOrderedQueryable<T> OrderByDescending<T>(this IQueryable<T> query, string propertyName)
|
||||
{
|
||||
return _OrderBy<T>(query, propertyName, true);
|
||||
}
|
||||
|
||||
private static IOrderedQueryable<T> _OrderBy<T>(IQueryable<T> query, string propertyName, bool isDesc)
|
||||
{
|
||||
var methodname = (isDesc) ? "OrderByDescendingInternal" : "OrderByInternal";
|
||||
|
||||
var memberProp = typeof(T).GetProperty(propertyName);
|
||||
|
||||
var method = typeof(QueryableExtension).GetMethod(methodname)
|
||||
.MakeGenericMethod(typeof(T), memberProp.PropertyType);
|
||||
|
||||
return (IOrderedQueryable<T>)method.Invoke(null, new object[] { query, memberProp });
|
||||
}
|
||||
|
||||
public static IOrderedQueryable<T> OrderByInternal<T, TProp>(IQueryable<T> query, PropertyInfo memberProperty)
|
||||
{//public
|
||||
return query.OrderBy(_GetLambda<T, TProp>(memberProperty));
|
||||
}
|
||||
|
||||
public static IOrderedQueryable<T> OrderByDescendingInternal<T, TProp>(IQueryable<T> query, PropertyInfo memberProperty)
|
||||
{//public
|
||||
return query.OrderByDescending(_GetLambda<T, TProp>(memberProperty));
|
||||
}
|
||||
|
||||
private static Expression<Func<T, TProp>> _GetLambda<T, TProp>(PropertyInfo memberProperty)
|
||||
{
|
||||
if (memberProperty.PropertyType != typeof(TProp)) throw new Exception();
|
||||
|
||||
var thisArg = Expression.Parameter(typeof(T));
|
||||
var lambda = Expression.Lambda<Func<T, TProp>>(Expression.Property(thisArg, memberProperty), thisArg);
|
||||
|
||||
return lambda;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -78,6 +78,7 @@
|
|||
public const string SpeedUnit = "";
|
||||
public const int MinFontSize = 10;
|
||||
public const string RebootAs = "rebootas";
|
||||
public const string AvaAssets = "avares://v2rayN/Assets/";
|
||||
|
||||
public static readonly List<string> IEProxyProtocols = new() {
|
||||
"{ip}:{http_port}",
|
||||
|
|
|
@ -766,69 +766,66 @@ namespace ServiceLib.Handler
|
|||
}).ToList();
|
||||
|
||||
Enum.TryParse(colName, true, out EServerColName name);
|
||||
var propertyName = string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case EServerColName.ConfigType:
|
||||
case EServerColName.Remarks:
|
||||
case EServerColName.Address:
|
||||
case EServerColName.Port:
|
||||
case EServerColName.Network:
|
||||
case EServerColName.StreamSecurity:
|
||||
propertyName = name.ToString();
|
||||
break;
|
||||
|
||||
case EServerColName.DelayVal:
|
||||
propertyName = "Delay";
|
||||
break;
|
||||
|
||||
case EServerColName.SpeedVal:
|
||||
propertyName = "Speed";
|
||||
break;
|
||||
|
||||
case EServerColName.SubRemarks:
|
||||
propertyName = "Subid";
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
var items = lstProfile.AsQueryable();
|
||||
|
||||
if (asc)
|
||||
{
|
||||
lstProfile = items.OrderBy(propertyName).ToList();
|
||||
lstProfile = name switch
|
||||
{
|
||||
EServerColName.ConfigType => lstProfile.OrderBy(t => t.ConfigType).ToList(),
|
||||
EServerColName.Remarks => lstProfile.OrderBy(t => t.Remarks).ToList(),
|
||||
EServerColName.Address => lstProfile.OrderBy(t => t.Address).ToList(),
|
||||
EServerColName.Port => lstProfile.OrderBy(t => t.Port).ToList(),
|
||||
EServerColName.Network => lstProfile.OrderBy(t => t.Network).ToList(),
|
||||
EServerColName.StreamSecurity => lstProfile.OrderBy(t => t.StreamSecurity).ToList(),
|
||||
EServerColName.DelayVal => lstProfile.OrderBy(t => t.Delay).ToList(),
|
||||
EServerColName.SpeedVal => lstProfile.OrderBy(t => t.Speed).ToList(),
|
||||
EServerColName.SubRemarks => lstProfile.OrderBy(t => t.Subid).ToList(),
|
||||
_ => lstProfile
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
lstProfile = items.OrderByDescending(propertyName).ToList();
|
||||
lstProfile = name switch
|
||||
{
|
||||
EServerColName.ConfigType => lstProfile.OrderByDescending(t => t.ConfigType).ToList(),
|
||||
EServerColName.Remarks => lstProfile.OrderByDescending(t => t.Remarks).ToList(),
|
||||
EServerColName.Address => lstProfile.OrderByDescending(t => t.Address).ToList(),
|
||||
EServerColName.Port => lstProfile.OrderByDescending(t => t.Port).ToList(),
|
||||
EServerColName.Network => lstProfile.OrderByDescending(t => t.Network).ToList(),
|
||||
EServerColName.StreamSecurity => lstProfile.OrderByDescending(t => t.StreamSecurity).ToList(),
|
||||
EServerColName.DelayVal => lstProfile.OrderByDescending(t => t.Delay).ToList(),
|
||||
EServerColName.SpeedVal => lstProfile.OrderByDescending(t => t.Speed).ToList(),
|
||||
EServerColName.SubRemarks => lstProfile.OrderByDescending(t => t.Subid).ToList(),
|
||||
_ => lstProfile
|
||||
};
|
||||
}
|
||||
for (int i = 0; i < lstProfile.Count; i++)
|
||||
|
||||
for (var i = 0; i < lstProfile.Count; i++)
|
||||
{
|
||||
ProfileExHandler.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10);
|
||||
}
|
||||
if (name == EServerColName.DelayVal)
|
||||
switch (name)
|
||||
{
|
||||
var maxSort = lstProfile.Max(t => t.Sort) + 10;
|
||||
foreach (var item in lstProfile)
|
||||
{
|
||||
if (item.Delay <= 0)
|
||||
case EServerColName.DelayVal:
|
||||
{
|
||||
ProfileExHandler.Instance.SetSort(item.IndexId, maxSort);
|
||||
var maxSort = lstProfile.Max(t => t.Sort) + 10;
|
||||
foreach (var item in lstProfile.Where(item => item.Delay <= 0))
|
||||
{
|
||||
ProfileExHandler.Instance.SetSort(item.IndexId, maxSort);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (name == EServerColName.SpeedVal)
|
||||
{
|
||||
var maxSort = lstProfile.Max(t => t.Sort) + 10;
|
||||
foreach (var item in lstProfile)
|
||||
{
|
||||
if (item.Speed <= 0)
|
||||
case EServerColName.SpeedVal:
|
||||
{
|
||||
ProfileExHandler.Instance.SetSort(item.IndexId, maxSort);
|
||||
var maxSort = lstProfile.Max(t => t.Sort) + 10;
|
||||
foreach (var item in lstProfile.Where(item => item.Speed <= 0))
|
||||
{
|
||||
ProfileExHandler.Instance.SetSort(item.IndexId, maxSort);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Media;
|
||||
using System.Reflection;
|
||||
|
||||
namespace v2rayN.Desktop.Common
|
||||
{
|
||||
|
@ -8,7 +7,7 @@ namespace v2rayN.Desktop.Common
|
|||
{
|
||||
public static AppBuilder WithFontByDefault(this AppBuilder appBuilder)
|
||||
{
|
||||
var uri = $"avares://{Assembly.GetExecutingAssembly().GetName().Name}/Assets/Fonts#Noto Sans SC";
|
||||
var uri = Path.Combine(Global.AvaAssets, "Fonts#Noto Sans SC");
|
||||
return appBuilder.With(new FontManagerOptions()
|
||||
{
|
||||
DefaultFamilyName = uri,
|
||||
|
|
|
@ -3,7 +3,6 @@ using Avalonia.Controls;
|
|||
using Avalonia.Input;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using System.Reflection;
|
||||
|
||||
namespace v2rayN.Desktop.Common
|
||||
{
|
||||
|
@ -41,7 +40,7 @@ namespace v2rayN.Desktop.Common
|
|||
public static WindowIcon GetAppIcon(ESysProxyType sysProxyType)
|
||||
{
|
||||
var index = (int)sysProxyType + 1;
|
||||
var uri = new Uri($"avares://{Assembly.GetExecutingAssembly().GetName().Name}/Assets/NotifyIcon{index}.ico");
|
||||
var uri = new Uri(Path.Combine(Global.AvaAssets, $"NotifyIcon{index}.ico"));
|
||||
using var bitmap = new Bitmap(AssetLoader.Open(uri));
|
||||
return new(bitmap);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace v2rayN
|
|||
|
||||
public App()
|
||||
{
|
||||
// Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());
|
||||
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
|
||||
|
|
Loading…
Reference in a new issue