]> granicus.if.org Git - handbrake/commitdiff
WinGui: Make the error message nicer when the system clipboard is unavailable. #1498
authorsr55 <sr55.hb@outlook.com>
Wed, 25 Jul 2018 20:13:35 +0000 (21:13 +0100)
committersr55 <sr55.hb@outlook.com>
Wed, 25 Jul 2018 20:13:35 +0000 (21:13 +0100)
win/CS/HandBrakeWPF/App.xaml.cs
win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
win/CS/HandBrakeWPF/Properties/Resources.resx
win/CS/HandBrakeWPF/ViewModels/ErrorViewModel.cs
win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs

index a3809bea75181da2c0bab6442910c6fe466a9fc6..60b1bf10e77fc95ac4cbb9b25d78e07bb7026950 100644 (file)
@@ -19,6 +19,7 @@ namespace HandBrakeWPF
     using Caliburn.Micro;\r
 \r
     using HandBrakeWPF.Helpers;\r
+    using HandBrakeWPF.Services.Interfaces;\r
     using HandBrakeWPF.Startup;\r
     using HandBrakeWPF.Utilities;\r
     using HandBrakeWPF.ViewModels;\r
@@ -175,9 +176,10 @@ namespace HandBrakeWPF
             try\r
             {\r
                 IWindowManager windowManager = IoC.Get<IWindowManager>();\r
+                IErrorService errorService = IoC.Get<IErrorService>();\r
                 if (windowManager != null)\r
                 {\r
-                    ErrorViewModel errorView = new ErrorViewModel();\r
+                    ErrorViewModel errorView = new ErrorViewModel(errorService);\r
                     GeneralApplicationException applicationException = null;\r
                     if (exception.GetType() == typeof(GeneralApplicationException))\r
                     {\r
index a22cf482b78fa7389662b371328cc56211acbe01..bbe866be0032e18c0d51c877a3f9d9d558568996 100644 (file)
@@ -575,6 +575,24 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The system clipboard is currently unavailable..\r
+        /// </summary>\r
+        public static string Clipboard_Unavailable {\r
+            get {\r
+                return ResourceManager.GetString("Clipboard_Unavailable", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to This may be due to another application monitoring or locking the clipboard for its own use. You will not be able to use the clipboard until it is unlocked..\r
+        /// </summary>\r
+        public static string Clipboard_Unavailable_Solution {\r
+            get {\r
+                return ResourceManager.GetString("Clipboard_Unavailable_Solution", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Confirm.\r
         /// </summary>\r
index 84d46f2b923dab2664c478b8b53628a08b2e7efb..21bed46f7bc7a53b20b7ff3bd04e3a5cc75af9cd 100644 (file)
@@ -885,4 +885,10 @@ Time Remaining: {5},  Elapsed: {6:d\:hh\:mm\:ss}</value>
     <value>The file '{0}' already exists!\r
 Would you like to overwrite it?</value>\r
   </data>\r
+  <data name="Clipboard_Unavailable" xml:space="preserve">\r
+    <value>The system clipboard is currently unavailable.</value>\r
+  </data>\r
+  <data name="Clipboard_Unavailable_Solution" xml:space="preserve">\r
+    <value>This may be due to another application monitoring or locking the clipboard for its own use. You will not be able to use the clipboard until it is unlocked.</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index be57cd8042464ab24a424c09532834a2719a4b3a..ddea7a5e5c5685ff125c41d80d2e29b774079622 100644 (file)
@@ -13,6 +13,7 @@ namespace HandBrakeWPF.ViewModels
     using System.Windows;\r
 \r
     using HandBrakeWPF.Properties;\r
+    using HandBrakeWPF.Services.Interfaces;\r
     using HandBrakeWPF.ViewModels.Interfaces;\r
 \r
     /// <summary>\r
@@ -20,32 +21,20 @@ namespace HandBrakeWPF.ViewModels
     /// </summary>\r
     public class ErrorViewModel : ViewModelBase, IErrorViewModel\r
     {\r
-        #region Constants and Fields\r
+        private readonly IErrorService errorService;\r
 \r
-        /// <summary>\r
-        /// The details.\r
-        /// </summary>\r
         private string details;\r
-\r
-        /// <summary>\r
-        /// The error message.\r
-        /// </summary>\r
         private string errorMessage;\r
-\r
-        /// <summary>\r
-        /// The solution.\r
-        /// </summary>\r
         private string solution;\r
 \r
-        #endregion\r
-\r
         #region Constructors and Destructors\r
 \r
         /// <summary>\r
         /// Initializes a new instance of the <see cref="ErrorViewModel"/> class.\r
         /// </summary>\r
-        public ErrorViewModel()\r
+        public ErrorViewModel(IErrorService errorService)\r
         {\r
+            this.errorService = errorService;\r
             this.Title = Resources.Error;\r
             this.ErrorMessage = Resources.ErrorViewModel_UnknownError;\r
             this.Details = Resources.ErrorViewModel_NoFurtherInformation;\r
@@ -128,7 +117,14 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void Copy()\r
         {\r
-            Clipboard.SetDataObject(this.ErrorMessage + Environment.NewLine + this.Details, true);\r
+            try\r
+            {\r
+                Clipboard.SetDataObject(this.ErrorMessage + Environment.NewLine + this.Details, true);\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                this.errorService.ShowError(Resources.Clipboard_Unavailable, Resources.Clipboard_Unavailable_Solution, exc);\r
+            }\r
         }\r
     }\r
 }
\ No newline at end of file
index 6573b1f5a29a28536e97bd38a00504fbb33e04b9..d1ed6654dd0af1b72ccdfe76a80325196c952626 100644 (file)
@@ -16,6 +16,8 @@ namespace HandBrakeWPF.ViewModels
 \r
     using Caliburn.Micro;\r
 \r
+    using HandBrakeWPF.Properties;\r
+    using HandBrakeWPF.Services.Interfaces;\r
     using HandBrakeWPF.Utilities;\r
     using HandBrakeWPF.ViewModels.Interfaces;\r
 \r
@@ -29,6 +31,8 @@ namespace HandBrakeWPF.ViewModels
     /// </summary>\r
     public class LogViewModel : ViewModelBase, ILogViewModel\r
     {\r
+        private readonly IErrorService errorService;\r
+\r
         #region Private Fields\r
 \r
         private readonly ILog logService;\r
@@ -40,8 +44,9 @@ namespace HandBrakeWPF.ViewModels
         /// <summary>\r
         /// Initializes a new instance of the <see cref="LogViewModel"/> class.\r
         /// </summary>\r
-        public LogViewModel()\r
+        public LogViewModel(IErrorService errorService)\r
         {\r
+            this.errorService = errorService;\r
             this.logService = LogService.GetLogger();\r
             this.Title = "Log Viewer";\r
         }\r
@@ -78,7 +83,14 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void CopyLog()\r
         {\r
-            Clipboard.SetDataObject(this.ActivityLog, true);\r
+            try\r
+            {\r
+                Clipboard.SetDataObject(this.ActivityLog, true);\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                this.errorService.ShowError(Resources.Clipboard_Unavailable, Resources.Clipboard_Unavailable_Solution, exc);\r
+            }\r
         }\r
 \r
         /// <summary>\r