Update 3
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
21
MainForm.Designer.cs
generated
21
MainForm.Designer.cs
generated
@@ -32,8 +32,8 @@
|
|||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
||||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
this.toggleHotkeyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.showToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.showToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toggleHotkeyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.contextMenuStrip1.SuspendLayout();
|
this.contextMenuStrip1.SuspendLayout();
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
|
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
|
||||||
this.notifyIcon1.Text = "notifyIcon1";
|
this.notifyIcon1.Text = "notifyIcon1";
|
||||||
this.notifyIcon1.Visible = true;
|
this.notifyIcon1.Visible = true;
|
||||||
this.notifyIcon1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick);
|
this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick);
|
||||||
//
|
//
|
||||||
// contextMenuStrip1
|
// contextMenuStrip1
|
||||||
//
|
//
|
||||||
@@ -55,14 +55,7 @@
|
|||||||
this.toolStripSeparator1,
|
this.toolStripSeparator1,
|
||||||
this.exitToolStripMenuItem});
|
this.exitToolStripMenuItem});
|
||||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
this.contextMenuStrip1.Size = new System.Drawing.Size(222, 98);
|
this.contextMenuStrip1.Size = new System.Drawing.Size(222, 76);
|
||||||
//
|
|
||||||
// toggleHotkeyToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.toggleHotkeyToolStripMenuItem.Name = "toggleHotkeyToolStripMenuItem";
|
|
||||||
this.toggleHotkeyToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
|
||||||
this.toggleHotkeyToolStripMenuItem.Text = "Disable Print Screen capture";
|
|
||||||
this.toggleHotkeyToolStripMenuItem.Click += new System.EventHandler(this.toggleHotkeyToolStripMenuItem_Click);
|
|
||||||
//
|
//
|
||||||
// showToolStripMenuItem
|
// showToolStripMenuItem
|
||||||
//
|
//
|
||||||
@@ -71,6 +64,13 @@
|
|||||||
this.showToolStripMenuItem.Text = "Show in Taskbar";
|
this.showToolStripMenuItem.Text = "Show in Taskbar";
|
||||||
this.showToolStripMenuItem.Click += new System.EventHandler(this.showToolStripMenuItem_Click);
|
this.showToolStripMenuItem.Click += new System.EventHandler(this.showToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// toggleHotkeyToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.toggleHotkeyToolStripMenuItem.Name = "toggleHotkeyToolStripMenuItem";
|
||||||
|
this.toggleHotkeyToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
||||||
|
this.toggleHotkeyToolStripMenuItem.Text = "Disable Print Screen capture";
|
||||||
|
this.toggleHotkeyToolStripMenuItem.Click += new System.EventHandler(this.toggleHotkeyToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// toolStripSeparator1
|
// toolStripSeparator1
|
||||||
//
|
//
|
||||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
@@ -92,6 +92,7 @@
|
|||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.Text = "MainForm";
|
this.Text = "MainForm";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||||
|
this.Resize += new System.EventHandler(this.MainForm_Resize);
|
||||||
this.contextMenuStrip1.ResumeLayout(false);
|
this.contextMenuStrip1.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
|||||||
37
MainForm.cs
37
MainForm.cs
@@ -114,29 +114,58 @@ namespace ScreenCaptureApp
|
|||||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
UnregisterHotKey(this.Handle, PRINT_SCREEN_ID);
|
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;
|
if (e.Button == MouseButtons.Right)
|
||||||
this.ShowInTaskbar = true;
|
{
|
||||||
|
// Показываем контекстное меню
|
||||||
|
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)
|
private void showToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.WindowState = FormWindowState.Normal;
|
this.WindowState = FormWindowState.Normal;
|
||||||
this.ShowInTaskbar = true;
|
this.ShowInTaskbar = true;
|
||||||
|
this.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
notifyIcon1.Visible = false;
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleHotkeyToolStripMenuItem_Click(object sender, EventArgs e)
|
private void toggleHotkeyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
captureOnKeyPress = !captureOnKeyPress;
|
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