Преглед изворни кода

Debug error messages, misc

Ruben пре 6 година
родитељ
комит
52d4d9832d

+ 5 - 2
PicView.sln

@@ -1,7 +1,7 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29209.62
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PicView", "PicView\PicView.csproj", "{9B5425DC-4329-4A7A-A0C5-F93161F77245}"
 EndProject
@@ -19,4 +19,7 @@ Global
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {764ABF0E-62C1-407A-B23C-B19DE8C2B1B4}
+	EndGlobalSection
 EndGlobal

+ 6 - 1
PicView/File Logic/ArchiveExtraction.cs

@@ -83,6 +83,11 @@ namespace PicView
         /// </summary>
         internal static async Task<bool> RecoverFailedArchiveAsync()
         {
+
+#if DEBUG
+            Trace.WriteLine("Entered RecoverFailedArchiveAsync");
+#endif
+
             if (Pics.Count > 0)
                 return true;
 
@@ -115,7 +120,7 @@ namespace PicView
 
                 // Kill it if it's asking for password
                 if (!getProcesses[0].HasExited)
-                    if (getProcesses[0].Threads[0].ThreadState == System.Diagnostics.ThreadState.Wait)
+                    if (getProcesses[0].Threads[0].ThreadState == ThreadState.Wait)
                     {
                         ToolTipStyle("Password protected archive not supported");
                         Reload(true);

+ 1 - 8
PicView/File Logic/DeleteFiles.cs

@@ -78,14 +78,7 @@ namespace PicView
                 filename = filename.Length >= 25 ? Shorten(filename, 21) : filename;
                 ToolTipStyle(Recyclebin ? "Sent " + filename + " to the recyle bin" : "Deleted " + filename);
 
-                if (reverse)
-                    FolderIndex = FolderIndex-- < 0 ? 0 : FolderIndex--;
-
-                if (FolderIndex > Pics.Count || Pics.Count < 0)
-                    Unload();
-                else
-                    // Go to next image
-                    Pic(FolderIndex);
+                Pic(reverse);
             }
             else
             {

+ 6 - 1
PicView/File Logic/Open_Save.cs

@@ -28,7 +28,12 @@ namespace PicView
                 ToolTipStyle(ExpFind);
                 Process.Start("explorer.exe", "/select,\"" + PicPath + "\"");
             }
-            catch (InvalidCastException) { }
+            catch (InvalidCastException e)
+            {
+#if DEBUG
+                Trace.WriteLine("Open_In_Explorer exception \n" + e.Message);
+#endif
+            }
         }
 
         /// <summary>

+ 9 - 2
PicView/File Logic/Wallpaper.cs

@@ -2,6 +2,7 @@
 using PicView.Native;
 using System;
 using System.ComponentModel;
+using System.Diagnostics;
 using System.IO;
 using System.Threading.Tasks;
 using System.Timers;
@@ -30,8 +31,11 @@ namespace PicView
                     {
                         Task.Run(() => SetDesktopWallpaper(path, style));
                     }
-                    catch (Exception)
+                    catch (Exception e)
                     {
+#if DEBUG
+                        Trace.WriteLine("Wallpaper exception \n" + e.Message);
+#endif
                         return;
                     }
                 }
@@ -53,8 +57,11 @@ namespace PicView
                         var timer = new Timer(2000);
                         timer.Elapsed += (s, x) => Directory.Delete(tempPath);
                     }
-                    catch (Exception)
+                    catch (Exception e)
                     {
+#if DEBUG
+                        Trace.WriteLine("Wallpaper download exception \n" + e.Message);
+#endif
                         return;
                     }
                 });

+ 9 - 2
PicView/Image Logic/ImageManager.cs

@@ -1,5 +1,6 @@
 using ImageMagick;
 using System;
+using System.Diagnostics;
 using System.IO;
 using System.Windows;
 using System.Windows.Media.Imaging;
@@ -31,8 +32,11 @@ namespace PicView
                 {
                     magick.Read(file, mrs);
                 }
-                catch (MagickException)
+                catch (MagickException e)
                 {
+#if DEBUG
+                    Trace.WriteLine("GetMagickImage returned " + file + " null, \n" + e.Message);
+#endif
                     return null;
                 }
 
@@ -211,8 +215,11 @@ namespace PicView
                     magick.AdaptiveResize(size, size);
                     
                 }
-                catch (MagickException)
+                catch (MagickException e)
                 {
+#if DEBUG
+                    Trace.WriteLine("GetMagickImage returned " + file + " null, \n" + e.Message);
+#endif
                     return null;
                 }
                 pic = magick.ToBitmapSource();

+ 1 - 0
PicView/Interface Logic/Interface.cs

@@ -189,6 +189,7 @@ namespace PicView
         {
             var fadeTo = show ? 1 : 0;
 
+            /// Might cause unnecessary cpu usage? Need to check
             await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
             {
                 if (!Properties.Settings.Default.ShowInterface | Slidetimer.Enabled == true)

+ 9 - 2
PicView/Loading/Preloader.cs

@@ -63,12 +63,16 @@ namespace PicView.PreLoading
                 IsLoading = false;
                 return;
             }
-            pic.Freeze();
+
+            if (!pic.IsFrozen)
+                pic.Freeze();
+
             Sources.TryAdd(file, pic);
+            IsLoading = false;
+
 #if DEBUG
             Trace.WriteLine("Added = " + file + " to Preloader, index " + Pics.IndexOf(file));
 #endif
-            IsLoading = false;
         }
 
         /// <summary>
@@ -161,6 +165,9 @@ namespace PicView.PreLoading
         /// </summary>
         internal static void Clear()
         {
+            if (Sources.Count <= 0)
+                return;
+
             Sources.Clear();
             PreloadCount = 4; // Reset to make sure
 #if DEBUG