Compare commits

...

8 commits

Author SHA1 Message Date
DHR60
4d93d9408a
Merge 5414bae069 into 4af528f8e2 2026-03-10 14:34:08 +08:00
DHR60
4af528f8e2
Typo (#8917) 2026-03-10 14:10:23 +08:00
DHR60
588e82f0d9
Tun ech protect (#8915)
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
2026-03-10 09:16:16 +08:00
DHR60
0c13488410
Fix (#8914)
* Fix

* Fix
2026-03-10 09:14:57 +08:00
DHR60
a88396c11d
Fix custom config sub chain (#8913) 2026-03-10 09:13:52 +08:00
DHR60
ef5fee9975
Fix (#8909)
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
release Linux / rpm (push) Has been cancelled
2026-03-08 19:00:27 +08:00
2dust
df800a60c2 Persist DataGrid column layout for ClashConnectionsView 2026-03-08 18:59:56 +08:00
2dust
679bd8afcc Persist DataGrid column layout for ClashConnectionsView
https://github.com/2dust/v2rayN/issues/8893
2026-03-08 17:57:09 +08:00
13 changed files with 307 additions and 92 deletions

View file

@ -227,7 +227,7 @@ public class CoreConfigContextBuilder
{ {
var result = NodeValidatorResult.Empty(); var result = NodeValidatorResult.Empty();
if (node.Subid.IsNullOrEmpty()) if (node.Subid.IsNullOrEmpty() || node.ConfigType == EConfigType.Custom)
{ {
return (null, result); return (null, result);
} }
@ -269,6 +269,7 @@ public class CoreConfigContextBuilder
IndexId = $"inner-{Utils.GetGuid(false)}", IndexId = $"inner-{Utils.GetGuid(false)}",
ConfigType = EConfigType.ProxyChain, ConfigType = EConfigType.ProxyChain,
CoreType = AppManager.Instance.GetCoreType(node, node.ConfigType), CoreType = AppManager.Instance.GetCoreType(node, node.ConfigType),
Remarks = node.Remarks,
}; };
List<string?> childItems = [prevNode?.IndexId, node.IndexId, nextNode?.IndexId]; List<string?> childItems = [prevNode?.IndexId, node.IndexId, nextNode?.IndexId];
var chainExtraItem = chainNode.GetProtocolExtra() with var chainExtraItem = chainNode.GetProtocolExtra() with

View file

@ -154,6 +154,7 @@ public static class ConfigHandler
DownMbps = 100 DownMbps = 100
}; };
config.ClashUIItem ??= new(); config.ClashUIItem ??= new();
config.ClashUIItem.ConnectionsColumnItem ??= new();
config.SystemProxyItem ??= new(); config.SystemProxyItem ??= new();
config.WebDavItem ??= new(); config.WebDavItem ??= new();
config.CheckUpdateItem ??= new(); config.CheckUpdateItem ??= new();
@ -722,8 +723,6 @@ public static class ConfigHandler
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
{ {
SalamanderPass = profileItem.GetProtocolExtra().SalamanderPass?.TrimEx(), SalamanderPass = profileItem.GetProtocolExtra().SalamanderPass?.TrimEx(),
UpMbps = profileItem.GetProtocolExtra().UpMbps is null or < 0 ? config.HysteriaItem.UpMbps : profileItem.GetProtocolExtra().UpMbps,
DownMbps = profileItem.GetProtocolExtra().DownMbps is null or < 0 ? config.HysteriaItem.DownMbps : profileItem.GetProtocolExtra().DownMbps,
HopInterval = profileItem.GetProtocolExtra().HopInterval?.TrimEx(), HopInterval = profileItem.GetProtocolExtra().HopInterval?.TrimEx(),
}); });

View file

@ -208,6 +208,7 @@ public class ClashUIItem
public int ProxiesAutoDelayTestInterval { get; set; } = 10; public int ProxiesAutoDelayTestInterval { get; set; } = 10;
public bool ConnectionsAutoRefresh { get; set; } public bool ConnectionsAutoRefresh { get; set; }
public int ConnectionsRefreshInterval { get; set; } = 2; public int ConnectionsRefreshInterval { get; set; } = 2;
public List<ColumnItem> ConnectionsColumnItem { get; set; }
} }
[Serializable] [Serializable]

View file

@ -360,6 +360,7 @@ public class TlsSettings4Ray
public bool? disableSystemRoot { get; set; } public bool? disableSystemRoot { get; set; }
public string? echConfigList { get; set; } public string? echConfigList { get; set; }
public string? echForceQuery { get; set; } public string? echForceQuery { get; set; }
public Sockopt4Ray? echSockopt { get; set; }
} }
public class CertificateSettings4Ray public class CertificateSettings4Ray

View file

@ -316,16 +316,24 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
SsMethod = Global.None, SsMethod = Global.None,
}); });
foreach (var outbound in _coreConfig.outbounds.Where(outbound => outbound.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true)) foreach (var outbound in _coreConfig.outbounds
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
{ {
outbound.streamSettings ??= new StreamSettings4Ray(); outbound.streamSettings ??= new();
outbound.streamSettings.sockopt ??= new Sockopt4Ray(); outbound.streamSettings.sockopt ??= new();
outbound.streamSettings.sockopt.dialerProxy = "tun-project-ss"; outbound.streamSettings.sockopt.dialerProxy = "tun-protect-ss";
}
// ech protected
foreach (var outbound in _coreConfig.outbounds
.Where(outbound => outbound.streamSettings?.tlsSettings?.echConfigList?.IsNullOrEmpty() == false))
{
outbound.streamSettings!.tlsSettings!.echSockopt ??= new();
outbound.streamSettings.tlsSettings.echSockopt.dialerProxy = "tun-protect-ss";
} }
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with _coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
{ {
Node = protectNode, Node = protectNode,
}).BuildProxyOutbound("tun-project-ss")); }).BuildProxyOutbound("tun-protect-ss"));
_coreConfig.routing.rules ??= []; _coreConfig.routing.rules ??= [];
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 }; var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };

View file

@ -27,10 +27,10 @@ public class AddServerViewModel : MyReactiveObject
public string Ports { get; set; } public string Ports { get; set; }
[Reactive] [Reactive]
public int UpMbps { get; set; } public int? UpMbps { get; set; }
[Reactive] [Reactive]
public int DownMbps { get; set; } public int? DownMbps { get; set; }
[Reactive] [Reactive]
public string HopInterval { get; set; } public string HopInterval { get; set; }
@ -113,8 +113,8 @@ public class AddServerViewModel : MyReactiveObject
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0; AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
Flow = protocolExtra?.Flow ?? string.Empty; Flow = protocolExtra?.Flow ?? string.Empty;
SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty; SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty;
UpMbps = protocolExtra?.UpMbps ?? _config.HysteriaItem.UpMbps; UpMbps = protocolExtra?.UpMbps;
DownMbps = protocolExtra?.DownMbps ?? _config.HysteriaItem.DownMbps; DownMbps = protocolExtra?.DownMbps;
HopInterval = protocolExtra?.HopInterval.IsNullOrEmpty() ?? true ? Global.Hysteria2DefaultHopInt.ToString() : protocolExtra.HopInterval; HopInterval = protocolExtra?.HopInterval.IsNullOrEmpty() ?? true ? Global.Hysteria2DefaultHopInt.ToString() : protocolExtra.HopInterval;
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity; VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None; VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
@ -175,8 +175,8 @@ public class AddServerViewModel : MyReactiveObject
AlterId = AlterId > 0 ? AlterId.ToString() : null, AlterId = AlterId > 0 ? AlterId.ToString() : null,
Flow = Flow.NullIfEmpty(), Flow = Flow.NullIfEmpty(),
SalamanderPass = SalamanderPass.NullIfEmpty(), SalamanderPass = SalamanderPass.NullIfEmpty(),
UpMbps = UpMbps >= 0 ? UpMbps : null, UpMbps = UpMbps,
DownMbps = DownMbps >= 0 ? DownMbps : null, DownMbps = DownMbps,
HopInterval = HopInterval.NullIfEmpty(), HopInterval = HopInterval.NullIfEmpty(),
VmessSecurity = VmessSecurity.NullIfEmpty(), VmessSecurity = VmessSecurity.NullIfEmpty(),
VlessEncryption = VlessEncryption.NullIfEmpty(), VlessEncryption = VlessEncryption.NullIfEmpty(),

View file

@ -22,8 +22,8 @@ public class OptionSettingViewModel : MyReactiveObject
[Reactive] public string defUserAgent { get; set; } [Reactive] public string defUserAgent { get; set; }
[Reactive] public string mux4SboxProtocol { get; set; } [Reactive] public string mux4SboxProtocol { get; set; }
[Reactive] public bool enableCacheFile4Sbox { get; set; } [Reactive] public bool enableCacheFile4Sbox { get; set; }
[Reactive] public int hyUpMbps { get; set; } [Reactive] public int? hyUpMbps { get; set; }
[Reactive] public int hyDownMbps { get; set; } [Reactive] public int? hyDownMbps { get; set; }
[Reactive] public bool enableFragment { get; set; } [Reactive] public bool enableFragment { get; set; }
#endregion Core #endregion Core
@ -336,8 +336,8 @@ public class OptionSettingViewModel : MyReactiveObject
_config.CoreBasicItem.DefUserAgent = defUserAgent; _config.CoreBasicItem.DefUserAgent = defUserAgent;
_config.Mux4SboxItem.Protocol = mux4SboxProtocol; _config.Mux4SboxItem.Protocol = mux4SboxProtocol;
_config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox; _config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox;
_config.HysteriaItem.UpMbps = hyUpMbps; _config.HysteriaItem.UpMbps = hyUpMbps ?? 0;
_config.HysteriaItem.DownMbps = hyDownMbps; _config.HysteriaItem.DownMbps = hyDownMbps ?? 0;
_config.CoreBasicItem.EnableFragment = enableFragment; _config.CoreBasicItem.EnableFragment = enableFragment;
_config.GuiItem.AutoRun = AutoRun; _config.GuiItem.AutoRun = AutoRun;

View file

@ -74,23 +74,28 @@
<DataGridTextColumn <DataGridTextColumn
Width="300" Width="300"
Binding="{Binding Host}" Binding="{Binding Host}"
Header="{x:Static resx:ResUI.TbSortingHost}" /> Header="{x:Static resx:ResUI.TbSortingHost}"
Tag="Host" />
<DataGridTextColumn <DataGridTextColumn
Width="500" Width="500"
Binding="{Binding Chain}" Binding="{Binding Chain}"
Header="{x:Static resx:ResUI.TbSortingChain}" /> Header="{x:Static resx:ResUI.TbSortingChain}"
Tag="Chain" />
<DataGridTextColumn <DataGridTextColumn
Width="80" Width="80"
Binding="{Binding Network}" Binding="{Binding Network}"
Header="{x:Static resx:ResUI.TbSortingNetwork}" /> Header="{x:Static resx:ResUI.TbSortingNetwork}"
Tag="Network" />
<DataGridTextColumn <DataGridTextColumn
Width="160" Width="160"
Binding="{Binding Type}" Binding="{Binding Type}"
Header="{x:Static resx:ResUI.TbSortingType}" /> Header="{x:Static resx:ResUI.TbSortingType}"
Tag="Type" />
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="100"
Binding="{Binding Elapsed}" Binding="{Binding Elapsed}"
Header="{x:Static resx:ResUI.TbSortingTime}" /> Header="{x:Static resx:ResUI.TbSortingTime}"
Tag="Elapsed" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</DockPanel> </DockPanel>

View file

@ -2,9 +2,15 @@ namespace v2rayN.Desktop.Views;
public partial class ClashConnectionsView : ReactiveUserControl<ClashConnectionsViewModel> public partial class ClashConnectionsView : ReactiveUserControl<ClashConnectionsViewModel>
{ {
private static Config _config;
private static readonly string _tag = "ClashConnectionsView";
public ClashConnectionsView() public ClashConnectionsView()
{ {
InitializeComponent(); InitializeComponent();
_config = AppManager.Instance.Config;
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler); ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click; btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
@ -19,7 +25,15 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
this.Bind(ViewModel, vm => vm.HostFilter, v => v.txtHostFilter.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.HostFilter, v => v.txtHostFilter.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ConnectionCloseAllCmd, v => v.btnConnectionCloseAll).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ConnectionCloseAllCmd, v => v.btnConnectionCloseAll).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables);
AppEvents.AppExitRequested
.AsObservable()
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => StorageUI())
.DisposeWith(disposables);
}); });
RestoreUI();
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
@ -51,4 +65,74 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
{ {
ViewModel?.ClashConnectionClose(false); ViewModel?.ClashConnectionClose(false);
} }
#region UI
private void RestoreUI()
{
try
{
var lvColumnItem = _config.ClashUIItem?.ConnectionsColumnItem?.OrderBy(t => t.Index).ToList();
if (lvColumnItem == null)
{
return;
}
var displayIndex = 0;
foreach (var item in lvColumnItem)
{
foreach (var item2 in lstConnections.Columns)
{
if (item2.Tag == null)
{
continue;
}
if (item2.Tag.Equals(item.Name))
{
if (item.Width < 0)
{
item2.IsVisible = false;
}
else
{
item2.Width = new DataGridLength(item.Width, DataGridLengthUnitType.Pixel);
item2.DisplayIndex = displayIndex++;
}
}
}
}
}
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
}
}
private void StorageUI()
{
try
{
List<ColumnItem> lvColumnItem = new();
foreach (var item2 in lstConnections.Columns)
{
if (item2.Tag == null)
{
continue;
}
lvColumnItem.Add(new()
{
Name = (string)item2.Tag,
Width = (int)(item2.IsVisible == true ? item2.ActualWidth : -1),
Index = item2.DisplayIndex
});
}
_config.ClashUIItem.ConnectionsColumnItem = lvColumnItem;
}
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
}
}
#endregion UI
} }

View file

@ -7,6 +7,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
{ {
private static Config _config; private static Config _config;
private Window? _window; private Window? _window;
private static readonly string _tag = "ProfilesView";
public ProfilesView() public ProfilesView()
{ {
@ -381,7 +382,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("ProfilesView", ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -398,6 +399,8 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
#region UI #region UI
private void RestoreUI() private void RestoreUI()
{
try
{ {
var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList(); var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList();
var displayIndex = 0; var displayIndex = 0;
@ -428,8 +431,15 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
} }
} }
} }
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
}
}
private void StorageUI() private void StorageUI()
{
try
{ {
List<ColumnItem> lvColumnItem = new(); List<ColumnItem> lvColumnItem = new();
foreach (var item2 in lstProfiles.Columns) foreach (var item2 in lstProfiles.Columns)
@ -447,6 +457,11 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
} }
_config.UiItem.MainColumnItem = lvColumnItem; _config.UiItem.MainColumnItem = lvColumnItem;
} }
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
}
}
#endregion UI #endregion UI

View file

@ -2,6 +2,7 @@
x:Class="v2rayN.Views.ClashConnectionsView" x:Class="v2rayN.Views.ClashConnectionsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="clr-namespace:v2rayN.Base"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -78,25 +79,30 @@
</ContextMenu> </ContextMenu>
</DataGrid.ContextMenu> </DataGrid.ContextMenu>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn <base:MyDGTextColumn
Width="300" Width="300"
Binding="{Binding Host}" Binding="{Binding Host}"
ExName="Host"
Header="{x:Static resx:ResUI.TbSortingHost}" /> Header="{x:Static resx:ResUI.TbSortingHost}" />
<DataGridTextColumn <base:MyDGTextColumn
Width="500" Width="500"
Binding="{Binding Chain}" Binding="{Binding Chain}"
ExName="Chain"
Header="{x:Static resx:ResUI.TbSortingChain}" /> Header="{x:Static resx:ResUI.TbSortingChain}" />
<DataGridTextColumn <base:MyDGTextColumn
Width="80" Width="80"
Binding="{Binding Network}" Binding="{Binding Network}"
ExName="Network"
Header="{x:Static resx:ResUI.TbSortingNetwork}" /> Header="{x:Static resx:ResUI.TbSortingNetwork}" />
<DataGridTextColumn <base:MyDGTextColumn
Width="160" Width="160"
Binding="{Binding Type}" Binding="{Binding Type}"
ExName="Type"
Header="{x:Static resx:ResUI.TbSortingType}" /> Header="{x:Static resx:ResUI.TbSortingType}" />
<DataGridTextColumn <base:MyDGTextColumn
Width="100" Width="100"
Binding="{Binding Elapsed}" Binding="{Binding Elapsed}"
ExName="Elapsed"
Header="{x:Static resx:ResUI.TbSortingTime}" /> Header="{x:Static resx:ResUI.TbSortingTime}" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>

View file

@ -1,4 +1,5 @@
using System.Windows.Controls; using System.Windows.Controls;
using v2rayN.Base;
namespace v2rayN.Views; namespace v2rayN.Views;
@ -7,9 +8,14 @@ namespace v2rayN.Views;
/// </summary> /// </summary>
public partial class ClashConnectionsView public partial class ClashConnectionsView
{ {
private static Config _config;
private static readonly string _tag = "ClashConnectionsView";
public ClashConnectionsView() public ClashConnectionsView()
{ {
InitializeComponent(); InitializeComponent();
_config = AppManager.Instance.Config;
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler); ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click; btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
@ -24,7 +30,15 @@ public partial class ClashConnectionsView
this.Bind(ViewModel, vm => vm.HostFilter, v => v.txtHostFilter.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.HostFilter, v => v.txtHostFilter.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ConnectionCloseAllCmd, v => v.btnConnectionCloseAll).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ConnectionCloseAllCmd, v => v.btnConnectionCloseAll).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables);
AppEvents.AppExitRequested
.AsObservable()
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => StorageUI())
.DisposeWith(disposables);
}); });
RestoreUI();
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
@ -48,7 +62,7 @@ public partial class ClashConnectionsView
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("ClashConnectionsView", ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -56,4 +70,71 @@ public partial class ClashConnectionsView
{ {
ViewModel?.ClashConnectionClose(false); ViewModel?.ClashConnectionClose(false);
} }
#region UI
private void RestoreUI()
{
try
{
var lvColumnItem = _config.ClashUIItem?.ConnectionsColumnItem?.OrderBy(t => t.Index).ToList();
if (lvColumnItem == null)
{
return;
}
var displayIndex = 0;
foreach (var item in lvColumnItem)
{
foreach (var col in lstConnections.Columns.Cast<MyDGTextColumn>())
{
if (col.ExName == item.Name)
{
if (item.Width > 0)
{
col.Width = item.Width;
}
col.DisplayIndex = displayIndex++;
break;
}
}
}
}
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
}
}
private void StorageUI()
{
try
{
List<ColumnItem> lvColumnItem = new();
foreach (var col in lstConnections.Columns.Cast<MyDGTextColumn>())
{
var name = col.ExName;
if (string.IsNullOrWhiteSpace(name))
{
continue;
}
lvColumnItem.Add(new()
{
Name = name,
Width = (int)col.ActualWidth,
Index = col.DisplayIndex
});
}
_config.ClashUIItem.ConnectionsColumnItem = lvColumnItem;
}
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
}
}
#endregion UI
} }

View file

@ -10,6 +10,7 @@ namespace v2rayN.Views;
public partial class ProfilesView public partial class ProfilesView
{ {
private static Config _config; private static Config _config;
private static readonly string _tag = "ProfilesView";
public ProfilesView() public ProfilesView()
{ {
@ -339,7 +340,7 @@ public partial class ProfilesView
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog("ProfilesView", ex); Logging.SaveLog(_tag, ex);
} }
} }
@ -356,12 +357,14 @@ public partial class ProfilesView
#region UI #region UI
private void RestoreUI() private void RestoreUI()
{
try
{ {
var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList(); var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList();
var displayIndex = 0; var displayIndex = 0;
foreach (var item in lvColumnItem) foreach (var item in lvColumnItem)
{ {
foreach (MyDGTextColumn item2 in lstProfiles.Columns) foreach (var item2 in lstProfiles.Columns.Cast<MyDGTextColumn>())
{ {
if (item2.ExName == item.Name) if (item2.ExName == item.Name)
{ {
@ -382,13 +385,19 @@ public partial class ProfilesView
} }
} }
} }
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
}
}
private void StorageUI() private void StorageUI()
{ {
List<ColumnItem> lvColumnItem = new(); try
foreach (var t in lstProfiles.Columns) {
List<ColumnItem> lvColumnItem = new();
foreach (var item2 in lstProfiles.Columns.Cast<MyDGTextColumn>())
{ {
var item2 = (MyDGTextColumn)t;
lvColumnItem.Add(new() lvColumnItem.Add(new()
{ {
Name = item2.ExName, Name = item2.ExName,
@ -398,6 +407,11 @@ public partial class ProfilesView
} }
_config.UiItem.MainColumnItem = lvColumnItem; _config.UiItem.MainColumnItem = lvColumnItem;
} }
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
}
}
#endregion UI #endregion UI
@ -405,7 +419,7 @@ public partial class ProfilesView
private Point startPoint = new(); private Point startPoint = new();
private int startIndex = -1; private int startIndex = -1;
private string formatData = "ProfileItemModel"; private readonly string formatData = "ProfileItemModel";
/// <summary> /// <summary>
/// Helper to search up the VisualTree /// Helper to search up the VisualTree