mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Notification when hover show url
This commit is contained in:
parent
c734f5c208
commit
f3d65825b0
1 changed files with 17 additions and 1 deletions
|
@ -52,12 +52,15 @@ public partial class NotificationForm : Form
|
||||||
private int closingAnimationInterval = 50;
|
private int closingAnimationInterval = 50;
|
||||||
private Font textFont;
|
private Font textFont;
|
||||||
private int textPadding = 5;
|
private int textPadding = 5;
|
||||||
|
private int urlPadding = 3;
|
||||||
private Size textRenderSize;
|
private Size textRenderSize;
|
||||||
|
|
||||||
public NotificationForm(int duration, ContentAlignment placement, Size size, Image img, string text, string url)
|
public NotificationForm(int duration, ContentAlignment placement, Size size, Image img, string text, string url)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
textFont = new Font("Arial", 10);
|
||||||
|
|
||||||
if (img != null)
|
if (img != null)
|
||||||
{
|
{
|
||||||
img = ImageHelpers.ResizeImageLimit(img, size);
|
img = ImageHelpers.ResizeImageLimit(img, size);
|
||||||
|
@ -67,7 +70,6 @@ public NotificationForm(int duration, ContentAlignment placement, Size size, Ima
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(text))
|
else if (!string.IsNullOrEmpty(text))
|
||||||
{
|
{
|
||||||
textFont = new Font("Arial", 10);
|
|
||||||
textRenderSize = Helpers.MeasureText(text, textFont, size.Width - textPadding * 2);
|
textRenderSize = Helpers.MeasureText(text, textFont, size.Width - textPadding * 2);
|
||||||
size = new Size(textRenderSize.Width + textPadding * 2, textRenderSize.Height + textPadding * 2 + 2);
|
size = new Size(textRenderSize.Width + textPadding * 2, textRenderSize.Height + textPadding * 2 + 2);
|
||||||
ToastText = text;
|
ToastText = text;
|
||||||
|
@ -132,6 +134,18 @@ protected override void OnPaint(PaintEventArgs e)
|
||||||
if (ToastImage != null)
|
if (ToastImage != null)
|
||||||
{
|
{
|
||||||
g.DrawImage(ToastImage, 1, 1, ToastImage.Width, ToastImage.Height);
|
g.DrawImage(ToastImage, 1, 1, ToastImage.Width, ToastImage.Height);
|
||||||
|
|
||||||
|
if (mouseInside && !string.IsNullOrEmpty(ToastURL))
|
||||||
|
{
|
||||||
|
Rectangle textRect = new Rectangle(0, 0, rect.Width, 40);
|
||||||
|
|
||||||
|
using (SolidBrush brush = new SolidBrush(Color.FromArgb(150, 255, 255, 255)))
|
||||||
|
{
|
||||||
|
g.FillRectangle(brush, textRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.DrawString(ToastURL, textFont, Brushes.Black, textRect.RectangleOffset(-urlPadding));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(ToastText))
|
else if (!string.IsNullOrEmpty(ToastText))
|
||||||
{
|
{
|
||||||
|
@ -184,6 +198,7 @@ private void NotificationForm_MouseClick(object sender, MouseEventArgs e)
|
||||||
private void NotificationForm_MouseEnter(object sender, EventArgs e)
|
private void NotificationForm_MouseEnter(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
mouseInside = true;
|
mouseInside = true;
|
||||||
|
Refresh();
|
||||||
|
|
||||||
tOpacity.Stop();
|
tOpacity.Stop();
|
||||||
Opacity = 1;
|
Opacity = 1;
|
||||||
|
@ -192,6 +207,7 @@ private void NotificationForm_MouseEnter(object sender, EventArgs e)
|
||||||
private void NotificationForm_MouseLeave(object sender, EventArgs e)
|
private void NotificationForm_MouseLeave(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
mouseInside = false;
|
mouseInside = false;
|
||||||
|
Refresh();
|
||||||
|
|
||||||
if (durationEnd)
|
if (durationEnd)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue