fasdfsa commited on
Commit
263e434
·
1 Parent(s): 10fabc0

托盘右键菜单

Browse files
Files changed (1) hide show
  1. src/WpfEditor/TreeMenuPage.xaml.cs +19 -1
src/WpfEditor/TreeMenuPage.xaml.cs CHANGED
@@ -29,6 +29,8 @@ namespace WpfEditor
29
  // 添加点击其他区域隐藏菜单的事件
30
  this.MouseDown += TreeMenuPage_MouseDown;
31
 
 
 
32
  GlobalHotKey.RegisterHotKey("Alt + S", () => {
33
 
34
  if (ScreenGrabber.IsCapturing) return;
@@ -60,7 +62,23 @@ namespace WpfEditor
60
  _notifyIcon = new NotifyIcon();
61
  _notifyIcon.Icon = new Icon("ico.ico");
62
  _notifyIcon.Visible = true;
63
- _notifyIcon.Text = "树形菜单页面";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  _notifyIcon.DoubleClick += (s, args) =>
65
  {
66
  Show();
 
29
  // 添加点击其他区域隐藏菜单的事件
30
  this.MouseDown += TreeMenuPage_MouseDown;
31
 
32
+
33
+
34
  GlobalHotKey.RegisterHotKey("Alt + S", () => {
35
 
36
  if (ScreenGrabber.IsCapturing) return;
 
62
  _notifyIcon = new NotifyIcon();
63
  _notifyIcon.Icon = new Icon("ico.ico");
64
  _notifyIcon.Visible = true;
65
+ _notifyIcon.Text = "EchoDict";
66
+
67
+ var contextMenu = new ContextMenuStrip();
68
+ var exitMenuItem = new ToolStripMenuItem("退出");
69
+ exitMenuItem.Click += (s, e) => {
70
+ System.Windows.Application.Current.Shutdown();
71
+ };
72
+ var ocrMenuItem = new ToolStripMenuItem("Alt+S 截图OCR");
73
+ ocrMenuItem.Click += (s, e) => {
74
+ if (ScreenGrabber.IsCapturing) return;
75
+ ScreenGrabber.OnCaptured = async (bitmap, type) => await ScreenshotCallbackAsync(bitmap, type, null);
76
+ ScreenGrabber.Capture(true);
77
+ };
78
+ contextMenu.Items.Add(ocrMenuItem);
79
+ contextMenu.Items.Add(exitMenuItem);
80
+ _notifyIcon.ContextMenuStrip = contextMenu;
81
+
82
  _notifyIcon.DoubleClick += (s, args) =>
83
  {
84
  Show();