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]
|
||||
public int TabMainSelectedIndex { get; set; }
|
||||
|
||||
[Reactive] public bool BlIsWindows { get; set; }
|
||||
|
||||
#endregion Menu
|
||||
|
||||
#region Init
|
||||
|
|
@ -70,6 +72,7 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
{
|
||||
_config = AppManager.Instance.Config;
|
||||
_updateView = updateView;
|
||||
BlIsWindows = Utils.IsWindows();
|
||||
|
||||
#region WhenAnyValue && ReactiveCommand
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,15 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
|
||||
#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
|
||||
|
||||
[Reactive] public bool notProxyLocalAddress { get; set; }
|
||||
|
|
@ -108,6 +117,10 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
{
|
||||
_config = AppManager.Instance.Config;
|
||||
_updateView = updateView;
|
||||
BlIsWindows = Utils.IsWindows();
|
||||
BlIsLinux = Utils.IsLinux();
|
||||
BlIsIsMacOS = Utils.IsMacOS();
|
||||
BlIsNonWindows = Utils.IsNonWindows();
|
||||
|
||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -75,10 +75,10 @@
|
|||
<MenuItem x:Name="menuRoutingSetting" Header="{x:Static resx:ResUI.menuRoutingSetting}" />
|
||||
<MenuItem x:Name="menuDNSSetting" Header="{x:Static resx:ResUI.menuDNSSetting}" />
|
||||
<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 />
|
||||
<MenuItem x:Name="menuRebootAsAdmin" Header="{x:Static resx:ResUI.menuRebootAsAdmin}" />
|
||||
<MenuItem x:Name="menuSettingsSetUWP" Header="{x:Static resx:ResUI.TbSettingsSetUWP}" />
|
||||
<MenuItem x:Name="menuRebootAsAdmin" Header="{x:Static resx:ResUI.menuRebootAsAdmin}" IsVisible="{Binding BlIsWindows}" />
|
||||
<MenuItem x:Name="menuSettingsSetUWP" Header="{x:Static resx:ResUI.TbSettingsSetUWP}" IsVisible="{Binding BlIsWindows}" />
|
||||
<MenuItem x:Name="menuClearServerStatistics" Header="{x:Static resx:ResUI.menuClearServerStatistics}" />
|
||||
<Separator />
|
||||
<MenuItem Header="{x:Static resx:ResUI.menuRegionalPresets}">
|
||||
|
|
|
|||
|
|
@ -161,10 +161,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||
else
|
||||
{
|
||||
Title = $"{Utils.GetVersion()}";
|
||||
|
||||
menuRebootAsAdmin.IsVisible = false;
|
||||
menuSettingsSetUWP.IsVisible = false;
|
||||
menuGlobalHotkeySetting.IsVisible = false;
|
||||
}
|
||||
menuAddServerViaScan.IsVisible = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -356,11 +356,11 @@
|
|||
Margin="{StaticResource Margin4}"
|
||||
HorizontalAlignment="Left" />
|
||||
<TextBlock
|
||||
x:Name="tbAutoRunTip"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding BlIsWindows}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsStartBootTip}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
|
|
@ -443,24 +443,25 @@
|
|||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
x:Name="labHide2TrayWhenClose"
|
||||
Grid.Row="9"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding BlIsLinux}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsHide2TrayWhenClose}" />
|
||||
<ToggleSwitch
|
||||
x:Name="togHide2TrayWhenClose"
|
||||
Grid.Row="9"
|
||||
Grid.Column="1"
|
||||
Margin="{StaticResource Margin4}"
|
||||
HorizontalAlignment="Left" />
|
||||
HorizontalAlignment="Left"
|
||||
IsVisible="{Binding BlIsLinux}" />
|
||||
<TextBlock
|
||||
x:Name="labHide2TrayWhenCloseTip"
|
||||
Grid.Row="9"
|
||||
Grid.Column="2"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding BlIsLinux}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsHide2TrayWhenCloseTip}" />
|
||||
|
||||
<TextBlock
|
||||
|
|
@ -675,8 +676,8 @@
|
|||
<TabItem Name="tabSystemproxy" Header="{x:Static resx:ResUI.TbSettingsSystemproxy}">
|
||||
<DockPanel Margin="{StaticResource Margin8}">
|
||||
<StackPanel
|
||||
Name="panSystemProxyUnix"
|
||||
DockPanel.Dock="Bottom"
|
||||
IsVisible="{Binding BlIsNonWindows}"
|
||||
Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
|
|
@ -690,7 +691,7 @@
|
|||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
Watermark="proxy_set.sh"/>
|
||||
Watermark="proxy_set.sh" />
|
||||
<Button
|
||||
x:Name="btnBrowseCustomSystemProxyScriptPath"
|
||||
Margin="{StaticResource Margin4}"
|
||||
|
|
@ -698,8 +699,8 @@
|
|||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Name="panSystemProxyAdvanced"
|
||||
DockPanel.Dock="Bottom"
|
||||
IsVisible="{Binding BlIsWindows}"
|
||||
Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
|
|
@ -735,7 +736,7 @@
|
|||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
Watermark="pac.txt"/>
|
||||
Watermark="pac.txt" />
|
||||
<Button
|
||||
x:Name="btnBrowseCustomSystemProxyPacPath"
|
||||
Margin="{StaticResource Margin4}"
|
||||
|
|
@ -744,16 +745,16 @@
|
|||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Name="txbSettingsExceptionTip"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Top"
|
||||
IsVisible="{Binding BlIsWindows}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsExceptionTip}" />
|
||||
<TextBlock
|
||||
Name="txbSettingsExceptionTip2"
|
||||
Margin="{StaticResource Margin4}"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Top"
|
||||
IsVisible="{Binding BlIsNonWindows}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsExceptionTip2}" />
|
||||
<TextBox
|
||||
x:Name="txtsystemProxyExceptions"
|
||||
|
|
|
|||
|
|
@ -125,34 +125,6 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
|||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue