Prechádzať zdrojové kódy

File restructure, updates, misc

Ruben 6 rokov pred
rodič
commit
ce63d4c99e
57 zmenil súbory, kde vykonal 960 pridanie a 884 odobranie
  1. 11 11
      PicView/App.xaml
  2. 1 4
      PicView/Configs/Configs.cs
  3. 0 0
      PicView/Configs/Styles/Backgrounds.xaml
  4. 0 0
      PicView/Configs/Styles/Border.xaml
  5. 0 0
      PicView/Configs/Styles/Button.xaml
  6. 0 0
      PicView/Configs/Styles/Colors.xaml
  7. 0 0
      PicView/Configs/Styles/FlatSlider.xaml
  8. 0 0
      PicView/Configs/Styles/Label.xaml
  9. 0 0
      PicView/Configs/Styles/ListBox.xaml
  10. 0 0
      PicView/Configs/Styles/ListView.xaml
  11. 0 0
      PicView/Configs/Styles/Menu.xaml
  12. 0 0
      PicView/Configs/Styles/ProgressBar.xaml
  13. 0 0
      PicView/Configs/Styles/RadioButton.xaml
  14. 0 0
      PicView/Configs/Styles/ScrollBar.xaml
  15. 0 0
      PicView/Configs/Styles/Separator.xaml
  16. 0 0
      PicView/Configs/Styles/Slider.xaml
  17. 0 0
      PicView/Configs/Styles/TabControl.xaml
  18. 0 0
      PicView/Configs/Styles/ToggleButton.xaml
  19. 0 0
      PicView/Configs/Styles/ToolBar.xaml
  20. 0 0
      PicView/Configs/Styles/ToolTip.xaml
  21. 2 2
      PicView/File Logic/ArchiveExtraction.cs
  22. 2 2
      PicView/File Logic/Copy_Paste.cs
  23. 9 7
      PicView/File Logic/DeleteFiles.cs
  24. 9 4
      PicView/File Logic/FileFunctions.cs
  25. 2 2
      PicView/File Logic/Open_Save.cs
  26. 1 1
      PicView/File Logic/RecentFiles.cs
  27. 1 1
      PicView/File Logic/Wallpaper.cs
  28. 145 0
      PicView/Image Logic/ImageDecoder.cs
  29. 40 127
      PicView/Image Logic/Resize_and_Zoom.cs
  30. 38 0
      PicView/Image Logic/SaveImages.cs
  31. 107 0
      PicView/Image Logic/Scroll.cs
  32. 2 150
      PicView/Image Logic/Thumbnails.cs
  33. 45 0
      PicView/Interface Logic/Animations/AjaxLoader.cs
  34. 0 0
      PicView/Interface Logic/Animations/AnimationHelper.cs
  35. 66 0
      PicView/Interface Logic/Animations/FadeControls.cs
  36. 0 0
      PicView/Interface Logic/Animations/MouseOverAnimations.cs
  37. 2 2
      PicView/Interface Logic/Drag and Drop/DragAndDrop.cs
  38. 0 0
      PicView/Interface Logic/Instantiate/ContextMenus.cs
  39. 0 0
      PicView/Interface Logic/Instantiate/LoadControls.cs
  40. 0 0
      PicView/Interface Logic/Instantiate/LoadWindows.cs
  41. 3 7
      PicView/Interface Logic/Instantiate/Timers.cs
  42. 0 395
      PicView/Interface Logic/Interface.cs
  43. 127 0
      PicView/Interface Logic/InterfaceUtilities.cs
  44. 90 0
      PicView/Interface Logic/SetTitle.cs
  45. 2 1
      PicView/Interface Logic/SlideShow.cs
  46. 64 0
      PicView/Interface Logic/Tooltip.cs
  47. 1 1
      PicView/Interface Logic/WindowLogic.cs
  48. 1 1
      PicView/Loading/Preloader.cs
  49. 3 1
      PicView/MainWindow.xaml.cs
  50. 2 4
      PicView/Misc/Fields.cs
  51. 19 6
      PicView/Misc/Helper.cs
  52. 0 0
      PicView/Misc/NativeMethods.cs
  53. 3 2
      PicView/Navigation/Error_Handling.cs
  54. 9 10
      PicView/Navigation/Navigation.cs
  55. 111 110
      PicView/PicGallery/PicGalleryLogic.cs
  56. 40 32
      PicView/PicVIew.csproj
  57. 2 1
      PicView/Shortcuts/Shortcuts.cs

+ 11 - 11
PicView/App.xaml

@@ -6,17 +6,17 @@
     <Application.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
-                <!--<ResourceDictionary Source="Library\Styles\Backgrounds.xaml" />-->
-                <ResourceDictionary Source="Library\Styles\Colors.xaml" />
-                <ResourceDictionary Source="Library\Styles\Menu.xaml" />
-                <ResourceDictionary Source="Library\Styles\Button.xaml" />
-                <ResourceDictionary Source="Library\Styles\Border.xaml" />
-                <ResourceDictionary Source="Library\Styles\ToggleButton.xaml" />
-                <ResourceDictionary Source="Library\Styles\ToolTip.xaml" />
-                <ResourceDictionary Source="Library\Styles\ScrollBar.xaml" />
-                <!--<ResourceDictionary Source="Library\Styles\TabControl.xaml" />-->
-                <ResourceDictionary Source="Library\Styles\RadioButton.xaml" />
-                <ResourceDictionary Source="Library\Styles\Label.xaml" />
+                <!--<ResourceDictionary Source="Configs\Styles\Backgrounds.xaml" />-->
+                <ResourceDictionary Source="Configs\Styles\Colors.xaml" />
+                <ResourceDictionary Source="Configs\Styles\Menu.xaml" />
+                <ResourceDictionary Source="Configs\Styles\Button.xaml" />
+                <ResourceDictionary Source="Configs\Styles\Border.xaml" />
+                <ResourceDictionary Source="Configs\Styles\ToggleButton.xaml" />
+                <ResourceDictionary Source="Configs\Styles\ToolTip.xaml" />
+                <ResourceDictionary Source="Configs\Styles\ScrollBar.xaml" />
+                <!--<ResourceDictionary Source="Configs\Styles\TabControl.xaml" />-->
+                <ResourceDictionary Source="Configs\Styles\RadioButton.xaml" />
+                <ResourceDictionary Source="Configs\Styles\Label.xaml" />
             </ResourceDictionary.MergedDictionaries>
 
             <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" />

+ 1 - 4
PicView/Configs/Configs.cs

@@ -1,8 +1,5 @@
 using System.Windows;
-using static PicView.Fields;
-using static PicView.Resize_and_Zoom;
-using static PicView.Helper;
-using static PicView.Interface;
+using static PicView.Scroll;
 
 namespace PicView
 {

+ 0 - 0
PicView/Library/Styles/Backgrounds.xaml → PicView/Configs/Styles/Backgrounds.xaml


+ 0 - 0
PicView/Library/Styles/Border.xaml → PicView/Configs/Styles/Border.xaml


+ 0 - 0
PicView/Library/Styles/Button.xaml → PicView/Configs/Styles/Button.xaml


+ 0 - 0
PicView/Library/Styles/Colors.xaml → PicView/Configs/Styles/Colors.xaml


+ 0 - 0
PicView/Library/Styles/FlatSlider.xaml → PicView/Configs/Styles/FlatSlider.xaml


+ 0 - 0
PicView/Library/Styles/Label.xaml → PicView/Configs/Styles/Label.xaml


+ 0 - 0
PicView/Library/Styles/ListBox.xaml → PicView/Configs/Styles/ListBox.xaml


+ 0 - 0
PicView/Library/Styles/ListView.xaml → PicView/Configs/Styles/ListView.xaml


+ 0 - 0
PicView/Library/Styles/Menu.xaml → PicView/Configs/Styles/Menu.xaml


+ 0 - 0
PicView/Library/Styles/ProgressBar.xaml → PicView/Configs/Styles/ProgressBar.xaml


+ 0 - 0
PicView/Library/Styles/RadioButton.xaml → PicView/Configs/Styles/RadioButton.xaml


+ 0 - 0
PicView/Library/Styles/ScrollBar.xaml → PicView/Configs/Styles/ScrollBar.xaml


+ 0 - 0
PicView/Library/Styles/Separator.xaml → PicView/Configs/Styles/Separator.xaml


+ 0 - 0
PicView/Library/Styles/Slider.xaml → PicView/Configs/Styles/Slider.xaml


+ 0 - 0
PicView/Library/Styles/TabControl.xaml → PicView/Configs/Styles/TabControl.xaml


+ 0 - 0
PicView/Library/Styles/ToggleButton.xaml → PicView/Configs/Styles/ToggleButton.xaml


+ 0 - 0
PicView/Library/Styles/ToolBar.xaml → PicView/Configs/Styles/ToolBar.xaml


+ 0 - 0
PicView/Library/Styles/ToolTip.xaml → PicView/Configs/Styles/ToolTip.xaml


+ 2 - 2
PicView/File Logic/ArchiveExtraction.cs

@@ -2,10 +2,10 @@
 using System.Diagnostics;
 using System.IO;
 using System.Threading.Tasks;
-using static PicView.Error_Handling;
 using static PicView.DeleteFiles;
+using static PicView.Error_Handling;
 using static PicView.Fields;
-using static PicView.Interface;
+using static PicView.Tooltip;
 
 namespace PicView
 {

+ 2 - 2
PicView/File Logic/Copy_Paste.cs

@@ -8,11 +8,11 @@ using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Media.Imaging;
 using static PicView.Error_Handling;
+using static PicView.Fields;
 using static PicView.FileFunctions;
 using static PicView.FileLists;
-using static PicView.Fields;
 using static PicView.Navigation;
-using static PicView.Interface;
+using static PicView.Tooltip;
 
 namespace PicView
 {

+ 9 - 7
PicView/File Logic/DeleteFiles.cs

@@ -2,11 +2,11 @@
 using System;
 using System.Diagnostics;
 using System.IO;
-using static PicView.Error_Handling;
-using static PicView.Fields;
-using static PicView.Helper;
-using static PicView.Interface;
 using static PicView.Navigation;
+using static PicView.Tooltip;
+using static PicView.Fields;
+using static PicView.Error_Handling;
+using static PicView.FileFunctions;
 
 namespace PicView
 {
@@ -56,13 +56,15 @@ namespace PicView
                 FileSystem.DeleteFile(file, UIOption.OnlyErrorDialogs, recycle);
                 Pics.Remove(file);
             }
+#if DEBUG
             catch (Exception e)
             {
-#if DEBUG
-                        Trace.WriteLine("Delete exception \n" + e.Message);
-#endif
+                Trace.WriteLine("Delete exception \n" + e.Message);
                 return false;
             }
+#else
+            catch (Exception) {return false; }
+#endif
             return true;
         }
 

+ 9 - 4
PicView/File Logic/FileFunctions.cs

@@ -60,9 +60,6 @@ namespace PicView
             return sign + readable.ToString("0.## ") + suffix + 'B';
         }
 
-        
-
-        #region File Methods
 
         internal static bool FilePathHasInvalidChars(string path)
         {
@@ -77,7 +74,15 @@ namespace PicView
             return Regex.Replace(name, invalidRegStr, "_");
         }
 
-        #endregion File Methods
+        internal static string Shorten(string name, int amount)
+        {
+            if (name.Length >= 25)
+            {
+                name = name.Substring(0, amount);
+                name += "...";
+            }
+            return name;
+        }
     }
 
    

+ 2 - 2
PicView/File Logic/Open_Save.cs

@@ -3,10 +3,10 @@ using System.Diagnostics;
 using System.IO;
 using static PicView.Error_Handling;
 using static PicView.Fields;
-using static PicView.ImageManager;
+using static PicView.ImageDecoder;
 using static PicView.Navigation;
-using static PicView.Interface;
 using static PicView.ToggleMenus;
+using static PicView.Tooltip;
 
 namespace PicView
 {

+ 1 - 1
PicView/File Logic/RecentFiles.cs

@@ -4,7 +4,7 @@ using System.IO;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
-using static PicView.Helper;
+using static PicView.FileFunctions;
 using static PicView.Navigation;
 using static PicView.SvgIcons;
 

+ 1 - 1
PicView/File Logic/Wallpaper.cs

@@ -159,7 +159,7 @@ namespace PicView
                 var dest = string.Format(@"{0}\Microsoft\Windows\Themes\{1}.jpg",
                         Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                         Path.GetFileNameWithoutExtension(path));
-                ImageManager.TrySaveImage(Rotateint, Flipped, path, dest);
+                ImageDecoder.TrySaveImage(Rotateint, Flipped, path, dest);
                 path = dest;
 
             }

+ 145 - 0
PicView/Image Logic/ImageDecoder.cs

@@ -0,0 +1,145 @@
+using ImageMagick;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+namespace PicView
+{
+    internal static class ImageDecoder
+    {
+        /// <summary>
+        /// Decodes image from file to BitMapSource
+        /// </summary>
+        /// <param name="file">Full path of the file</param>
+        /// <returns></returns>
+        internal static BitmapSource RenderToBitmapSource(string file)
+        {
+            if (string.IsNullOrWhiteSpace(file) || file.Length < 2)
+                return null;
+
+            using (MagickImage magick = new MagickImage())
+            {
+                var mrs = new MagickReadSettings()
+                {
+                    Density = new Density(300, 300),
+                    BackgroundColor = MagickColors.Transparent,
+                };
+
+                try
+                {
+                    magick.Read(file, mrs);
+                }
+#if DEBUG
+                catch (MagickException e)
+                {
+                    Trace.WriteLine("GetMagickImage returned " + file + " null, \n" + e.Message);
+                    return null;
+                }
+#else
+                catch (MagickException) { return null; }
+#endif
+                // Set values for maximum quality
+                magick.Quality = 100;
+                magick.ColorSpace = ColorSpace.Transparent;
+
+                var pic = magick.ToBitmapSource();
+                pic.Freeze();
+                return pic;
+            }
+        }
+        
+
+        internal static BitmapSource GetMagickImage(Stream s)
+        {
+            BitmapSource pic;
+
+            using (MagickImage magick = new MagickImage())
+            {
+                magick.Quality = 100;
+                var mrs = new MagickReadSettings()
+                {
+                    Density = new Density(300)
+                };
+
+                magick.Read(s);
+                magick.ColorSpace = ColorSpace.Transparent;
+                pic = magick.ToBitmapSource();
+
+                pic.Freeze();
+                return pic;
+            }
+        }
+
+        /// <summary>
+        /// Tries to save image to the specified destination,
+        /// returns false if unsuccesful
+        /// </summary>
+        /// <param name="rotate">Degrees image is rotated by</param>
+        /// <param name="flipped">Whether to flip image or not</param>
+        /// <param name="path">The path of the source file</param>
+        /// <param name="destination">Where to save image to</param>
+        /// <returns></returns>
+        internal static bool TrySaveImage(int rotate, bool flipped, string path, string destination)
+        {
+            if (File.Exists(path))
+            {
+                try
+                {
+                    using (var SaveImage = new MagickImage())
+                    {
+                        // Set maximum quality
+                        var mrs = new MagickReadSettings()
+                        {
+                            Density = new Density(300, 300),
+                        };
+                        SaveImage.Quality = 100;
+
+                        SaveImage.Read(path, mrs);
+
+                        // Apply transformation values
+                        if (flipped)
+                            SaveImage.Flop();
+                        SaveImage.Rotate(rotate);
+
+                        SaveImage.Write(destination);
+                    }
+                }
+                catch (Exception)
+                {
+                    return false;
+                }
+            }
+            else
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        internal static Size? ImageSize (string file)
+        {
+            using (MagickImage magick = new MagickImage())
+            {
+                try
+                {
+                    magick.Read(file);
+                }
+#if DEBUG
+                catch (MagickException e)
+                {
+                    Trace.WriteLine("ImageSize returned " + file + " null, \n" + e.Message);
+                    return null;
+                }
+#else
+                catch (MagickException) { return null; }
+#endif
+
+                return new Size(magick.Width, magick.Height);
+            }
+        }
+
+    }
+}

+ 40 - 127
PicView/Image Logic/Resize_and_Zoom.cs

@@ -4,76 +4,16 @@ using System.Windows;
 using System.Windows.Input;
 using System.Windows.Media;
 using static PicView.Fields;
-using static PicView.Interface;
 using static PicView.Navigation;
+using static PicView.Scroll;
+using static PicView.SetTitle;
+using static PicView.Tooltip;
 using static PicView.WindowLogic;
 
 namespace PicView
 {
     internal static class Resize_and_Zoom
-    {
-        #region Zoom, Scroll, Rotate and Flip
-
-        // Auto scroll
-
-        /// <summary>
-        /// Starts the auto scroll feature and shows the sign on the ui
-        /// </summary>
-        /// <param name="e"></param>
-        internal static void StartAutoScroll(MouseButtonEventArgs e)
-        {
-            // Don't scroll if not scrollable
-            if (mainWindow.Scroller.ComputedVerticalScrollBarVisibility == Visibility.Collapsed)
-                return;
-
-            autoScrolling = true;
-            autoScrollOrigin = e.GetPosition(mainWindow.Scroller);
-
-            ShowAutoScrollSign();
-        }
-
-        /// <summary>
-        /// Stop auto scroll feature and remove sign from the ui
-        /// </summary>
-        internal static void StopAutoScroll()
-        {
-            autoScrollTimer.Stop();
-            //window.ReleaseMouseCapture();
-            autoScrollTimer.Enabled = false;
-            autoScrolling = false;
-            autoScrollOrigin = null;
-            HideAutoScrollSign();
-        }
-
-        /// <summary>
-        /// Uses timer to scroll vertical up/down every seventh milisecond
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="E"></param>
-        internal static async void AutoScrollTimerEvent(object sender, System.Timers.ElapsedEventArgs E)
-        {
-            // Error checking
-            if (autoScrollPos == null || autoScrollOrigin == null)
-                return;
-
-            // Start in dispatcher because timer is threaded
-            await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
-            {
-                if (autoScrollOrigin.HasValue)
-                {
-                    // Calculate offset by Y coordinate
-                    var offset = (autoScrollPos.Y - autoScrollOrigin.Value.Y) / 15;
-
-                    //ToolTipStyle("pos = " + autoScrollPos.Y.ToString() + " origin = " + autoScrollOrigin.Value.Y.ToString()
-                    //    + Environment.NewLine + "offset = " + offset, false);
-
-                    if (autoScrolling)
-                        // Tell the scrollviewer to scroll to calculated offset
-                        mainWindow.Scroller.ScrollToVerticalOffset(mainWindow.Scroller.VerticalOffset + offset);
-                }
-            }));
-        }
-
+    { 
         // Zoom
         /// <summary>
         /// Pan and Zoom, reset zoom and double click to reset
@@ -82,11 +22,13 @@ namespace PicView
         /// <param name="e"></param>
         internal static void Zoom_img_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
+            // Move window when Ctrl is being held down
             if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
             {
                 Move(sender, e);
                 return;
             }
+            // Logic for auto scrolling
             if (autoScrolling)
             {
                 // Report position and enable autoscrolltimer
@@ -94,11 +36,13 @@ namespace PicView
                 autoScrollTimer.Enabled = true;
                 return;
             }
+            // Reset zoom on double click
             if (e.ClickCount == 2)
             {
                 ResetZoom();
                 return;
             }
+            // Drag logic
             if (!IsScrollEnabled)
             {
                 // Report position for image drag
@@ -184,18 +128,15 @@ namespace PicView
                         mainWindow.Scroller.ScrollToVerticalOffset(mainWindow.Scroller.VerticalOffset + zoomSpeed);
                 }
             }
+            // Change image with shift being held down
             else if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
-            {
                 Pic(e.Delta > 0);
-            }
+            // Scale when Ctrl being held down
             else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && !autoScrolling)
-            {
                 Zoom(e.Delta, true);
-            }
-            else
-            {
+            // Zoom
+            else if (!autoScrolling)
                 Zoom(e.Delta, false);
-            }
         }
 
         /// <summary>
@@ -205,7 +146,7 @@ namespace PicView
         internal static void InitializeZoom()
         {
             // Set center
-            mainWindow.img.RenderTransformOrigin = new Point(0.5, 0.5);
+            //mainWindow.img.RenderTransformOrigin = new Point(0.5, 0.5); // Already set in xaml
 
             // Add children, which can be manipulated ;)
             mainWindow.img.RenderTransform = new TransformGroup
@@ -248,22 +189,11 @@ namespace PicView
             ZoomFit(xWidth, xHeight);
 
             // Display non-zoomed values
-            string[] titleString;
             if (canNavigate)
-            {
-                titleString = TitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, FolderIndex);
-                mainWindow.Title = titleString[0];
-                mainWindow.Bar.Text = titleString[1];
-                mainWindow.Bar.ToolTip = titleString[2];
-            }
+                SetTitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, FolderIndex);
             else
-            {
                 // Display values from web
-                titleString = TitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, PicPath);
-                mainWindow.Title = titleString[0];
-                mainWindow.Bar.Text = titleString[1];
-                mainWindow.Bar.ToolTip = titleString[1];
-            }
+                SetTitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, PicPath);
         }
 
         /// <summary>
@@ -273,19 +203,15 @@ namespace PicView
         /// <param name="zoomMode"></param>
         internal static void Zoom(int i, bool zoomMode)
         {
-            // Don't zoom when gallery is open
+            /// Don't zoom when gallery is open
             if (picGallery != null)
-            {
                 if (PicGalleryLogic.IsOpen)
-                {
                     return;
-                }
-            }
 
-            // Scales the window with img.LayoutTransform
+            /// Scales the window with img.LayoutTransform
             if (zoomMode)
             {
-                // Start from 1 or zoom value
+                /// Start from 1 or zoom value
                 if (isZoomed)
                     AspectRatio += i > 0 ? .01 : -.01;
                 else
@@ -297,16 +223,16 @@ namespace PicView
                 mainWindow.img.LayoutTransform = scaletransform;
             }
 
-            // Pan and zoom
+            /// Pan and zoom
             else
             {
-                // Get position where user points cursor
+                /// Get position where user points cursor
                 var position = Mouse.GetPosition(mainWindow.img);
 
-                // Use our position as starting point for zoom
+                /// Use our position as starting point for zoom
                 mainWindow.img.RenderTransformOrigin = new Point(position.X / xWidth, position.Y / xHeight);
 
-                // Determine zoom speed
+                /// Determine zoom speed
                 var zoomValue = st.ScaleX > 1.3 ? .03 : .01;
                 if (st.ScaleX > 1.5)
                     zoomValue += .005;
@@ -323,7 +249,7 @@ namespace PicView
 
                 if (st.ScaleX < 1.0)
                 {
-                    // Don't zoom less than 1.0, does not work so good...
+                    /// Don't zoom less than 1.0, does not work so good...
                     st.ScaleX = st.ScaleY = 1.0;
                 }
                 //zoomValue = i > 0 ? zoomValue : -zoomValue;
@@ -333,29 +259,18 @@ namespace PicView
 
             isZoomed = true;
 
-            // Displays zoompercentage in the center window
+            /// Displays zoompercentage in the center window
             if (!string.IsNullOrEmpty(ZoomPercentage))
                 ToolTipStyle(ZoomPercentage, true);
             else
                 CloseToolTipStyle();
 
-            // Display updated values
-            string[] titleString;
+            /// Display updated values
             if (canNavigate)
-            {
-                titleString = TitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, FolderIndex);
-                mainWindow.Title = titleString[0];
-                mainWindow.Bar.Text = titleString[1];
-                mainWindow.Bar.ToolTip = titleString[2];
-            }
+                SetTitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, FolderIndex);
             else
-            {
-                // Display values from web
-                titleString = TitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, PicPath);
-                mainWindow.Title = titleString[0];
-                mainWindow.Bar.Text = titleString[1];
-                mainWindow.Bar.ToolTip = titleString[1];
-            }
+                /// Display values from web
+                SetTitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, PicPath);
         }
 
         /// <summary>
@@ -367,17 +282,17 @@ namespace PicView
         internal static void ZoomFit(double width, double height)
         {
             double maxWidth, maxHeight;
-            var interfaceHeight = 93; // TopBar + mainWindow.LowerBar height
-            //var interfaceHeight = (mainWindow.TitleBar.ActualHeight + mainWindow.LowerBar.ActualHeight) + 2; // + 2 for window border
+            var interfaceHeight = 85; /// TopBar + mainWindow.LowerBar height + extra padding
 
             if (FitToWindow)
             {
-                // Get max width and height, based on user's screen
+                /// Get max width and height, based on user's screen
                 if (Properties.Settings.Default.ShowInterface)
                 {
                     maxWidth = Math.Min(MonitorInfo.Width - ComfySpace, width);
                     maxHeight = Math.Min((MonitorInfo.Height - interfaceHeight), height);
                 }
+                /// - 2 for window border
                 else
                 {
                     maxWidth = Math.Min(MonitorInfo.Width - 2, width - 2);
@@ -386,7 +301,7 @@ namespace PicView
             }       
             else
             {
-                // Get max width and height, based on window size
+                /// Get max width and height, based on window size
                 maxWidth = Math.Min(mainWindow.Width, width);
 
                 if (Properties.Settings.Default.ShowInterface)
@@ -399,35 +314,35 @@ namespace PicView
 
             if (IsScrollEnabled)
             {
-                // Calculate height based on width
+                /// Calculate height based on width
                 mainWindow.img.Width = maxWidth;
                 mainWindow.img.Height = maxWidth * height / width;
 
-                // Set mainWindow.Scroller height to aspect ratio calculation
+                /// Set mainWindow.Scroller height to aspect ratio calculation
                 mainWindow.Scroller.Height = (height * AspectRatio);
 
-                // Update values
+                /// Update values
                 xWidth = mainWindow.img.Width;
                 xHeight = mainWindow.Scroller.Height;
             }
             else
             {
-                // Reset mainWindow.Scroller's height to auto
+                /// Reset mainWindow.Scroller's height to auto
                 mainWindow.Scroller.Height = double.NaN;
 
-                // Fit image by aspect ratio calculation
-                // and update values
+                /// Fit image by aspect ratio calculation
+                /// and update values
                 mainWindow.img.Height = xHeight = (height * AspectRatio);
                 mainWindow.img.Width = xWidth = (width * AspectRatio);
             }
 
             if (FitToWindow)
             {
-                // Update mainWindow.TitleBar width to fit new size
+                /// Update mainWindow.TitleBar width to dynamically fit new size
                 var interfaceSize = 220; // logo and buttons width + extra padding
                 mainWindow.Bar.MaxWidth = xWidth - interfaceSize < interfaceSize ? interfaceSize : xWidth - interfaceSize;
 
-                // Loses position gradually if not forced to center
+                /// Loses position gradually if not forced to center
                 if (!Properties.Settings.Default.Fullscreen)
                     CenterWindowOnScreen();
             }
@@ -459,7 +374,5 @@ namespace PicView
                    So much math!
             */
         }
-
-        #endregion Zoom, Scroll, Rotate and Flip
     }
 }

+ 38 - 0
PicView/Image Logic/SaveImages.cs

@@ -0,0 +1,38 @@
+using ImageMagick;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+namespace PicView
+{
+    internal static class SaveImages
+    {
+        internal static void ResizeImageToFile(string file, int NewWidth, int NewHeight)
+        {
+            try
+            {
+                using (MagickImage magick = new MagickImage())
+                {
+                    MagickGeometry size = new MagickGeometry(NewWidth, NewHeight)
+                    {
+                        IgnoreAspectRatio = true
+                    };
+                    magick.Resize(size);
+                    magick.Quality = 100;
+                    magick.Write(file);
+                }
+            }
+#if DEBUG
+            catch (MagickException e)
+            {
+                Trace.WriteLine("ResizeImageToFile " + file + " null, \n" + e.Message);
+                return;
+            }
+#else
+                catch (MagickException) { return; }
+#endif         
+        }
+    }
+}

+ 107 - 0
PicView/Image Logic/Scroll.cs

@@ -0,0 +1,107 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using static PicView.Fields;
+using static PicView.Resize_and_Zoom;
+using static PicView.Tooltip;
+
+namespace PicView
+{
+    internal static class Scroll
+    {
+        /// <summary>
+        /// Toggles scroll and displays it with TooltipStle
+        /// </summary>
+        internal static bool IsScrollEnabled
+        {
+            get { return Properties.Settings.Default.ScrollEnabled; }
+            set
+            {
+                Properties.Settings.Default.ScrollEnabled = value;
+                mainWindow.Scroller.VerticalScrollBarVisibility = value ? ScrollBarVisibility.Auto : ScrollBarVisibility.Disabled;
+                if (!freshStartup && !string.IsNullOrEmpty(PicPath))
+                {
+                    ZoomFit(mainWindow.img.Source.Width, mainWindow.img.Source.Height);
+                    ToolTipStyle(value ? "Scrolling enabled" : "Scrolling disabled");
+                }
+            }
+        }
+
+        // AutoScrollSign
+
+        internal static void HideAutoScrollSign()
+        {
+            autoScrollSign.Visibility = Visibility.Collapsed;
+            autoScrollSign.Opacity = 0;
+        }
+
+        internal static void ShowAutoScrollSign()
+        {
+            Canvas.SetTop(autoScrollSign, autoScrollOrigin.Value.Y);
+            Canvas.SetLeft(autoScrollSign, autoScrollOrigin.Value.X);
+            autoScrollSign.Visibility = Visibility.Visible;
+            autoScrollSign.Opacity = 1;
+        }
+
+        // Auto scroll
+
+        /// <summary>
+        /// Starts the auto scroll feature and shows the sign on the ui
+        /// </summary>
+        /// <param name="e"></param>
+        internal static void StartAutoScroll(MouseButtonEventArgs e)
+        {
+            // Don't scroll if not scrollable
+            if (mainWindow.Scroller.ComputedVerticalScrollBarVisibility == Visibility.Collapsed)
+                return;
+
+            autoScrolling = true;
+            autoScrollOrigin = e.GetPosition(mainWindow.Scroller);
+
+            ShowAutoScrollSign();
+        }
+
+        /// <summary>
+        /// Stop auto scroll feature and remove sign from the ui
+        /// </summary>
+        internal static void StopAutoScroll()
+        {
+            autoScrollTimer.Stop();
+            //window.ReleaseMouseCapture();
+            autoScrollTimer.Enabled = false;
+            autoScrolling = false;
+            autoScrollOrigin = null;
+            HideAutoScrollSign();
+        }
+
+        /// <summary>
+        /// Uses timer to scroll vertical up/down every seventh milisecond
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="E"></param>
+        internal static async void AutoScrollTimerEvent(object sender, System.Timers.ElapsedEventArgs E)
+        {
+            // Error checking
+            if (autoScrollPos == null || autoScrollOrigin == null)
+                return;
+
+            // Start in dispatcher because timer is threaded
+            await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
+            {
+                if (autoScrollOrigin.HasValue)
+                {
+                    // Calculate offset by Y coordinate
+                    var offset = (autoScrollPos.Y - autoScrollOrigin.Value.Y) / 15;
+
+                    //ToolTipStyle("pos = " + autoScrollPos.Y.ToString() + " origin = " + autoScrollOrigin.Value.Y.ToString()
+                    //    + Environment.NewLine + "offset = " + offset, false);
+
+                    if (autoScrolling)
+                        // Tell the scrollviewer to scroll to calculated offset
+                        mainWindow.Scroller.ScrollToVerticalOffset(mainWindow.Scroller.VerticalOffset + offset);
+                }
+            }));
+        }
+    }
+}

+ 2 - 150
PicView/Image Logic/ImageManager.cs → PicView/Image Logic/Thumbnails.cs

@@ -1,56 +1,12 @@
 using ImageMagick;
-using System;
 using System.Diagnostics;
 using System.IO;
-using System.Windows;
 using System.Windows.Media.Imaging;
 
 namespace PicView
 {
-    internal static class ImageManager
+    internal static class Thumbnails
     {
-        /// <summary>
-        /// Decodes image from file to BitMapSource
-        /// </summary>
-        /// <param name="file">Full path of the file</param>
-        /// <param name="extension">file extension beggining with dot</param>
-        /// <returns></returns>
-        internal static BitmapSource RenderToBitmapSource(string file)
-        {
-            if (string.IsNullOrWhiteSpace(file) || file.Length < 2)
-                return null;
-
-            using (MagickImage magick = new MagickImage())
-            {
-                var mrs = new MagickReadSettings()
-                {
-                    Density = new Density(300, 300),
-                    BackgroundColor = MagickColors.Transparent,
-                };
-
-                try
-                {
-                    magick.Read(file, mrs);
-                }
-                catch (MagickException e)
-                {
-#if DEBUG
-                    Trace.WriteLine("GetMagickImage returned " + file + " null, \n" + e.Message);
-#endif
-                    return null;
-                }
-
-                // Set values for maximum quality
-                magick.Quality = 100;
-                magick.ColorSpace = ColorSpace.Transparent;
-
-                var pic = magick.ToBitmapSource();
-                pic.Freeze();
-                magick.Dispose();
-                return pic;
-            }
-        }
-
         internal static BitmapSource GetBitmapSourceThumb(string path)
         {
             var ext = Path.GetExtension(path).ToLower();
@@ -213,7 +169,7 @@ namespace PicView
                 {
                     magick.Read(file);
                     magick.AdaptiveResize(size, size);
-                    
+
                 }
                 catch (MagickException e)
                 {
@@ -228,110 +184,6 @@ namespace PicView
             }
         }
 
-        internal static BitmapSource GetMagickImage(Stream s)
-        {
-            BitmapSource pic;
-
-            using (MagickImage magick = new MagickImage())
-            {
-                magick.Quality = 100;
-                var mrs = new MagickReadSettings()
-                {
-                    Density = new Density(300)
-                };
-
-                magick.Read(s);
-                magick.ColorSpace = ColorSpace.Transparent;
-                pic = magick.ToBitmapSource();
-
-                pic.Freeze();
-                return pic;
-            }
-        }
-
-        /// <summary>
-        /// Tries to save image to the specified destination,
-        /// returns false if unsuccesful
-        /// </summary>
-        /// <param name="rotate">Degrees image is rotated by</param>
-        /// <param name="flipped">Whether to flip image or not</param>
-        /// <param name="path">The path of the source file</param>
-        /// <param name="destination">Where to save image to</param>
-        /// <returns></returns>
-        internal static bool TrySaveImage(int rotate, bool flipped, string path, string destination)
-        {
-            if (File.Exists(path))
-            {
-                try
-                {
-                    using (var SaveImage = new MagickImage())
-                    {
-                        // Set maximum quality
-                        var mrs = new MagickReadSettings()
-                        {
-                            Density = new Density(300, 300),
-                        };
-                        SaveImage.Quality = 100;
-
-                        SaveImage.Read(path, mrs);
-
-                        // Apply transformation values
-                        if (flipped)
-                            SaveImage.Flop();
-                        SaveImage.Rotate(rotate);
-
-                        SaveImage.Write(destination);
-                    }
-                }
-                catch (Exception)
-                {
-                    return false;
-                }
-            }
-            else
-            {
-                return false;
-            }
-
-            return true;
-        }
-
-        internal static Size? ImageSize (string file)
-        {
-            using (MagickImage magick = new MagickImage())
-            {
-                try
-                {
-                    magick.Read(file);
-                }
-                catch (MagickException)
-                {
-                    return null;
-                }
-                
-                return new Size(magick.Width, magick.Height);
-            }
-        }
-
-        internal static void ResizeImage(string Pic, int NewWidth, int NewHeight)
-        {
-            try
-            {
-                using (MagickImage magick = new MagickImage(Pic))
-                {
-                    MagickGeometry size = new MagickGeometry(NewWidth, NewHeight);
-                    size.IgnoreAspectRatio = true;
-                    magick.Resize(size);
-                    magick.Quality = 100;
-                    magick.Write(Pic);
-                }
-            }
-            catch (MagickException)
-            {
-                return;
-            }          
-        }
-
         /// <summary>
         /// Returns a Windows Thumbnail
         /// </summary>

+ 45 - 0
PicView/Interface Logic/Animations/AjaxLoader.cs

@@ -0,0 +1,45 @@
+using System;
+using static PicView.Fields;
+
+namespace PicView
+{
+    internal static class AjaxLoader
+    {
+        //// AjaxLoading
+        ///// <summary>
+        ///// Loads AjaxLoading and adds it to the window
+        ///// </summary>
+        //internal static void LoadAjaxLoading()
+        //{
+        //    ajaxLoading = new AjaxLoading
+        //    {
+        //        Focusable = false,
+        //        Opacity = 0
+        //    };
+
+        //    mainWindow.bg.Children.Add(ajaxLoading);
+        //}
+
+        /// <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));
+            }
+        }
+    }
+}

+ 0 - 0
PicView/Helpers/AnimationHelper.cs → PicView/Interface Logic/Animations/AnimationHelper.cs


+ 66 - 0
PicView/Interface Logic/Animations/FadeControls.cs

@@ -0,0 +1,66 @@
+using System;
+using static PicView.Fields;
+namespace PicView
+{
+    internal static class FadeControls
+    {
+        /// <summary>
+        /// Hides/shows interface elements with a fade animation
+        /// </summary>
+        /// <param name="show"></param>
+        internal static async void FadeControlsAsync(bool show, double time = .5)
+        {
+            /// Might cause unnecessary cpu usage? Need to check
+            await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
+            {
+                if (!Properties.Settings.Default.ShowInterface | Slidetimer.Enabled == true)
+                {
+                    if (clickArrowRight != null && clickArrowLeft != null && x2 != null)
+                    {
+                        var fadeTo = show ? 1 : 0;
+                        var timespan = TimeSpan.FromSeconds(time);
+
+                        AnimationHelper.Fade(clickArrowLeft, fadeTo, timespan);
+                        AnimationHelper.Fade(clickArrowRight, fadeTo, timespan);
+                        AnimationHelper.Fade(x2, fadeTo, timespan);
+                        AnimationHelper.Fade(minus, fadeTo, timespan);
+                    }
+                }
+
+                ScrollbarFade(show);
+            }));
+        }
+
+        /// <summary>
+        /// Find scrollbar and start fade animation
+        /// </summary>
+        /// <param name="show"></param>
+        internal static void ScrollbarFade(bool show)
+        {
+            var s = mainWindow.Scroller.Template.FindName("PART_VerticalScrollBar", mainWindow.Scroller) as System.Windows.Controls.Primitives.ScrollBar;
+
+            if (show)
+            {
+                AnimationHelper.Fade(s, 1, TimeSpan.FromSeconds(.7));
+            }
+            else
+            {
+                AnimationHelper.Fade(s, 0, TimeSpan.FromSeconds(1));
+            }
+        }
+
+        //internal static async void FadeCursor(double time = .5)
+        //{
+        //    /// Might cause unnecessary cpu usage? Need to check
+        //    await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
+        //    {
+        //        AnimationHelper.Fade(clickArrowLeft, 0, TimeSpan.FromSeconds(.5));
+        //        AnimationHelper.Fade(clickArrowRight, 0, TimeSpan.FromSeconds(.5));
+        //        AnimationHelper.Fade(x2, 0, TimeSpan.FromSeconds(.5));
+        //        Mouse.OverrideCursor = Cursors.None;
+
+        //        MouseIdleTimer.Stop();
+        //    }));
+        //}
+    }
+}

+ 0 - 0
PicView/Interface Logic/MouseOverAnimations.cs → PicView/Interface Logic/Animations/MouseOverAnimations.cs


+ 2 - 2
PicView/Drag and Drop/DragAndDrop.cs → PicView/Interface Logic/Drag and Drop/DragAndDrop.cs

@@ -5,9 +5,9 @@ using System.Reflection;
 using System.Threading.Tasks;
 using System.Windows;
 using static PicView.Fields;
-using static PicView.ImageManager;
 using static PicView.Navigation;
-using static PicView.Interface;
+using static PicView.Thumbnails;
+using static PicView.Tooltip;
 
 namespace PicView
 {

+ 0 - 0
PicView/Interface Logic/ContextMenus.cs → PicView/Interface Logic/Instantiate/ContextMenus.cs


+ 0 - 0
PicView/Interface Logic/LoadControls.cs → PicView/Interface Logic/Instantiate/LoadControls.cs


+ 0 - 0
PicView/Interface Logic/LoadWindows.cs → PicView/Interface Logic/Instantiate/LoadWindows.cs


+ 3 - 7
PicView/Interface Logic/Timers.cs → PicView/Interface Logic/Instantiate/Timers.cs

@@ -1,11 +1,7 @@
-using System;
-using System.Timers;
-using System.Windows.Input;
-using System.Windows.Threading;
+using System.Timers;
+using static PicView.FadeControls;
 using static PicView.Fields;
-using static PicView.Interface;
-using static PicView.Navigation;
-using static PicView.Resize_and_Zoom;
+using static PicView.Scroll;
 
 namespace PicView
 {

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

@@ -1,395 +0,0 @@
-using System;
-using System.IO;
-using System.Text;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using static PicView.Fields;
-using static PicView.FileFunctions;
-using static PicView.Resize_and_Zoom;
-using static PicView.WindowLogic;
-
-namespace PicView
-{
-    internal static class Interface
-    {
-
-        #region UserControl Specifics
-
-        /// <summary>
-        /// Shows a black tooltip on screen in a given time
-        /// </summary>
-        /// <param name="message">The message to display</param>
-        /// <param name="center">If centered or on bottom</param>
-        /// <param name="time">How long until it fades away</param>
-        internal static void ToolTipStyle(object message, bool center, TimeSpan time)
-        {
-            sexyToolTip.Visibility = Visibility.Visible;
-
-            if (center)
-            {
-                sexyToolTip.Margin = new Thickness(0, 0, 0, 0);
-                sexyToolTip.VerticalAlignment = VerticalAlignment.Center;
-            }
-            else
-            {
-                sexyToolTip.Margin = new Thickness(0, 0, 0, 15);
-                sexyToolTip.VerticalAlignment = VerticalAlignment.Bottom;
-            }
-
-            sexyToolTip.SexyToolTipText.Text = message.ToString();
-            var anim = new DoubleAnimation(1, TimeSpan.FromSeconds(.5));
-            anim.Completed += (s, _) => AnimationHelper.Fade(sexyToolTip, TimeSpan.FromSeconds(1.5), time, 1, 0);
-
-            sexyToolTip.BeginAnimation(UIElement.OpacityProperty, anim);
-        }
-
-        /// <summary>
-        /// Shows a black tooltip on screen for a small time
-        /// </summary>
-        /// <param name="message">The message to display</param>
-        internal static void ToolTipStyle(object message, bool center = false)
-        {
-            ToolTipStyle(message, center, TimeSpan.FromSeconds(1));
-        }
-
-        /// <summary>
-        /// Hides the Messagebox ToolTipStyle
-        /// </summary>
-        internal static void CloseToolTipStyle()
-        {
-            sexyToolTip.Visibility = Visibility.Hidden;
-        }
-
-        //// AjaxLoading
-        ///// <summary>
-        ///// Loads AjaxLoading and adds it to the window
-        ///// </summary>
-        //internal static void LoadAjaxLoading()
-        //{
-        //    ajaxLoading = new AjaxLoading
-        //    {
-        //        Focusable = false,
-        //        Opacity = 0
-        //    };
-
-        //    mainWindow.bg.Children.Add(ajaxLoading);
-        //}
-
-        /// <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));
-            }
-        }
-
-        // AutoScrollSign
-
-       
-
-        internal static void HideAutoScrollSign()
-        {
-            autoScrollSign.Visibility = Visibility.Collapsed;
-            autoScrollSign.Opacity = 0;
-        }
-
-        internal static void ShowAutoScrollSign()
-        {
-            Canvas.SetTop(autoScrollSign, autoScrollOrigin.Value.Y);
-            Canvas.SetLeft(autoScrollSign, autoScrollOrigin.Value.X);
-            autoScrollSign.Visibility = Visibility.Visible;
-            autoScrollSign.Opacity = 1;
-        }
-
-        
-
-        #endregion UserControl Specifics
-
-        #region Manipulate Interface        
-
-        /// <summary>
-        /// Toggle between hidden interface and default
-        /// </summary>
-        internal static void HideInterface(bool slideshow = false, bool navigationButtons = true)
-        {
-            // Hide interface
-            if (Properties.Settings.Default.ShowInterface)
-            {
-                mainWindow.TitleBar.Visibility =
-                mainWindow.LowerBar.Visibility =
-                mainWindow.LeftBorderRectangle.Visibility =
-                mainWindow.RightBorderRectangle.Visibility
-                = Visibility.Collapsed;
-
-                if (navigationButtons)
-                    clickArrowLeft.Visibility =
-                    clickArrowRight.Visibility =
-                    x2.Visibility =
-                    minus.Visibility = Visibility.Visible;
-                else
-                    clickArrowLeft.Visibility =
-                    clickArrowRight.Visibility =
-                    x2.Visibility =
-                    minus.Visibility = Visibility.Collapsed;
-
-                if (!slideshow || !Properties.Settings.Default.Fullscreen)
-                    Properties.Settings.Default.ShowInterface = false;
-
-                if (activityTimer != null)
-                    activityTimer.Start();
-            }
-            // Show interface
-            else
-            {
-                Properties.Settings.Default.ShowInterface = true;
-
-                mainWindow.TitleBar.Visibility =
-                mainWindow.LowerBar.Visibility =
-                mainWindow.LeftBorderRectangle.Visibility =
-                mainWindow.RightBorderRectangle.Visibility = Visibility.Visible;
-
-                clickArrowLeft.Visibility =
-                clickArrowRight.Visibility =
-                x2.Visibility =
-                minus.Visibility = Visibility.Collapsed;
-
-                if (activityTimer != null)
-                    activityTimer.Stop();
-            }
-            if (xWidth != 0 && xHeight != 0)
-                ZoomFit(xWidth, xHeight);
-
-            ToggleMenus.Close_UserControls();
-        }
-
-
-
-        /// <summary>
-        /// Logic for mouse enter mainwindow event
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        internal static void MainWindow_MouseEnter(object sender, MouseEventArgs e)
-        {
-            // Start timer when mouse enters mainwindow
-            activityTimer.Start();
-            //FadeControlsAsync(true);
-        }
-
-
-        /// <summary>
-        /// Logic for mouse movements on MainWindow
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        internal static void MainWindow_MouseMove(object sender, MouseEventArgs e)
-        {
-            ////If Mouse is hidden, show it and interface elements.
-            //if (e.MouseDevice.OverrideCursor == Cursors.None)
-            //{
-            //    Mouse.OverrideCursor = null;
-            //    HideCursorTimer.Stop();
-            //}
-
-
-            // If mouse moves on mainwindow, show elements
-            FadeControlsAsync(true);
-
-
-            //// If Slideshow is running the interface will hide after 2,5 sec.
-            //if (Slidetimer.Enabled == true)
-            //{
-            //    MouseIdleTimer.Start();
-            //}
-            //else
-            //{
-            //    MouseIdleTimer.Stop();
-            //}
-        }
-
-        /// <summary>
-        /// Logic for mouse leave mainwindow event
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        internal static void MainWindow_MouseLeave(object sender, MouseEventArgs e)
-        {
-            // Start timer when mouse leaves mainwindow
-            //activityTimer.Start();
-            FadeControlsAsync(false);
-        }
-
-        /// <summary>
-        /// Find scrollbar and start fade animation
-        /// </summary>
-        /// <param name="show"></param>
-        internal static void ScrollbarFade(bool show)
-        {
-            var s = mainWindow.Scroller.Template.FindName("PART_VerticalScrollBar", mainWindow.Scroller) as System.Windows.Controls.Primitives.ScrollBar;
-
-            if (show)
-            {
-                AnimationHelper.Fade(s, 1, TimeSpan.FromSeconds(.7));
-            }
-            else
-            {
-                AnimationHelper.Fade(s, 0, TimeSpan.FromSeconds(1));
-            }
-        }
-
-        /// <summary>
-        /// Returns string with file name, folder position,
-        /// zoom, aspect ratio, resolution and file size
-        /// </summary>
-        /// <param name="width"></param>
-        /// <param name="height"></param>
-        /// <param name="index"></param>
-        /// <returns></returns>
-        internal static string[] TitleString(int width, int height, int index)
-        {
-            var s1 = new StringBuilder();
-            s1.Append(AppName).Append(" - ").Append(Path.GetFileName(Pics[index])).Append(" ").Append(index + 1).Append("/").Append(Pics.Count).Append(" files")
-                    .Append(" (").Append(width).Append(" x ").Append(height).Append(StringAspect(width, height)).Append(GetSizeReadable(new FileInfo(Pics[index]).Length));
-
-            if (!string.IsNullOrEmpty(ZoomPercentage))
-                s1.Append(" - ").Append(ZoomPercentage);
-
-            var array = new string[3];
-            array[0] = s1.ToString();
-            s1.Remove(0, AppName.Length + 3);   // Remove AppName + " - "
-            array[1] = s1.ToString();
-            s1.Replace(Path.GetFileName(Pics[index]), Pics[index]);
-            array[2] = s1.ToString();
-            return array;
-        }
-
-        /// <summary>
-        /// Returns string with file name,
-        /// zoom, aspect ratio and resolution
-        /// </summary>
-        /// <param name="width"></param>
-        /// <param name="height"></param>
-        /// <param name="path"></param>
-        /// <returns></returns>
-        internal static string[] TitleString(int width, int height, string path)
-        {
-            var s1 = new StringBuilder();
-            s1.Append(AppName).Append(" - ").Append(path).Append(" (").Append(width).Append(" x ").Append(height).Append(StringAspect(width, height));
-
-            if (!string.IsNullOrEmpty(ZoomPercentage))
-                s1.Append(" - ").Append(ZoomPercentage);
-
-            var array = new string[2];
-            array[0] = s1.ToString();
-            s1.Remove(0, AppName.Length + 3);   // Remove AppName + " - "
-            array[1] = s1.ToString();
-            return array;
-        }
-
-        /// <summary>
-        /// Toggles scroll and displays it with TooltipStle
-        /// </summary>
-        internal static bool IsScrollEnabled
-        {
-            get { return Properties.Settings.Default.ScrollEnabled; }
-            set
-            {
-                Properties.Settings.Default.ScrollEnabled = value;
-                mainWindow.Scroller.VerticalScrollBarVisibility = value ? ScrollBarVisibility.Auto : ScrollBarVisibility.Disabled;
-                if (!freshStartup && !string.IsNullOrEmpty(PicPath))
-                {
-                    ZoomFit(mainWindow.img.Source.Width, mainWindow.img.Source.Height);
-                    ToolTipStyle(value ? "Scrolling enabled" : "Scrolling disabled");
-                }
-            }
-        }
-
-        internal static void ChangeBackground(object sender, RoutedEventArgs e)
-        {
-            if (mainWindow.imgBorder == null)
-                return;
-
-            if (!(mainWindow.imgBorder.Background is SolidColorBrush cc))
-                return;
-
-            if (cc.Color == Colors.White)
-            {
-                mainWindow.imgBorder.Background = new SolidColorBrush(Colors.Transparent);
-                Properties.Settings.Default.BgColorWhite = false;
-            }
-
-            else
-            {
-                mainWindow.imgBorder.Background = new SolidColorBrush(Colors.White);
-                Properties.Settings.Default.BgColorWhite = true;
-            }
-
-        }
-
-
-
-        #endregion Manipulate Interface
-
-        #region Fade controls 
-
-        /// <summary>
-        /// Hides/shows interface elements with a fade animation
-        /// </summary>
-        /// <param name="show"></param>
-        internal static async void FadeControlsAsync(bool show, double time = .5)
-        {
-            /// Might cause unnecessary cpu usage? Need to check
-            await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
-            {
-                if (!Properties.Settings.Default.ShowInterface | Slidetimer.Enabled == true)
-                {
-                    if (clickArrowRight != null && clickArrowLeft != null && x2 != null)
-                    {
-                        var fadeTo = show ? 1 : 0;
-                        var timespan = TimeSpan.FromSeconds(time);
-
-                        AnimationHelper.Fade(clickArrowLeft, fadeTo, timespan);
-                        AnimationHelper.Fade(clickArrowRight, fadeTo, timespan);
-                        AnimationHelper.Fade(x2, fadeTo, timespan);
-                        AnimationHelper.Fade(minus, fadeTo, timespan);
-                    }
-                }
-
-                ScrollbarFade(show);
-            }));
-        }
-
-        //internal static async void FadeCursor(double time = .5)
-        //{
-        //    /// Might cause unnecessary cpu usage? Need to check
-        //    await mainWindow.Dispatcher.BeginInvoke((Action)(() =>
-        //    {
-        //        AnimationHelper.Fade(clickArrowLeft, 0, TimeSpan.FromSeconds(.5));
-        //        AnimationHelper.Fade(clickArrowRight, 0, TimeSpan.FromSeconds(.5));
-        //        AnimationHelper.Fade(x2, 0, TimeSpan.FromSeconds(.5));
-        //        Mouse.OverrideCursor = Cursors.None;
-
-        //        MouseIdleTimer.Stop();
-        //    }));
-        //}
-
-        #endregion
-    }
-}

+ 127 - 0
PicView/Interface Logic/InterfaceUtilities.cs

@@ -0,0 +1,127 @@
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Media;
+using static PicView.FadeControls;
+using static PicView.Fields;
+using static PicView.Resize_and_Zoom;
+
+namespace PicView
+{
+    internal static class HideInterfaceLogic
+    {     
+
+        /// <summary>
+        /// Toggle between hidden interface and default
+        /// </summary>
+        internal static void HideInterface(bool slideshow = false, bool navigationButtons = true)
+        {
+            // Hide interface
+            if (Properties.Settings.Default.ShowInterface)
+            {
+                mainWindow.TitleBar.Visibility =
+                mainWindow.LowerBar.Visibility =
+                mainWindow.LeftBorderRectangle.Visibility =
+                mainWindow.RightBorderRectangle.Visibility
+                = Visibility.Collapsed;
+
+                if (navigationButtons)
+                    clickArrowLeft.Visibility =
+                    clickArrowRight.Visibility =
+                    x2.Visibility =
+                    minus.Visibility = Visibility.Visible;
+                else
+                    clickArrowLeft.Visibility =
+                    clickArrowRight.Visibility =
+                    x2.Visibility =
+                    minus.Visibility = Visibility.Collapsed;
+
+                if (!slideshow || !Properties.Settings.Default.Fullscreen)
+                    Properties.Settings.Default.ShowInterface = false;
+
+                if (activityTimer != null)
+                    activityTimer.Start();
+            }
+            // Show interface
+            else
+            {
+                Properties.Settings.Default.ShowInterface = true;
+
+                mainWindow.TitleBar.Visibility =
+                mainWindow.LowerBar.Visibility =
+                mainWindow.LeftBorderRectangle.Visibility =
+                mainWindow.RightBorderRectangle.Visibility = Visibility.Visible;
+
+                clickArrowLeft.Visibility =
+                clickArrowRight.Visibility =
+                x2.Visibility =
+                minus.Visibility = Visibility.Collapsed;
+
+                if (activityTimer != null)
+                    activityTimer.Stop();
+            }
+            if (xWidth != 0 && xHeight != 0)
+                ZoomFit(xWidth, xHeight);
+
+            ToggleMenus.Close_UserControls();
+        }
+
+
+
+        /// <summary>
+        /// Logic for mouse enter mainwindow event
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        internal static void MainWindow_MouseEnter(object sender, MouseEventArgs e)
+        {
+            // Start timer when mouse enters mainwindow
+            activityTimer.Start();
+            //FadeControlsAsync(true);
+        }
+
+
+        /// <summary>
+        /// Logic for mouse movements on MainWindow
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        internal static void MainWindow_MouseMove(object sender, MouseEventArgs e)
+        {
+            ////If Mouse is hidden, show it and interface elements.
+            //if (e.MouseDevice.OverrideCursor == Cursors.None)
+            //{
+            //    Mouse.OverrideCursor = null;
+            //    HideCursorTimer.Stop();
+            //}
+
+
+            // If mouse moves on mainwindow, show elements
+            FadeControlsAsync(true);
+
+
+            //// If Slideshow is running the interface will hide after 2,5 sec.
+            //if (Slidetimer.Enabled == true)
+            //{
+            //    MouseIdleTimer.Start();
+            //}
+            //else
+            //{
+            //    MouseIdleTimer.Stop();
+            //}
+        }
+
+        /// <summary>
+        /// Logic for mouse leave mainwindow event
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        internal static void MainWindow_MouseLeave(object sender, MouseEventArgs e)
+        {
+            // Start timer when mouse leaves mainwindow
+            //activityTimer.Start();
+            FadeControlsAsync(false);
+        }      
+
+
+    }
+}

+ 90 - 0
PicView/Interface Logic/SetTitle.cs

@@ -0,0 +1,90 @@
+using System.IO;
+using System.Text;
+using static PicView.Fields;
+using static PicView.FileFunctions;
+namespace PicView
+{
+    internal static class SetTitle
+    {
+        /// <summary>
+        /// Returns string with file name, folder position,
+        /// zoom, aspect ratio, resolution and file size
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="index"></param>
+        /// <returns></returns>
+        internal static string[] TitleString(int width, int height, int index)
+        {
+            var s1 = new StringBuilder();
+            s1.Append(AppName).Append(" - ").Append(Path.GetFileName(Pics[index])).Append(" ").Append(index + 1).Append("/").Append(Pics.Count).Append(" files")
+                    .Append(" (").Append(width).Append(" x ").Append(height).Append(StringAspect(width, height)).Append(GetSizeReadable(new FileInfo(Pics[index]).Length));
+
+            if (!string.IsNullOrEmpty(ZoomPercentage))
+                s1.Append(" - ").Append(ZoomPercentage);
+
+            var array = new string[3];
+            array[0] = s1.ToString();
+            s1.Remove(0, AppName.Length + 3);   // Remove AppName + " - "
+            array[1] = s1.ToString();
+            s1.Replace(Path.GetFileName(Pics[index]), Pics[index]);
+            array[2] = s1.ToString();
+            return array;
+        }
+
+        /// <summary>
+        /// Sets title string with file name, folder position,
+        /// zoom, aspect ratio, resolution and file size
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="index"></param>
+        /// <returns></returns>
+        internal static void SetTitleString(int width, int height, int index)
+        {
+            var titleString = TitleString(width, height, index);
+            mainWindow.Title = titleString[0];
+            mainWindow.Bar.Text = titleString[1];
+            mainWindow.Bar.ToolTip = titleString[1];
+        }
+
+        /// <summary>
+        /// Returns string with file name,
+        /// zoom, aspect ratio and resolution
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="path"></param>
+        /// <returns></returns>
+        internal static string[] TitleString(int width, int height, string path)
+        {
+            var s1 = new StringBuilder();
+            s1.Append(AppName).Append(" - ").Append(path).Append(" (").Append(width).Append(" x ").Append(height).Append(StringAspect(width, height));
+
+            if (!string.IsNullOrEmpty(ZoomPercentage))
+                s1.Append(" - ").Append(ZoomPercentage);
+
+            var array = new string[2];
+            array[0] = s1.ToString();
+            s1.Remove(0, AppName.Length + 3);   // Remove AppName + " - "
+            array[1] = s1.ToString();
+            return array;
+        }
+
+        /// <summary>
+        /// Sets title string with file name,
+        /// zoom, aspect ratio and resolution
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="path"></param>
+        /// <returns></returns>
+        internal static void SetTitleString(int width, int height, string path)
+        {
+            var titleString = TitleString(width, height, path);
+            mainWindow.Title = titleString[0];
+            mainWindow.Bar.Text = titleString[1];
+            mainWindow.Bar.ToolTip = titleString[1];
+        }
+    }
+}

+ 2 - 1
PicView/Interface Logic/SlideShow.cs

@@ -4,8 +4,9 @@ using System.IO;
 using System.Windows;
 using System.Windows.Input;
 using static PicView.Fields;
-using static PicView.Interface;
+using static PicView.HideInterfaceLogic;
 using static PicView.Navigation;
+using static PicView.Tooltip;
 using static PicView.WindowLogic;
 
 namespace PicView

+ 64 - 0
PicView/Interface Logic/Tooltip.cs

@@ -0,0 +1,64 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using static PicView.Fields;
+using static PicView.FileFunctions;
+using static PicView.Resize_and_Zoom;
+using static PicView.FadeControls;
+
+namespace PicView
+{
+    internal static class Tooltip
+    {
+        /// <summary>
+        /// Shows a black tooltip on screen in a given time
+        /// </summary>
+        /// <param name="message">The message to display</param>
+        /// <param name="center">If centered or on bottom</param>
+        /// <param name="time">How long until it fades away</param>
+        internal static void ToolTipStyle(object message, bool center, TimeSpan time)
+        {
+            sexyToolTip.Visibility = Visibility.Visible;
+
+            if (center)
+            {
+                sexyToolTip.Margin = new Thickness(0, 0, 0, 0);
+                sexyToolTip.VerticalAlignment = VerticalAlignment.Center;
+            }
+            else
+            {
+                sexyToolTip.Margin = new Thickness(0, 0, 0, 15);
+                sexyToolTip.VerticalAlignment = VerticalAlignment.Bottom;
+            }
+
+            sexyToolTip.SexyToolTipText.Text = message.ToString();
+            var anim = new DoubleAnimation(1, TimeSpan.FromSeconds(.5));
+            anim.Completed += (s, _) => AnimationHelper.Fade(sexyToolTip, TimeSpan.FromSeconds(1.5), time, 1, 0);
+
+            sexyToolTip.BeginAnimation(UIElement.OpacityProperty, anim);
+        }
+
+        /// <summary>
+        /// Shows a black tooltip on screen for a small time
+        /// </summary>
+        /// <param name="message">The message to display</param>
+        internal static void ToolTipStyle(object message, bool center = false)
+        {
+            ToolTipStyle(message, center, TimeSpan.FromSeconds(1));
+        }
+
+        /// <summary>
+        /// Hides the Messagebox ToolTipStyle
+        /// </summary>
+        internal static void CloseToolTipStyle()
+        {
+            sexyToolTip.Visibility = Visibility.Hidden;
+        }
+
+    }
+}

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

@@ -5,7 +5,7 @@ using System.Windows.Controls;
 using System.Windows.Input;
 using static PicView.Fields;
 using static PicView.Helper;
-using static PicView.Interface;
+using static PicView.HideInterfaceLogic;
 using static PicView.Resize_and_Zoom;
 
 namespace PicView

+ 1 - 1
PicView/Loading/Preloader.cs

@@ -57,7 +57,7 @@ namespace PicView.PreLoading
 
             IsLoading = true;
 
-            var pic = ImageManager.RenderToBitmapSource(file);
+            var pic = ImageDecoder.RenderToBitmapSource(file);
             if (pic == null)
             {
                 IsLoading = false;

+ 3 - 1
PicView/MainWindow.xaml.cs

@@ -6,6 +6,7 @@ using System.ComponentModel;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
+using static PicView.AjaxLoader;
 using static PicView.ContextMenus;
 using static PicView.Copy_Paste;
 using static PicView.DeleteFiles;
@@ -13,7 +14,7 @@ using static PicView.DragAndDrop;
 using static PicView.Error_Handling;
 using static PicView.Fields;
 using static PicView.Helper;
-using static PicView.Interface;
+using static PicView.HideInterfaceLogic;
 using static PicView.LoadControls;
 using static PicView.LoadWindows;
 using static PicView.MouseOverAnimations;
@@ -22,6 +23,7 @@ using static PicView.Open_Save;
 using static PicView.PicGalleryLogic;
 using static PicView.Resize_and_Zoom;
 using static PicView.Rotate_and_Flip;
+using static PicView.Scroll;
 using static PicView.Shortcuts;
 using static PicView.SlideShow;
 using static PicView.Timers;

+ 2 - 4
PicView/Helpers/Fields.cs → PicView/Misc/Fields.cs

@@ -1,6 +1,5 @@
 using PicView.UserControls;
 using PicView.UserControls.Menus;
-using PicView.Windows;
 using System;
 using System.Collections.Generic;
 using System.Timers;
@@ -8,7 +7,6 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
 using static PicView.Helper;
-using static PicView.Resize_and_Zoom;
 
 namespace PicView
 {
@@ -222,12 +220,12 @@ namespace PicView
         /// <summary>
         /// Timer used for hide/show cursor.
         /// </summary>
-        internal static Timer HideCursorTimer;
+        //internal static Timer HideCursorTimer;
 
         /// <summary>
         /// Timer used to check if mouse is idle.
         /// </summary>
-        internal static Timer MouseIdleTimer;
+        //internal static Timer MouseIdleTimer;
 
         /// <summary>
         /// Timer used for slideshow

+ 19 - 6
PicView/Helpers/Helper.cs → PicView/Misc/Helper.cs

@@ -2,6 +2,7 @@
 using System.Diagnostics;
 using System.Windows;
 using System.Windows.Media;
+using static PicView.Fields;
 
 namespace PicView
 {
@@ -74,16 +75,28 @@ namespace PicView
             }
         }
 
-        internal static string Shorten(string name,int amount)
+        internal static void ChangeBackground(object sender, RoutedEventArgs e)
         {
-            if (name.Length >= 25)
+            if (mainWindow.imgBorder == null)
+                return;
+
+            if (!(mainWindow.imgBorder.Background is SolidColorBrush cc))
+                return;
+
+            if (cc.Color == Colors.White)
             {
-                name = name.Substring(0, amount);
-                name += "...";
+                mainWindow.imgBorder.Background = new SolidColorBrush(Colors.Transparent);
+                Properties.Settings.Default.BgColorWhite = false;
             }
-            return name;
+
+            else
+            {
+                mainWindow.imgBorder.Background = new SolidColorBrush(Colors.White);
+                Properties.Settings.Default.BgColorWhite = true;
+            }
+
         }
-     
+
 
     }
 }

+ 0 - 0
PicView/Native/NativeMethods.cs → PicView/Misc/NativeMethods.cs


+ 3 - 2
PicView/Error Handling/Error_Handling.cs → PicView/Navigation/Error_Handling.cs

@@ -3,15 +3,16 @@ using System;
 using System.Diagnostics;
 using System.IO;
 using System.Windows.Media.Imaging;
+using static PicView.AjaxLoader;
 using static PicView.DeleteFiles;
 using static PicView.Fields;
 using static PicView.FileLists;
 using static PicView.Helper;
-using static PicView.ImageManager;
-using static PicView.Interface;
+using static PicView.ImageDecoder;
 using static PicView.Navigation;
 using static PicView.Resize_and_Zoom;
 using static PicView.Rotate_and_Flip;
+using static PicView.Tooltip;
 
 namespace PicView
 {

+ 9 - 10
PicView/Image Logic/Navigation.cs → PicView/Navigation/Navigation.cs

@@ -6,15 +6,19 @@ using System.Threading.Tasks;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Threading;
+using static PicView.AjaxLoader;
 using static PicView.ArchiveExtraction;
 using static PicView.DeleteFiles;
 using static PicView.Error_Handling;
 using static PicView.Fields;
 using static PicView.FileLists;
 using static PicView.Helper;
-using static PicView.ImageManager;
-using static PicView.Interface;
+using static PicView.ImageDecoder;
 using static PicView.Resize_and_Zoom;
+using static PicView.Scroll;
+using static PicView.SetTitle;
+using static PicView.Thumbnails;
+using static PicView.Tooltip;
 
 namespace PicView
 {
@@ -225,10 +229,7 @@ namespace PicView
 
             // Update values
             canNavigate = true;
-            var titleString = TitleString(pic.PixelWidth, pic.PixelHeight, x);
-            mainWindow.Title = titleString[0];
-            mainWindow.Bar.Text = titleString[1];
-            mainWindow.Bar.ToolTip = titleString[2];
+            SetTitleString(pic.PixelWidth, pic.PixelHeight, x);
             PicPath = Pics[x];
             FolderIndex = x;
             AjaxLoadingEnd();
@@ -283,10 +284,7 @@ namespace PicView
             ZoomFit(pic.PixelWidth, pic.PixelHeight);
             CloseToolTipStyle();
 
-            var titleString = TitleString(pic.PixelWidth, pic.PixelHeight, imageName);
-            mainWindow.Title = titleString[0];
-            mainWindow.Bar.Text = titleString[1];
-            mainWindow.Bar.ToolTip = titleString[1];
+            SetTitleString(pic.PixelWidth, pic.PixelHeight, imageName);
 
             NoProgress();
             PicPath = string.Empty;
@@ -466,6 +464,7 @@ namespace PicView
                 mainWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                 {
                     mainWindow.Title = mainWindow.Bar.Text = e.BytesReceived + "/" + e.TotalBytesToReceive + ". " + e.ProgressPercentage + "% complete...";
+                    mainWindow.Bar.ToolTip = mainWindow.Title;
                 }));
 
                 var bytes = await client.DownloadDataTaskAsync(new Uri(address));

+ 111 - 110
PicView/Interface Logic/PicGalleryLogic.cs → PicView/PicGallery/PicGalleryLogic.cs

@@ -11,9 +11,10 @@ using System.Windows.Media.Animation;
 using System.Windows.Media.Imaging;
 using System.Windows.Threading;
 using static PicView.Fields;
-using static PicView.ImageManager;
-using static PicView.Interface;
+using static PicView.ImageDecoder;
+using static PicView.HideInterfaceLogic;
 using static PicView.Navigation;
+using static PicView.Thumbnails;
 using static PicView.WindowLogic;
 
 
@@ -29,20 +30,24 @@ namespace PicView
         internal const int picGalleryItem_Size = 230;
         internal const int picGalleryItem_Size_s = 200;
 
-        public static int Current_page
+        public static int Horizontal_items
         {
             get
             {
-                return (int)Math.Floor((double)FolderIndex / Items_per_page);
+                if (picGallery == null) return 0;
+                return (int)Math.Floor(picGallery.Width / picGalleryItem_Size);
             }
             set { }
         }
 
-        public static int Total_pages
+        public static int Vertical_items
         {
             get
             {
-                return (int)Math.Floor((double)Pics.Count / Items_per_page);
+                if (picGallery == null) return 0;
+                return Properties.Settings.Default.PicGallery == 1 ?
+                    (int)Math.Floor(picGallery.Height / picGalleryItem_Size) :
+                    Pics.Count;
             }
             set { }
         }
@@ -59,30 +64,122 @@ namespace PicView
             set { }
         }
 
-        public static int Horizontal_items
+        public static int Current_page
         {
             get
             {
-                if (picGallery == null) return 0;
-                return (int)Math.Floor(picGallery.Width / picGalleryItem_Size);
+                return (int)Math.Floor((double)FolderIndex / Items_per_page);
             }
             set { }
         }
 
-        public static int Vertical_items
+        public static int Total_pages
         {
             get
             {
-                if (picGallery == null) return 0;
-                return Properties.Settings.Default.PicGallery == 1 ?
-                    (int)Math.Floor(picGallery.Height / picGalleryItem_Size) :
-                    Pics.Count;
+                return (int)Math.Floor((double)Pics.Count / Items_per_page);
             }
             set { }
         }
 
         #endregion
 
+        #region Scroll
+
+        /// <summary>
+        /// Scrolls to center of current item
+        /// </summary>
+        /// <param name="item">The index of picGalleryItem</param>
+        internal static void ScrollTo()
+        {
+            if (Properties.Settings.Default.PicGallery == 1)
+                picGallery.Scroller.ScrollToHorizontalOffset((picGalleryItem_Size * Horizontal_items) * Current_page);
+            else
+                picGallery.Scroller.ScrollToVerticalOffset((picGalleryItem_Size * Items_per_page) * Current_page);
+        }
+
+        private static void Scroller_MouseWheel(object sender, MouseWheelEventArgs e)
+        {
+            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
+                ScrollTo(e.Delta > 0);
+            else
+                ScrollTo(e.Delta > 0, false);
+        }
+
+        /// <summary>
+        /// Scrolls a page back or forth
+        /// </summary>
+        /// <param name="next"></param>
+        /// <param name="end"></param>
+        internal static void ScrollTo(bool next, bool end = false, bool speedUp = false, bool animate = false)
+        {
+            if (end)
+            {
+                if (next)
+                    picGallery.Scroller.ScrollToRightEnd();
+                else
+                    picGallery.Scroller.ScrollToLeftEnd();
+            }
+            else
+            {
+                var speed = speedUp ? picGalleryItem_Size * 4.7 : picGalleryItem_Size;
+                var direction = next ? picGallery.Scroller.HorizontalOffset - speed : picGallery.Scroller.HorizontalOffset + speed;
+
+                if (Properties.Settings.Default.PicGallery == 1)
+                {
+                    if (animate)
+                    {
+                        //var anim = new DoubleAnimation
+                        //{
+                        //    From = Scroller.HorizontalOffset,
+                        //    To = direction,
+                        //    Duration = TimeSpan.FromSeconds(.3),
+                        //    AccelerationRatio = 0.2,
+                        //    DecelerationRatio = 0.4
+                        //};
+
+                        //var sb = new Storyboard();
+                        //sb.Children.Add(anim);
+                        //Storyboard.SetTarget(anim, Scroller);
+                        //Storyboard.SetTargetProperty(anim, new PropertyPath(ScrollAnimationBehavior.VerticalOffsetProperty))
+                    }
+                    else
+                    {
+                        picGallery.Scroller.ScrollToHorizontalOffset(direction);
+                    }
+                }
+                else
+                {
+                    if (animate)
+                    {
+                        //DoubleAnimation verticalAnimation = new DoubleAnimation
+                        //{
+                        //    From = scrollViewer.VerticalOffset,
+                        //    To = some
+                        //};
+                        //value;
+                        //verticalAnimation.Duration = new Duration(some duration);
+
+                        //Storyboard storyboard = new Storyboard();
+
+                        //storyboard.Children.Add(verticalAnimation);
+                        //Storyboard.SetTarget(verticalAnimation, scrollViewer);
+                        //Storyboard.SetTargetProperty(verticalAnimation, new PropertyPath(ScrollAnimationBehavior.VerticalOffsetProperty)); // Attached dependency property
+                        //storyboard.Begin();
+                    }
+                    else
+                    {
+                        if (next)
+                            picGallery.Scroller.ScrollToVerticalOffset(picGallery.Scroller.VerticalOffset - speed);
+                        else
+                            picGallery.Scroller.ScrollToVerticalOffset(picGallery.Scroller.VerticalOffset + speed);
+                    }
+                }
+            }
+        }
+
+        #endregion Scroll
+
         #region Open/Close
 
         internal static void PicGalleryToggle(bool change = false)
@@ -322,102 +419,6 @@ namespace PicView
 
         #endregion
 
-        #region Scroll
-
-        private static void Scroller_MouseWheel(object sender, MouseWheelEventArgs e)
-        {
-            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
-                ScrollTo(e.Delta > 0);
-            else
-                ScrollTo(e.Delta > 0, false);
-        }
-
-        /// <summary>
-        /// Scrolls a page back or forth
-        /// </summary>
-        /// <param name="next"></param>
-        /// <param name="end"></param>
-        internal static void ScrollTo(bool next, bool end = false, bool speedUp = false, bool animate = false)
-        {
-            if (end)
-            {
-                if (next)
-                    picGallery.Scroller.ScrollToRightEnd();
-                else
-                    picGallery.Scroller.ScrollToLeftEnd();
-            }
-            else
-            {
-                var speed = speedUp ? picGalleryItem_Size * 4.7 : picGalleryItem_Size;
-                var direction = next ? picGallery.Scroller.HorizontalOffset - speed : picGallery.Scroller.HorizontalOffset + speed;
-
-                if (Properties.Settings.Default.PicGallery == 1)
-                {
-                    if (animate)
-                    {
-                        //var anim = new DoubleAnimation
-                        //{
-                        //    From = Scroller.HorizontalOffset,
-                        //    To = direction,
-                        //    Duration = TimeSpan.FromSeconds(.3),
-                        //    AccelerationRatio = 0.2,
-                        //    DecelerationRatio = 0.4
-                        //};
-
-                        //var sb = new Storyboard();
-                        //sb.Children.Add(anim);
-                        //Storyboard.SetTarget(anim, Scroller);
-                        //Storyboard.SetTargetProperty(anim, new PropertyPath(ScrollAnimationBehavior.VerticalOffsetProperty))
-                    }
-                    else
-                    {
-                        picGallery.Scroller.ScrollToHorizontalOffset(direction);
-                    }
-                }
-                else
-                {
-                    if (animate)
-                    {
-                        //DoubleAnimation verticalAnimation = new DoubleAnimation
-                        //{
-                        //    From = scrollViewer.VerticalOffset,
-                        //    To = some
-                        //};
-                        //value;
-                        //verticalAnimation.Duration = new Duration(some duration);
-
-                        //Storyboard storyboard = new Storyboard();
-
-                        //storyboard.Children.Add(verticalAnimation);
-                        //Storyboard.SetTarget(verticalAnimation, scrollViewer);
-                        //Storyboard.SetTargetProperty(verticalAnimation, new PropertyPath(ScrollAnimationBehavior.VerticalOffsetProperty)); // Attached dependency property
-                        //storyboard.Begin();
-                    }
-                    else
-                    {
-                        if (next)
-                            picGallery.Scroller.ScrollToVerticalOffset(picGallery.Scroller.VerticalOffset - speed);
-                        else
-                            picGallery.Scroller.ScrollToVerticalOffset(picGallery.Scroller.VerticalOffset + speed);
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// Scrolls to center of current item
-        /// </summary>
-        /// <param name="item">The index of picGalleryItem</param>
-        internal static void ScrollTo()
-        {
-            if (Properties.Settings.Default.PicGallery == 1)
-                picGallery.Scroller.ScrollToHorizontalOffset((picGalleryItem_Size * Horizontal_items) * Current_page);
-            else
-                picGallery.Scroller.ScrollToVerticalOffset((picGalleryItem_Size * Items_per_page) * Current_page);
-        }
-
-        #endregion Scroll
-
         #region Item Click
 
         internal static void Click(int id)

+ 40 - 32
PicView/PicVIew.csproj

@@ -140,8 +140,9 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
-    <Compile Include="Drag and Drop\DragAndDrop.cs" />
-    <Compile Include="Error Handling\Error_Handling.cs" />
+    <Compile Include="Interface Logic\Drag and Drop\DragAndDrop.cs" />
+    <Compile Include="Interface Logic\SetTitle.cs" />
+    <Compile Include="Navigation\Error_Handling.cs" />
     <Compile Include="File Logic\Copy_Paste.cs" />
     <Compile Include="File Logic\DeleteFiles.cs" />
     <Compile Include="File Logic\FileLists.cs" />
@@ -149,22 +150,28 @@
     <Compile Include="GlobalSuppressions.cs" />
     <Compile Include="File Logic\ArchiveExtraction.cs" />
     <Compile Include="File Logic\FileFunctions.cs" />
-    <Compile Include="Image Logic\Navigation.cs" />
-    <Compile Include="Interface Logic\LoadControls.cs" />
-    <Compile Include="Interface Logic\LoadWindows.cs" />
-    <Compile Include="Interface Logic\MouseOverAnimations.cs" />
-    <Compile Include="Interface Logic\PicGalleryLogic.cs" />
+    <Compile Include="Image Logic\SaveImages.cs" />
+    <Compile Include="Image Logic\Thumbnails.cs" />
+    <Compile Include="Interface Logic\Animations\AjaxLoader.cs" />
+    <Compile Include="Interface Logic\Animations\FadeControls.cs" />
+    <Compile Include="Image Logic\Scroll.cs" />
+    <Compile Include="Interface Logic\Tooltip.cs" />
+    <Compile Include="Navigation\Navigation.cs" />
+    <Compile Include="Interface Logic\Instantiate\LoadControls.cs" />
+    <Compile Include="Interface Logic\Instantiate\LoadWindows.cs" />
+    <Compile Include="Interface Logic\Animations\MouseOverAnimations.cs" />
+    <Compile Include="PicGallery\PicGalleryLogic.cs" />
     <Compile Include="Image Logic\Resize_and_Zoom.cs" />
     <Compile Include="Image Logic\Rotate_and_Flip.cs" />
     <Compile Include="Interface Logic\WindowLogic.cs" />
     <Compile Include="Interface Logic\SlideShow.cs" />
-    <Compile Include="Interface Logic\ContextMenus.cs" />
-    <Compile Include="Interface Logic\Interface.cs" />
+    <Compile Include="Interface Logic\Instantiate\ContextMenus.cs" />
+    <Compile Include="Interface Logic\InterfaceUtilities.cs" />
     <Compile Include="Interface Logic\SvgIcons.cs" />
-    <Compile Include="Interface Logic\Timers.cs" />
+    <Compile Include="Interface Logic\Instantiate\Timers.cs" />
     <Compile Include="Interface Logic\ToggleMenus.cs" />
     <Compile Include="Screen-Logic\MonitorSize.cs" />
-    <Compile Include="Native\NativeMethods.cs" />
+    <Compile Include="Misc\NativeMethods.cs" />
     <Compile Include="File Logic\RecentFiles.cs" />
     <Compile Include="Configs\Configs.cs" />
     <Compile Include="Shortcuts\Shortcuts.cs" />
@@ -186,7 +193,7 @@
     <Compile Include="Windows\AllSettings.xaml.cs">
       <DependentUpon>AllSettings.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Helpers\Fields.cs" />
+    <Compile Include="Misc\Fields.cs" />
     <Compile Include="Windows\FakeWindow.xaml.cs">
       <DependentUpon>FakeWindow.xaml</DependentUpon>
     </Compile>
@@ -196,71 +203,71 @@
     <Compile Include="Windows\About.xaml.cs">
       <DependentUpon>About.xaml</DependentUpon>
     </Compile>
-    <Page Include="Library\Styles\Backgrounds.xaml">
+    <Page Include="Configs\Styles\Backgrounds.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Library\Styles\Colors.xaml">
+    <Page Include="Configs\Styles\Colors.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\Border.xaml">
+    <Page Include="Configs\Styles\Border.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\Button.xaml">
+    <Page Include="Configs\Styles\Button.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\FlatSlider.xaml">
+    <Page Include="Configs\Styles\FlatSlider.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\Label.xaml">
+    <Page Include="Configs\Styles\Label.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\ListBox.xaml">
+    <Page Include="Configs\Styles\ListBox.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\ListView.xaml">
+    <Page Include="Configs\Styles\ListView.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\Menu.xaml">
+    <Page Include="Configs\Styles\Menu.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\ProgressBar.xaml">
+    <Page Include="Configs\Styles\ProgressBar.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\RadioButton.xaml">
+    <Page Include="Configs\Styles\RadioButton.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\ScrollBar.xaml">
+    <Page Include="Configs\Styles\ScrollBar.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\Separator.xaml">
+    <Page Include="Configs\Styles\Separator.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\Slider.xaml">
+    <Page Include="Configs\Styles\Slider.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\TabControl.xaml">
+    <Page Include="Configs\Styles\TabControl.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\ToggleButton.xaml">
+    <Page Include="Configs\Styles\ToggleButton.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Library\Styles\ToolTip.xaml">
+    <Page Include="Configs\Styles\ToolTip.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
@@ -336,9 +343,9 @@
       <DependentUpon>App.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="Helpers\AnimationHelper.cs" />
-    <Compile Include="Helpers\Helper.cs" />
-    <Compile Include="Image Logic\ImageManager.cs" />
+    <Compile Include="Interface Logic\Animations\AnimationHelper.cs" />
+    <Compile Include="Misc\Helper.cs" />
+    <Compile Include="Image Logic\ImageDecoder.cs" />
     <Compile Include="Loading\Preloader.cs" />
     <Compile Include="UserControls\CustomControls\AjaxLoading.xaml.cs">
       <DependentUpon>AjaxLoading.xaml</DependentUpon>
@@ -439,6 +446,7 @@
       <DefaultIcon>lib\img\Brainleaf-Dark-Blog-Reflex.ico</DefaultIcon>
     </FileAssociation>
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
     <PostBuildEvent>

+ 2 - 1
PicView/Shortcuts/Shortcuts.cs

@@ -6,12 +6,13 @@ using static PicView.DeleteFiles;
 using static PicView.Error_Handling;
 using static PicView.Fields;
 using static PicView.Helper;
-using static PicView.Interface;
+using static PicView.HideInterfaceLogic;
 using static PicView.LoadWindows;
 using static PicView.Navigation;
 using static PicView.Open_Save;
 using static PicView.Resize_and_Zoom;
 using static PicView.Rotate_and_Flip;
+using static PicView.Scroll;
 using static PicView.SlideShow;
 using static PicView.ToggleMenus;
 using static PicView.WindowLogic;