mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Notification form top most
This commit is contained in:
parent
c9dff4a04a
commit
44f1c4330f
2 changed files with 9 additions and 8 deletions
1
ShareX/Forms/NotificationForm.Designer.cs
generated
1
ShareX/Forms/NotificationForm.Designer.cs
generated
|
@ -47,6 +47,7 @@ private void InitializeComponent()
|
||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||||
this.Text = "ToastForm";
|
this.Text = "ToastForm";
|
||||||
|
this.TopMost = true;
|
||||||
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.NotificationForm_MouseClick);
|
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.NotificationForm_MouseClick);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,9 @@ public NotificationForm(int duration, Size size, string text, Image image, strin
|
||||||
URL = url;
|
URL = url;
|
||||||
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
|
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
|
||||||
Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - Width - windowOffset, Screen.PrimaryScreen.WorkingArea.Bottom - Height - windowOffset);
|
Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - Width - windowOffset, Screen.PrimaryScreen.WorkingArea.Bottom - Height - windowOffset);
|
||||||
NativeMethods.AnimateWindow(Handle, 1000, AnimateWindowFlags.AW_BLEND);
|
NativeMethods.SetWindowPos(Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, 0, 0, 0, 0,
|
||||||
|
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
|
||||||
|
NativeMethods.AnimateWindow(Handle, 500, AnimateWindowFlags.AW_SLIDE | AnimateWindowFlags.AW_VER_NEGATIVE);
|
||||||
tDuration.Interval = duration;
|
tDuration.Interval = duration;
|
||||||
tDuration.Start();
|
tDuration.Start();
|
||||||
}
|
}
|
||||||
|
@ -75,9 +77,9 @@ protected override void OnPaint(PaintEventArgs e)
|
||||||
|
|
||||||
g.DrawImage(ToastImage, 1, 1, ToastImage.Width, ToastImage.Height);
|
g.DrawImage(ToastImage, 1, 1, ToastImage.Width, ToastImage.Height);
|
||||||
|
|
||||||
using (SolidBrush brush = new SolidBrush(Color.FromArgb(200, 255, 255, 255)))
|
using (SolidBrush brush = new SolidBrush(Color.FromArgb(150, 255, 255, 255)))
|
||||||
{
|
{
|
||||||
g.FillRectangle(brush, new Rectangle(0, 0, e.ClipRectangle.Width, 40));
|
g.FillRectangle(brush, new Rectangle(0, 0, e.ClipRectangle.Width, 45));
|
||||||
}
|
}
|
||||||
|
|
||||||
using (Font font = new Font("Arial", 10))
|
using (Font font = new Font("Arial", 10))
|
||||||
|
@ -114,11 +116,9 @@ private void NotificationForm_MouseClick(object sender, MouseEventArgs e)
|
||||||
Helpers.LoadBrowserAsync(URL);
|
Helpers.LoadBrowserAsync(URL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.Button == MouseButtons.Right)
|
|
||||||
{
|
|
||||||
tDuration.Stop();
|
tDuration.Stop();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue