Browse Source

StorageUI and RestoreUI

pull/5767/head
2dust 2 months ago
parent
commit
77a59e9107
  1. 45
      v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml
  2. 116
      v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs

45
v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml

@ -116,6 +116,8 @@
<ComboBox
x:Name="cmbMoveToGroup"
Width="200"
DisplayMemberBinding="{Binding remarks}"
ItemsSource="{Binding SubItems}"
ToolTip.Tip="{x:Static resx:ResUI.menuSubscription}" />
</DockPanel>
</MenuItem.Header>
@ -141,36 +143,46 @@
</DataGrid.ContextMenu>
<DataGrid.Columns>
<DataGridCheckBoxColumn Width="40" Binding="{Binding isActive}" />
<DataGridCheckBoxColumn
Width="40"
Binding="{Binding isActive}"
Tag="isActive" />
<DataGridTextColumn
Width="80"
Binding="{Binding configType}"
Header="{x:Static resx:ResUI.LvServiceType}" />
Header="{x:Static resx:ResUI.LvServiceType}"
Tag="configType" />
<DataGridTextColumn
Width="150"
Binding="{Binding remarks}"
Header="{x:Static resx:ResUI.LvRemarks}" />
Header="{x:Static resx:ResUI.LvRemarks}"
Tag="remarks" />
<DataGridTextColumn
Width="120"
Binding="{Binding address}"
Header="{x:Static resx:ResUI.LvAddress}" />
Header="{x:Static resx:ResUI.LvAddress}"
Tag="address" />
<DataGridTextColumn
Width="60"
Binding="{Binding port}"
Header="{x:Static resx:ResUI.LvPort}" />
Header="{x:Static resx:ResUI.LvPort}"
Tag="port" />
<DataGridTextColumn
Width="100"
Binding="{Binding network}"
Header="{x:Static resx:ResUI.LvTransportProtocol}" />
Header="{x:Static resx:ResUI.LvTransportProtocol}"
Tag="network" />
<DataGridTextColumn
Width="100"
Binding="{Binding streamSecurity}"
Header="{x:Static resx:ResUI.LvTLS}" />
Header="{x:Static resx:ResUI.LvTLS}"
Tag="streamSecurity" />
<DataGridTextColumn
Width="100"
Binding="{Binding subRemarks}"
Header="{x:Static resx:ResUI.LvSubscription}" />
<DataGridTemplateColumn SortMemberPath="delay">
Header="{x:Static resx:ResUI.LvSubscription}"
Tag="subRemarks" />
<DataGridTemplateColumn SortMemberPath="delay" Tag="delay">
<DataGridTemplateColumn.Header>
<TextBlock Text="{x:Static resx:ResUI.LvTestDelay}" />
</DataGridTemplateColumn.Header>
@ -188,24 +200,29 @@
<DataGridTextColumn
Width="100"
Binding="{Binding speedVal}"
Header="{x:Static resx:ResUI.LvTestSpeed}" />
Header="{x:Static resx:ResUI.LvTestSpeed}"
Tag="speedVal" />
<DataGridTextColumn
Width="100"
Binding="{Binding todayUp}"
Header="{x:Static resx:ResUI.LvTodayUploadDataAmount}" />
Header="{x:Static resx:ResUI.LvTodayUploadDataAmount}"
Tag="todayUp" />
<DataGridTextColumn
Width="100"
Binding="{Binding todayDown}"
Header="{x:Static resx:ResUI.LvTodayDownloadDataAmount}" />
Header="{x:Static resx:ResUI.LvTodayDownloadDataAmount}"
Tag="todayDown" />
<DataGridTextColumn
Width="100"
Binding="{Binding totalUp}"
Header="{x:Static resx:ResUI.LvTotalUploadDataAmount}" />
Header="{x:Static resx:ResUI.LvTotalUploadDataAmount}"
Tag="totalUp" />
<DataGridTextColumn
Width="100"
Binding="{Binding totalDown}"
Header="{x:Static resx:ResUI.LvTotalDownloadDataAmount}" />
Header="{x:Static resx:ResUI.LvTotalDownloadDataAmount}"
Tag="totalDown" />
</DataGrid.Columns>
</DataGrid>
</DockPanel>

116
v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs

@ -64,7 +64,7 @@ namespace v2rayN.Desktop.Views
this.BindCommand(ViewModel, vm => vm.SetDefaultLoadBalanceServerCmd, v => v.menuSetDefaultLoadBalanceServer).DisposeWith(disposables);
//servers move
this.OneWayBind(ViewModel, vm => vm.SubItems, v => v.cmbMoveToGroup.ItemsSource).DisposeWith(disposables);
//this.OneWayBind(ViewModel, vm => vm.SubItems, v => v.cmbMoveToGroup.ItemsSource).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedMoveToGroup, v => v.cmbMoveToGroup.SelectedItem).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.MoveTopCmd, v => v.menuMoveTop).DisposeWith(disposables);
@ -86,9 +86,9 @@ namespace v2rayN.Desktop.Views
this.BindCommand(ViewModel, vm => vm.Export2ShareUrlBase64Cmd, v => v.menuExport2ShareUrlBase64).DisposeWith(disposables);
});
//RestoreUI();
RestoreUI();
ViewModel?.RefreshServers();
}
}
//#region Event
@ -194,6 +194,7 @@ namespace v2rayN.Desktop.Views
{
ViewModel?.EditServerAsync(EConfigType.Custom);
}
StorageUI();
}
private void LstProfiles_LoadingRow(object? sender, DataGridRowEventArgs e)
@ -301,6 +302,7 @@ namespace v2rayN.Desktop.Views
{
it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
}
StorageUI();
}
private void TxtServerFilter_KeyDown(object? sender, KeyEventArgs e)
@ -315,61 +317,61 @@ namespace v2rayN.Desktop.Views
//#region UI
//private void RestoreUI()
//{
// var lvColumnItem = _config.uiItem.mainColumnItem.OrderBy(t => t.Index).ToList();
// var displayIndex = 0;
// foreach (var item in lvColumnItem)
// {
// foreach (MyDGTextColumn item2 in lstProfiles.Columns)
// {
// if (item2.ExName == item.Name)
// {
// if (item.Width < 0)
// {
// item2.IsVisible = false;
// }
// else
// {
// item2.Width = item.Width;
// item2.DisplayIndex = displayIndex++;
// }
// }
// }
// }
// if (!_config.guiItem.enableStatistics)
// {
// colTodayUp.IsVisible =
// colTodayDown.IsVisible =
// colTotalUp.IsVisible =
// colTotalDown.IsVisible = false;
// }
// else
// {
// colTodayUp.IsVisible =
// colTodayDown.IsVisible =
// colTotalUp.IsVisible =
// colTotalDown.IsVisible = true;
// }
//}
private void RestoreUI()
{
var lvColumnItem = _config.uiItem.mainColumnItem.OrderBy(t => t.Index).ToList();
var displayIndex = 0;
foreach (var item in lvColumnItem)
{
foreach (var item2 in lstProfiles.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++;
}
if (item.Name.StartsWith("to"))
{
if (!_config.guiItem.enableStatistics)
{
item2.IsVisible = false;
}
}
}
}
}
}
//private void StorageUI()
//{
// List<ColumnItem> lvColumnItem = new();
// for (int k = 0; k < lstProfiles.Columns.Count; k++)
// {
// var item2 = (MyDGTextColumn)lstProfiles.Columns[k];
// lvColumnItem.Add(new()
// {
// Name = item2.ExName,
// Width = item2.IsVisible == true ? Utils.ToInt(item2.ActualWidth) : -1,
// Index = item2.DisplayIndex
// });
// }
// _config.uiItem.mainColumnItem = lvColumnItem;
// ConfigHandler.SaveConfig(_config);
//}
private void StorageUI()
{
List<ColumnItem> lvColumnItem = new();
for (int k = 0; k < lstProfiles.Columns.Count; k++)
{
var item2 = lstProfiles.Columns[k];
if (item2.Tag == null)
{
continue;
}
lvColumnItem.Add(new()
{
Name = (string)item2.Tag,
Width = item2.IsVisible == true ? Utils.ToInt(item2.ActualWidth) : -1,
Index = item2.DisplayIndex
});
}
_config.uiItem.mainColumnItem = lvColumnItem;
ConfigHandler.SaveConfig(_config);
}
//#endregion UI

Loading…
Cancel
Save