Skip to content

Commit

Permalink
publish v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Surbowl committed Feb 12, 2021
1 parent 7fd2985 commit 39ee2f4
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 21 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@


## Download
- [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)
- 添加切换窗体透明度的快捷键 Ctrl+Q
- [v1.0.3_win_x86](https://github.com/Surbowl/Oh-Subtitle/raw/master/publish/Oh-Subtitle_v1.0.3_win_x86.zip)
Expand Down
Binary file added publish/Oh-Subtitle_v1.0.5_win_x86.zip
Binary file not shown.
26 changes: 26 additions & 0 deletions src/Helpers/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Text.RegularExpressions;

namespace OhSubtitle.Helpers
{
/// <summary>
/// 字符串拓展方法
/// </summary>
public static class StringExtensions
{
/// <summary>
/// 判断是否是单个英文单词
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool IsAEnglishWord(this string str)
{
str = str.Trim();
if (str.Length > 45)
{
return false;
}

return new Regex(@"^([a-zA-Z]|-|\.|·|')+$").Match(str).Success;
}
}
}
10 changes: 10 additions & 0 deletions src/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@
<fa:ImageAwesome x:Name="imgEye" Icon="Eye" Margin="0,0,2,0" Width="14" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Column="3" Foreground="FloralWhite"/>
</Grid>
</Grid>
<Window.ContextMenu>
<ContextMenu Name="menu">
<MenuItem Name="menuColorWhite" Header="亮白 White" IsCheckable="True" Checked="MenuColorWhite_Checked"></MenuItem>
<MenuItem Name="menuColorLightGray" Header="亮灰 LightGray" IsCheckable="True" Checked="MenuColorLightGray_Checked"></MenuItem>
<MenuItem Name="menuColorDimGray" Header="暗灰 DimGray" IsCheckable="True" Checked="MenuColorDimGray_Checked"></MenuItem>
<MenuItem Name="menuColorBlack" Header="暗黑 Black" IsCheckable="True" Checked="MenuColorBlack_Checked" IsChecked="True"></MenuItem>
<Separator />
<MenuItem Name="menuExit" Header="退出 Exit" Click="MenuExit_Click"></MenuItem>
</ContextMenu>
</Window.ContextMenu>
</Window>
97 changes: 79 additions & 18 deletions src/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
using OhSubtitle.Services.Interfaces;
using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Threading;

namespace OhSubtitle
Expand Down Expand Up @@ -171,6 +171,7 @@ private void ImgReset_MouseDown(object sender, MouseButtonEventArgs e)
/// <param name="e"></param>
private void ImgClose_MouseDown(object sender, MouseButtonEventArgs e)
{
_isExit = true;
Application.Current.Shutdown();
}

Expand All @@ -196,6 +197,82 @@ private void GridEye_MouseLeave(object sender, MouseEventArgs e)
Opacity = 1;
}

/// <summary>
/// 右键菜单
/// 退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuExit_Click(object sender, RoutedEventArgs e)
{
_isExit = true;
Application.Current.Shutdown();
}

/// <summary>
/// 右键菜单
/// 亮白
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuColorWhite_Checked(object sender, RoutedEventArgs e)
{
menuColorLightGray.IsChecked = false;
menuColorDimGray.IsChecked = false;
menuColorBlack.IsChecked = false;
Background = txtInput.Background = Brushes.White;
txtInput.Foreground = txtResult.Foreground = Brushes.Black;
imgLoading.Foreground = imgReset.Foreground = imgEye.Foreground = imgClose.Foreground = Brushes.Black;
}

/// <summary>
/// 右键菜单
/// 亮灰
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuColorLightGray_Checked(object sender, RoutedEventArgs e)
{
menuColorWhite.IsChecked = false;
menuColorDimGray.IsChecked = false;
menuColorBlack.IsChecked = false;
Background = txtInput.Background = Brushes.LightGray;
txtInput.Foreground = txtResult.Foreground = Brushes.Black;
imgLoading.Foreground = imgReset.Foreground = imgEye.Foreground = imgClose.Foreground = Brushes.Black;
}

/// <summary>
/// 右键菜单
/// 暗灰
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuColorDimGray_Checked(object sender, RoutedEventArgs e)
{
menuColorWhite.IsChecked = false;
menuColorLightGray.IsChecked = false;
menuColorBlack.IsChecked = false;
Background = txtInput.Background = Brushes.DimGray;
txtInput.Foreground = txtResult.Foreground = Brushes.White;
imgLoading.Foreground = imgReset.Foreground = imgEye.Foreground = imgClose.Foreground = Brushes.White;
}

/// <summary>
/// 右键菜单
/// 暗黑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuColorBlack_Checked(object sender, RoutedEventArgs e)
{
menuColorWhite.IsChecked = false;
menuColorDimGray.IsChecked = false;
menuColorLightGray.IsChecked = false;
Background = txtInput.Background = Brushes.Black;
txtInput.Foreground = txtResult.Foreground = Brushes.FloralWhite;
imgLoading.Foreground = imgReset.Foreground = imgEye.Foreground = imgClose.Foreground = Brushes.FloralWhite;
}

/// <summary>
/// 快捷键
/// 切换窗体不透明度
Expand Down Expand Up @@ -233,7 +310,7 @@ private async void HandleTypingTimerTimeoutAsync(object sender, EventArgs e)
{
txtResult.Text = string.Empty;
}
else if (IsAEnglishWord(txtInput.Text))
else if (txtInput.Text.IsAEnglishWord())
{
var result = await _dictionaryService.QueryAsync(txtInput.Text);
if (string.IsNullOrEmpty(result))
Expand All @@ -254,21 +331,5 @@ private async void HandleTypingTimerTimeoutAsync(object sender, EventArgs e)
imgReset.Visibility = Visibility.Visible;
}
}

/// <summary>
/// 判断是否是单个英文单词
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private bool IsAEnglishWord(string str)
{
str = str.Trim();
if (str.Length > 45)
{
return false;
}

return new Regex(@"^([a-zA-Z]|-|\.|·|')+$").Match(str).Success;
}
}
}
6 changes: 3 additions & 3 deletions src/OhSubtitle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>https://github.com/Surbowl/Oh-Subtitle</PackageReleaseNotes>
<SignAssembly>false</SignAssembly>
<AssemblyVersion>1.0.4.0</AssemblyVersion>
<FileVersion>1.0.4.0</FileVersion>
<Version>1.0.4</Version>
<AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.5.0</FileVersion>
<Version>1.0.5</Version>
<Nullable>enable</Nullable>
<WarningsAsErrors>$(WarningsAsErrors);CS8600;CS8602;CS8603;CS8618;CS8625</WarningsAsErrors>
</PropertyGroup>
Expand Down

0 comments on commit 39ee2f4

Please sign in to comment.