Skip to content

Commit

Permalink
加入手动处理的自动保留开关
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-luke committed Jan 14, 2022
1 parent 658f3cb commit e15a7b1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Manual.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</mah:MetroWindow.RightWindowCommands>

<Grid>
<Button Content="合 并 换 行" Margin="12,10,12,0" FontFamily="Microsoft YaHei UI" FontSize="14" Click="MergeLineBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Square.Accent}" BorderBrush="{x:Null}" Height="32" Padding="1,2,1,2" UseLayoutRounding="True" FontWeight="Bold" />
<Button Content="合 并 换 行" Margin="12,10,12,0" FontFamily="Microsoft YaHei UI" FontSize="14" Click="MergeLineBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Square.Accent}" BorderBrush="{x:Null}" Height="32" Padding="1,2,1,2" UseLayoutRounding="True" FontWeight="Bold" MouseRightButtonUp="OnMergeRight" />
<Button Content="合 并 空 格" Margin="12,46,12,0" FontFamily="Microsoft YaHei UI" FontSize="14" Click="MergeSpacesBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Square.Accent}" BorderBrush="{x:Null}" Height="32" Padding="1,2,1,2" UseLayoutRounding="True" FontWeight="Bold" />
<Button Content="全 角 转 半" Margin="12,82,12,0" FontFamily="Microsoft YaHei UI" FontSize="14" Click="WidthBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Square.Accent}" BorderBrush="{x:Null}" Height="32" Padding="1,2,1,2" UseLayoutRounding="True" FontWeight="Bold" />
</Grid>
Expand Down
19 changes: 18 additions & 1 deletion Manual.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace CopyPlusPlus
Expand All @@ -12,7 +13,13 @@ namespace CopyPlusPlus
/// </summary>
public partial class Manual
{
//Get MainWindow
private readonly MainWindow _mainWindow =
Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;

// 如果正在处理中,再次点击按钮,直接返回
private bool _lineStatus;

private bool _spaceStatus;
private bool _widthStatus;

Expand All @@ -38,7 +45,8 @@ private void MergeLineBtn_Click(object sender, RoutedEventArgs e)
if (text[counter + 1] == '\r')
{
// 如果检测到句号结尾,则不去掉换行
if (text[counter] == '。') continue;
if (text[counter] == '。' && _mainWindow.RemainChinese) continue;
if (text[counter] == '.' && _mainWindow.RemainEnglish) continue;

// 去除换行
try
Expand Down Expand Up @@ -117,5 +125,14 @@ private void Manual_OnClosed(object sender, EventArgs e)
mainWindow.Show();
mainWindow.GlobalSwitch = true;
}

private void OnMergeRight(object sender, MouseButtonEventArgs e)
{
var remain = new RemainOriginal
{
Owner = this
};
remain.Show();
}
}
}

0 comments on commit e15a7b1

Please sign in to comment.