mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Add right click actions to tray icon
This commit is contained in:
@@ -53,10 +53,21 @@ namespace DesktopMagic
|
||||
try
|
||||
{
|
||||
Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/DesktopMagic;component/icon.ico")).Stream;
|
||||
notifyIcon.Click += TaskbarIcon_TrayLeftClick;
|
||||
notifyIcon.MouseClick += NotifyIcon_MouseClick;
|
||||
notifyIcon.Visible = true;
|
||||
notifyIcon.Text = App.AppName;
|
||||
notifyIcon.Icon = new System.Drawing.Icon(iconStream);
|
||||
notifyIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip()
|
||||
{
|
||||
Items =
|
||||
{
|
||||
new System.Windows.Forms.ToolStripMenuItem("Open", null, (s, e) => RestoreWindow()),
|
||||
new System.Windows.Forms.ToolStripMenuItem("Toggle Edit Mode", null, (s, e) => { EditCheckBox.IsChecked = !EditCheckBox.IsChecked; EditCheckBox_Click(null, null); }),
|
||||
new System.Windows.Forms.ToolStripMenuItem("Plugin Manager", null, (s, e) => PluginManagerButton_Click(null!, null!)),
|
||||
new System.Windows.Forms.ToolStripMenuItem("GitHub", null, (s, e) => GitHubButton_Click(null!, null!)),
|
||||
new System.Windows.Forms.ToolStripMenuItem("Exit", null, (s, e) => Close()),
|
||||
}
|
||||
};
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
@@ -569,6 +580,7 @@ namespace DesktopMagic
|
||||
}
|
||||
|
||||
EditCheckBox.IsChecked = false;
|
||||
EditCheckBox_Click(null, null);
|
||||
blockWindowsClosing = true;
|
||||
Windows.Clear();
|
||||
WindowNames.Clear();
|
||||
@@ -634,10 +646,13 @@ namespace DesktopMagic
|
||||
LoadLayout(false);
|
||||
}
|
||||
|
||||
private void TaskbarIcon_TrayLeftClick(object? sender, EventArgs e)
|
||||
private void NotifyIcon_MouseClick(object? sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
||||
{
|
||||
RestoreWindow();
|
||||
}
|
||||
}
|
||||
|
||||
private void GitHubButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user