mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Toast window duration and size settings
This commit is contained in:
parent
fa0b0a9ac8
commit
e0934da422
3 changed files with 17 additions and 4 deletions
|
@ -95,18 +95,23 @@ protected override void OnPaint(PaintEventArgs e)
|
|||
g.DrawRectangleProper(Pens.Black, e.ClipRectangle);
|
||||
}
|
||||
|
||||
public static void Show(string imagePath, string url)
|
||||
public static void Show(int duration, Size size, string imagePath, string url)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(imagePath) && Helpers.IsImageFile(imagePath) && File.Exists(imagePath))
|
||||
if (duration > 0 && !size.IsEmpty && !string.IsNullOrEmpty(imagePath) && Helpers.IsImageFile(imagePath) && File.Exists(imagePath))
|
||||
{
|
||||
Image img = ImageHelpers.LoadImage(imagePath);
|
||||
NotificationForm form = new NotificationForm(4000, new Size(400, 300), img, url);
|
||||
NotificationForm form = new NotificationForm(duration, size, img, url);
|
||||
NativeMethods.ShowWindow(form.Handle, (int)WindowShowStyle.ShowNoActivate);
|
||||
NativeMethods.SetWindowPos(form.Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, 0, 0, 0, 0,
|
||||
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Show(string imagePath, string url)
|
||||
{
|
||||
Show(4000, new Size(400, 300), imagePath, url);
|
||||
}
|
||||
|
||||
private void NotificationForm_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
tDuration.Stop();
|
||||
|
|
|
@ -324,7 +324,7 @@ private static void task_UploadCompleted(UploadTask task)
|
|||
|
||||
if (task.Info.TaskSettings.GeneralSettings.ShowToastWindowAfterTask)
|
||||
{
|
||||
NotificationForm.Show(info.FilePath, result);
|
||||
NotificationForm.Show((int)(task.Info.TaskSettings.AdvancedSettings.ToastWindowDuration * 1000), task.Info.TaskSettings.AdvancedSettings.ToastWindowSize, info.FilePath, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ You should have received a copy of the GNU General Public License
|
|||
using ScreenCaptureLib;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using UploadersLib;
|
||||
|
||||
namespace ShareX
|
||||
|
@ -167,6 +168,7 @@ private void SetDefaultSettings()
|
|||
{
|
||||
CaptureSettings = defaultTaskSettings.CaptureSettings;
|
||||
}
|
||||
|
||||
if (UseDefaultUploadSettings)
|
||||
{
|
||||
UploadSettings = defaultTaskSettings.UploadSettings;
|
||||
|
@ -294,6 +296,12 @@ public class TaskSettingsAdvanced
|
|||
[Category("After upload"), DefaultValue(""), Description("Balloon tip content format after uploading. Supported variables: $result, $url, $shorturl, $thumbnailurl, $deletionurl, $filepath, $filename, $filenamenoext, $folderpath, $foldername, $uploadtime and other variables such as %y-%mo-%d etc.")]
|
||||
public string BalloonTipContentFormat { get; set; }
|
||||
|
||||
[Category("After upload"), DefaultValue(4f), Description("How much toast window will stay on screen.")]
|
||||
public float ToastWindowDuration { get; set; }
|
||||
|
||||
[Category("After upload"), DefaultValue(typeof(Size), "400, 300"), Description("Maximum toast window size.")]
|
||||
public Size ToastWindowSize { get; set; }
|
||||
|
||||
[Category("After upload"), DefaultValue(false), Description("After upload form will be automatically closed after 60 seconds.")]
|
||||
public bool AutoCloseAfterUploadForm { get; set; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue