Update after Final revision
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
25
MainForm.Designer.cs
generated
25
MainForm.Designer.cs
generated
@@ -32,7 +32,7 @@
|
|||||||
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.disablePrintScreenCaptureToolStripMenuItem = 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();
|
||||||
@@ -49,30 +49,29 @@
|
|||||||
// contextMenuStrip1
|
// contextMenuStrip1
|
||||||
//
|
//
|
||||||
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.disablePrintScreenCaptureToolStripMenuItem,
|
this.toggleHotkeyToolStripMenuItem,
|
||||||
this.toolStripSeparator1,
|
this.toolStripSeparator1,
|
||||||
this.exitToolStripMenuItem});
|
this.exitToolStripMenuItem});
|
||||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
this.contextMenuStrip1.Size = new System.Drawing.Size(222, 54);
|
this.contextMenuStrip1.Size = new System.Drawing.Size(181, 76);
|
||||||
this.contextMenuStrip1.Text = "test";
|
this.contextMenuStrip1.Text = "contextMenuStrip1";
|
||||||
//
|
//
|
||||||
// disablePrintScreenCaptureToolStripMenuItem
|
// toggleHotkeyToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.disablePrintScreenCaptureToolStripMenuItem.Name = "disablePrintScreenCaptureToolStripMenuItem";
|
this.toggleHotkeyToolStripMenuItem.Name = "toggleHotkeyToolStripMenuItem";
|
||||||
this.disablePrintScreenCaptureToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
this.toggleHotkeyToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.disablePrintScreenCaptureToolStripMenuItem.Text = "Disable Print Screen capture";
|
this.toggleHotkeyToolStripMenuItem.Click += new System.EventHandler(this.toggleHotkeyToolStripMenuItem_Click);
|
||||||
this.disablePrintScreenCaptureToolStripMenuItem.Click += new System.EventHandler(this.toggleHotkeyToolStripMenuItem_Click);
|
|
||||||
//
|
//
|
||||||
// toolStripSeparator1
|
// toolStripSeparator1
|
||||||
//
|
//
|
||||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
this.toolStripSeparator1.Size = new System.Drawing.Size(218, 6);
|
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
|
||||||
//
|
//
|
||||||
// exitToolStripMenuItem
|
// exitToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.exitToolStripMenuItem.Text = "Exit";
|
this.exitToolStripMenuItem.Text = "Закрыть";
|
||||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
@@ -93,7 +92,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
private System.Windows.Forms.NotifyIcon notifyIcon1;
|
private System.Windows.Forms.NotifyIcon notifyIcon1;
|
||||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem disablePrintScreenCaptureToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem toggleHotkeyToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
}
|
}
|
||||||
|
|||||||
26
MainForm.cs
26
MainForm.cs
@@ -21,7 +21,7 @@ namespace ScreenCaptureApp
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
if (!RegisterHotKey(this.Handle, PRINT_SCREEN_ID, 0x0, 0x2C))
|
if (!RegisterHotKey(this.Handle, PRINT_SCREEN_ID, 0x0, 0x2C))
|
||||||
{
|
{
|
||||||
notifyIcon1.ShowBalloonTip(1000, "Error", "Failed to register Print Screen hotkey", ToolTipIcon.Error);
|
notifyIcon1.ShowBalloonTip(1000, "Ошибка", "Не удалось привязать Print Screen", ToolTipIcon.Error);
|
||||||
}
|
}
|
||||||
this.WindowState = FormWindowState.Minimized;
|
this.WindowState = FormWindowState.Minimized;
|
||||||
}
|
}
|
||||||
@@ -53,14 +53,14 @@ namespace ScreenCaptureApp
|
|||||||
{
|
{
|
||||||
using (SaveFileDialog sfd = new SaveFileDialog())
|
using (SaveFileDialog sfd = new SaveFileDialog())
|
||||||
{
|
{
|
||||||
sfd.Title = "Save screenshot";
|
sfd.Title = "Сохранить скриншот";
|
||||||
sfd.Filter = "PNG Image|*.png|JPEG Image|*.jpg|Bitmap Image|*.bmp";
|
sfd.Filter = "PNG Image|*.png|JPEG Image|*.jpg|Bitmap Image|*.bmp";
|
||||||
sfd.FileName = $"screenshot_{DateTime.Now:dd-MM-yyyy_HH.mm.ss}";
|
sfd.FileName = $"screenshot_{DateTime.Now:dd-MM-yyyy_HH.mm.ss}";
|
||||||
|
|
||||||
if (sfd.ShowDialog() == DialogResult.OK)
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
captureForm.CapturedImage.Save(sfd.FileName, GetImageFormat(sfd.FileName));
|
captureForm.CapturedImage.Save(sfd.FileName, GetImageFormat(sfd.FileName));
|
||||||
notifyIcon1.ShowBalloonTip(1000, "Success", "Screenshot saved!", ToolTipIcon.Info);
|
notifyIcon1.ShowBalloonTip(1000, "Успех", "Скриншот сохранен!", ToolTipIcon.Info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,11 +69,11 @@ namespace ScreenCaptureApp
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Clipboard.SetImage(captureForm.CapturedImage);
|
Clipboard.SetImage(captureForm.CapturedImage);
|
||||||
notifyIcon1.ShowBalloonTip(1000, "Success", "Copied to clipboard!", ToolTipIcon.Info);
|
notifyIcon1.ShowBalloonTip(1000, "Успех", "Скриншот скопирован в буфер обмена!", ToolTipIcon.Info);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
notifyIcon1.ShowBalloonTip(1000, "Error", $"Copy failed: {ex.Message}", ToolTipIcon.Error);
|
notifyIcon1.ShowBalloonTip(1000, "Ошибка", $"Копирование не удалось: {ex.Message}", ToolTipIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,8 +84,7 @@ namespace ScreenCaptureApp
|
|||||||
|
|
||||||
private System.Drawing.Imaging.ImageFormat GetImageFormat(string fileName)
|
private System.Drawing.Imaging.ImageFormat GetImageFormat(string fileName)
|
||||||
{
|
{
|
||||||
string ext = System.IO.Path.GetExtension(fileName).ToLower();
|
switch (System.IO.Path.GetExtension(fileName).ToLower())
|
||||||
switch (ext)
|
|
||||||
{
|
{
|
||||||
case ".jpg": return System.Drawing.Imaging.ImageFormat.Jpeg;
|
case ".jpg": return System.Drawing.Imaging.ImageFormat.Jpeg;
|
||||||
case ".jpeg": return System.Drawing.Imaging.ImageFormat.Jpeg;
|
case ".jpeg": return System.Drawing.Imaging.ImageFormat.Jpeg;
|
||||||
@@ -96,7 +95,7 @@ namespace ScreenCaptureApp
|
|||||||
|
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
disablePrintScreenCaptureToolStripMenuItem.Text = $"Print Screen Capture: {(captureOnKeyPress ? "ON" : "OFF")}";
|
toggleHotkeyToolStripMenuItem.Text = $"Отлик на Print Screen: {(captureOnKeyPress ? "ON" : "OFF")}";
|
||||||
this.Hide();
|
this.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,9 +124,9 @@ namespace ScreenCaptureApp
|
|||||||
private void toggleHotkeyToolStripMenuItem_Click(object sender, EventArgs e)
|
private void toggleHotkeyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
captureOnKeyPress = !captureOnKeyPress;
|
captureOnKeyPress = !captureOnKeyPress;
|
||||||
disablePrintScreenCaptureToolStripMenuItem.Text = $"Print Screen Capture: {(captureOnKeyPress ? "ON" : "OFF")}";
|
toggleHotkeyToolStripMenuItem.Text = $"Отлик на Print Screen: {(captureOnKeyPress ? "ON" : "OFF")}";
|
||||||
notifyIcon1.ShowBalloonTip(250, "Screen Capture",
|
notifyIcon1.ShowBalloonTip(250, "Захват экрана",
|
||||||
captureOnKeyPress ? "Print Screen capture enabled" : "Print Screen capture disabled",
|
captureOnKeyPress ? "Отлик на Print Screen включен" : "Отлик на Print Screen отключен",
|
||||||
ToolTipIcon.Info);
|
ToolTipIcon.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,10 +135,5 @@ namespace ScreenCaptureApp
|
|||||||
base.OnFormClosing(e as FormClosingEventArgs);
|
base.OnFormClosing(e as FormClosingEventArgs);
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bigButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CaptureScreen();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,12 +18,7 @@ namespace ScreenCaptureApp
|
|||||||
|
|
||||||
public ScreenCaptureForm()
|
public ScreenCaptureForm()
|
||||||
{
|
{
|
||||||
InitializeForm();
|
this.SetTopLevel(true);
|
||||||
CaptureScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitializeForm()
|
|
||||||
{
|
|
||||||
this.FormBorderStyle = FormBorderStyle.None;
|
this.FormBorderStyle = FormBorderStyle.None;
|
||||||
this.WindowState = FormWindowState.Maximized;
|
this.WindowState = FormWindowState.Maximized;
|
||||||
this.Opacity = 0.3;
|
this.Opacity = 0.3;
|
||||||
@@ -35,6 +30,8 @@ namespace ScreenCaptureApp
|
|||||||
this.Size = Screen.PrimaryScreen.Bounds.Size;
|
this.Size = Screen.PrimaryScreen.Bounds.Size;
|
||||||
|
|
||||||
_selectionPen = new Pen(Color.Red, 2) { DashStyle = System.Drawing.Drawing2D.DashStyle.Dash };
|
_selectionPen = new Pen(Color.Red, 2) { DashStyle = System.Drawing.Drawing2D.DashStyle.Dash };
|
||||||
|
|
||||||
|
CaptureScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CaptureScreen()
|
private void CaptureScreen()
|
||||||
|
|||||||
Reference in New Issue
Block a user