From 9ecbf3c30f12f27b0bbc0647318bfb9bc08f1b77 Mon Sep 17 00:00:00 2001 From: Michael Delpach Date: Sat, 15 Aug 2015 07:35:33 +0800 Subject: [PATCH] LargeFileSizeWarning uses MB or MiB --- ShareX/ApplicationConfig.cs | 5 ++--- ShareX/UploadTask.cs | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ShareX/ApplicationConfig.cs b/ShareX/ApplicationConfig.cs index 3acc238ac..f004f8e93 100644 --- a/ShareX/ApplicationConfig.cs +++ b/ShareX/ApplicationConfig.cs @@ -40,7 +40,6 @@ public class ApplicationConfig : SettingsBase public string FileUploadDefaultDirectory = ""; public bool ShowUploadWarning = true; // First time upload warning public bool ShowMultiUploadWarning = true; // More than 10 files upload warning - public bool ShowLargeFileUploadWarning = true; public bool ShowTrayLeftClickTip = true; // Tray icon left click tip public int NameParserAutoIncrementNumber = 0; public RecentItem[] RecentLinks = null; @@ -152,8 +151,8 @@ public ApplicationConfig() [Category("Application"), DefaultValue(10), Description("In recent links tray menu max how many links to show.")] public int RecentLinksMaxCount { get; set; } - [Category("Application"), DefaultValue(104857600), Description("Large file size defined in bytes. ShareX will warn before uploading large files. 0 disables this feature.")] - public long LargeFileSize { get; set; } + [Category("Application"), DefaultValue(100), Description("Large file size defined in MiB or MB. ShareX will warn before uploading large files. 0 disables this feature.")] + public int LargeFileSizeWarning { get; set; } [Category("Application"), DefaultValue(""), Description("URLs will open using this path instead of default browser. Example path: chrome.exe")] [Editor(typeof(ExeFileNameEditor), typeof(UITypeEditor))] diff --git a/ShareX/UploadTask.cs b/ShareX/UploadTask.cs index 30defe742..cec9b5bad 100644 --- a/ShareX/UploadTask.cs +++ b/ShareX/UploadTask.cs @@ -311,16 +311,20 @@ private void DoUploadJob() Stop(); } - if (Program.Settings.LargeFileSize != 0 && Data.Length > Program.Settings.LargeFileSize) + if (Program.Settings.LargeFileSizeWarning != 0) { - using (MyMessageBox msgbox = new MyMessageBox( - "You are attempting to upload a large file.\n\nAre you sure you want to continue?", - Application.ProductName, - MessageBoxButtons.YesNo, Resources.UploadManager_IsUploadConfirmed_Don_t_show_this_message_again_)) + long dataSize = Program.Settings.BinaryUnits ? Program.Settings.LargeFileSizeWarning * 1024 * 1024 : Program.Settings.LargeFileSizeWarning * 1000 * 1000; + if (Data != null && Data.Length > dataSize) { - msgbox.ShowDialog(); - Program.Settings.ShowLargeFileUploadWarning = !msgbox.IsChecked; - if (msgbox.DialogResult == DialogResult.No) Stop(); + using (MyMessageBox msgbox = new MyMessageBox( + "You are attempting to upload a large file.\n\nAre you sure you want to continue?", + Application.ProductName, + MessageBoxButtons.YesNo, Resources.UploadManager_IsUploadConfirmed_Don_t_show_this_message_again_)) + { + msgbox.ShowDialog(); + if (msgbox.IsChecked) Program.Settings.LargeFileSizeWarning = 0; + if (msgbox.DialogResult == DialogResult.No) Stop(); + } } }