Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Update #15 全屏十字光标显示、放大镜显示
Browse files Browse the repository at this point in the history
Update #16 截图中保留鼠标显示
  • Loading branch information
tylearymf committed Jan 8, 2021
1 parent 8432703 commit ab04855
Show file tree
Hide file tree
Showing 12 changed files with 1,645 additions and 64 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ A best screenshot small tool (support high dpi screenshots)
- 支持快捷键隐藏、显示所有截图(3.x 新增)

- ###### 配置方法:选项 -> 截图设置

- 支持显示全屏十字光标

- ###### 配置方法:选项 -> 杂项设置 -> 全屏十字光标样式

- 支持在截图中保留鼠标的显示

- ###### 配置方法:选项 -> 杂项设置 -> 其他 -> 在截图中保留鼠标

- 支持显示放大镜以更准确的截取图片

- ###### 配置方法:选项 -> 杂项设置 -> 其他 -> 显示放大镜

---

Expand Down
21 changes: 6 additions & 15 deletions SETUNA/Main/CaptureForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

167 changes: 153 additions & 14 deletions SETUNA/Main/CaptureForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public Bitmap ClipBitmap
// (get) Token: 0x0600029A RID: 666 RVA: 0x0000DE96 File Offset: 0x0000C096
public Size ClipSize => ptClipSize;

public Screen TargetScreen => targetScreen;


// Token: 0x1700006F RID: 111
// (set) Token: 0x0600029B RID: 667 RVA: 0x0000DE9E File Offset: 0x0000C09E
public CaptureForm.CaptureClosedDelegate OnCaptureClose
Expand Down Expand Up @@ -142,9 +145,72 @@ public CaptureForm(SetunaOption.SetunaOptionData opt)
CaptureForm.selLineVer1.Visible = false;
CaptureForm.selLineVer2.Visible = false;
CaptureForm.selArea.Visible = false;

fullscreenHorLine = new CaptureSelLine(SelLineType.Horizon, opt.SelectLineSolid, opt.SelectLineColor);
InitChildForm(fullscreenHorLine, true);
fullscreenVerLine = new CaptureSelLine(SelLineType.Vertical, opt.SelectLineSolid, opt.SelectLineColor);
InitChildForm(fullscreenVerLine, true);

magnifier = new Magnifier(this);
base.AddOwnedForm(magnifier);
magnifier.Show();
magnifier.Visible = false;

base.Opacity = 0.99000000953674316;
}


void InitChildForm(Form form, bool adjustOpacity = false)
{
base.AddOwnedForm(form);
form.Cursor = Cursors.Cross;

if (adjustOpacity)
form.Opacity = 0.0099999997764825821;

form.MouseDown += (sender, e) => Form_MouseEvent(CaptureForm_MouseDown, sender, e);
form.MouseMove += (sender, e) => Form_MouseEvent(CaptureForm_MouseMove, sender, e);
form.MouseUp += (sender, e) => Form_MouseEvent(CaptureForm_MouseUp, sender, e);

form.Show(this);
form.Visible = false;
}

private void Form_MouseEvent(Action<object, MouseEventArgs> action, object sender, MouseEventArgs e)
{
if (sender is Form form)
{
if (form == fullscreenHorLine)
{
action(sender, new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y + form.Top, e.Delta));
}
else if (form == fullscreenVerLine)
{
action(sender, new MouseEventArgs(e.Button, e.Clicks, e.X + form.Left, e.Y, e.Delta));
}
else if (form == selLineHor1)
{
action(sender, new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y + form.Top, e.Delta));
}
else if (form == selLineHor2)
{
action(sender, new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y + form.Top, e.Delta));
}
else if (form == selLineVer1)
{
action(sender, new MouseEventArgs(e.Button, e.Clicks, e.X + form.Left, e.Y, e.Delta));
}
else if (form == selLineVer2)
{
action(sender, new MouseEventArgs(e.Button, e.Clicks, e.X + form.Left, e.Y, e.Delta));
}
else if (form == selArea)
{
action(sender, new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
}
}
}

