From 11af88fe070069f93d97caa12ffc7d5fbcd68a3c Mon Sep 17 00:00:00 2001 From: database64128 Date: Sun, 18 Oct 2020 02:30:54 +0800 Subject: [PATCH] =?UTF-8?q?=E2=8F=A9=20ForwardProxyView:=20disable=20TextB?= =?UTF-8?q?ox=20when=20no=20proxy=20+=20add=20timeout=20unit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Thanks @DuckSoft for the review suggestions --- shadowsocks-csharp/Localization/Strings.Designer.cs | 2 +- shadowsocks-csharp/Localization/Strings.fr.resx | 2 +- shadowsocks-csharp/Localization/Strings.ja.resx | 2 +- shadowsocks-csharp/Localization/Strings.ko.resx | 2 +- shadowsocks-csharp/Localization/Strings.resx | 2 +- shadowsocks-csharp/Localization/Strings.ru.resx | 2 +- shadowsocks-csharp/Localization/Strings.zh-Hans.resx | 2 +- shadowsocks-csharp/Localization/Strings.zh-Hant.resx | 2 +- .../ViewModels/ForwardProxyViewModel.cs | 6 ++++++ shadowsocks-csharp/Views/ForwardProxyView.xaml.cs | 12 ++++++++++++ 10 files changed, 26 insertions(+), 8 deletions(-) diff --git a/shadowsocks-csharp/Localization/Strings.Designer.cs b/shadowsocks-csharp/Localization/Strings.Designer.cs index 4534a9cf..6aa6738a 100644 --- a/shadowsocks-csharp/Localization/Strings.Designer.cs +++ b/shadowsocks-csharp/Localization/Strings.Designer.cs @@ -340,7 +340,7 @@ namespace Shadowsocks.Localization { } /// - /// Looks up a localized string similar to Timeout. + /// Looks up a localized string similar to Timeout (sec). /// internal static string Timeout { get { diff --git a/shadowsocks-csharp/Localization/Strings.fr.resx b/shadowsocks-csharp/Localization/Strings.fr.resx index be01a273..da708dd2 100644 --- a/shadowsocks-csharp/Localization/Strings.fr.resx +++ b/shadowsocks-csharp/Localization/Strings.fr.resx @@ -130,7 +130,7 @@ adresse - Délai d'attente + Délai d'attente (sec) Annuler diff --git a/shadowsocks-csharp/Localization/Strings.ja.resx b/shadowsocks-csharp/Localization/Strings.ja.resx index 4d8f997d..b47f5ba1 100644 --- a/shadowsocks-csharp/Localization/Strings.ja.resx +++ b/shadowsocks-csharp/Localization/Strings.ja.resx @@ -130,7 +130,7 @@ ポート - タイムアウト + タイムアウト (秒) キャンセル diff --git a/shadowsocks-csharp/Localization/Strings.ko.resx b/shadowsocks-csharp/Localization/Strings.ko.resx index 16df3925..65c899e4 100644 --- a/shadowsocks-csharp/Localization/Strings.ko.resx +++ b/shadowsocks-csharp/Localization/Strings.ko.resx @@ -130,7 +130,7 @@ 포트 - 시간 초과 + 시간 초과 (초) 취소 diff --git a/shadowsocks-csharp/Localization/Strings.resx b/shadowsocks-csharp/Localization/Strings.resx index 17d6e307..9348c488 100644 --- a/shadowsocks-csharp/Localization/Strings.resx +++ b/shadowsocks-csharp/Localization/Strings.resx @@ -139,7 +139,7 @@ Port - Timeout + Timeout (sec) Credentials (optional) diff --git a/shadowsocks-csharp/Localization/Strings.ru.resx b/shadowsocks-csharp/Localization/Strings.ru.resx index 7c0ceb3d..ce007448 100644 --- a/shadowsocks-csharp/Localization/Strings.ru.resx +++ b/shadowsocks-csharp/Localization/Strings.ru.resx @@ -130,7 +130,7 @@ порт - Таймаут + Таймаут (сек) Отмена diff --git a/shadowsocks-csharp/Localization/Strings.zh-Hans.resx b/shadowsocks-csharp/Localization/Strings.zh-Hans.resx index 9ca554ed..f3ef9520 100644 --- a/shadowsocks-csharp/Localization/Strings.zh-Hans.resx +++ b/shadowsocks-csharp/Localization/Strings.zh-Hans.resx @@ -148,7 +148,7 @@ 端口 - 超时 + 超时 (秒) 确定 diff --git a/shadowsocks-csharp/Localization/Strings.zh-Hant.resx b/shadowsocks-csharp/Localization/Strings.zh-Hant.resx index 91610dc5..e52f7e3f 100644 --- a/shadowsocks-csharp/Localization/Strings.zh-Hant.resx +++ b/shadowsocks-csharp/Localization/Strings.zh-Hant.resx @@ -130,7 +130,7 @@ 位址 - 逾時 + 逾時 (秒) 取消 diff --git a/shadowsocks-csharp/ViewModels/ForwardProxyViewModel.cs b/shadowsocks-csharp/ViewModels/ForwardProxyViewModel.cs index 2d9e9bb0..f901cac8 100644 --- a/shadowsocks-csharp/ViewModels/ForwardProxyViewModel.cs +++ b/shadowsocks-csharp/ViewModels/ForwardProxyViewModel.cs @@ -33,6 +33,9 @@ namespace Shadowsocks.ViewModels Username = _config.proxy.authUser; Password = _config.proxy.authPwd; + this.WhenAnyValue(x => x.NoProxy, x => !x) + .ToPropertyEx(this, x => x.CanModifyDetails); + AddressRule = this.ValidationRule( viewModel => viewModel.Address, address => !string.IsNullOrWhiteSpace(address), @@ -73,6 +76,9 @@ namespace Shadowsocks.ViewModels public ReactiveCommand Save { get; } public ReactiveCommand Cancel { get; } + [ObservableAsProperty] + public bool CanModifyDetails { get; } + [Reactive] public bool NoProxy { get; set; } diff --git a/shadowsocks-csharp/Views/ForwardProxyView.xaml.cs b/shadowsocks-csharp/Views/ForwardProxyView.xaml.cs index 362696f4..bc9a6658 100644 --- a/shadowsocks-csharp/Views/ForwardProxyView.xaml.cs +++ b/shadowsocks-csharp/Views/ForwardProxyView.xaml.cs @@ -40,6 +40,18 @@ namespace Shadowsocks.Views viewModel => viewModel.Timeout, view => view.timeoutTextBox.Text) .DisposeWith(disposables); + this.OneWayBind(ViewModel, + viewModel => viewModel.CanModifyDetails, + view => view.addressTextBox.IsEnabled) + .DisposeWith(disposables); + this.OneWayBind(ViewModel, + viewModel => viewModel.CanModifyDetails, + view => view.portTextBox.IsEnabled) + .DisposeWith(disposables); + this.OneWayBind(ViewModel, + viewModel => viewModel.CanModifyDetails, + view => view.timeoutTextBox.IsEnabled) + .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.Username,