Update 3
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
37
MainForm.cs
37
MainForm.cs
@@ -114,29 +114,58 @@ namespace ScreenCaptureApp
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
UnregisterHotKey(this.Handle, PRINT_SCREEN_ID);
|
||||
notifyIcon1.Visible = false;
|
||||
notifyIcon1.Dispose();
|
||||
}
|
||||
|
||||
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
this.ShowInTaskbar = true;
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
// Показываем контекстное меню
|
||||
MethodInvoker mi = new MethodInvoker(() => {
|
||||
notifyIcon1.ContextMenuStrip.Show(Cursor.Position);
|
||||
});
|
||||
this.BeginInvoke(mi);
|
||||
}
|
||||
else if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
// Левый клик - показываем основное окно
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
this.ShowInTaskbar = true;
|
||||
this.Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void showToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
this.ShowInTaskbar = true;
|
||||
this.Show();
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
notifyIcon1.Visible = false;
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void toggleHotkeyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
captureOnKeyPress = !captureOnKeyPress;
|
||||
toggleHotkeyToolStripMenuItem.Text = captureOnKeyPress ? "Disable Print Screen capture" : "Enable Print Screen capture";
|
||||
var item = (ToolStripMenuItem)sender;
|
||||
item.Text = captureOnKeyPress ? "Disable Print Screen capture" : "Enable Print Screen capture";
|
||||
notifyIcon1.ShowBalloonTip(1000, "Screen Capture",
|
||||
captureOnKeyPress ? "Print Screen capture enabled" : "Print Screen capture disabled",
|
||||
ToolTipIcon.Info);
|
||||
}
|
||||
|
||||
private void MainForm_Resize(object sender, EventArgs e)
|
||||
{
|
||||
if (this.WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
this.ShowInTaskbar = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user