// Token: 0x0600029D RID: 669 RVA: 0x0000E104 File Offset: 0x0000C304
public void ShowCapture(SetunaOption.SetunaOptionData opt)
{
Expand Down Expand Up @@ -231,6 +297,11 @@ public void ShowCapture(SetunaOption.SetunaOptionData opt)
DateTime.Now.Millisecond
}));

CaptureForm.fullscreenHorLine.SetPen(opt.FullscreenCursorSolid, opt.FullscreenCursorLineColor);
CaptureForm.fullscreenHorLine.SetBounds(targetScreen.Bounds.X, targetScreen.Bounds.Y, targetScreen.Bounds.Width, targetScreen.Bounds.Height);
CaptureForm.fullscreenVerLine.SetPen(opt.FullscreenCursorSolid, opt.FullscreenCursorLineColor);
CaptureForm.fullscreenVerLine.SetBounds(targetScreen.Bounds.X, targetScreen.Bounds.Y, targetScreen.Bounds.Width, targetScreen.Bounds.Height);

Thread.Sleep(1);
Cursor.Clip = targetScreen.Bounds;
}
Expand Down Expand Up @@ -321,9 +392,38 @@ private void ShowForm()
base.Opacity = 0.0099999997764825821;
base.Visible = true;
base.Opacity = 0.0099999997764825821;

if (Mainform.Instance.optSetuna.Setuna.FullscreenCursor)
{
fullscreenHorLine.Opacity = base.Opacity;
fullscreenHorLine.Visible = base.Visible;
fullscreenVerLine.Opacity = base.Opacity;
fullscreenVerLine.Visible = base.Visible;
fullscreenHorLine.Refresh();
fullscreenVerLine.Refresh();
}

if (Mainform.Instance.optSetuna.Setuna.MagnifierEnabled)
{
magnifier.Opacity = base.Opacity;
magnifier.Visible = base.Visible;
magnifier.Refresh();
}

Refresh();
Thread.Sleep(10);
base.Opacity = 0.99000000953674316;

if (Mainform.Instance.optSetuna.Setuna.FullscreenCursor)
{
fullscreenHorLine.Opacity = base.Opacity;
fullscreenVerLine.Opacity = base.Opacity;
}

if (Mainform.Instance.optSetuna.Setuna.MagnifierEnabled)
{
magnifier.Opacity = base.Opacity;
}
}

// Token: 0x060002A2 RID: 674 RVA: 0x0000E832 File Offset: 0x0000CA32
Expand Down Expand Up @@ -361,6 +461,12 @@ private void LineRefresh()
CaptureForm.selLineHor2.SetBounds(targetScreen.Bounds.X, targetScreen.Bounds.Y - 10, targetScreen.Bounds.Width, 1);
CaptureForm.selLineVer1.SetBounds(targetScreen.Bounds.X - 10, targetScreen.Bounds.Y, 1, targetScreen.Bounds.Height);
CaptureForm.selLineVer2.SetBounds(targetScreen.Bounds.X - 10, targetScreen.Bounds.Y, 1, CaptureForm.selLineVer2.Height = targetScreen.Bounds.Height);

fullscreenHorLine.Hide();
fullscreenVerLine.Hide();

magnifier.Hide();

