Skip to content

Commit e15a7b1

Browse files
committed
加入手动处理的自动保留开关
1 parent 658f3cb commit e15a7b1

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Manual.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</mah:MetroWindow.RightWindowCommands>
2222

2323
<Grid>
24-
<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" />
24+
<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" />
2525
<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" />
2626
<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" />
2727
</Grid>

Manual.xaml.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Text;
44
using System.Text.RegularExpressions;
55
using System.Windows;
6+
using System.Windows.Input;
67
using System.Windows.Media;
78

89
namespace CopyPlusPlus
@@ -12,7 +13,13 @@ namespace CopyPlusPlus
1213
/// </summary>
1314
public partial class Manual
1415
{
16+
//Get MainWindow
17+
private readonly MainWindow _mainWindow =
18+
Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;
19+
20+
// 如果正在处理中,再次点击按钮,直接返回
1521
private bool _lineStatus;
22+
1623
private bool _spaceStatus;
1724
private bool _widthStatus;
1825

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

4351
// 去除换行
4452
try
@@ -117,5 +125,14 @@ private void Manual_OnClosed(object sender, EventArgs e)
117125
mainWindow.Show();
118126
mainWindow.GlobalSwitch = true;
119127
}
128+
129+
private void OnMergeRight(object sender, MouseButtonEventArgs e)
130+
{
131+
var remain = new RemainOriginal
132+
{
133+
Owner = this
134+
};
135+
remain.Show();
136+
}
120137
}
121138
}

0 commit comments

Comments
 (0)