mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-05 06:30:36 +12:00
fixed #690: Workaround for rectangle capture hotkey problem
This commit is contained in:
parent
ea4e246427
commit
5cfbb60445
|
@ -54,8 +54,9 @@ public class Surface : Form
|
||||||
protected Pen borderPen, borderDotPen, textBackgroundPenWhite, textBackgroundPenBlack;
|
protected Pen borderPen, borderDotPen, textBackgroundPenWhite, textBackgroundPenBlack;
|
||||||
protected Brush nodeBackgroundBrush, textBackgroundBrush;
|
protected Brush nodeBackgroundBrush, textBackgroundBrush;
|
||||||
protected Font textFont, infoFont;
|
protected Font textFont, infoFont;
|
||||||
protected Stopwatch timer;
|
protected Stopwatch timerStart, timerFPS;
|
||||||
protected int frameCount;
|
protected int frameCount;
|
||||||
|
protected bool isKeyAllowed;
|
||||||
|
|
||||||
public static GraphicsPath LastRegionFillPath, LastRegionDrawPath;
|
public static GraphicsPath LastRegionFillPath, LastRegionDrawPath;
|
||||||
|
|
||||||
|
@ -73,7 +74,8 @@ public Surface()
|
||||||
|
|
||||||
DrawableObjects = new List<DrawableObject>();
|
DrawableObjects = new List<DrawableObject>();
|
||||||
Config = new SurfaceOptions();
|
Config = new SurfaceOptions();
|
||||||
timer = new Stopwatch();
|
timerStart = new Stopwatch();
|
||||||
|
timerFPS = new Stopwatch();
|
||||||
|
|
||||||
borderPen = new Pen(Color.Black);
|
borderPen = new Pen(Color.Black);
|
||||||
borderDotPen = new Pen(Color.White);
|
borderDotPen = new Pen(Color.White);
|
||||||
|
@ -151,19 +153,26 @@ private void Surface_Shown(object sender, EventArgs e)
|
||||||
|
|
||||||
private void Surface_KeyUp(object sender, KeyEventArgs e)
|
private void Surface_KeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
|
if (!isKeyAllowed && timerStart.ElapsedMilliseconds < 1000)
|
||||||
{
|
{
|
||||||
MonitorKey(e.KeyCode - Keys.D0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
|
isKeyAllowed = true;
|
||||||
|
|
||||||
|
if (e.KeyData >= Keys.D0 && e.KeyData <= Keys.D9)
|
||||||
{
|
{
|
||||||
MonitorKey(e.KeyCode - Keys.NumPad0);
|
MonitorKey(e.KeyData - Keys.D0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (e.KeyCode)
|
if (e.KeyData >= Keys.NumPad0 && e.KeyData <= Keys.NumPad9)
|
||||||
|
{
|
||||||
|
MonitorKey(e.KeyData - Keys.NumPad0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (e.KeyData)
|
||||||
{
|
{
|
||||||
case Keys.Escape:
|
case Keys.Escape:
|
||||||
Close(SurfaceResult.Close);
|
Close(SurfaceResult.Close);
|
||||||
|
@ -243,7 +252,11 @@ public void Close(SurfaceResult result)
|
||||||
|
|
||||||
protected new virtual void Update()
|
protected new virtual void Update()
|
||||||
{
|
{
|
||||||
if (!timer.IsRunning) timer.Start();
|
if (!timerStart.IsRunning)
|
||||||
|
{
|
||||||
|
timerStart.Start();
|
||||||
|
timerFPS.Start();
|
||||||
|
}
|
||||||
|
|
||||||
InputManager.Update();
|
InputManager.Update();
|
||||||
|
|
||||||
|
@ -288,7 +301,7 @@ protected new virtual void Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
borderDotPen.DashOffset = (float)timer.Elapsed.TotalSeconds * 10;
|
borderDotPen.DashOffset = (float)timerStart.Elapsed.TotalSeconds * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Draw(Graphics g)
|
protected virtual void Draw(Graphics g)
|
||||||
|
@ -311,12 +324,12 @@ private void CheckFPS()
|
||||||
{
|
{
|
||||||
frameCount++;
|
frameCount++;
|
||||||
|
|
||||||
if (timer.ElapsedMilliseconds >= 1000)
|
if (timerFPS.ElapsedMilliseconds >= 1000)
|
||||||
{
|
{
|
||||||
FPS = (int)(frameCount / timer.Elapsed.TotalSeconds);
|
FPS = (int)(frameCount / timerFPS.Elapsed.TotalSeconds);
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
timer.Reset();
|
timerFPS.Reset();
|
||||||
timer.Start();
|
timerFPS.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue