Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mouse click effect capability for screen recording #7622

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
review: switch to full circle
  • Loading branch information
Vertygo committed Oct 2, 2024
commit dd383c8817e4079bd891d5933d9d3d2c07bac127
11 changes: 6 additions & 5 deletions ShareX.HelpersLib/Input/MouseClickEffectForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public MouseClickEffectForm()
AllowTransparency = true;
BackColor = Color.White; // Set a key color for transparency
TransparencyKey = Color.White; // Make that color transparent
Opacity = 0.3;
}

/// <summary>
Expand All @@ -40,24 +41,24 @@ public void ClearMouseEffect()
}

/// <summary>
/// Draw a hollow circle as an mouse effect
/// Draw a circle as an mouse effect
/// </summary>
protected override void OnPaint(PaintEventArgs e)
{
if (_drawEffect)
{
Graphics g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// Define a pen to draw hollow circle
Pen pen = new Pen(Color.Red, 3);
int diameter = 10;
// Define a brush to draw circle
Brush brush = new SolidBrush(Color.Red);
int diameter = 20;

// Calculate the top-left corner to center the circle
int x = (ClientSize.Width - diameter) / 2;
int y = (ClientSize.Height - diameter) / 2;

// .NET GDI+ is not precise when drawign circles this would be better off with WPF/vector-based drawing
g.DrawEllipse(pen, x, y, diameter, diameter);
g.FillEllipse(brush, x, y, diameter, diameter);
}

base.OnPaint(e);
Expand Down