mirror of
https://github.com/2dust/v2rayN.git
synced 2025-11-12 18:32:52 +00:00
Refactor UI platform visibility to use ViewModel properties
This commit is contained in:
parent
4da59cd767
commit
e6cb146671
6 changed files with 30 additions and 45 deletions
|
|
@ -62,6 +62,8 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public int TabMainSelectedIndex { get; set; }
|
public int TabMainSelectedIndex { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public bool BlIsWindows { get; set; }
|
||||||
|
|
||||||
#endregion Menu
|
#endregion Menu
|
||||||
|
|
||||||
#region Init
|
#region Init
|
||||||
|
|
@ -70,6 +72,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
_config = AppManager.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
BlIsWindows = Utils.IsWindows();
|
||||||
|
|
||||||
#region WhenAnyValue && ReactiveCommand
|
#region WhenAnyValue && ReactiveCommand
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,15 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
#endregion UI
|
#endregion UI
|
||||||
|
|
||||||
|
#region UI visibility
|
||||||
|
|
||||||
|
[Reactive] public bool BlIsWindows { get; set; }
|
||||||
|
[Reactive] public bool BlIsLinux { get; set; }
|
||||||
|
[Reactive] public bool BlIsIsMacOS { get; set; }
|
||||||
|
[Reactive] public bool BlIsNonWindows { get; set; }
|
||||||
|
|
||||||
|
#endregion UI visibility
|
||||||
|
|
||||||
#region System proxy
|
#region System proxy
|
||||||
|
|
||||||
[Reactive] public bool notProxyLocalAddress { get; set; }
|
[Reactive] public bool notProxyLocalAddress { get; set; }
|
||||||
|
|
@ -108,6 +117,10 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
_config = AppManager.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
BlIsWindows = Utils.IsWindows();
|
||||||
|
BlIsLinux = Utils.IsLinux();
|
||||||
|
BlIsIsMacOS = Utils.IsMacOS();
|
||||||
|
BlIsNonWindows = Utils.IsNonWindows();
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -75,10 +75,10 @@
|
||||||
<MenuItem x:Name="menuRoutingSetting" Header="{x:Static resx:ResUI.menuRoutingSetting}" />
|
<MenuItem x:Name="menuRoutingSetting" Header="{x:Static resx:ResUI.menuRoutingSetting}" />
|
||||||
<MenuItem x:Name="menuDNSSetting" Header="{x:Static resx:ResUI.menuDNSSetting}" />
|
<MenuItem x:Name="menuDNSSetting" Header="{x:Static resx:ResUI.menuDNSSetting}" />
|
||||||
<MenuItem x:Name="menuFullConfigTemplate" Header="{x:Static resx:ResUI.menuFullConfigTemplate}" />
|
<MenuItem x:Name="menuFullConfigTemplate" Header="{x:Static resx:ResUI.menuFullConfigTemplate}" />
|
||||||
<MenuItem x:Name="menuGlobalHotkeySetting" Header="{x:Static resx:ResUI.menuGlobalHotkeySetting}" />
|
<MenuItem x:Name="menuGlobalHotkeySetting" Header="{x:Static resx:ResUI.menuGlobalHotkeySetting}" IsVisible="{Binding BlIsWindows}" />
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem x:Name="menuRebootAsAdmin" Header="{x:Static resx:ResUI.menuRebootAsAdmin}" />
|
<MenuItem x:Name="menuRebootAsAdmin" Header="{x:Static resx:ResUI.menuRebootAsAdmin}" IsVisible="{Binding BlIsWindows}" />
|
||||||
<MenuItem x:Name="menuSettingsSetUWP" Header="{x:Static resx:ResUI.TbSettingsSetUWP}" />
|
<MenuItem x:Name="menuSettingsSetUWP" Header="{x:Static resx:ResUI.TbSettingsSetUWP}" IsVisible="{Binding BlIsWindows}" />
|
||||||
<MenuItem x:Name="menuClearServerStatistics" Header="{x:Static resx:ResUI.menuClearServerStatistics}" />
|
<MenuItem x:Name="menuClearServerStatistics" Header="{x:Static resx:ResUI.menuClearServerStatistics}" />
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem Header="{x:Static resx:ResUI.menuRegionalPresets}">
|
<MenuItem Header="{x:Static resx:ResUI.menuRegionalPresets}">
|
||||||
|
|
|
||||||
|
|
@ -161,10 +161,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Title = $"{Utils.GetVersion()}";
|
Title = $"{Utils.GetVersion()}";
|
||||||
|
|
||||||
menuRebootAsAdmin.IsVisible = false;
|
|
||||||
menuSettingsSetUWP.IsVisible = false;
|
|
||||||
menuGlobalHotkeySetting.IsVisible = false;
|
|
||||||
}
|
}
|
||||||
menuAddServerViaScan.IsVisible = false;
|
menuAddServerViaScan.IsVisible = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -356,11 +356,11 @@
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
HorizontalAlignment="Left" />
|
HorizontalAlignment="Left" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="tbAutoRunTip"
|
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
IsVisible="{Binding BlIsWindows}"
|
||||||
Text="{x:Static resx:ResUI.TbSettingsStartBootTip}"
|
Text="{x:Static resx:ResUI.TbSettingsStartBootTip}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
|
|
@ -443,24 +443,25 @@
|
||||||
HorizontalAlignment="Left" />
|
HorizontalAlignment="Left" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="labHide2TrayWhenClose"
|
|
||||||
Grid.Row="9"
|
Grid.Row="9"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
IsVisible="{Binding BlIsLinux}"
|
||||||
Text="{x:Static resx:ResUI.TbSettingsHide2TrayWhenClose}" />
|
Text="{x:Static resx:ResUI.TbSettingsHide2TrayWhenClose}" />
|
||||||
<ToggleSwitch
|
<ToggleSwitch
|
||||||
x:Name="togHide2TrayWhenClose"
|
x:Name="togHide2TrayWhenClose"
|
||||||
Grid.Row="9"
|
Grid.Row="9"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
HorizontalAlignment="Left" />
|
HorizontalAlignment="Left"
|
||||||
|
IsVisible="{Binding BlIsLinux}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="labHide2TrayWhenCloseTip"
|
|
||||||
Grid.Row="9"
|
Grid.Row="9"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
IsVisible="{Binding BlIsLinux}"
|
||||||
Text="{x:Static resx:ResUI.TbSettingsHide2TrayWhenCloseTip}" />
|
Text="{x:Static resx:ResUI.TbSettingsHide2TrayWhenCloseTip}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|
@ -675,8 +676,8 @@
|
||||||
<TabItem Name="tabSystemproxy" Header="{x:Static resx:ResUI.TbSettingsSystemproxy}">
|
<TabItem Name="tabSystemproxy" Header="{x:Static resx:ResUI.TbSettingsSystemproxy}">
|
||||||
<DockPanel Margin="{StaticResource Margin8}">
|
<DockPanel Margin="{StaticResource Margin8}">
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Name="panSystemProxyUnix"
|
|
||||||
DockPanel.Dock="Bottom"
|
DockPanel.Dock="Bottom"
|
||||||
|
IsVisible="{Binding BlIsNonWindows}"
|
||||||
Orientation="Vertical">
|
Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|
@ -698,8 +699,8 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Name="panSystemProxyAdvanced"
|
|
||||||
DockPanel.Dock="Bottom"
|
DockPanel.Dock="Bottom"
|
||||||
|
IsVisible="{Binding BlIsWindows}"
|
||||||
Orientation="Vertical">
|
Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|
@ -744,16 +745,16 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Name="txbSettingsExceptionTip"
|
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Top"
|
DockPanel.Dock="Top"
|
||||||
|
IsVisible="{Binding BlIsWindows}"
|
||||||
Text="{x:Static resx:ResUI.TbSettingsExceptionTip}" />
|
Text="{x:Static resx:ResUI.TbSettingsExceptionTip}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Name="txbSettingsExceptionTip2"
|
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Top"
|
DockPanel.Dock="Top"
|
||||||
|
IsVisible="{Binding BlIsNonWindows}"
|
||||||
Text="{x:Static resx:ResUI.TbSettingsExceptionTip2}" />
|
Text="{x:Static resx:ResUI.TbSettingsExceptionTip2}" />
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="txtsystemProxyExceptions"
|
x:Name="txtsystemProxyExceptions"
|
||||||
|
|
|
||||||
|
|
@ -125,34 +125,6 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Utils.IsWindows())
|
|
||||||
{
|
|
||||||
txbSettingsExceptionTip2.IsVisible = false;
|
|
||||||
|
|
||||||
labHide2TrayWhenClose.IsVisible = false;
|
|
||||||
togHide2TrayWhenClose.IsVisible = false;
|
|
||||||
labHide2TrayWhenCloseTip.IsVisible = false;
|
|
||||||
panSystemProxyUnix.IsVisible = false;
|
|
||||||
}
|
|
||||||
else if (Utils.IsLinux())
|
|
||||||
{
|
|
||||||
txbSettingsExceptionTip.IsVisible = false;
|
|
||||||
panSystemProxyAdvanced.IsVisible = false;
|
|
||||||
|
|
||||||
tbAutoRunTip.IsVisible = false;
|
|
||||||
}
|
|
||||||
else if (Utils.IsMacOS())
|
|
||||||
{
|
|
||||||
txbSettingsExceptionTip.IsVisible = false;
|
|
||||||
panSystemProxyAdvanced.IsVisible = false;
|
|
||||||
|
|
||||||
tbAutoRunTip.IsVisible = false;
|
|
||||||
|
|
||||||
labHide2TrayWhenClose.IsVisible = false;
|
|
||||||
togHide2TrayWhenClose.IsVisible = false;
|
|
||||||
labHide2TrayWhenCloseTip.IsVisible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue