Преглед на файлове

Async await task performance enhancement

Ruben преди 5 години
родител
ревизия
0de9d1a30a
променени са 31 файла, в които са добавени 186 реда и са изтрити 586 реда
  1. 3 0
      .editorconfig
  2. 0 4
      PicView/ChangeImage/Error_Handling.cs
  3. 14 9
      PicView/ChangeImage/GoToLogic.cs
  4. 1 9
      PicView/ChangeImage/LoadFromWeb.cs
  5. 0 15
      PicView/ChangeImage/Navigation.cs
  6. 0 4
      PicView/ChangeImage/Preloader.cs
  7. 2 2
      PicView/FileHandling/DeleteFiles.cs
  8. 1 1
      PicView/FileHandling/RecentFiles.cs
  9. 1 1
      PicView/Library/Resources/Timers.cs
  10. 1 1
      PicView/Properties/launchSettings.json
  11. 2 2
      PicView/Shortcuts/CustomTextBoxShortcuts.cs
  12. 4 4
      PicView/Shortcuts/GotoPicsShortcuts.cs
  13. 1 2
      PicView/Shortcuts/MainShortcuts.cs
  14. 2 8
      PicView/SystemIntegration/MonitorSize.cs
  15. 6 3
      PicView/SystemIntegration/NativeMethods.cs
  16. 1 3
      PicView/UI/DragAndDrop.cs
  17. 2 2
      PicView/UI/EditTitleBar.cs
  18. 4 4
      PicView/UI/HideInterfaceLogic.cs
  19. 0 32
      PicView/UI/Loading/AjaxLoader.cs
  20. 10 10
      PicView/UI/Loading/EventsHandling.cs
  21. 18 18
      PicView/UI/Loading/LoadContextMenus.cs
  22. 4 14
      PicView/UI/Loading/StartLoading.cs
  23. 2 2
      PicView/UI/PicGallery/GalleryLoad.cs
  24. 2 2
      PicView/UI/SlideShow.cs
  25. 3 3
      PicView/UI/TransformImage/Zoom.cs
  26. 100 95
      PicView/UI/UpdateUIValues.cs
  27. 1 1
      PicView/UI/UserControls/Menus/QuickSettingsMenu.xaml.cs
  28. 0 318
      PicView/UI/UserControls/Misc/AjaxLoading.xaml
  29. 0 15
      PicView/UI/UserControls/Misc/AjaxLoading.xaml.cs
  30. 0 1
      PicView/UI/UserControls/UC.cs
  31. 1 1
      PicView/UI/Windows/MainWindow.xaml.cs

+ 3 - 0
.editorconfig

@@ -2,3 +2,6 @@
 
 
 # CA1031: Do not catch general exception types
 # CA1031: Do not catch general exception types
 dotnet_diagnostic.CA1031.severity = none
 dotnet_diagnostic.CA1031.severity = none
+
+# IDE0060: Remove unused parameter
+dotnet_code_quality_unused_parameters = all:suggestion

+ 0 - 4
PicView/ChangeImage/Error_Handling.cs

@@ -12,7 +12,6 @@ using static PicView.FileHandling.DeleteFiles;
 using static PicView.FileHandling.FileLists;
 using static PicView.FileHandling.FileLists;
 using static PicView.ImageHandling.ImageDecoder;
 using static PicView.ImageHandling.ImageDecoder;
 using static PicView.Library.Fields;
 using static PicView.Library.Fields;
-using static PicView.UI.Loading.AjaxLoader;
 using static PicView.UI.Tooltip;
 using static PicView.UI.Tooltip;
 using static PicView.UI.TransformImage.Rotation;
 using static PicView.UI.TransformImage.Rotation;
 using static PicView.UI.UserControls.UC;
 using static PicView.UI.UserControls.UC;
@@ -136,8 +135,6 @@ namespace PicView.ChangeImage
                 ShowTooltipMessage("File not found or unable to render, " + file, false, TimeSpan.FromSeconds(2.5));
                 ShowTooltipMessage("File not found or unable to render, " + file, false, TimeSpan.FromSeconds(2.5));
             }
             }
 
 
-            AjaxLoadingEnd();
-
             // Repeat process if the next image was not found
             // Repeat process if the next image was not found
             if (FolderIndex > 0 && FolderIndex < Pics.Count)
             if (FolderIndex > 0 && FolderIndex < Pics.Count)
             {
             {
@@ -262,7 +259,6 @@ namespace PicView.ChangeImage
             }
             }
 
 
             SystemIntegration.Taskbar.NoProgress();
             SystemIntegration.Taskbar.NoProgress();
-            AnimationHelper.Fade(ajaxLoading, 0, TimeSpan.FromSeconds(.2));
         }
         }
     }
     }
 }
 }

+ 14 - 9
PicView/ChangeImage/GoToLogic.cs

@@ -1,4 +1,4 @@
-using PicView.UI.Loading;
+using System;
 using System.Globalization;
 using System.Globalization;
 using System.Windows;
 using System.Windows;
 using System.Windows.Input;
 using System.Windows.Input;
@@ -18,7 +18,10 @@ namespace PicView.ChangeImage
                 x = x <= 0 ? 0 : x;
                 x = x <= 0 ? 0 : x;
                 x = x >= Pics.Count ? Pics.Count - 1 : x;
                 x = x >= Pics.Count ? Pics.Count - 1 : x;
                 await Navigation.Pic(x).ConfigureAwait(false);
                 await Navigation.Pic(x).ConfigureAwait(false);
-                quickSettingsMenu.GoToPicBox.Text = (x + 1).ToString(CultureInfo.CurrentCulture);
+                await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
+                {
+                    quickSettingsMenu.GoToPicBox.Text = (x + 1).ToString(CultureInfo.CurrentCulture);
+                }));
             }
             }
             else
             else
             {
             {
@@ -27,14 +30,16 @@ namespace PicView.ChangeImage
             }
             }
         }
         }
 
 
-        internal static void ClearGoTo()
+        internal static async System.Threading.Tasks.Task ClearGoToAsync()
         {
         {
-            quickSettingsMenu.GoToPicBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
-            FocusManager.SetFocusedElement(FocusManager.GetFocusScope(quickSettingsMenu.GoToPicBox), null);
-            Close_UserControls();
-            Keyboard.ClearFocus();
-            mainWindow.Focus();
-            AjaxLoader.AjaxLoadingEnd();
+            await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
+            {
+                quickSettingsMenu.GoToPicBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
+                FocusManager.SetFocusedElement(FocusManager.GetFocusScope(quickSettingsMenu.GoToPicBox), null);
+                Close_UserControls();
+                Keyboard.ClearFocus();
+                mainWindow.Focus();
+            }));
         }
         }
     }
     }
 }
 }

+ 1 - 9
PicView/ChangeImage/LoadFromWeb.cs

@@ -10,10 +10,8 @@ using static PicView.ChangeImage.Error_Handling;
 using static PicView.ChangeImage.Navigation;
 using static PicView.ChangeImage.Navigation;
 using static PicView.ImageHandling.ImageDecoder;
 using static PicView.ImageHandling.ImageDecoder;
 using static PicView.Library.Fields;
 using static PicView.Library.Fields;
-using static PicView.UI.Loading.AjaxLoader;
 using static PicView.UI.SetTitle;
 using static PicView.UI.SetTitle;
 using static PicView.UI.Tooltip;
 using static PicView.UI.Tooltip;
-using static PicView.UI.UserControls.UC;
 
 
 namespace PicView.ChangeImage
 namespace PicView.ChangeImage
 {
 {
@@ -25,11 +23,6 @@ namespace PicView.ChangeImage
         /// <param name="path"></param>
         /// <param name="path"></param>
         internal static async Task PicWeb(string path)
         internal static async Task PicWeb(string path)
         {
         {
-            if (ajaxLoading.Opacity != 1)
-            {
-                AjaxLoadingStart();
-            }
-
             mainWindow.Bar.Text = Loading;
             mainWindow.Bar.Text = Loading;
 
 
             BitmapSource pic;
             BitmapSource pic;
@@ -53,8 +46,7 @@ namespace PicView.ChangeImage
 
 
             if (pic == null)
             if (pic == null)
             {
             {
-                Reload(true);
-                AjaxLoadingEnd();
+                await Reload(true).ConfigureAwait(false);
                 return;
                 return;
             }
             }
 
 

+ 0 - 15
PicView/ChangeImage/Navigation.cs

@@ -14,7 +14,6 @@ using static PicView.FileHandling.FileLists;
 using static PicView.ImageHandling.ImageDecoder;
 using static PicView.ImageHandling.ImageDecoder;
 using static PicView.ImageHandling.Thumbnails;
 using static PicView.ImageHandling.Thumbnails;
 using static PicView.Library.Fields;
 using static PicView.Library.Fields;
-using static PicView.UI.Loading.AjaxLoader;
 using static PicView.UI.SetTitle;
 using static PicView.UI.SetTitle;
 using static PicView.UI.Sizing.ScaleImage;
 using static PicView.UI.Sizing.ScaleImage;
 using static PicView.UI.Tooltip;
 using static PicView.UI.Tooltip;
@@ -36,10 +35,6 @@ namespace PicView.ChangeImage
             // Set Loading
             // Set Loading
             mainWindow.Title = mainWindow.Bar.Text = Loading;
             mainWindow.Title = mainWindow.Bar.Text = Loading;
             mainWindow.Bar.ToolTip = Loading;
             mainWindow.Bar.ToolTip = Loading;
-            if (mainWindow.img.Source == null)
-            {
-                AjaxLoadingStart();
-            }
 
 
             // Handle if from web
             // Handle if from web
             if (!File.Exists(path))
             if (!File.Exists(path))
@@ -115,10 +110,6 @@ namespace PicView.ChangeImage
             if (FreshStartup)
             if (FreshStartup)
                 Trace.WriteLine("Pic(string path) entering Pic(int x)");
                 Trace.WriteLine("Pic(string path) entering Pic(int x)");
 #endif
 #endif
-            if (ajaxLoading.Opacity != 0)
-            {
-                AjaxLoadingEnd();
-            }
 
 
             // Navigate to picture using obtained index
             // Navigate to picture using obtained index
             await Pic(FolderIndex).ConfigureAwait(false);
             await Pic(FolderIndex).ConfigureAwait(false);
@@ -186,16 +177,12 @@ namespace PicView.ChangeImage
                 }
                 }
                 else
                 else
                 {
                 {
-                    AjaxLoadingStart();
-
                     do
                     do
                     {
                     {
                         // Try again while loading
                         // Try again while loading
                         pic = Preloader.Load(Pics[x]);
                         pic = Preloader.Load(Pics[x]);
                         await Task.Delay(3).ConfigureAwait(true);
                         await Task.Delay(3).ConfigureAwait(true);
                     } while (Preloader.IsLoading);
                     } while (Preloader.IsLoading);
-
-                    AjaxLoadingEnd();
                 }
                 }
 
 
                 // If pic is still null, image can't be rendered
                 // If pic is still null, image can't be rendered
@@ -332,8 +319,6 @@ namespace PicView.ChangeImage
 
 
             quickSettingsMenu.GoToPicBox.Text = (FolderIndex + 1).ToString(CultureInfo.CurrentCulture);
             quickSettingsMenu.GoToPicBox.Text = (FolderIndex + 1).ToString(CultureInfo.CurrentCulture);
 
 
-            AjaxLoadingEnd();
-
             prevPicResource = null; // Make sure to not waste memory
             prevPicResource = null; // Make sure to not waste memory
         }
         }
 
 

+ 0 - 4
PicView/ChangeImage/Preloader.cs

@@ -90,10 +90,6 @@ namespace PicView.ChangeImage
 
 
             IsLoading = true;
             IsLoading = true;
 
 
-            //#if DEBUG
-            //            System.Threading.Thread.Sleep(1000);
-            //#endif
-
             if (File.Exists(Pics[i]))
             if (File.Exists(Pics[i]))
             {
             {
                 if (!Contains(Pics[i]))
                 if (!Contains(Pics[i]))

+ 2 - 2
PicView/FileHandling/DeleteFiles.cs

@@ -84,7 +84,7 @@ namespace PicView.FileHandling
         /// and display information
         /// and display information
         /// </summary>
         /// </summary>
         /// <param name="Recyclebin"></param>
         /// <param name="Recyclebin"></param>
-        internal static void DeleteFile(string file, bool Recyclebin)
+        internal static async System.Threading.Tasks.Task DeleteFileAsync(string file, bool Recyclebin)
         {
         {
             if (!TryDeleteFile(file, Recyclebin))
             if (!TryDeleteFile(file, Recyclebin))
             {
             {
@@ -105,7 +105,7 @@ namespace PicView.FileHandling
 
 
             PreloadCount = Reverse ? PreloadCount - 1 : PreloadCount + 1;
             PreloadCount = Reverse ? PreloadCount - 1 : PreloadCount + 1;
 
 
-            Pic(Reverse);
+            await Pic(Reverse).ConfigureAwait(false);
         }
         }
     }
     }
 }
 }

+ 1 - 1
PicView/FileHandling/RecentFiles.cs

@@ -63,7 +63,7 @@ namespace PicView.FileHandling
         internal static void Add(string fileName)
         internal static void Add(string fileName)
         {
         {
             // Don't add zipped files
             // Don't add zipped files
-            if (IsZipped)
+            if (IsZipped || MRUlist == null)
             {
             {
                 return;
                 return;
             }
             }

+ 1 - 1
PicView/Library/Resources/Timers.cs

@@ -26,7 +26,7 @@ namespace PicView.Library.Resources
                 AutoReset = true,
                 AutoReset = true,
                 Enabled = false
                 Enabled = false
             };
             };
-            activityTimer.Elapsed += delegate { FadeControlsAsync(false); };
+            activityTimer.Elapsed += async delegate { await FadeControlsAsync(false).ConfigureAwait(false); };
 
 
             //fastPicTimer = new Timer()
             //fastPicTimer = new Timer()
             //{
             //{

+ 1 - 1
PicView/Properties/launchSettings.json

@@ -2,7 +2,7 @@
   "profiles": {
   "profiles": {
     "PicView": {
     "PicView": {
       "commandName": "Project",
       "commandName": "Project",
-      "commandLineArgs": "\"B:\\Pictures\\Somewhat SFW Characters\\323_paul_kwon_2b_nier_automata_02_zeronis_lr.jpg\""
+      "commandLineArgs": "\"B:\\Pictures\\Characters\\030_2b_full_body_by_kruel_kaiser_dcf7dd5.png\""
     }
     }
   }
   }
 }
 }

+ 2 - 2
PicView/Shortcuts/CustomTextBoxShortcuts.cs

@@ -6,12 +6,12 @@ namespace PicView
 {
 {
     internal static class CustomTextBoxShortcuts
     internal static class CustomTextBoxShortcuts
     {
     {
-        internal static void CustomTextBox_KeyDown(object sender, KeyEventArgs e)
+        internal static async System.Threading.Tasks.Task CustomTextBox_KeyDownAsync(object sender, KeyEventArgs e)
         {
         {
             switch (e.Key)
             switch (e.Key)
             {
             {
                 case Key.Enter:
                 case Key.Enter:
-                    EditTitleBar.HandleRename();
+                    await EditTitleBar.HandleRenameAsync().ConfigureAwait(false);
                     break;
                     break;
 
 
                 case Key.Escape:
                 case Key.Escape:

+ 4 - 4
PicView/Shortcuts/GotoPicsShortcuts.cs

@@ -8,7 +8,7 @@ namespace PicView
 {
 {
     internal static class GotoPicsShortcuts
     internal static class GotoPicsShortcuts
     {
     {
-        internal static void GoToPicPreviewKeys(object sender, KeyEventArgs e)
+        internal static async System.Threading.Tasks.Task GoToPicPreviewKeysAsync(object sender, KeyEventArgs e)
         {
         {
             switch (e.Key)
             switch (e.Key)
             {
             {
@@ -50,12 +50,12 @@ namespace PicView
                     }
                     }
                 case Key.Escape: // Escape logic
                 case Key.Escape: // Escape logic
                     quickSettingsMenu.GoToPicBox.Text = FolderIndex.ToString(CultureInfo.CurrentCulture);
                     quickSettingsMenu.GoToPicBox.Text = FolderIndex.ToString(CultureInfo.CurrentCulture);
-                    ClearGoTo();
+                    await ClearGoToAsync().ConfigureAwait(false);
                     break;
                     break;
 
 
                 case Key.Enter: // Execute it!
                 case Key.Enter: // Execute it!
-                    GoToPicEventAsync(sender, e);
-                    ClearGoTo();
+                    await GoToPicEventAsync(sender, e).ConfigureAwait(false);
+                    await ClearGoToAsync().ConfigureAwait(false);
                     break;
                     break;
 
 
                 default:
                 default:

+ 1 - 2
PicView/Shortcuts/MainShortcuts.cs

@@ -10,7 +10,6 @@ using static PicView.FileHandling.Copy_Paste;
 using static PicView.FileHandling.DeleteFiles;
 using static PicView.FileHandling.DeleteFiles;
 using static PicView.FileHandling.Open_Save;
 using static PicView.FileHandling.Open_Save;
 using static PicView.Library.Fields;
 using static PicView.Library.Fields;
-using static PicView.Library.Utilities;
 using static PicView.UI.Loading.LoadWindows;
 using static PicView.UI.Loading.LoadWindows;
 using static PicView.UI.PicGallery.GalleryScroll;
 using static PicView.UI.PicGallery.GalleryScroll;
 using static PicView.UI.PicGallery.GalleryToggle;
 using static PicView.UI.PicGallery.GalleryToggle;
@@ -360,7 +359,7 @@ namespace PicView.Shortcuts
 
 
                     // Delete, Shift + Delete
                     // Delete, Shift + Delete
                     case Key.Delete:
                     case Key.Delete:
-                        DeleteFile(Pics[FolderIndex], !shiftDown);
+                        await DeleteFileAsync(Pics[FolderIndex], !shiftDown).ConfigureAwait(false);
                         break;
                         break;
 
 
                     // Ctrl + C, Ctrl + Shift + C, Ctrl + Alt + C
                     // Ctrl + C, Ctrl + Shift + C, Ctrl + Alt + C

+ 2 - 8
PicView/SystemIntegration/MonitorSize.cs

@@ -20,13 +20,7 @@ namespace PicView.SystemIntegration
             throw new NotImplementedException();
             throw new NotImplementedException();
         }
         }
 
 
-        public override bool Equals(object obj)
-        {
-            if (obj == null || !(obj is MonitorSize))
-                return false;
-
-            return Equals((MonitorSize)obj);
-        }
+        public override bool Equals(object obj) => obj != null && obj is MonitorSize size && Equals(size);
 
 
         public static bool operator ==(MonitorSize e1, MonitorSize e2)
         public static bool operator ==(MonitorSize e1, MonitorSize e2)
         {
         {
@@ -73,7 +67,7 @@ namespace PicView.SystemIntegration
             // https://stackoverflow.com/a/32599760
             // https://stackoverflow.com/a/32599760
             var currentMonitor = WpfScreenHelper.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(Application.Current.MainWindow).Handle);
             var currentMonitor = WpfScreenHelper.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(Application.Current.MainWindow).Handle);
 
 
-            //find out if our app is being scaled by the monitor
+            //find out if the app is being scaled by the monitor
             var source = PresentationSource.FromVisual(Application.Current.MainWindow);
             var source = PresentationSource.FromVisual(Application.Current.MainWindow);
             var dpiScaling = source != null && source.CompositionTarget != null ? source.CompositionTarget.TransformFromDevice.M11 : 1;
             var dpiScaling = source != null && source.CompositionTarget != null ? source.CompositionTarget.TransformFromDevice.M11 : 1;
 
 

+ 6 - 3
PicView/SystemIntegration/NativeMethods.cs

@@ -76,9 +76,6 @@ namespace PicView.SystemIntegration
             public IntPtr hProcess;
             public IntPtr hProcess;
         }
         }
 
 
-        //[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
-        //public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
-
         // Remove from Alt + tab
         // Remove from Alt + tab
         [DllImport("user32.dll", SetLastError = true)]
         [DllImport("user32.dll", SetLastError = true)]
         internal static extern int GetWindowLong(IntPtr hWnd, int nIndex);
         internal static extern int GetWindowLong(IntPtr hWnd, int nIndex);
@@ -104,7 +101,13 @@ namespace PicView.SystemIntegration
         private const int WM_EXITSIZEMOVE = 0x232;
         private const int WM_EXITSIZEMOVE = 0x232;
         private static bool WindowWasResized;
         private static bool WindowWasResized;
 
 
+
+        /// Supress warnings about unused parameters, because they are required by OS.
+        /// Executes when user manually resized window
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "<Pending>")]
+#pragma warning disable IDE0060 // Remove unused parameter
         public static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
         public static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+#pragma warning restore IDE0060 // Remove unused parameter
         {
         {
             if (msg == WM_SIZING)
             if (msg == WM_SIZING)
             {
             {

+ 1 - 3
PicView/UI/DragAndDrop.cs

@@ -1,6 +1,5 @@
 using PicView.ChangeImage;
 using PicView.ChangeImage;
 using PicView.FileHandling;
 using PicView.FileHandling;
-using PicView.UI.Loading;
 using System.Collections.Specialized;
 using System.Collections.Specialized;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.IO;
 using System.IO;
@@ -157,7 +156,7 @@ namespace PicView.UI
                 {
                 {
                     if (Directory.GetFiles(files[0]).Length > 0)
                     if (Directory.GetFiles(files[0]).Length > 0)
                     {
                     {
-                        PicFolderAsync(files[0]);
+                        await PicFolderAsync(files[0]).ConfigureAwait(false);
                     }
                     }
                     return;
                     return;
                 }
                 }
@@ -178,7 +177,6 @@ namespace PicView.UI
 
 
             // Don't show drop message any longer
             // Don't show drop message any longer
             CloseToolTipMessage();
             CloseToolTipMessage();
-            AjaxLoader.AjaxLoadingEnd();
 
 
             // Start multiple clients if user drags multiple files
             // Start multiple clients if user drags multiple files
             // TODO no longer working after converting to .NET Core...
             // TODO no longer working after converting to .NET Core...

+ 2 - 2
PicView/UI/EditTitleBar.cs

@@ -61,13 +61,13 @@ namespace PicView.UI
             mainWindow.Bar.Bar.Select(start, end);
             mainWindow.Bar.Bar.Select(start, end);
         }
         }
 
 
-        internal static void HandleRename()
+        internal static async System.Threading.Tasks.Task HandleRenameAsync()
         {
         {
             if (FileFunctions.RenameFile(Pics[FolderIndex], mainWindow.Bar.Text))
             if (FileFunctions.RenameFile(Pics[FolderIndex], mainWindow.Bar.Text))
             {
             {
                 Pics[FolderIndex] = mainWindow.Bar.Text;
                 Pics[FolderIndex] = mainWindow.Bar.Text;
                 Refocus();
                 Refocus();
-                Error_Handling.Reload(); // TODO proper renaming of window title, tooltip, etc.
+                await Error_Handling.Reload().ConfigureAwait(false); // TODO proper renaming of window title, tooltip, etc.
             }
             }
             else
             else
             {
             {

+ 4 - 4
PicView/UI/HideInterfaceLogic.cs

@@ -156,7 +156,7 @@ namespace PicView.UI
         /// </summary>
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="sender"></param>
         /// <param name="e"></param>
         /// <param name="e"></param>
-        internal static void Interface_MouseMove(object sender, MouseEventArgs e)
+        internal static async System.Threading.Tasks.Task Interface_MouseMoveAsync(object sender, MouseEventArgs e)
         {
         {
             if (AutoScrolling)
             if (AutoScrolling)
             {
             {
@@ -172,7 +172,7 @@ namespace PicView.UI
 
 
             // If mouse moves on mainwindow, show elements
             // If mouse moves on mainwindow, show elements
 
 
-            FadeControlsAsync(true);
+            await FadeControlsAsync(true).ConfigureAwait(false);
 
 
             //// If Slideshow is running the interface will hide after 2,5 sec.
             //// If Slideshow is running the interface will hide after 2,5 sec.
             //if (Slidetimer.Enabled == true)
             //if (Slidetimer.Enabled == true)
@@ -190,11 +190,11 @@ namespace PicView.UI
         /// </summary>
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="sender"></param>
         /// <param name="e"></param>
         /// <param name="e"></param>
-        internal static void Interface_MouseLeave(object sender, MouseEventArgs e)
+        internal static async System.Threading.Tasks.Task Interface_MouseLeaveAsync(object sender, MouseEventArgs e)
         {
         {
             // Start timer when mouse leaves mainwindow
             // Start timer when mouse leaves mainwindow
             //activityTimer.Start();
             //activityTimer.Start();
-            FadeControlsAsync(false);
+            await FadeControlsAsync(false).ConfigureAwait(false);
         }
         }
     }
     }
 }
 }

+ 0 - 32
PicView/UI/Loading/AjaxLoader.cs

@@ -1,32 +0,0 @@
-using PicView.UI.Animations;
-using System;
-using static PicView.UI.UserControls.UC;
-
-namespace PicView.UI.Loading
-{
-    internal static class AjaxLoader
-    {
-
-        /// <summary>
-        /// Start loading animation
-        /// </summary>
-        internal static void AjaxLoadingStart()
-        {
-            if (ajaxLoading.Opacity != 1)
-            {
-                AnimationHelper.Fade(ajaxLoading, 1, TimeSpan.FromSeconds(.2));
-            }
-        }
-
-        /// <summary>
-        /// End loading animation
-        /// </summary>
-        internal static void AjaxLoadingEnd()
-        {
-            if (ajaxLoading.Opacity != 0)
-            {
-                AnimationHelper.Fade(ajaxLoading, 0, TimeSpan.FromSeconds(.2));
-            }
-        }
-    }
-}

+ 10 - 10
PicView/UI/Loading/EventsHandling.cs

@@ -83,15 +83,15 @@ namespace PicView.UI.Loading
             imageSettingsMenu.RotateRightButton.Click += (s, x) => Rotate(true);
             imageSettingsMenu.RotateRightButton.Click += (s, x) => Rotate(true);
             imageSettingsMenu.RotateLeftButton.Click += (s, x) => Rotate(false);
             imageSettingsMenu.RotateLeftButton.Click += (s, x) => Rotate(false);
 
 
-            imageSettingsMenu.Contained_Gallery.Click += delegate
+            imageSettingsMenu.Contained_Gallery.Click += async delegate
             {
             {
                 Close_UserControls();
                 Close_UserControls();
-                GalleryToggle.OpenContainedGallery();
+                await GalleryToggle.OpenContainedGallery().ConfigureAwait(false);
             };
             };
-            imageSettingsMenu.Fullscreen_Gallery.Click += delegate
+            imageSettingsMenu.Fullscreen_Gallery.Click += async delegate
             {
             {
                 Close_UserControls();
                 Close_UserControls();
-                GalleryToggle.OpenFullscreenGallery();
+                await GalleryToggle.OpenFullscreenGallery().ConfigureAwait(false);
             };
             };
             imageSettingsMenu.SlideshowButton.Click += delegate { SlideShow.StartSlideshow(); };
             imageSettingsMenu.SlideshowButton.Click += delegate { SlideShow.StartSlideshow(); };
 
 
@@ -147,12 +147,12 @@ namespace PicView.UI.Loading
             minus.MouseEnter += Interface_MouseEnter_Negative;
             minus.MouseEnter += Interface_MouseEnter_Negative;
 
 
             // GalleryShortcut
             // GalleryShortcut
-            galleryShortcut.MouseLeftButtonDown += (s, x) => GalleryToggle.ToggleAsync();
+            galleryShortcut.MouseLeftButtonDown += async (s, x) => await GalleryToggle.ToggleAsync().ConfigureAwait(false);
             galleryShortcut.MouseEnter += Interface_MouseEnter_Negative;
             galleryShortcut.MouseEnter += Interface_MouseEnter_Negative;
 
 
             // Bar
             // Bar
             mainWindow.Bar.GotKeyboardFocus += EditTitleBar.EditTitleBar_Text;
             mainWindow.Bar.GotKeyboardFocus += EditTitleBar.EditTitleBar_Text;
-            mainWindow.Bar.Bar.PreviewKeyDown += CustomTextBoxShortcuts.CustomTextBox_KeyDown;
+            mainWindow.Bar.Bar.PreviewKeyDown += async (s, x) => await CustomTextBoxShortcuts.CustomTextBox_KeyDownAsync(s, x).ConfigureAwait(false);
             mainWindow.Bar.PreviewMouseLeftButtonDown += EditTitleBar.Bar_PreviewMouseLeftButtonDown;
             mainWindow.Bar.PreviewMouseLeftButtonDown += EditTitleBar.Bar_PreviewMouseLeftButtonDown;
 
 
             // img
             // img
@@ -160,7 +160,7 @@ namespace PicView.UI.Loading
             mainWindow.img.MouseLeftButtonDown += Zoom_img_MouseLeftButtonDown;
             mainWindow.img.MouseLeftButtonDown += Zoom_img_MouseLeftButtonDown;
             mainWindow.img.MouseLeftButtonUp += Zoom_img_MouseLeftButtonUp;
             mainWindow.img.MouseLeftButtonUp += Zoom_img_MouseLeftButtonUp;
             mainWindow.img.MouseMove += Zoom_img_MouseMove;
             mainWindow.img.MouseMove += Zoom_img_MouseMove;
-            mainWindow.img.MouseWheel += Zoom_img_MouseWheel;
+            mainWindow.img.MouseWheel += async (s, x) => await Zoom_img_MouseWheelAsync(s, x).ConfigureAwait(false);
 
 
             // bg
             // bg
             mainWindow.bg.MouseLeftButtonDown += Bg_MouseLeftButtonDown;
             mainWindow.bg.MouseLeftButtonDown += Bg_MouseLeftButtonDown;
@@ -168,11 +168,11 @@ namespace PicView.UI.Loading
             mainWindow.bg.DragEnter += Image_DragEnter;
             mainWindow.bg.DragEnter += Image_DragEnter;
             mainWindow.bg.DragLeave += Image_DragLeave;
             mainWindow.bg.DragLeave += Image_DragLeave;
             mainWindow.bg.MouseEnter += Interface_MouseEnter;
             mainWindow.bg.MouseEnter += Interface_MouseEnter;
-            mainWindow.bg.MouseMove += Interface_MouseMove;
-            mainWindow.bg.MouseLeave += Interface_MouseLeave;
+            mainWindow.bg.MouseMove += async (s, x) => await Interface_MouseMoveAsync(s, x).ConfigureAwait(false);
+            mainWindow.bg.MouseLeave += async (s, x) => await Interface_MouseLeaveAsync(s, x).ConfigureAwait(false);
 
 
             // TooltipStyle
             // TooltipStyle
-            toolTipMessage.MouseWheel += Zoom_img_MouseWheel;
+            toolTipMessage.MouseWheel += async (s, x) => await Zoom_img_MouseWheelAsync(s, x).ConfigureAwait(false);
 
 
             // TitleBar
             // TitleBar
             mainWindow.TitleBar.MouseLeftButtonDown += Move;
             mainWindow.TitleBar.MouseLeftButtonDown += Move;

+ 18 - 18
PicView/UI/Loading/LoadContextMenus.cs

@@ -43,7 +43,7 @@ namespace PicView.UI.Loading
             opencmIcon.Width = opencmIcon.Height = 12;
             opencmIcon.Width = opencmIcon.Height = 12;
             opencmIcon.Fill = scbf;
             opencmIcon.Fill = scbf;
             opencm.Icon = opencmIcon;
             opencm.Icon = opencmIcon;
-            opencm.Click += (s, x) => Open();
+            opencm.Click += async (s, x) => await Open().ConfigureAwait(false);
             cm.Items.Add(opencm);
             cm.Items.Add(opencm);
 
 
             ///////////////////////////
             ///////////////////////////
@@ -64,7 +64,7 @@ namespace PicView.UI.Loading
             savecmIcon.Width = savecmIcon.Height = 12;
             savecmIcon.Width = savecmIcon.Height = 12;
             savecmIcon.Fill = scbf;
             savecmIcon.Fill = scbf;
             savecm.Icon = savecmIcon;
             savecm.Icon = savecmIcon;
-            savecm.Click += (s, x) => SaveFiles();
+            savecm.Click += async (s, x) => await SaveFiles().ConfigureAwait(false);
             cm.Items.Add(savecm);
             cm.Items.Add(savecm);
 
 
             ///////////////////////////
             ///////////////////////////
@@ -158,8 +158,8 @@ namespace PicView.UI.Loading
                 MinWidth = 125,
                 MinWidth = 125,
                 IsChecked = Properties.Settings.Default.SortPreference == 0
                 IsChecked = Properties.Settings.Default.SortPreference == 0
             };
             };
-            sortcmChild0Header.Click += delegate { UpdateUIValues.ChangeSortingAsync(0); cm.IsOpen = false; };
-            sortcmChild0.Click += delegate { UpdateUIValues.ChangeSortingAsync(0); cm.IsOpen = false; };
+            sortcmChild0Header.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(0).ConfigureAwait(false);  };
+            sortcmChild0.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(0).ConfigureAwait(false);  };
             sortcmChild0.Header = sortcmChild0Header;
             sortcmChild0.Header = sortcmChild0Header;
             sortcm.Items.Add(sortcmChild0);
             sortcm.Items.Add(sortcmChild0);
 
 
@@ -174,8 +174,8 @@ namespace PicView.UI.Loading
                 MinWidth = 125,
                 MinWidth = 125,
                 IsChecked = Properties.Settings.Default.SortPreference == 1
                 IsChecked = Properties.Settings.Default.SortPreference == 1
             };
             };
-            sortcmChild1Header.Click += delegate { UpdateUIValues.ChangeSortingAsync(1); cm.IsOpen = false; };
-            sortcmChild1.Click += delegate { UpdateUIValues.ChangeSortingAsync(1); cm.IsOpen = false; };
+            sortcmChild1Header.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(1).ConfigureAwait(false);  };
+            sortcmChild1.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(1).ConfigureAwait(false);  };
             sortcmChild1.Header = sortcmChild1Header;
             sortcmChild1.Header = sortcmChild1Header;
             sortcm.Items.Add(sortcmChild1);
             sortcm.Items.Add(sortcmChild1);
 
 
@@ -190,8 +190,8 @@ namespace PicView.UI.Loading
                 MinWidth = 125,
                 MinWidth = 125,
                 IsChecked = Properties.Settings.Default.SortPreference == 2
                 IsChecked = Properties.Settings.Default.SortPreference == 2
             };
             };
-            sortcmChild2Header.Click += delegate { UpdateUIValues.ChangeSortingAsync(2); cm.IsOpen = false; };
-            sortcmChild2.Click += delegate { UpdateUIValues.ChangeSortingAsync(2); cm.IsOpen = false; };
+            sortcmChild2Header.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(2).ConfigureAwait(false);  };
+            sortcmChild2.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(2).ConfigureAwait(false); };
             sortcmChild2.Header = sortcmChild2Header;
             sortcmChild2.Header = sortcmChild2Header;
             sortcm.Items.Add(sortcmChild2);
             sortcm.Items.Add(sortcmChild2);
 
 
@@ -206,8 +206,8 @@ namespace PicView.UI.Loading
                 MinWidth = 125,
                 MinWidth = 125,
                 IsChecked = Properties.Settings.Default.SortPreference == 3
                 IsChecked = Properties.Settings.Default.SortPreference == 3
             };
             };
-            sortcmChild3Header.Click += delegate { UpdateUIValues.ChangeSortingAsync(3); cm.IsOpen = false; };
-            sortcmChild3.Click += delegate { UpdateUIValues.ChangeSortingAsync(3); cm.IsOpen = false; };
+            sortcmChild3Header.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(3).ConfigureAwait(false);  };
+            sortcmChild3.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(3).ConfigureAwait(false);  };
             sortcmChild3.Header = sortcmChild3Header;
             sortcmChild3.Header = sortcmChild3Header;
             sortcm.Items.Add(sortcmChild3);
             sortcm.Items.Add(sortcmChild3);
 
 
@@ -222,8 +222,8 @@ namespace PicView.UI.Loading
                 MinWidth = 125,
                 MinWidth = 125,
                 IsChecked = Properties.Settings.Default.SortPreference == 4
                 IsChecked = Properties.Settings.Default.SortPreference == 4
             };
             };
-            sortcmChild4Header.Click += delegate { UpdateUIValues.ChangeSortingAsync(4); cm.IsOpen = false; };
-            sortcmChild4.Click += delegate { UpdateUIValues.ChangeSortingAsync(4); cm.IsOpen = false; };
+            sortcmChild4Header.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(4).ConfigureAwait(false);  };
+            sortcmChild4.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(4).ConfigureAwait(false);  };
             sortcmChild4.Header = sortcmChild4Header;
             sortcmChild4.Header = sortcmChild4Header;
             sortcm.Items.Add(sortcmChild4);
             sortcm.Items.Add(sortcmChild4);
 
 
@@ -238,8 +238,8 @@ namespace PicView.UI.Loading
                 MinWidth = 125,
                 MinWidth = 125,
                 IsChecked = Properties.Settings.Default.SortPreference == 5
                 IsChecked = Properties.Settings.Default.SortPreference == 5
             };
             };
-            sortcmChild5Header.Click += delegate { UpdateUIValues.ChangeSortingAsync(5); cm.IsOpen = false; };
-            sortcmChild5.Click += delegate { UpdateUIValues.ChangeSortingAsync(5); cm.IsOpen = false; };
+            sortcmChild5Header.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(5).ConfigureAwait(false); };
+            sortcmChild5.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(5).ConfigureAwait(false);  };
             sortcmChild5.Header = sortcmChild5Header;
             sortcmChild5.Header = sortcmChild5Header;
             sortcm.Items.Add(sortcmChild5);
             sortcm.Items.Add(sortcmChild5);
 
 
@@ -254,8 +254,8 @@ namespace PicView.UI.Loading
                 MinWidth = 125,
                 MinWidth = 125,
                 IsChecked = Properties.Settings.Default.SortPreference == 6
                 IsChecked = Properties.Settings.Default.SortPreference == 6
             };
             };
-            sortcmChild6Header.Click += delegate { UpdateUIValues.ChangeSortingAsync(6); cm.IsOpen = false; };
-            sortcmChild6.Click += delegate { UpdateUIValues.ChangeSortingAsync(6); cm.IsOpen = false; };
+            sortcmChild6Header.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(6).ConfigureAwait(false); };
+            sortcmChild6.Click += async delegate { cm.IsOpen = false; await UpdateUIValues.ChangeSortingAsync(6).ConfigureAwait(false);  };
             sortcmChild6.Header = sortcmChild6Header;
             sortcmChild6.Header = sortcmChild6Header;
             sortcm.Items.Add(sortcmChild6);
             sortcm.Items.Add(sortcmChild6);
             cm.Items.Add(sortcm);
             cm.Items.Add(sortcm);
@@ -576,7 +576,7 @@ namespace PicView.UI.Loading
                 Fill = scbf
                 Fill = scbf
             };
             };
             pastecm.Icon = pastecmIcon;
             pastecm.Icon = pastecmIcon;
-            pastecm.Click += (s, x) => Paste();
+            pastecm.Click += async (s, x) => await Paste().ConfigureAwait(false);
             cm.Items.Add(pastecm);
             cm.Items.Add(pastecm);
 
 
             ///////////////////////////
             ///////////////////////////
@@ -598,7 +598,7 @@ namespace PicView.UI.Loading
                 Fill = scbf
                 Fill = scbf
             };
             };
             MovetoRecycleBin.Icon = MovetoRecycleBinIcon;
             MovetoRecycleBin.Icon = MovetoRecycleBinIcon;
-            MovetoRecycleBin.Click += (s, x) => DeleteFile(Pics[FolderIndex], true);
+            MovetoRecycleBin.Click += async (s, x) => await DeleteFileAsync(Pics[FolderIndex], true).ConfigureAwait(false);
             cm.Items.Add(MovetoRecycleBin);
             cm.Items.Add(MovetoRecycleBin);
 
 
             ///////////////////////////
             ///////////////////////////

+ 4 - 14
PicView/UI/Loading/StartLoading.cs

@@ -1,7 +1,6 @@
 using PicView.FileHandling;
 using PicView.FileHandling;
 using PicView.SystemIntegration;
 using PicView.SystemIntegration;
 using PicView.UI.PicGallery;
 using PicView.UI.PicGallery;
-using PicView.UI.UserControls;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics;
@@ -13,7 +12,6 @@ using static PicView.ChangeImage.Error_Handling;
 using static PicView.ChangeImage.Navigation;
 using static PicView.ChangeImage.Navigation;
 using static PicView.Library.Fields;
 using static PicView.Library.Fields;
 using static PicView.Library.Resources.Timers;
 using static PicView.Library.Resources.Timers;
-using static PicView.UI.Loading.AjaxLoader;
 using static PicView.UI.Loading.LoadContextMenus;
 using static PicView.UI.Loading.LoadContextMenus;
 using static PicView.UI.Loading.LoadControls;
 using static PicView.UI.Loading.LoadControls;
 using static PicView.UI.Sizing.WindowLogic;
 using static PicView.UI.Sizing.WindowLogic;
@@ -46,13 +44,6 @@ namespace PicView.UI.Loading
                 mainWindow.RightBorderRectangle.Visibility
                 mainWindow.RightBorderRectangle.Visibility
                 = Visibility.Collapsed;
                 = Visibility.Collapsed;
             }
             }
-
-            ajaxLoading = new AjaxLoading
-            {
-                Opacity = 0
-            };
-            mainWindow.bg.Children.Add(ajaxLoading);
-            AjaxLoadingStart();
         }
         }
 
 
         internal static async Task Start()
         internal static async Task Start()
@@ -115,9 +106,9 @@ namespace PicView.UI.Loading
                 await Pic(Application.Current.Properties["ArbitraryArgName"].ToString()).ConfigureAwait(false);
                 await Pic(Application.Current.Properties["ArbitraryArgName"].ToString()).ConfigureAwait(false);
             }
             }
 
 
-            await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
+            await mainWindow.Dispatcher.BeginInvoke((Action)(async () =>
             {
             {
-                AddUIElementsAndUpdateValues();
+                await AddUIElementsAndUpdateValuesAsync().ConfigureAwait(false);
             }));
             }));
 
 
 #if DEBUG
 #if DEBUG
@@ -125,7 +116,7 @@ namespace PicView.UI.Loading
 #endif
 #endif
         }
         }
 
 
-        private static void AddUIElementsAndUpdateValues()
+        private static async Task AddUIElementsAndUpdateValuesAsync()
         {
         {
             // Update values
             // Update values
             ConfigColors.SetColors();
             ConfigColors.SetColors();
@@ -170,7 +161,7 @@ namespace PicView.UI.Loading
 
 
                 if (Properties.Settings.Default.PicGallery == 2)
                 if (Properties.Settings.Default.PicGallery == 2)
                 {
                 {
-                    GalleryToggle.OpenFullscreenGallery();
+                    await GalleryToggle.OpenFullscreenGallery().ConfigureAwait(true);
                 }
                 }
             }
             }
 
 
@@ -188,7 +179,6 @@ namespace PicView.UI.Loading
 
 
             // Add things!
             // Add things!
             Eventshandling.Go();
             Eventshandling.Go();
-            AjaxLoadingEnd();
             AddTimers();
             AddTimers();
             AddContextMenus();
             AddContextMenus();
 
 

+ 2 - 2
PicView/UI/PicGallery/GalleryLoad.cs

@@ -70,7 +70,7 @@ namespace PicView.UI.PicGallery
         internal static Task Load()
         internal static Task Load()
         {
         {
             IsLoading = true;
             IsLoading = true;
-            return Task.Run(() =>
+            return Task.Run(async () =>
             {
             {
                 /// TODO Maybe make this start at at folder index
                 /// TODO Maybe make this start at at folder index
                 /// and get it work with a real sorting method?
                 /// and get it work with a real sorting method?
@@ -85,7 +85,7 @@ namespace PicView.UI.PicGallery
                             pic.Freeze();
                             pic.Freeze();
                         }
                         }
 
 
-                        Add(pic, i);
+                        await Add(pic, i).ConfigureAwait(false);
                     }
                     }
                     // TODO find a placeholder for null images?
                     // TODO find a placeholder for null images?
                 }
                 }

+ 2 - 2
PicView/UI/SlideShow.cs

@@ -66,10 +66,10 @@ namespace PicView.UI
         /// <param name="e"></param>
         /// <param name="e"></param>
         internal static async void SlideTimer_Elapsed(object server, ElapsedEventArgs e)
         internal static async void SlideTimer_Elapsed(object server, ElapsedEventArgs e)
         {
         {
-            await mainWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
+            await mainWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(async () =>
             {
             {
                 AnimationHelper.Fade(mainWindow.img, TimeSpan.FromSeconds(0.8), TimeSpan.FromSeconds(0), 0, .5);
                 AnimationHelper.Fade(mainWindow.img, TimeSpan.FromSeconds(0.8), TimeSpan.FromSeconds(0), 0, .5);
-                Pic();
+                await Pic().ConfigureAwait(false);
                 AnimationHelper.Fade(mainWindow.img, TimeSpan.FromSeconds(0.7), TimeSpan.FromSeconds(0), .5, 1);
                 AnimationHelper.Fade(mainWindow.img, TimeSpan.FromSeconds(0.7), TimeSpan.FromSeconds(0), .5, 1);
             }));
             }));
         }
         }

+ 3 - 3
PicView/UI/TransformImage/Zoom.cs

@@ -158,7 +158,7 @@ namespace PicView.UI.TransformImage
         /// </summary>
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="sender"></param>
         /// <param name="e"></param>
         /// <param name="e"></param>
-        internal static void Zoom_img_MouseWheel(object sender, MouseWheelEventArgs e)
+        internal static async System.Threading.Tasks.Task Zoom_img_MouseWheelAsync(object sender, MouseWheelEventArgs e)
         {
         {
             // Disable normal scroll, so we can use our own values
             // Disable normal scroll, so we can use our own values
             e.Handled = true;
             e.Handled = true;
@@ -171,7 +171,7 @@ namespace PicView.UI.TransformImage
                 }
                 }
                 else if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                 else if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                 {
                 {
-                    Pic(e.Delta > 0);
+                    await Pic(e.Delta > 0).ConfigureAwait(false);
                 }
                 }
                 else
                 else
                 {
                 {
@@ -190,7 +190,7 @@ namespace PicView.UI.TransformImage
             // Change image with shift being held down
             // Change image with shift being held down
             else if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
             else if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
             {
             {
-                Pic(e.Delta > 0);
+                await Pic(e.Delta > 0).ConfigureAwait(false);
             }
             }
             // Scale when Ctrl being held down
             // Scale when Ctrl being held down
             else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && !AutoScrolling)
             else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && !AutoScrolling)

+ 100 - 95
PicView/UI/UpdateUIValues.cs

@@ -1,6 +1,7 @@
 using PicView.UI.PicGallery;
 using PicView.UI.PicGallery;
 using PicView.UI.Sizing;
 using PicView.UI.Sizing;
 using PicView.UI.UserControls;
 using PicView.UI.UserControls;
+using System;
 using System.IO;
 using System.IO;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows;
@@ -30,101 +31,105 @@ namespace PicView.UI
                 PreloadCount = 4;
                 PreloadCount = 4;
                 await Pic(Pics.IndexOf(tmp)).ConfigureAwait(false);
                 await Pic(Pics.IndexOf(tmp)).ConfigureAwait(false);
             }
             }
-            var sortcm = cm.Items[6] as MenuItem;
-
-            var sort0 = sortcm.Items[0] as MenuItem;
-            var sort0Header = sort0.Header as RadioButton;
-
-            var sort1 = sortcm.Items[1] as MenuItem;
-            var sort1Header = sort1.Header as RadioButton;
-
-            var sort2 = sortcm.Items[2] as MenuItem;
-            var sort2Header = sort2.Header as RadioButton;
-
-            var sort3 = sortcm.Items[3] as MenuItem;
-            var sort3Header = sort3.Header as RadioButton;
-
-            var sort4 = sortcm.Items[4] as MenuItem;
-            var sort4Header = sort4.Header as RadioButton;
-
-            var sort5 = sortcm.Items[5] as MenuItem;
-            var sort5Header = sort5.Header as RadioButton;
-
-            var sort6 = sortcm.Items[6] as MenuItem;
-            var sort6Header = sort6.Header as RadioButton;
-
-            switch (sorting)
+            await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
             {
             {
-                case 0:
-                    sort0Header.IsChecked = true;
-                    sort1Header.IsChecked = false;
-                    sort2Header.IsChecked = false;
-                    sort3Header.IsChecked = false;
-                    sort4Header.IsChecked = false;
-                    sort5Header.IsChecked = false;
-                    sort6Header.IsChecked = false;
-                    break;
-
-                case 1:
-                    sort0Header.IsChecked = false;
-                    sort1Header.IsChecked = true;
-                    sort2Header.IsChecked = false;
-                    sort3Header.IsChecked = false;
-                    sort4Header.IsChecked = false;
-                    sort5Header.IsChecked = false;
-                    sort6Header.IsChecked = false;
-                    break;
-
-                case 2:
-                    sort0Header.IsChecked = false;
-                    sort1Header.IsChecked = false;
-                    sort2Header.IsChecked = true;
-                    sort3Header.IsChecked = false;
-                    sort4Header.IsChecked = false;
-                    sort5Header.IsChecked = false;
-                    sort6Header.IsChecked = false;
-                    break;
-
-                case 3:
-                    sort0Header.IsChecked = false;
-                    sort1Header.IsChecked = false;
-                    sort2Header.IsChecked = false;
-                    sort3Header.IsChecked = true;
-                    sort4Header.IsChecked = false;
-                    sort5Header.IsChecked = false;
-                    sort6Header.IsChecked = false;
-                    break;
-
-                case 4:
-                    sort0Header.IsChecked = false;
-                    sort1Header.IsChecked = false;
-                    sort2Header.IsChecked = false;
-                    sort3Header.IsChecked = false;
-                    sort4Header.IsChecked = true;
-                    sort5Header.IsChecked = false;
-                    sort6Header.IsChecked = false;
-                    break;
-
-                case 5:
-                    sort0Header.IsChecked = false;
-                    sort1Header.IsChecked = false;
-                    sort2Header.IsChecked = false;
-                    sort3Header.IsChecked = false;
-                    sort4Header.IsChecked = false;
-                    sort5Header.IsChecked = true;
-                    sort6Header.IsChecked = false;
-                    break;
-
-                case 6:
-                    sort0Header.IsChecked = false;
-                    sort1Header.IsChecked = false;
-                    sort2Header.IsChecked = false;
-                    sort3Header.IsChecked = false;
-                    sort4Header.IsChecked = false;
-                    sort5Header.IsChecked = false;
-                    sort6Header.IsChecked = true;
-                    break;
-            }
+                var sortcm = cm.Items[6] as MenuItem;
+
+                var sort0 = sortcm.Items[0] as MenuItem;
+                var sort0Header = sort0.Header as RadioButton;
+
+                var sort1 = sortcm.Items[1] as MenuItem;
+                var sort1Header = sort1.Header as RadioButton;
+
+                var sort2 = sortcm.Items[2] as MenuItem;
+                var sort2Header = sort2.Header as RadioButton;
+
+                var sort3 = sortcm.Items[3] as MenuItem;
+                var sort3Header = sort3.Header as RadioButton;
+
+                var sort4 = sortcm.Items[4] as MenuItem;
+                var sort4Header = sort4.Header as RadioButton;
+
+                var sort5 = sortcm.Items[5] as MenuItem;
+                var sort5Header = sort5.Header as RadioButton;
+
+                var sort6 = sortcm.Items[6] as MenuItem;
+                var sort6Header = sort6.Header as RadioButton;
+
+                switch (sorting)
+                {
+                    default:
+                    case 0:
+                        sort0Header.IsChecked = true;
+                        sort1Header.IsChecked = false;
+                        sort2Header.IsChecked = false;
+                        sort3Header.IsChecked = false;
+                        sort4Header.IsChecked = false;
+                        sort5Header.IsChecked = false;
+                        sort6Header.IsChecked = false;
+                        break;
+
+                    case 1:
+                        sort0Header.IsChecked = false;
+                        sort1Header.IsChecked = true;
+                        sort2Header.IsChecked = false;
+                        sort3Header.IsChecked = false;
+                        sort4Header.IsChecked = false;
+                        sort5Header.IsChecked = false;
+                        sort6Header.IsChecked = false;
+                        break;
+
+                    case 2:
+                        sort0Header.IsChecked = false;
+                        sort1Header.IsChecked = false;
+                        sort2Header.IsChecked = true;
+                        sort3Header.IsChecked = false;
+                        sort4Header.IsChecked = false;
+                        sort5Header.IsChecked = false;
+                        sort6Header.IsChecked = false;
+                        break;
+
+                    case 3:
+                        sort0Header.IsChecked = false;
+                        sort1Header.IsChecked = false;
+                        sort2Header.IsChecked = false;
+                        sort3Header.IsChecked = true;
+                        sort4Header.IsChecked = false;
+                        sort5Header.IsChecked = false;
+                        sort6Header.IsChecked = false;
+                        break;
+
+                    case 4:
+                        sort0Header.IsChecked = false;
+                        sort1Header.IsChecked = false;
+                        sort2Header.IsChecked = false;
+                        sort3Header.IsChecked = false;
+                        sort4Header.IsChecked = true;
+                        sort5Header.IsChecked = false;
+                        sort6Header.IsChecked = false;
+                        break;
+
+                    case 5:
+                        sort0Header.IsChecked = false;
+                        sort1Header.IsChecked = false;
+                        sort2Header.IsChecked = false;
+                        sort3Header.IsChecked = false;
+                        sort4Header.IsChecked = false;
+                        sort5Header.IsChecked = true;
+                        sort6Header.IsChecked = false;
+                        break;
+
+                    case 6:
+                        sort0Header.IsChecked = false;
+                        sort1Header.IsChecked = false;
+                        sort2Header.IsChecked = false;
+                        sort3Header.IsChecked = false;
+                        sort4Header.IsChecked = false;
+                        sort5Header.IsChecked = false;
+                        sort6Header.IsChecked = true;
+                        break;
+                }
+            }));
         }
         }
 
 
         internal static void SetScrolling(object sender, RoutedEventArgs e)
         internal static void SetScrolling(object sender, RoutedEventArgs e)
@@ -221,7 +226,7 @@ namespace PicView.UI
 
 
         internal static void SetSlidetimer()
         internal static void SetSlidetimer()
         {
         {
-            switch (Properties.Settings.Default.SlideTimer.ToString("0"))
+            switch (Properties.Settings.Default.SlideTimer.ToString())
             {
             {
                 case "1":
                 case "1":
                     Properties.Settings.Default.SlideTimer = 1000;
                     Properties.Settings.Default.SlideTimer = 1000;

+ 1 - 1
PicView/UI/UserControls/Menus/QuickSettingsMenu.xaml.cs

@@ -52,7 +52,7 @@ namespace PicView.UI.UserControls
             {
             {
                 GoToPicBox.CaretBrush = new SolidColorBrush(UI.ConfigColors.mainColor);
                 GoToPicBox.CaretBrush = new SolidColorBrush(UI.ConfigColors.mainColor);
             };
             };
-            GoToPicBox.PreviewKeyDown += GotoPicsShortcuts.GoToPicPreviewKeys;
+            GoToPicBox.PreviewKeyDown += async (s, x) => await GotoPicsShortcuts.GoToPicPreviewKeysAsync(s, x).ConfigureAwait(false);
 
 
             #region Animation events
             #region Animation events
 
 

+ 0 - 318
PicView/UI/UserControls/Misc/AjaxLoading.xaml

@@ -1,318 +0,0 @@
-<UserControl
-    x:Class="PicView.UI.UserControls.AjaxLoading"
-    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-    d:DesignHeight="100"
-    d:DesignWidth="100"
-    mc:Ignorable="d">
-    <Grid
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:system="clr-namespace:System;assembly=mscorlib">
-        <Grid.Resources>
-            <!--  Particle Styling  -->
-            <SolidColorBrush x:Key="ParticleColor" Color="{DynamicResource ChosenColor}" />
-            <SolidColorBrush x:Key="ParticleBackgroundColor" Color="Transparent" />
-            <system:Double x:Key="ParticleOpacity">1</system:Double>
-            <system:Double x:Key="ParticleRadius">5</system:Double>
-
-            <system:Double x:Key="StartingPointX">0</system:Double>
-            <system:Double x:Key="StartingPointY">-20</system:Double>
-
-            <system:Double x:Key="RotationPointX">0.5</system:Double>
-            <system:Double x:Key="RotationPointY">0.5</system:Double>
-
-            <!--  StoryBoard  -->
-            <system:TimeSpan x:Key="StoryBoardBeginTimeP0">00:00:00.000</system:TimeSpan>
-            <system:TimeSpan x:Key="StoryBoardBeginTimeP1">00:00:00.100</system:TimeSpan>
-            <system:TimeSpan x:Key="StoryBoardBeginTimeP2">00:00:00.200</system:TimeSpan>
-            <system:TimeSpan x:Key="StoryBoardBeginTimeP3">00:00:00.300</system:TimeSpan>
-            <system:TimeSpan x:Key="StoryBoardBeginTimeP4">00:00:00.400</system:TimeSpan>
-            <Duration x:Key="StoryBoardDuration">00:00:01.800</Duration>
-
-            <!--  Particle Origin Angles  -->
-            <system:Double x:Key="ParticleOriginAngleP0">0</system:Double>
-            <system:Double x:Key="ParticleOriginAngleP1">-10</system:Double>
-            <system:Double x:Key="ParticleOriginAngleP2">-20</system:Double>
-            <system:Double x:Key="ParticleOriginAngleP3">-30</system:Double>
-            <system:Double x:Key="ParticleOriginAngleP4">-40</system:Double>
-
-            <!--  Particle Position & Timing 1  -->
-            <system:Double x:Key="ParticleBeginAngle1">0</system:Double>
-            <system:Double x:Key="ParticleEndAngle1">90</system:Double>
-            <system:TimeSpan x:Key="ParticleBeginTime1">00:00:00.000</system:TimeSpan>
-            <Duration x:Key="ParticleDuration1">00:00:00.750</Duration>
-
-            <!--  Particle Position & Timing 2  -->
-            <system:Double x:Key="ParticleBeginAngle2">90</system:Double>
-            <system:Double x:Key="ParticleEndAngle2">270</system:Double>
-            <system:TimeSpan x:Key="ParticleBeginTime2">00:00:00.751</system:TimeSpan>
-            <Duration x:Key="ParticleDuration2">00:00:00.300</Duration>
-
-            <!--  Particle Position & Timing 3  -->
-            <system:Double x:Key="ParticleBeginAngle3">270</system:Double>
-            <system:Double x:Key="ParticleEndAngle3">360</system:Double>
-            <system:TimeSpan x:Key="ParticleBeginTime3">00:00:01.052</system:TimeSpan>
-            <Duration x:Key="ParticleDuration3">00:00:00.750</Duration>
-
-            <Style x:Key="EllipseStyle" TargetType="Ellipse">
-                <Setter Property="Width" Value="{StaticResource ParticleRadius}" />
-                <Setter Property="Height" Value="{StaticResource ParticleRadius}" />
-                <Setter Property="Fill" Value="{StaticResource ParticleColor}" />
-                <Setter Property="RenderTransformOrigin" Value="0.5, 0.5" />
-                <Setter Property="Opacity" Value="{StaticResource ParticleOpacity}" />
-            </Style>
-        </Grid.Resources>
-        <Canvas Width="50" Height="50">
-            <Canvas.Triggers>
-                <EventTrigger RoutedEvent="Canvas.Loaded">
-                    <EventTrigger.Actions>
-                        <BeginStoryboard>
-                            <Storyboard
-                                BeginTime="{StaticResource StoryBoardBeginTimeP0}"
-                                RepeatBehavior="Forever"
-                                Duration="{StaticResource StoryBoardDuration}">
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime1}"
-                                    Storyboard.TargetName="p0"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle1}"
-                                    To="{StaticResource ParticleEndAngle1}"
-                                    Duration="{StaticResource ParticleDuration1}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime2}"
-                                    Storyboard.TargetName="p0"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle2}"
-                                    To="{StaticResource ParticleEndAngle2}"
-                                    Duration="{StaticResource ParticleDuration2}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime3}"
-                                    Storyboard.TargetName="p0"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle3}"
-                                    To="{StaticResource ParticleEndAngle3}"
-                                    Duration="{StaticResource ParticleDuration3}" />
-                            </Storyboard>
-                        </BeginStoryboard>
-                        <BeginStoryboard>
-                            <Storyboard
-                                BeginTime="{StaticResource StoryBoardBeginTimeP1}"
-                                RepeatBehavior="Forever"
-                                Duration="{StaticResource StoryBoardDuration}">
-
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime1}"
-                                    Storyboard.TargetName="p1"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle1}"
-                                    To="{StaticResource ParticleEndAngle1}"
-                                    Duration="{StaticResource ParticleDuration1}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime2}"
-                                    Storyboard.TargetName="p1"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle2}"
-                                    To="{StaticResource ParticleEndAngle2}"
-                                    Duration="{StaticResource ParticleDuration2}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime3}"
-                                    Storyboard.TargetName="p1"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle3}"
-                                    To="{StaticResource ParticleEndAngle3}"
-                                    Duration="{StaticResource ParticleDuration3}" />
-                            </Storyboard>
-                        </BeginStoryboard>
-                        <BeginStoryboard>
-                            <Storyboard
-                                BeginTime="{StaticResource StoryBoardBeginTimeP2}"
-                                RepeatBehavior="Forever"
-                                Duration="{StaticResource StoryBoardDuration}">
-
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime1}"
-                                    Storyboard.TargetName="p2"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle1}"
-                                    To="{StaticResource ParticleEndAngle1}"
-                                    Duration="{StaticResource ParticleDuration1}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime2}"
-                                    Storyboard.TargetName="p2"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle2}"
-                                    To="{StaticResource ParticleEndAngle2}"
-                                    Duration="{StaticResource ParticleDuration2}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime3}"
-                                    Storyboard.TargetName="p2"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle3}"
-                                    To="{StaticResource ParticleEndAngle3}"
-                                    Duration="{StaticResource ParticleDuration3}" />
-                            </Storyboard>
-                        </BeginStoryboard>
-
-                        <BeginStoryboard>
-                            <Storyboard
-                                BeginTime="{StaticResource StoryBoardBeginTimeP3}"
-                                RepeatBehavior="Forever"
-                                Duration="{StaticResource StoryBoardDuration}">
-
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime1}"
-                                    Storyboard.TargetName="p3"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle1}"
-                                    To="{StaticResource ParticleEndAngle1}"
-                                    Duration="{StaticResource ParticleDuration1}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime2}"
-                                    Storyboard.TargetName="p3"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle2}"
-                                    To="{StaticResource ParticleEndAngle2}"
-                                    Duration="{StaticResource ParticleDuration2}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime3}"
-                                    Storyboard.TargetName="p3"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle3}"
-                                    To="{StaticResource ParticleEndAngle3}"
-                                    Duration="{StaticResource ParticleDuration3}" />
-                            </Storyboard>
-                        </BeginStoryboard>
-
-                        <BeginStoryboard>
-                            <Storyboard
-                                BeginTime="{StaticResource StoryBoardBeginTimeP4}"
-                                RepeatBehavior="Forever"
-                                Duration="{StaticResource StoryBoardDuration}">
-
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime1}"
-                                    Storyboard.TargetName="p4"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle1}"
-                                    To="{StaticResource ParticleEndAngle1}"
-                                    Duration="{StaticResource ParticleDuration1}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime2}"
-                                    Storyboard.TargetName="p4"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle2}"
-                                    To="{StaticResource ParticleEndAngle2}"
-                                    Duration="{StaticResource ParticleDuration2}" />
-                                <DoubleAnimation
-                                    BeginTime="{StaticResource ParticleBeginTime3}"
-                                    Storyboard.TargetName="p4"
-                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
-                                    From="{StaticResource ParticleBeginAngle3}"
-                                    To="{StaticResource ParticleEndAngle3}"
-                                    Duration="{StaticResource ParticleDuration3}" />
-                            </Storyboard>
-                        </BeginStoryboard>
-                    </EventTrigger.Actions>
-                </EventTrigger>
-            </Canvas.Triggers>
-            <Border
-                x:Name="p0"
-                Background="{StaticResource ParticleBackgroundColor}"
-                Opacity="{StaticResource ParticleOpacity}">
-                <Border.RenderTransform>
-                    <RotateTransform />
-                </Border.RenderTransform>
-                <Border.RenderTransformOrigin>
-                    <Point X="{StaticResource RotationPointX}" Y="{StaticResource RotationPointY}" />
-                </Border.RenderTransformOrigin>
-                <Ellipse Style="{StaticResource EllipseStyle}">
-                    <Ellipse.RenderTransform>
-                        <TransformGroup>
-                            <TranslateTransform X="{StaticResource StartingPointX}" Y="{StaticResource StartingPointY}" />
-                            <RotateTransform Angle="{StaticResource ParticleOriginAngleP0}" />
-                        </TransformGroup>
-                    </Ellipse.RenderTransform>
-                </Ellipse>
-            </Border>
-            <Border
-                x:Name="p1"
-                Background="{StaticResource ParticleBackgroundColor}"
-                Opacity="{StaticResource ParticleOpacity}">
-                <Border.RenderTransform>
-                    <RotateTransform />
-                </Border.RenderTransform>
-                <Border.RenderTransformOrigin>
-                    <Point X="{StaticResource RotationPointX}" Y="{StaticResource RotationPointY}" />
-                </Border.RenderTransformOrigin>
-                <Ellipse Style="{StaticResource EllipseStyle}">
-                    <Ellipse.RenderTransform>
-                        <TransformGroup>
-                            <TranslateTransform X="{StaticResource StartingPointX}" Y="{StaticResource StartingPointY}" />
-                            <RotateTransform Angle="{StaticResource ParticleOriginAngleP1}" />
-                        </TransformGroup>
-                    </Ellipse.RenderTransform>
-                </Ellipse>
-            </Border>
-            <Border
-                x:Name="p2"
-                Background="{StaticResource ParticleBackgroundColor}"
-                Opacity="{StaticResource ParticleOpacity}">
-                <Border.RenderTransform>
-                    <RotateTransform />
-                </Border.RenderTransform>
-                <Border.RenderTransformOrigin>
-                    <Point X="{StaticResource RotationPointX}" Y="{StaticResource RotationPointY}" />
-                </Border.RenderTransformOrigin>
-                <Ellipse Style="{StaticResource EllipseStyle}">
-                    <Ellipse.RenderTransform>
-                        <TransformGroup>
-                            <TranslateTransform X="{StaticResource StartingPointX}" Y="{StaticResource StartingPointY}" />
-                            <RotateTransform Angle="{StaticResource ParticleOriginAngleP2}" />
-                        </TransformGroup>
-                    </Ellipse.RenderTransform>
-                </Ellipse>
-            </Border>
-            <Border
-                x:Name="p3"
-                Background="{StaticResource ParticleBackgroundColor}"
-                Opacity="{StaticResource ParticleOpacity}">
-                <Border.RenderTransform>
-                    <RotateTransform />
-                </Border.RenderTransform>
-                <Border.RenderTransformOrigin>
-                    <Point X="{StaticResource RotationPointX}" Y="{StaticResource RotationPointY}" />
-                </Border.RenderTransformOrigin>
-                <Ellipse Style="{StaticResource EllipseStyle}">
-                    <Ellipse.RenderTransform>
-                        <TransformGroup>
-                            <TranslateTransform X="{StaticResource StartingPointX}" Y="{StaticResource StartingPointY}" />
-                            <RotateTransform Angle="{StaticResource ParticleOriginAngleP3}" />
-                        </TransformGroup>
-                    </Ellipse.RenderTransform>
-                </Ellipse>
-            </Border>
-            <Border
-                x:Name="p4"
-                Background="{StaticResource ParticleBackgroundColor}"
-                Opacity="{StaticResource ParticleOpacity}">
-                <Border.RenderTransform>
-                    <RotateTransform />
-                </Border.RenderTransform>
-                <Border.RenderTransformOrigin>
-                    <Point X="{StaticResource RotationPointX}" Y="{StaticResource RotationPointY}" />
-                </Border.RenderTransformOrigin>
-                <Ellipse Style="{StaticResource EllipseStyle}">
-                    <Ellipse.RenderTransform>
-                        <TransformGroup>
-                            <TranslateTransform X="{StaticResource StartingPointX}" Y="{StaticResource StartingPointY}" />
-                            <RotateTransform Angle="{StaticResource ParticleOriginAngleP4}" />
-                        </TransformGroup>
-                    </Ellipse.RenderTransform>
-                </Ellipse>
-            </Border>
-        </Canvas>
-    </Grid>
-</UserControl>

+ 0 - 15
PicView/UI/UserControls/Misc/AjaxLoading.xaml.cs

@@ -1,15 +0,0 @@
-using System.Windows.Controls;
-
-namespace PicView.UI.UserControls
-{
-    /// <summary>
-    /// Interaction logic for AjaxLoading.xaml
-    /// </summary>
-    public partial class AjaxLoading : UserControl
-    {
-        public AjaxLoading()
-        {
-            InitializeComponent();
-        }
-    }
-}

+ 0 - 1
PicView/UI/UserControls/UC.cs

@@ -13,7 +13,6 @@ namespace PicView.UI.UserControls
         internal static FileMenu fileMenu;
         internal static FileMenu fileMenu;
         internal static QuickSettingsMenu quickSettingsMenu;
         internal static QuickSettingsMenu quickSettingsMenu;
         internal static ToolsAndEffectsMenu toolsAndEffectsMenu;
         internal static ToolsAndEffectsMenu toolsAndEffectsMenu;
-        internal static AjaxLoading ajaxLoading;
         internal static ToolTipMessage toolTipMessage;
         internal static ToolTipMessage toolTipMessage;
         internal static AutoScrollSign autoScrollSign;
         internal static AutoScrollSign autoScrollSign;
         internal static ClickArrow clickArrowLeft;
         internal static ClickArrow clickArrowLeft;

+ 1 - 1
PicView/UI/Windows/MainWindow.xaml.cs

@@ -13,7 +13,7 @@ namespace PicView.UI.Windows
         {
         {
             InitializeComponent();
             InitializeComponent();
             Loaded += delegate { StartLoading.PreStart(); };
             Loaded += delegate { StartLoading.PreStart(); };
-            ContentRendered += delegate { StartLoading.Start(); };
+            ContentRendered += async delegate { await StartLoading.Start().ConfigureAwait(false); };
         }
         }
 
 
         #region OnRenderSizeChanged override
         #region OnRenderSizeChanged override