From dfe36cec41328c1db624cc34fcf90b55de1d89d7 Mon Sep 17 00:00:00 2001 From: "SONGE9B3\\song_pd_win11" Date: Tue, 27 Dec 2022 10:24:08 +0800 Subject: [PATCH] perf: beautify the combobox by original codes --- STranslate/Images/iconfont.ttf | Bin 0 -> 3684 bytes STranslate/MainWindow.xaml | 369 ++++++++++++++++++++++++++------- STranslate/MainWindow.xaml.cs | 8 +- STranslate/STranslate.csproj | 3 + STranslate/ViewModel/MainVM.cs | 7 + 5 files changed, 306 insertions(+), 81 deletions(-) create mode 100644 STranslate/Images/iconfont.ttf diff --git a/STranslate/Images/iconfont.ttf b/STranslate/Images/iconfont.ttf new file mode 100644 index 0000000000000000000000000000000000000000..abfa740163b26fee883541f27dacd004ba69d5f3 GIT binary patch literal 3684 zcmd^CU2Gf25uUjtk35n`N<5O1sMzL@L?X3KNwiEdk*!!wEC)#n8*%Es6p1K_`mrgJ zpeWZ45LiZlqG@Bqb@CA8p;i;Wv@dlKv`E#aRbm6}LxBcG)4wFOiULf9Hf>PAFM&k% z+q;uw$wG}j_l~>!&FswV+|1nWk(h|wG*2@19y|HvFGjxA{VWmZz$x3;) z_S^mQLqys#<}VU_m*<=F^i>wRTzb8KF) zv3wDR>qFx##>5<_lo+58CUn^0VO!MaaotTT$lX=)T zXBcu~mce0CEUwK)e3|Tc))%B-f%lR*^4}@V(3Hq7gS*3ZV&dpHE!Amd(TE4hA0ayC zN}JM>SnysAB3K{QK(x;k=huu_5WNDfh{`^Uhy?gHngZ>o7I36G)pynJuV?F5R_
Y)xOn#fpvm)S&y>i3&X z)KxueHbj%^SIj1Ad{{5*c#Z)2cqdgKFo1FdIu+yZS7C7zM+(XR46FD z77jKJ2g6=PwQEB|kz6#Ii|`GMkNvEXi)3T5Y=m$256jV<0?Ax3ygS4#Do89AUfBcUwSy5abU+WdahYPZX-3wV~C7yJ%BbH2L z`{4tA$WL~V2c&eUE#zZ35W+7Ql5OtR>$%+ZR=3LD!FDOgYO=#=>u9-lt);`}>`1B{ zklP2n%o&Xvr}+D8e+?|3ve%t}W=2?)PeFOPb%WEnHN+exK9n^Ly2I*XCmb@%TWD zpZ5Cw-p1?UL?SF*?CkFDjB2{BMKBc`;1OM0f<5+Ytm#)ZJul{#JON$v`q!>v1{Osp z2O+=q9y&d&!_c5GwDw*&0TSy-gXqM2*SsYE8#UsiJ(R@D8chkWHy%cWpfwO`iy9A; zh})yVcq?xC<<&nWbGf9PK)?EycosP!`n4B%>4zuZo@LB+Cm(nqx%y!eZ>FxTeux0T zYq?v~7ancI`D4_maemoYS}@k{p@--=Jws)>Krhi%`T_l%eoeRNU)1C_q7FuGqUj9$ z6G2zld?`14?FNm!88kAhbjM8^sR#+$v5k&yqmej6e_ejN{()`s_oDw-{d@V74I0I@ z?xUzt>_+KOA}r5~T3JOezrA`{w%cX7g1+%i!ywoo4)=${E1C(=XZpg%uRHM zyEJgCDc74fqQdw&UwPZD9rc!xna77d~oX zH!N1L6R}Oj3JH4N!i+Ds?^#$PFa6lUGWfr+unqY47Pez=|HQ%y_-ht+(J9s}?4|^d zJzOp1YlZR1==sR>Sh+M&F4fk@CkvBv#e8+0Tpv#rs5&fW@gV$ zrfao{$V9a~6B&lRLa|tmRI26Eg|S*{s#dE!*wZ7{5&YCxd4?XQDitVCHT2^Yp;0=I zewxOx`ITtG=xcY;PeOW<=BNnG>Rq$jwNF91O0$p?HY3zWDf}haE_Do2B|~z%H?wpW ztEJ&%4IV|%s<1QzG;H}-fG0)Z2ofmfPQ%U^q*FLxg;s?gq#oSs&$BL{GM;lr{An;R z@!w^qOJ#{=wy~WRcCeFGc9H$ubiSCkPs}|#HLcX<#-~e@o@${uT{v6VKQUJ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -38,14 +279,28 @@ - @@ -56,15 +311,14 @@ - - + + SelectedItem="{Binding InputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> @@ -138,8 +386,7 @@ @@ -149,67 +396,35 @@ BorderBrush="{x:Null}" BorderThickness="0" IsReadOnly="True" - Margin="5,5,5,30" + Margin="10,10,5,35" MaxHeight="400" FontSize="16" TextWrapping="Wrap" VerticalContentAlignment="Top" HorizontalScrollBarVisibility="Disabled" - VerticalScrollBarVisibility="Auto" + VerticalScrollBarVisibility="Hidden" Text="{Binding OutputTxt}"/> - + Command="{Binding CopyResultCmd}"/> - - - - - + Command="{Binding CopyLargeHumpResultCmd}"/> diff --git a/STranslate/MainWindow.xaml.cs b/STranslate/MainWindow.xaml.cs index d9573a7..550fb29 100644 --- a/STranslate/MainWindow.xaml.cs +++ b/STranslate/MainWindow.xaml.cs @@ -88,7 +88,7 @@ namespace STranslate this.Hide(); //取消置顶 - this.TopImg.Source = UnLockImgPath; + vm.TopImgSource = UnLockImgPath; } //置顶 Ctrl+Shift+T if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) @@ -159,7 +159,7 @@ namespace STranslate /// private void Window_Deactivated(object sender, EventArgs e) { - if (this.TopImg.Source == UnLockImgPath) + if (vm.TopImgSource == UnLockImgPath) { this.Hide(); } @@ -244,7 +244,7 @@ namespace STranslate /// private void Top_Click(object sender, RoutedEventArgs e) { - this.TopImg.Source = TopImg.Source == LockImgPath ? UnLockImgPath : LockImgPath; + vm.TopImgSource = vm.TopImgSource == LockImgPath ? UnLockImgPath : LockImgPath; } /// /// 退出 @@ -259,7 +259,7 @@ namespace STranslate } private void InitView() { - this.TopImg.Source = UnLockImgPath; + vm.TopImgSource = UnLockImgPath; this.Activate(); this.TextBoxInput.Focus(); diff --git a/STranslate/STranslate.csproj b/STranslate/STranslate.csproj index eff20bd..2d58541 100644 --- a/STranslate/STranslate.csproj +++ b/STranslate/STranslate.csproj @@ -125,6 +125,9 @@ ResXFileCodeGenerator Resources.Designer.cs + + PreserveNewest + SettingsSingleFileGenerator diff --git a/STranslate/ViewModel/MainVM.cs b/STranslate/ViewModel/MainVM.cs index 2a456b4..58b0db5 100644 --- a/STranslate/ViewModel/MainVM.cs +++ b/STranslate/ViewModel/MainVM.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; +using System.Windows.Media.Imaging; namespace STranslate.ViewModel { @@ -213,6 +214,12 @@ namespace STranslate.ViewModel private string _LargeHumpRet; public string LargeHumpRet { get => _LargeHumpRet; set => UpdateProperty(ref _LargeHumpRet, value); } + /// + /// 置顶图标 + /// + private BitmapImage _TopImgSource; + public BitmapImage TopImgSource { get => _TopImgSource; set => UpdateProperty(ref _TopImgSource, value); } + private string _InputTxt; public string InputTxt { get => _InputTxt; set => UpdateProperty(ref _InputTxt, value); }