base.Hide();
Console.WriteLine("Hide end---");
}
Expand Down Expand Up @@ -429,8 +535,8 @@ private void CaptureForm_FormClosing(object sender, FormClosingEventArgs e)
// Token: 0x060002AB RID: 683 RVA: 0x0000EC00 File Offset: 0x0000CE00
private void CaptureForm_MouseDown(object sender, MouseEventArgs e)
{
ptStart.X = targetScreen.Bounds.X + e.Location.X;
ptStart.Y = targetScreen.Bounds.Y + e.Location.Y;
ptStart.X = targetScreen.Bounds.X + e.X;
ptStart.Y = targetScreen.Bounds.Y + e.Y;
DrawSelectArea(0, 0, 1, 1, BoundsSpecified.Size);
blDrag = true;
}
Expand Down Expand Up @@ -501,12 +607,47 @@ private void CaptureForm_MouseUp(object sender, MouseEventArgs e)
// Token: 0x060002AE RID: 686 RVA: 0x0000EEF4 File Offset: 0x0000D0F4
private void CaptureForm_MouseMove(object sender, MouseEventArgs e)
{
if (Mainform.Instance.optSetuna.Setuna.FullscreenCursor)
{
var cursorPos = Cursor.Position;
var cursorRealPos = new Point(cursorPos.X - targetScreen.Bounds.X, cursorPos.Y - targetScreen.Bounds.Y);
fullscreenHorLine.SetSelSize(0, targetScreen.Bounds.Width);
if (fullscreenHorLine.Top != cursorPos.Y)
{
fullscreenHorLine.Top = cursorPos.Y;
}
fullscreenVerLine.SetSelSize(0, targetScreen.Bounds.Height);
if (fullscreenVerLine.Left != cursorPos.X)
{
fullscreenVerLine.Left = cursorPos.X;
}
}

if (blDrag)
{
DrawSelRect();
return;
}
DrawSelectArea(0, 0, 1, 1, BoundsSpecified.All);
else
{
DrawSelectArea(0, 0, 1, 1, BoundsSpecified.All);
}

if (Mainform.Instance.optSetuna.Setuna.MagnifierEnabled)
{
var cursorPos = Cursor.Position;
var point = Point.Empty;
var point2 = Point.Empty;

if (blDrag)
{
point.X = Math.Min(ptStart.X, ptEnd.X);
point.Y = Math.Min(ptStart.Y, ptEnd.Y);
point2.X = Math.Max(ptStart.X, ptEnd.X);
point2.Y = Math.Max(ptStart.Y, ptEnd.Y);
}

magnifier.SetText(cursorPos.X, cursorPos.Y, point2.X - point.X, point2.Y - point.Y);
}
}

// Token: 0x060002AF RID: 687 RVA: 0x0000EF14 File Offset: 0x0000D114
Expand Down Expand Up @@ -594,16 +735,6 @@ private void CreateClip(Point pt, Size size)
}
}

// Token: 0x060002B4 RID: 692 RVA: 0x0000F248 File Offset: 0x0000D448
private void timer1_Tick(object sender, EventArgs e)
{
CaptureSelLine.AddDashOffset();
CaptureForm.selLineVer1.Refresh();
CaptureForm.selLineVer2.Refresh();
CaptureForm.selLineHor1.Refresh();
CaptureForm.selLineHor2.Refresh();
}

// Token: 0x060002B5 RID: 693 RVA: 0x0000F278 File Offset: 0x0000D478
private void CaptureForm_KeyPress(object sender, KeyPressEventArgs e)
{
Expand Down Expand Up @@ -634,6 +765,7 @@ private void CaptureForm_KeyUp(object sender, KeyEventArgs e)
}
}


// Token: 0x04000127 RID: 295
private const int GW_OWNER = 4;

Expand Down Expand Up @@ -744,5 +876,12 @@ public struct RECT
// Token: 0x02000070 RID: 112
// (Invoke) Token: 0x060003AE RID: 942
private delegate void LineRefreshDelegate();


private static CaptureSelLine fullscreenHorLine;
private static CaptureSelLine fullscreenVerLine;

private static Magnifier magnifier;

}
}
7 changes: 2 additions & 5 deletions SETUNA/Main/CaptureForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.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>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
26 changes: 25 additions & 1 deletion SETUNA/Main/Common/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
namespace SETUNA.Main
using System.Drawing;
using System.Drawing.Drawing2D;

namespace SETUNA.Main
{
class URLUtils
{
public const string OriginURL = "http://www.clearunit.com/clearup/setuna2/";

public const string NewURL = "https://www.github.com/tylearymf/setuna2/";
}


static class BitmapUtils
{
public static Bitmap ScaleToSize(this Bitmap bitmap, int width, int height)
{
if (bitmap.Width == width && bitmap.Height == height)
{
return bitmap;
}

var scaledBitmap = new Bitmap(width, height);
using (var g = Graphics.FromImage(scaledBitmap))
{
g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.DrawImage(bitmap, 0, 0, width, height);
}

return scaledBitmap;
}
}
}
Loading

0 comments on commit ab04855

Please sign in to comment.