diff --git a/README.md b/README.md index 521be76..b07edf3 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ ## Download +- [v1.1.0_win_x86](https://github.com/Surbowl/Oh-Subtitle/raw/master/publish/Oh-Subtitle_v1.1.0_win_x86.zip) + - 添加对日语的支持 + - 添加笔记本功能 + - 启动时自动还原上次的位置、大小、主题色和语言模式 - [v1.0.5_win_x86](https://github.com/Surbowl/Oh-Subtitle/raw/master/publish/Oh-Subtitle_v1.0.5_win_x86.zip) - 新增右键菜单,可选亮白、亮灰、暗灰、暗黑四种主题色 - [v1.0.4_win_x86](https://github.com/Surbowl/Oh-Subtitle/raw/master/publish/Oh-Subtitle_v1.0.4_win_x86.zip) diff --git a/publish/Oh-Subtitle_v1.1.0_win_x86.zip b/publish/Oh-Subtitle_v1.1.0_win_x86.zip new file mode 100644 index 0000000..607f575 Binary files /dev/null and b/publish/Oh-Subtitle_v1.1.0_win_x86.zip differ diff --git a/src/MainWindow.xaml b/src/MainWindow.xaml index 7b367cb..b8edb54 100644 --- a/src/MainWindow.xaml +++ b/src/MainWindow.xaml @@ -21,6 +21,8 @@ TextChanged="TxtInput_TextChanged"/> <fa:ImageAwesome x:Name="imgWriteNote" Icon="BookmarkOutline" Width="13" Height="13" Grid.Column="1" Margin="0,30,0,2" Foreground="FloralWhite" Visibility="Hidden" MouseDown="ImgWriteNote_MouseDown" Cursor="Hand" ToolTip="记笔记 WriteNote"/> + <fa:ImageAwesome x:Name="imgNoteWrote" Icon="Bookmark" Width="13" Height="13" Grid.Column="1" Margin="0,30,0,2" Foreground="FloralWhite" Visibility="Hidden" + ToolTip="笔记已添加到文件:我的笔记MyNote.csv"/> <fa:ImageAwesome x:Name="imgReset" Icon="TrashOutline" Height="14" Width="14" Grid.Column="1" Margin="0,2,0,20" Foreground="FloralWhite" Visibility="Hidden" MouseDown="ImgReset_MouseDown" Cursor="Hand" ToolTip="清空输入框 ClearInput"/> <fa:ImageAwesome x:Name="imgLoading" Icon="Refresh" Spin="True" Height="14" Width="14" Grid.Column="1" Foreground="FloralWhite" Visibility="Hidden"/> diff --git a/src/MainWindow.xaml.cs b/src/MainWindow.xaml.cs index 24bde91..25d8870 100644 --- a/src/MainWindow.xaml.cs +++ b/src/MainWindow.xaml.cs @@ -304,7 +304,7 @@ private void SetWindowColor(Brush background, Brush foreground) { Background = txtInput.Background = background; txtInput.Foreground = txtResult.Foreground = foreground; - imgLoading.Foreground = imgReset.Foreground = imgWriteNote.Foreground = imgEye.Foreground = imgClose.Foreground = foreground; + imgLoading.Foreground = imgReset.Foreground = imgWriteNote.Foreground = imgNoteWrote.Foreground = imgEye.Foreground = imgClose.Foreground = foreground; } #endregion WindowEvent & Action 窗体事件与方法 @@ -367,10 +367,16 @@ private async void ImgWriteNote_MouseDown(object sender, MouseButtonEventArgs e) { try { + imgWriteNote.Visibility = Visibility.Hidden; + imgNoteWrote.Visibility = Visibility.Visible; + await _noteService.WriteAsync(txtInput.Text, txtResult.Text); } catch { + imgWriteNote.Visibility = Visibility.Visible; + imgNoteWrote.Visibility = Visibility.Hidden; + txtInput.Text = "笔记记录失败,可能是因为文件被占用或没有写入文件的权限。如果您已打开笔记文件,请将其关闭后再记录笔记;如果依然无法记录笔记,请尝试使用系统管理员权限启动本应用。"; } } @@ -505,6 +511,7 @@ private void TxtInput_TextChanged(object sender, TextChangedEventArgs e) private async void HandleTypingTimerTimeoutAsync(object sender, EventArgs e) { imgWriteNote.Visibility = Visibility.Hidden; + imgNoteWrote.Visibility = Visibility.Hidden; imgReset.Visibility = Visibility.Hidden; imgLoading.Visibility = Visibility.Visible; diff --git a/src/Services/CsvFileNoteService.cs b/src/Services/CsvFileNoteService.cs index 6373e8e..1134bbf 100644 --- a/src/Services/CsvFileNoteService.cs +++ b/src/Services/CsvFileNoteService.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -13,7 +14,7 @@ public class CsvFileNoteService : INoteService /// <summary> /// 表头 /// </summary> - const string TableHeader = "原文,翻译"; + const string TableHeader = "时间,原文,翻译"; /// <summary> /// 笔记文件名 @@ -69,8 +70,8 @@ public async Task WriteAsync(string orig, string translated, CancellationToken c translated = translated.Replace('\n', ' ') .Replace(',', ','); - string appendText = File.Exists(FullFilePath) ? $"\n{orig},{translated}" - : $"{TableHeader}\n{orig},{translated}"; + string appendText = File.Exists(FullFilePath) ? $"\n{DateTime.Now:yyyy-MM-dd HH:mm},{orig},{translated}" + : $"{TableHeader}\n{DateTime.Now:yyyy-MM-dd HH:mm},{orig},{translated}"; if (cancellationToken.IsCancellationRequested) { return;