Final revision
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
38
MainForm.Designer.cs
generated
38
MainForm.Designer.cs
generated
@@ -32,8 +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.showToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
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();
|
||||||
@@ -43,33 +42,26 @@
|
|||||||
//
|
//
|
||||||
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
|
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
|
||||||
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 = "ScreenCaptureApp";
|
||||||
this.notifyIcon1.Visible = true;
|
this.notifyIcon1.Visible = true;
|
||||||
this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick);
|
this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick);
|
||||||
//
|
//
|
||||||
// contextMenuStrip1
|
// contextMenuStrip1
|
||||||
//
|
//
|
||||||
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.showToolStripMenuItem,
|
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, 76);
|
this.contextMenuStrip1.Size = new System.Drawing.Size(222, 54);
|
||||||
|
this.contextMenuStrip1.Text = "test";
|
||||||
//
|
//
|
||||||
// showToolStripMenuItem
|
// disablePrintScreenCaptureToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.showToolStripMenuItem.Name = "showToolStripMenuItem";
|
this.disablePrintScreenCaptureToolStripMenuItem.Name = "disablePrintScreenCaptureToolStripMenuItem";
|
||||||
this.showToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
this.disablePrintScreenCaptureToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
||||||
this.showToolStripMenuItem.Text = "Show in Taskbar";
|
this.disablePrintScreenCaptureToolStripMenuItem.Text = "Disable Print Screen capture";
|
||||||
this.showToolStripMenuItem.Click += new System.EventHandler(this.showToolStripMenuItem_Click);
|
this.disablePrintScreenCaptureToolStripMenuItem.Click += new System.EventHandler(this.toggleHotkeyToolStripMenuItem_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
|
||||||
//
|
//
|
||||||
@@ -87,23 +79,23 @@
|
|||||||
//
|
//
|
||||||
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(184, 61);
|
||||||
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.Load += new System.EventHandler(this.MainForm_Load);
|
||||||
this.contextMenuStrip1.ResumeLayout(false);
|
this.contextMenuStrip1.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#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 toggleHotkeyToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem disablePrintScreenCaptureToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem showToolStripMenuItem;
|
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
|
||||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
160
MainForm.cs
160
MainForm.cs
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ScreenCaptureApp
|
namespace ScreenCaptureApp
|
||||||
{
|
{
|
||||||
@@ -20,34 +19,11 @@ namespace ScreenCaptureApp
|
|||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
RegisterHotkey();
|
|
||||||
this.Hide(); // Сразу скрываем основное окно
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ShowMainWindow()
|
|
||||||
{
|
|
||||||
if (this.WindowState == FormWindowState.Minimized)
|
|
||||||
{
|
|
||||||
this.WindowState = FormWindowState.Normal;
|
|
||||||
}
|
|
||||||
this.Show();
|
|
||||||
this.Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RegisterHotkey()
|
|
||||||
{
|
|
||||||
// Регистрируем Print Screen (0x2C) без модификаторов (0x0)
|
|
||||||
if (!RegisterHotKey(this.Handle, PRINT_SCREEN_ID, 0x0, 0x2C))
|
if (!RegisterHotKey(this.Handle, PRINT_SCREEN_ID, 0x0, 0x2C))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Failed to register Print Screen hotkey", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
notifyIcon1.ShowBalloonTip(1000, "Error", "Failed to register Print Screen hotkey", ToolTipIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
this.WindowState = FormWindowState.Minimized;
|
||||||
|
|
||||||
private void ExitApplication()
|
|
||||||
{
|
|
||||||
UnregisterHotKey(this.Handle, PRINT_SCREEN_ID);
|
|
||||||
notifyIcon1.Visible = false;
|
|
||||||
Application.Exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
@@ -64,56 +40,45 @@ namespace ScreenCaptureApp
|
|||||||
|
|
||||||
private void CaptureScreen()
|
private void CaptureScreen()
|
||||||
{
|
{
|
||||||
this.Hide();
|
using (ScreenCaptureForm captureForm = new ScreenCaptureForm())
|
||||||
using (var captureForm = new ScreenCaptureForm())
|
|
||||||
{
|
{
|
||||||
|
captureForm.Focus();
|
||||||
if (captureForm.ShowDialog() == DialogResult.OK)
|
if (captureForm.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
ProcessCapturedImage(captureForm.CapturedImage);
|
using (captureForm.CapturedImage)
|
||||||
}
|
{
|
||||||
}
|
using (ResultForm resultForm = new ResultForm(captureForm.CapturedImage))
|
||||||
this.Show();
|
{
|
||||||
}
|
if (resultForm.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
using (SaveFileDialog sfd = new SaveFileDialog())
|
||||||
|
{
|
||||||
|
sfd.Title = "Save screenshot";
|
||||||
|
sfd.Filter = "PNG Image|*.png|JPEG Image|*.jpg|Bitmap Image|*.bmp";
|
||||||
|
sfd.FileName = $"screenshot_{DateTime.Now:dd-MM-yyyy_HH.mm.ss}";
|
||||||
|
|
||||||
private void ProcessCapturedImage(Image image)
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
using (var resultForm = new ResultForm(image))
|
captureForm.CapturedImage.Save(sfd.FileName, GetImageFormat(sfd.FileName));
|
||||||
{
|
notifyIcon1.ShowBalloonTip(1000, "Success", "Screenshot saved!", ToolTipIcon.Info);
|
||||||
var result = resultForm.ShowDialog();
|
}
|
||||||
if (result == DialogResult.OK)
|
}
|
||||||
{
|
}
|
||||||
SaveImage(image);
|
else if (resultForm.DialogResult == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Clipboard.SetImage(captureForm.CapturedImage);
|
||||||
|
notifyIcon1.ShowBalloonTip(1000, "Success", "Copied to clipboard!", ToolTipIcon.Info);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
notifyIcon1.ShowBalloonTip(1000, "Error", $"Copy failed: {ex.Message}", ToolTipIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (result == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
CopyToClipboard(image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveImage(Image image)
|
|
||||||
{
|
|
||||||
using (var sfd = new SaveFileDialog())
|
|
||||||
{
|
|
||||||
sfd.Filter = "PNG Image|*.png|JPEG Image|*.jpg|Bitmap Image|*.bmp";
|
|
||||||
if (sfd.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
image.Save(sfd.FileName, GetImageFormat(sfd.FileName));
|
|
||||||
notifyIcon1.ShowBalloonTip(1000, "Success", "Screenshot saved!", ToolTipIcon.Info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CopyToClipboard(Image image)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Clipboard.SetImage(image);
|
|
||||||
notifyIcon1.ShowBalloonTip(1000, "Success", "Copied to clipboard!", ToolTipIcon.Info);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
notifyIcon1.ShowBalloonTip(1000, "Error", $"Copy failed: {ex.Message}", ToolTipIcon.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,35 +94,52 @@ namespace ScreenCaptureApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyIcon1_MouseClick(object sender, EventArgs e) => ShowMainWindow();
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
disablePrintScreenCaptureToolStripMenuItem.Text = $"Print Screen Capture: {(captureOnKeyPress ? "ON" : "OFF")}";
|
||||||
|
this.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
private void showToolStripMenuItem_Click(object sender, EventArgs e) => ShowMainWindow();
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
UnregisterHotKey(this.Handle, PRINT_SCREEN_ID);
|
||||||
|
notifyIcon1.Visible = false;
|
||||||
|
this.Dispose(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Button == MouseButtons.Right)
|
||||||
|
{
|
||||||
|
MethodInvoker mi = new MethodInvoker(() => {
|
||||||
|
notifyIcon1.ContextMenuStrip.Show(Cursor.Position);
|
||||||
|
});
|
||||||
|
this.BeginInvoke(mi);
|
||||||
|
}
|
||||||
|
else if (e.Button == MouseButtons.Left)
|
||||||
|
{
|
||||||
|
CaptureScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void toggleHotkeyToolStripMenuItem_Click(object sender, EventArgs e)
|
private void toggleHotkeyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
captureOnKeyPress = !captureOnKeyPress;
|
captureOnKeyPress = !captureOnKeyPress;
|
||||||
var item = (ToolStripMenuItem)sender;
|
disablePrintScreenCaptureToolStripMenuItem.Text = $"Print Screen Capture: {(captureOnKeyPress ? "ON" : "OFF")}";
|
||||||
item.Text = $"Print Screen Capture: {(captureOnKeyPress ? "ON" : "OFF")}";
|
notifyIcon1.ShowBalloonTip(250, "Screen Capture",
|
||||||
notifyIcon1.ShowBalloonTip(1000, "Hotkey",
|
captureOnKeyPress ? "Print Screen capture enabled" : "Print Screen capture disabled",
|
||||||
$"Print Screen capture {(captureOnKeyPress ? "enabled" : "disabled")}",
|
|
||||||
ToolTipIcon.Info);
|
ToolTipIcon.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exitToolStripMenuItem_Click(Object sender, EventArgs e)
|
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ExitApplication();
|
base.OnFormClosing(e as FormClosingEventArgs);
|
||||||
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLoad(EventArgs e)
|
private void bigButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnLoad(e);
|
CaptureScreen();
|
||||||
this.Hide(); // Гарантированно скрываем окно при загрузке
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnFormClosing(e);
|
|
||||||
ExitApplication();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,10 +118,10 @@
|
|||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="notifyIcon1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="notifyIcon1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>132, 17</value>
|
<value>17, 13</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>246, 17</value>
|
<value>131, 13</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="notifyIcon1.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="notifyIcon1.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
|||||||
57
ResultForm.Designer.cs
generated
57
ResultForm.Designer.cs
generated
@@ -32,23 +32,29 @@
|
|||||||
this.btnSave = new System.Windows.Forms.Button();
|
this.btnSave = new System.Windows.Forms.Button();
|
||||||
this.btnCopy = new System.Windows.Forms.Button();
|
this.btnCopy = new System.Windows.Forms.Button();
|
||||||
this.btnCancel = new System.Windows.Forms.Button();
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
|
this.tableLayoutPanel1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// pictureBox1
|
// pictureBox1
|
||||||
//
|
//
|
||||||
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
|
this.tableLayoutPanel1.SetColumnSpan(this.pictureBox1, 4);
|
||||||
|
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBox1.Location = new System.Drawing.Point(3, 3);
|
||||||
this.pictureBox1.Name = "pictureBox1";
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
this.pictureBox1.Size = new System.Drawing.Size(716, 346);
|
this.pictureBox1.Size = new System.Drawing.Size(793, 530);
|
||||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||||
this.pictureBox1.TabIndex = 0;
|
this.pictureBox1.TabIndex = 0;
|
||||||
this.pictureBox1.TabStop = false;
|
this.pictureBox1.TabStop = false;
|
||||||
//
|
//
|
||||||
// btnSave
|
// btnSave
|
||||||
//
|
//
|
||||||
this.btnSave.Location = new System.Drawing.Point(491, 364);
|
this.btnSave.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.btnSave.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||||
|
this.btnSave.Location = new System.Drawing.Point(433, 539);
|
||||||
this.btnSave.Name = "btnSave";
|
this.btnSave.Name = "btnSave";
|
||||||
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
this.btnSave.Size = new System.Drawing.Size(117, 29);
|
||||||
this.btnSave.TabIndex = 1;
|
this.btnSave.TabIndex = 1;
|
||||||
this.btnSave.Text = "Save";
|
this.btnSave.Text = "Save";
|
||||||
this.btnSave.UseVisualStyleBackColor = true;
|
this.btnSave.UseVisualStyleBackColor = true;
|
||||||
@@ -56,9 +62,11 @@
|
|||||||
//
|
//
|
||||||
// btnCopy
|
// btnCopy
|
||||||
//
|
//
|
||||||
this.btnCopy.Location = new System.Drawing.Point(572, 364);
|
this.btnCopy.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.btnCopy.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||||
|
this.btnCopy.Location = new System.Drawing.Point(556, 539);
|
||||||
this.btnCopy.Name = "btnCopy";
|
this.btnCopy.Name = "btnCopy";
|
||||||
this.btnCopy.Size = new System.Drawing.Size(75, 23);
|
this.btnCopy.Size = new System.Drawing.Size(116, 29);
|
||||||
this.btnCopy.TabIndex = 2;
|
this.btnCopy.TabIndex = 2;
|
||||||
this.btnCopy.Text = "Copy";
|
this.btnCopy.Text = "Copy";
|
||||||
this.btnCopy.UseVisualStyleBackColor = true;
|
this.btnCopy.UseVisualStyleBackColor = true;
|
||||||
@@ -66,27 +74,47 @@
|
|||||||
//
|
//
|
||||||
// btnCancel
|
// btnCancel
|
||||||
//
|
//
|
||||||
this.btnCancel.Location = new System.Drawing.Point(653, 364);
|
this.btnCancel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.btnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||||
|
this.btnCancel.Location = new System.Drawing.Point(678, 539);
|
||||||
this.btnCancel.Name = "btnCancel";
|
this.btnCancel.Name = "btnCancel";
|
||||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
this.btnCancel.Size = new System.Drawing.Size(118, 29);
|
||||||
this.btnCancel.TabIndex = 3;
|
this.btnCancel.TabIndex = 3;
|
||||||
this.btnCancel.Text = "Cancel";
|
this.btnCancel.Text = "Cancel";
|
||||||
this.btnCancel.UseVisualStyleBackColor = true;
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||||
//
|
//
|
||||||
|
// tableLayoutPanel1
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel1.ColumnCount = 4;
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 53.86703F));
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.46811F));
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.33243F));
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.19674F));
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.btnCancel, 3, 1);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.btnCopy, 2, 1);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.btnSave, 1, 1);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.pictureBox1, 0, 0);
|
||||||
|
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||||
|
this.tableLayoutPanel1.RowCount = 2;
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 93.95866F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.041336F));
|
||||||
|
this.tableLayoutPanel1.Size = new System.Drawing.Size(799, 571);
|
||||||
|
this.tableLayoutPanel1.TabIndex = 4;
|
||||||
|
//
|
||||||
// ResultForm
|
// ResultForm
|
||||||
//
|
//
|
||||||
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(737, 396);
|
this.ClientSize = new System.Drawing.Size(799, 571);
|
||||||
this.Controls.Add(this.btnCancel);
|
this.Controls.Add(this.tableLayoutPanel1);
|
||||||
this.Controls.Add(this.btnCopy);
|
|
||||||
this.Controls.Add(this.btnSave);
|
|
||||||
this.Controls.Add(this.pictureBox1);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
|
||||||
this.Name = "ResultForm";
|
this.Name = "ResultForm";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "ResultForm";
|
this.Text = "ResultForm";
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
|
this.tableLayoutPanel1.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -97,5 +125,6 @@
|
|||||||
private System.Windows.Forms.Button btnSave;
|
private System.Windows.Forms.Button btnSave;
|
||||||
private System.Windows.Forms.Button btnCopy;
|
private System.Windows.Forms.Button btnCopy;
|
||||||
private System.Windows.Forms.Button btnCancel;
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace ScreenCaptureApp
|
namespace ScreenCaptureApp
|
||||||
{
|
{
|
||||||
public partial class ResultForm : Form
|
public partial class ResultForm : Form, IDisposable
|
||||||
{
|
{
|
||||||
public ResultForm(Image capturedImage)
|
public ResultForm(Image capturedImage)
|
||||||
{
|
{
|
||||||
@@ -30,4 +30,4 @@ namespace ScreenCaptureApp
|
|||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace ScreenCaptureApp
|
namespace ScreenCaptureApp
|
||||||
{
|
{
|
||||||
public sealed class ScreenCaptureForm : Form
|
public partial class ScreenCaptureForm : Form
|
||||||
{
|
{
|
||||||
private Point _startPoint;
|
private Point _startPoint;
|
||||||
private Point _endPoint;
|
private Point _endPoint;
|
||||||
@@ -46,7 +46,7 @@ namespace ScreenCaptureApp
|
|||||||
Screen.PrimaryScreen.Bounds.Height,
|
Screen.PrimaryScreen.Bounds.Height,
|
||||||
PixelFormat.Format32bppArgb);
|
PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
using (var g = Graphics.FromImage(_screenBitmap))
|
using (Graphics g = Graphics.FromImage(_screenBitmap))
|
||||||
{
|
{
|
||||||
g.CopyFromScreen(
|
g.CopyFromScreen(
|
||||||
Screen.PrimaryScreen.Bounds.X,
|
Screen.PrimaryScreen.Bounds.X,
|
||||||
@@ -100,10 +100,9 @@ namespace ScreenCaptureApp
|
|||||||
{
|
{
|
||||||
if (_isSelecting)
|
if (_isSelecting)
|
||||||
{
|
{
|
||||||
var rect = GetSelectionRectangle();
|
Rectangle rect = GetSelectionRectangle();
|
||||||
e.Graphics.DrawRectangle(_selectionPen, rect);
|
e.Graphics.DrawRectangle(_selectionPen, rect);
|
||||||
|
|
||||||
// Перекрестие для точного выбора
|
|
||||||
e.Graphics.DrawLine(_selectionPen,
|
e.Graphics.DrawLine(_selectionPen,
|
||||||
new Point(rect.X, rect.Y + rect.Height / 2),
|
new Point(rect.X, rect.Y + rect.Height / 2),
|
||||||
new Point(rect.X + rect.Width, rect.Y + rect.Height / 2));
|
new Point(rect.X + rect.Width, rect.Y + rect.Height / 2));
|
||||||
@@ -137,7 +136,7 @@ namespace ScreenCaptureApp
|
|||||||
{
|
{
|
||||||
CapturedImage = new Bitmap(_selectedRegion.Width, _selectedRegion.Height);
|
CapturedImage = new Bitmap(_selectedRegion.Width, _selectedRegion.Height);
|
||||||
|
|
||||||
using (var g = Graphics.FromImage(CapturedImage))
|
using (Graphics g = Graphics.FromImage(CapturedImage))
|
||||||
{
|
{
|
||||||
g.DrawImage(_screenBitmap,
|
g.DrawImage(_screenBitmap,
|
||||||
new Rectangle(0, 0, _selectedRegion.Width, _selectedRegion.Height),
|
new Rectangle(0, 0, _selectedRegion.Width, _selectedRegion.Height),
|
||||||
|
|||||||
Reference in New Issue
Block a user