Update 2
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
72
MainForm.Designer.cs
generated
72
MainForm.Designer.cs
generated
@@ -28,35 +28,83 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.bigButton = new System.Windows.Forms.Button();
|
this.components = new System.ComponentModel.Container();
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
|
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(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.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.contextMenuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// bigButton
|
// notifyIcon1
|
||||||
//
|
//
|
||||||
this.bigButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
|
||||||
this.bigButton.Location = new System.Drawing.Point(12, 12);
|
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
|
||||||
this.bigButton.Name = "bigButton";
|
this.notifyIcon1.Text = "notifyIcon1";
|
||||||
this.bigButton.Size = new System.Drawing.Size(314, 163);
|
this.notifyIcon1.Visible = true;
|
||||||
this.bigButton.TabIndex = 2;
|
this.notifyIcon1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick);
|
||||||
this.bigButton.Text = "SHOOOOOT";
|
//
|
||||||
this.bigButton.UseVisualStyleBackColor = true;
|
// contextMenuStrip1
|
||||||
this.bigButton.Click += new System.EventHandler(this.btnCapture_Click);
|
//
|
||||||
|
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.showToolStripMenuItem,
|
||||||
|
this.toggleHotkeyToolStripMenuItem,
|
||||||
|
this.toolStripSeparator1,
|
||||||
|
this.exitToolStripMenuItem});
|
||||||
|
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
|
this.contextMenuStrip1.Size = new System.Drawing.Size(222, 98);
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
this.showToolStripMenuItem.Name = "showToolStripMenuItem";
|
||||||
|
this.showToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
||||||
|
this.showToolStripMenuItem.Text = "Show in Taskbar";
|
||||||
|
this.showToolStripMenuItem.Click += new System.EventHandler(this.showToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// toolStripSeparator1
|
||||||
|
//
|
||||||
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
|
this.toolStripSeparator1.Size = new System.Drawing.Size(218, 6);
|
||||||
|
//
|
||||||
|
// exitToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||||
|
this.exitToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
||||||
|
this.exitToolStripMenuItem.Text = "Exit";
|
||||||
|
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(339, 186);
|
this.ClientSize = new System.Drawing.Size(339, 186);
|
||||||
this.Controls.Add(this.bigButton);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.Text = "MainForm";
|
this.Text = "MainForm";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||||
|
this.contextMenuStrip1.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private System.Windows.Forms.Button bigButton;
|
|
||||||
|
private System.Windows.Forms.NotifyIcon notifyIcon1;
|
||||||
|
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem toggleHotkeyToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem showToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
67
MainForm.cs
67
MainForm.cs
@@ -1,24 +1,59 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace ScreenCaptureApp
|
namespace ScreenCaptureApp
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
|
// Импорт функции для регистрации горячих клавиш
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||||
|
|
||||||
|
private const int WM_HOTKEY = 0x0312;
|
||||||
|
private const int PRINT_SCREEN_ID = 1;
|
||||||
|
private bool captureOnKeyPress = true;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
RegisterHotkey();
|
||||||
|
this.WindowState = FormWindowState.Minimized;
|
||||||
|
this.ShowInTaskbar = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCapture_Click(object sender, EventArgs e)
|
private void RegisterHotkey()
|
||||||
|
{
|
||||||
|
// Регистрируем Print Screen (0x2C) без модификаторов (0x0)
|
||||||
|
if (!RegisterHotKey(this.Handle, PRINT_SCREEN_ID, 0x0, 0x2C))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Failed to register Print Screen hotkey", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void WndProc(ref Message m)
|
||||||
|
{
|
||||||
|
if (m.Msg == WM_HOTKEY && captureOnKeyPress)
|
||||||
|
{
|
||||||
|
if (m.WParam.ToInt32() == PRINT_SCREEN_ID)
|
||||||
|
{
|
||||||
|
CaptureScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
base.WndProc(ref m);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CaptureScreen()
|
||||||
{
|
{
|
||||||
this.Hide();
|
this.Hide();
|
||||||
using (var captureForm = new ScreenCaptureForm())
|
using (var captureForm = new ScreenCaptureForm())
|
||||||
{
|
{
|
||||||
if (captureForm.ShowDialog() == DialogResult.OK)
|
if (captureForm.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
// Добавляем кнопки для выбора действия
|
|
||||||
using (var resultForm = new ResultForm(captureForm.CapturedImage))
|
using (var resultForm = new ResultForm(captureForm.CapturedImage))
|
||||||
{
|
{
|
||||||
if (resultForm.ShowDialog() == DialogResult.OK)
|
if (resultForm.ShowDialog() == DialogResult.OK)
|
||||||
@@ -75,5 +110,33 @@ namespace ScreenCaptureApp
|
|||||||
default: return System.Drawing.Imaging.ImageFormat.Png;
|
default: return System.Drawing.Imaging.ImageFormat.Png;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
UnregisterHotKey(this.Handle, PRINT_SCREEN_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
this.WindowState = FormWindowState.Normal;
|
||||||
|
this.ShowInTaskbar = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.WindowState = FormWindowState.Normal;
|
||||||
|
this.ShowInTaskbar = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleHotkeyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
captureOnKeyPress = !captureOnKeyPress;
|
||||||
|
toggleHotkeyToolStripMenuItem.Text = captureOnKeyPress ? "Disable Print Screen capture" : "Enable Print Screen capture";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1139
MainForm.resx
1139
MainForm.resx
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user