Skip to content

Commit

Permalink
优化界面,完善逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-luke committed Jan 6, 2022
1 parent feaa1f8 commit d89cd66
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
4 changes: 2 additions & 2 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<!--<TextBlock x:Name="TextAbstract2" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="22,30,0,0" FontSize="13" Width="403"><Run Text="2. 快捷键触发" /></TextBlock>-->
<mah:ToggleSwitch x:Name="SwitchSelectText" MinWidth="0" ContentDirection="LeftToRight" Content="划词 " FontWeight="Bold" ContentPadding="0,0,-10,0" FontFamily="Microsoft YaHei UI" Margin="35,0,0,0" IsOn="True" />
<mah:ToggleSwitch x:Name="SwitchShortcut" MinWidth="0" ContentDirection="LeftToRight" Content="Control+C+C " FontWeight="Bold" ContentPadding="0,0,-10,0" FontFamily="Microsoft YaHei UI" IsOn="True" Margin="156,0,0,0" />
<Button Content="手动处理" HorizontalAlignment="Left" Margin="338,0,0,0" VerticalAlignment="Center" FontFamily="Microsoft YaHei UI" Click="ManualBtn_Click" Height="20" Width="80" />
<Button Content="手动处理" HorizontalAlignment="Left" Margin="344,0,0,0" VerticalAlignment="Center" FontFamily="Microsoft YaHei UI" Click="ManualBtn_Click" Height="26" Width="66" Style="{DynamicResource MahApps.Styles.Button.Flat}" Padding="10,3,10,3" FontSize="11" />

<!--<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="16,46,0,0" FontSize="13" Width="187" Text="祝君创作顺利,走向人生巅峰!" />-->
</Grid>
Expand Down Expand Up @@ -82,7 +82,7 @@
IsEnabled="False" Toggled="SwitchManyPopups_OnToggled" />
<!--<mah:ToggleSwitch x:Name="SwitchDictionary" MinWidth="0" ContentDirection="LeftToRight" Content="单词词典" FontWeight="Bold" ContentPadding="0,0,-10,0" FontFamily="Microsoft YaHei UI" VerticalAlignment="Top" Margin="229,65,0,0" IsEnabled="False" Toggled="SwitchManyPopups_OnToggled" />-->
<Button x:Name="AddReplace" FontFamily="Microsoft YaHei UI" Content="自定义替换字符" HorizontalAlignment="Left"
Margin="239,68,0,0" VerticalAlignment="Top" Width="82" Click="DiyReplace" />
Margin="235,68,0,0" VerticalAlignment="Top" Width="92" Click="DiyReplace" Style="{DynamicResource MahApps.Styles.Button.Flat}" FontSize="11" Padding="5,5,5,5" />

<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="338,9,0,0" FontWeight="Bold"
FontSize="11" FontFamily="Microsoft YaHei UI">
Expand Down
9 changes: 6 additions & 3 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public MainWindow()

private async void AfterKeySequence()
{
if(!GlobalSwitch) return;

if (SwitchShortcut.IsOn == false) return;

await Task.Delay(50);
Expand Down Expand Up @@ -204,8 +206,6 @@ private async void OnMouseDragFinished(object sender, MouseEventArgs e)

public void ProcessText(string text)
{
if (!GlobalSwitch) return;

// 去掉 CAJ viewer 造成的莫名的空格符号
text = text.Replace("", "");

Expand Down Expand Up @@ -575,7 +575,7 @@ private void MainWindow_Closed(object sender, EventArgs e)
private void MainWindow_OnStateChanged(object sender, EventArgs e)
{
if (WindowState != WindowState.Minimized) return;
NotifyIcon.Visibility = Visibility.Visible;
//NotifyIcon.Visibility = Visibility.Visible;
NotifyIcon.ShowBalloonTip("Copy++", "软件已最小化至托盘,点击图标显示主界面,右键可退出", BalloonIcon.Info);

Hide();
Expand Down Expand Up @@ -684,6 +684,9 @@ private void SwitchAutoStart_OnToggled(object sender, RoutedEventArgs e)

private void ManualBtn_Click(object sender, RoutedEventArgs e)
{
Hide();
GlobalSwitch = false;

var manual = new Manual();
manual.Show();
}
Expand Down
14 changes: 7 additions & 7 deletions Manual.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
mc:Ignorable="d"
Title="" Height="152" Width="108" WindowStyle="SingleBorderWindow" Topmost="True"
WindowStartupLocation="CenterScreen" ResizeMode="NoResize" ShowInTaskbar="False"
Closed="Manual_OnClosed"
WindowTransitionsEnabled="False"

NonActiveWindowTitleBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
WindowTitleBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}">
WindowTitleBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" TitleBarHeight="25">
<mah:MetroWindow.RightWindowCommands>
<mah:WindowCommands>
<Button x:Name="Pin" Click="PinSwitch" Background="#FFF6F2F2">
<mah:WindowCommands FontSize="10">
<Button x:Name="Pin" Click="PinSwitch" Background="#FFFFFEFF">
<wpf:TextBlock Text="📌" />
</Button>
</mah:WindowCommands>
</mah:MetroWindow.RightWindowCommands>

<Grid>
<Button Content="合并换行" Margin="15,10,15,0" FontFamily="Microsoft YaHei UI" Click="MergeLineBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.MetroSquare.Accent}" />
<Button Content="合并空格" Margin="15,45,15,0" FontFamily="Microsoft YaHei UI" Click="MergeSpacesBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Flat}" />
<Button Content="全角转半" Margin="15,80,15,0" FontFamily="Microsoft YaHei UI" Click="WidthBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Flat}" />
<Button Content="合并换行" Margin="15,10,15,0" FontFamily="Microsoft YaHei UI" Click="MergeLineBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Square.Accent}" BorderBrush="{x:Null}" Height="29" />
<Button Content="合并空格" Margin="15,48,15,0" FontFamily="Microsoft YaHei UI" Click="MergeSpacesBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Square.Accent}" BorderBrush="{x:Null}" Height="29" />
<Button Content="全角转半" Margin="15,85,15,0" FontFamily="Microsoft YaHei UI" Click="WidthBtn_Click" VerticalAlignment="Top" Style="{DynamicResource MahApps.Styles.Button.Square.Accent}" BorderBrush="{x:Null}" Height="30" />
</Grid>
</mah:MetroWindow>
21 changes: 17 additions & 4 deletions Manual.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Text;
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Media;
Expand Down Expand Up @@ -91,7 +93,8 @@ private void WidthBtn_Click(object sender, RoutedEventArgs e)
if (_widthStatus) return;
_widthStatus = true;

if (Clipboard.ContainsText()) Clipboard.SetDataObject(Clipboard.GetText().Normalize(NormalizationForm.FormKC));
if (Clipboard.ContainsText())
Clipboard.SetDataObject(Clipboard.GetText().Normalize(NormalizationForm.FormKC));

_widthStatus = false;
}
Expand All @@ -100,9 +103,19 @@ private void PinSwitch(object sender, RoutedEventArgs e)
{
Topmost = !Topmost;
var converter = new BrushConverter();
Pin.Background = Pin.Background.ToString() == "#FFF6F2F2"
Pin.Background = Pin.Background.ToString() == "#FFFFFEFF"
? (Brush)converter.ConvertFromString("#00F6F2F2")
: (Brush)converter.ConvertFromString("#FFF6F2F2");
: (Brush)converter.ConvertFromString("#FFFFFEFF");
}

private void Manual_OnClosed(object sender, EventArgs e)
{
//Get MainWindow
if (!(Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) is
MainWindow mainWindow)) return;

mainWindow.Show();
mainWindow.GlobalSwitch = true;
}
}
}
2 changes: 1 addition & 1 deletion TranslateResult.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</mah:MetroWindow.IconTemplate>
<mah:MetroWindow.RightWindowCommands>
<mah:WindowCommands>
<Button x:Name="Pin" Click="PinSwitch" Background="#FFF6F2F2">
<Button x:Name="Pin" Click="PinSwitch" Background="#FFFFFEFF">
<wpf:TextBlock Text="📌" />
</Button>
</mah:WindowCommands>
Expand Down
4 changes: 2 additions & 2 deletions TranslateResult.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ private void PinSwitch(object sender, RoutedEventArgs e)
{
Topmost = !Topmost;
var converter = new BrushConverter();
Pin.Background = Pin.Background.ToString() == "#FFF6F2F2"
Pin.Background = Pin.Background.ToString() == "#FFFFFEFF"
? (Brush)converter.ConvertFromString("#00F6F2F2")
: (Brush)converter.ConvertFromString("#FFF6F2F2");
: (Brush)converter.ConvertFromString("#FFFFFEFF");
}
}
}

0 comments on commit d89cd66

Please sign in to comment.