93 lines
2.2 KiB
C#
93 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ScreenCapture
|
|
{
|
|
public partial class MainForm : Form
|
|
{
|
|
private KeyboardHook hook;
|
|
|
|
public MainForm()
|
|
{
|
|
InitializeComponent();
|
|
hook = new KeyboardHook(this.Handle);
|
|
hook.KeyPressed += CaptureWindow_Click;
|
|
hook.RegisterHotKey(ModifierKeysWin.Win, Keys.F12);
|
|
}
|
|
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
if (hook != null)
|
|
{
|
|
hook.WndProc(ref m);
|
|
}
|
|
|
|
base.WndProc(ref m);
|
|
}
|
|
|
|
private void Open()
|
|
{
|
|
Show();
|
|
|
|
if (!this.ShowInTaskbar)
|
|
this.ShowInTaskbar = true;
|
|
|
|
if (this.WindowState == FormWindowState.Minimized)
|
|
this.WindowState = FormWindowState.Normal;
|
|
}
|
|
|
|
private async void CaptureWindow_Click(object sender, EventArgs e)
|
|
{
|
|
ScreenCapture sc = ScreenCapture.Instance;
|
|
sc.CaptureWindow();
|
|
string link = await Web.upload(sc.Stream, sc.FileName);
|
|
sc.Release();
|
|
|
|
Clipboard.SetText(link);
|
|
ShowNotification(link);
|
|
|
|
}
|
|
|
|
private void Close_Click(object sender, EventArgs e)
|
|
{
|
|
Application.Exit();
|
|
}
|
|
|
|
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
{
|
|
Open();
|
|
}
|
|
|
|
private void settingsMenu_Click(object sender, EventArgs e)
|
|
{
|
|
Open();
|
|
}
|
|
|
|
private void OnClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
e.Cancel = true;
|
|
this.ShowInTaskbar = false;
|
|
this.WindowState = FormWindowState.Minimized;
|
|
Hide();
|
|
}
|
|
|
|
private void MainForm_Load(object sender, EventArgs e)
|
|
{
|
|
Hide();
|
|
}
|
|
|
|
private void ShowNotification(string str)
|
|
{
|
|
notifyIcon.BalloonTipText = str;
|
|
notifyIcon.ShowBalloonTip(3000);
|
|
}
|
|
}
|
|
}
|