Skip to content

Commit

Permalink
Adjust UI for desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jan 9, 2025
1 parent 8b4a07d commit e0ae101
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 233 deletions.
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Resx/ResUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Resx/ResUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@
<value>Add</value>
</data>
<data name="menuRoutingAdvancedImportRules" xml:space="preserve">
<value>Import Advanced Rules</value>
<value>Import Rules</value>
</data>
<data name="menuRoutingAdvancedRemove" xml:space="preserve">
<value>Remove selected (Delete)</value>
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@
<value>添加规则集</value>
</data>
<data name="menuRoutingAdvancedImportRules" xml:space="preserve">
<value>一键导入高级规则</value>
<value>一键导入规则集</value>
</data>
<data name="menuRoutingAdvancedRemove" xml:space="preserve">
<value>移除所选规则 (Delete)</value>
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@
<value>新增規則集</value>
</data>
<data name="menuRoutingAdvancedImportRules" xml:space="preserve">
<value>一鍵匯入進階規則</value>
<value>一鍵匯入規則集</value>
</data>
<data name="menuRoutingAdvancedRemove" xml:space="preserve">
<value>移除所選規則 (Delete)</value>
Expand Down
17 changes: 0 additions & 17 deletions v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@ public class StatusBarViewModel : MyReactiveObject
[Reactive]
public bool BlSystemProxyPac { get; set; }

[Reactive]
public bool BlNotSystemProxyClear { get; set; }

[Reactive]
public bool BlNotSystemProxySet { get; set; }

[Reactive]
public bool BlNotSystemProxyNothing { get; set; }

[Reactive]
public bool BlNotSystemProxyPac { get; set; }

public ReactiveCommand<Unit, Unit> SystemProxyClearCmd { get; }
public ReactiveCommand<Unit, Unit> SystemProxySetCmd { get; }
public ReactiveCommand<Unit, Unit> SystemProxyNothingCmd { get; }
Expand Down Expand Up @@ -333,11 +321,6 @@ public async Task ChangeSystemProxyAsync(ESysProxyType type, bool blChange)
BlSystemProxyNothing = (type == ESysProxyType.Unchanged);
BlSystemProxyPac = (type == ESysProxyType.Pac);

BlNotSystemProxyClear = !BlSystemProxyClear;
BlNotSystemProxySet = !BlSystemProxySet;
BlNotSystemProxyNothing = !BlSystemProxyNothing;
BlNotSystemProxyPac = !BlSystemProxyPac;

if (blChange)
{
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
Expand Down
26 changes: 6 additions & 20 deletions v2rayN/v2rayN.Desktop/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,18 @@
<NativeMenuItem
Command="{Binding SystemProxyClearCmd}"
Header="{x:Static resx:ResUI.menuSystemProxyClear}"
IsVisible="{Binding BlNotSystemProxyClear}" />
<NativeMenuItem
Command="{Binding SystemProxyClearCmd}"
Header="{x:Static resx:ResUI.menuSystemProxyClear}"
Icon="/Assets/NotifyIcon1.ico"
IsVisible="{Binding BlSystemProxyClear}" />

IsChecked="{Binding BlSystemProxyClear}"
ToggleType="Radio" />
<NativeMenuItem
Command="{Binding SystemProxySetCmd}"
Header="{x:Static resx:ResUI.menuSystemProxySet}"
IsVisible="{Binding BlNotSystemProxySet}" />
<NativeMenuItem
Command="{Binding SystemProxySetCmd}"
Header="{x:Static resx:ResUI.menuSystemProxySet}"
Icon="/Assets/NotifyIcon2.ico"
IsVisible="{Binding BlSystemProxySet}" />

<NativeMenuItem
Command="{Binding SystemProxyNothingCmd}"
Header="{x:Static resx:ResUI.menuSystemProxyNothing}"
IsVisible="{Binding BlNotSystemProxyNothing}" />
IsChecked="{Binding BlSystemProxySet}"
ToggleType="Radio" />
<NativeMenuItem
Command="{Binding SystemProxyNothingCmd}"
Header="{x:Static resx:ResUI.menuSystemProxyNothing}"
Icon="/Assets/NotifyIcon3.ico"
IsVisible="{Binding BlSystemProxyNothing}" />
IsChecked="{Binding BlSystemProxyNothing}"
ToggleType="Radio" />
<NativeMenuItemSeparator />
<NativeMenuItem Click="MenuAddServerViaClipboardClick" Header="{x:Static resx:ResUI.menuAddServerViaClipboard}" />
<NativeMenuItem Header="{x:Static resx:ResUI.menuAddServerViaScan}" IsVisible="False" />
Expand Down
26 changes: 14 additions & 12 deletions v2rayN/v2rayN.Desktop/Common/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ public static async Task<ButtonResult> ShowYesNo(Window owner, string msg)

public static async Task<string?> OpenFileDialog(Window owner, FilePickerFileType? filter)
{
var topLevel = TopLevel.GetTopLevel(owner);
if (topLevel == null)
{
return null;
}
var sp = GetStorageProvider(owner);
if (sp is null) return null;

// Start async operation to open the dialog.
var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
var files = await sp.OpenFilePickerAsync(new FilePickerOpenOptions
{
AllowMultiple = false,
FileTypeFilter = filter is null ? [FilePickerFileTypes.All, FilePickerFileTypes.ImagePng] : [filter]
Expand All @@ -34,17 +32,21 @@ public static async Task<ButtonResult> ShowYesNo(Window owner, string msg)

public static async Task<string?> SaveFileDialog(Window owner, string filter)
{
var topLevel = TopLevel.GetTopLevel(owner);
if (topLevel == null)
{
return null;
}
var sp = GetStorageProvider(owner);
if (sp is null) return null;

// Start async operation to open the dialog.
var files = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
var files = await sp.SaveFilePickerAsync(new FilePickerSaveOptions
{
});

return files?.TryGetLocalPath();
}

private static IStorageProvider? GetStorageProvider(Window owner)
{
var topLevel = TopLevel.GetTopLevel(owner);
return topLevel?.StorageProvider;
}
}
}
180 changes: 89 additions & 91 deletions v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
HorizontalAlignment="Left"
Classes="Margin8"
SelectionMode="Multiple"
Theme="{DynamicResource PureCardRadioGroupListBox}" />
Theme="{DynamicResource CardCheckGroupListBox}" />

<TextBlock
Grid.Row="6"
Expand Down Expand Up @@ -714,102 +714,100 @@
</TabItem>

<TabItem Header="{x:Static resx:ResUI.TbSettingsTunMode}">
<DockPanel Classes="Margin8">
<Grid
Classes="Margin8"
ColumnDefinitions="Auto,Auto,Auto"
DockPanel.Dock="Top"
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Grid
Classes="Margin8"
ColumnDefinitions="Auto,Auto,Auto"
DockPanel.Dock="Top"
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">

<TextBlock
Grid.Row="2"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="Strict Route" />
<ToggleSwitch
x:Name="togStrictRoute"
Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="Strict Route" />
<ToggleSwitch
x:Name="togStrictRoute"
Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8" />

<TextBlock
Grid.Row="3"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="Stack" />
<ComboBox
x:Name="cmbStack"
Grid.Row="3"
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="Stack" />
<ComboBox
x:Name="cmbStack"
Grid.Row="3"
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />

<TextBlock
Grid.Row="4"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="Mtu" />
<ComboBox
x:Name="cmbMtu"
Grid.Row="4"
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="4"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="Mtu" />
<ComboBox
x:Name="cmbMtu"
Grid.Row="4"
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />

<TextBlock
Grid.Row="5"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsEnableExInbound}" />
<ToggleSwitch
x:Name="togEnableExInbound"
Grid.Row="5"
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="5"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsEnableExInbound}" />
<ToggleSwitch
x:Name="togEnableExInbound"
Grid.Row="5"
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8" />

<TextBlock
Grid.Row="6"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsEnableIPv6Address}" />
<ToggleSwitch
x:Name="togEnableIPv6Address"
Grid.Row="6"
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="6"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsEnableIPv6Address}" />
<ToggleSwitch
x:Name="togEnableIPv6Address"
Grid.Row="6"
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8" />

<TextBlock
Grid.Row="7"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsLinuxSudoPassword}" />
<TextBox
x:Name="txtLinuxSudoPassword"
Grid.Row="7"
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="7"
Grid.Column="2"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsLinuxSudoPasswordTip}"
TextWrapping="Wrap" />
</Grid>
</DockPanel>
<TextBlock
Grid.Row="7"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsLinuxSudoPassword}" />
<TextBox
x:Name="txtLinuxSudoPassword"
Grid.Row="7"
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="7"
Grid.Column="2"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsLinuxSudoPasswordTip}"
TextWrapping="Wrap" />
</Grid>
</TabItem>

<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreType}">
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
HorizontalAlignment="Left"
Classes="Margin8"
SelectionMode="Multiple"
Theme="{DynamicResource PureCardRadioGroupListBox}" />
Theme="{DynamicResource CardCheckGroupListBox}" />

<TextBlock
Grid.Row="4"
Expand All @@ -109,7 +109,7 @@
Grid.Column="1"
Classes="Margin8"
SelectionMode="Multiple"
Theme="{DynamicResource PureCardRadioGroupListBox}" />
Theme="{DynamicResource CardCheckGroupListBox}" />
<TextBlock
Grid.Row="4"
Grid.Column="2"
Expand Down
Loading

0 comments on commit e0ae101

Please sign in to comment.