From 0750b8072e58ac758c58ea1886f107b583bc8963 Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BO4HSG\\ksat" Date: Sat, 24 Dec 2022 16:20:05 +0800 Subject: [PATCH] fix: copy cmd notify delay problem --- STranslate/MainWindow.xaml | 8 ++++++++ STranslate/ViewModel/MainVM.cs | 25 +++++-------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/STranslate/MainWindow.xaml b/STranslate/MainWindow.xaml index bc48a43..7fcda5b 100644 --- a/STranslate/MainWindow.xaml +++ b/STranslate/MainWindow.xaml @@ -22,6 +22,9 @@ + + + @@ -107,6 +110,7 @@ Margin="5,0,0,5" HorizontalAlignment="Left" VerticalAlignment="Bottom" + Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}" Command="{Binding CopyInputCmd}"> @@ -182,6 +186,7 @@ HorizontalAlignment="Left" VerticalAlignment="Bottom" ToolTip="直接复制" + Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}" Command="{Binding CopyResultCmd}"> @@ -191,6 +196,7 @@ HorizontalAlignment="Left" VerticalAlignment="Bottom" ToolTip="蛇形" + Visibility="{Binding SnakeRet,Converter={StaticResource String2VisibilityConverter}}" Command="{Binding CopySnakeResultCmd}"> @@ -199,6 +205,7 @@ HorizontalAlignment="Left" VerticalAlignment="Bottom" ToolTip="小驼峰" + Visibility="{Binding SmallHumpRet,Converter={StaticResource String2VisibilityConverter}}" Command="{Binding CopySmallHumpResultCmd}"> @@ -207,6 +214,7 @@ HorizontalAlignment="Left" VerticalAlignment="Bottom" ToolTip="大驼峰" + Visibility="{Binding LargeHumpRet,Converter={StaticResource String2VisibilityConverter}}" Command="{Binding CopyLargeHumpResultCmd}"> diff --git a/STranslate/ViewModel/MainVM.cs b/STranslate/ViewModel/MainVM.cs index 5f708ce..2525932 100644 --- a/STranslate/ViewModel/MainVM.cs +++ b/STranslate/ViewModel/MainVM.cs @@ -37,42 +37,27 @@ namespace STranslate.ViewModel config = ConfigUtil.ReadConfig(ConfigPath); //复制输入 - CopyInputCmd = new RelayCommand((_) => - { - return string.IsNullOrEmpty(InputTxt) ? false : true; - }, (_) => + CopyInputCmd = new RelayCommand((_) => true, (_) => { Clipboard.SetText(InputTxt); }); //复制翻译结果 - CopyResultCmd = new RelayCommand((_) => - { - return string.IsNullOrEmpty(OutputTxt) ? false : true; - }, (_) => + CopyResultCmd = new RelayCommand((_) => true, (_) => { Clipboard.SetText(OutputTxt); }); //复制蛇形结果 - CopySnakeResultCmd = new RelayCommand((_) => - { - return string.IsNullOrEmpty(SnakeRet) ? false : true; - }, (_) => + CopySnakeResultCmd = new RelayCommand((_) => true, (_) => { Clipboard.SetText(SnakeRet); }); //复制小驼峰结果 - CopySmallHumpResultCmd = new RelayCommand((_) => - { - return string.IsNullOrEmpty(SmallHumpRet) ? false : true; - }, (_) => + CopySmallHumpResultCmd = new RelayCommand((_) => true, (_) => { Clipboard.SetText(SmallHumpRet); }); //复制大驼峰结果 - CopyLargeHumpResultCmd = new RelayCommand((_) => - { - return string.IsNullOrEmpty(LargeHumpRet) ? false : true; - }, (_) => + CopyLargeHumpResultCmd = new RelayCommand((_) => true, (_) => { Clipboard.SetText(LargeHumpRet); });