Pārlūkot izejas kodu

Added handler for MissingSettingException

Kenric Nugteren 1 gadu atpakaļ
vecāks
revīzija
d023e1ba4d
1 mainītis faili ar 26 papildinājumiem un 0 dzēšanām
  1. 26 0
      prs.desktop/Utils/PostUtils.cs

+ 26 - 0
prs.desktop/Utils/PostUtils.cs

@@ -78,6 +78,32 @@ public static class PostUtils
         {
             MessageWindow.ShowMessage("Processing cancelled.", "Cancelled");
         }
+        catch(MissingSettingException e)
+        {
+            if (configurePost is not null && Security.CanConfigurePost<T>())
+            {
+                if (MessageWindow.ShowYesNo($"'{e.Setting}' has not been set-up for {inflector.Pluralize(typeof(T).Name)}. Would you like to configure this now?",
+                    "Configure Processing?"))
+                {
+                    if (e.SettingsType.IsAssignableTo(typeof(IGlobalPosterSettings)))
+                    {
+                        PostableSettingsGrid.ConfigureGlobalPosterSettings(e.SettingsType);
+                    }
+                    else
+                    {
+                        PostableSettingsGrid.ConfigurePosterSettings<T>(e.SettingsType);
+                    }
+                }
+                else
+                {
+                    MessageWindow.ShowMessage("Processing cancelled.", "Cancelled");
+                }
+            }
+            else
+            {
+                MessageWindow.ShowMessage($"'{e.Setting}' has not been set-up for {inflector.Pluralize(typeof(T).Name)}", "Unconfigured");
+            }
+        }
         catch (MissingSettingsException)
         {
             if (configurePost is not null && Security.CanConfigurePost<T>())