diff --git a/PicView/Drag and Drop/DragAndDrop.cs b/PicView/Drag and Drop/DragAndDrop.cs index bd26ea23d..651f2a320 100644 --- a/PicView/Drag and Drop/DragAndDrop.cs +++ b/PicView/Drag and Drop/DragAndDrop.cs @@ -4,12 +4,12 @@ using System.Reflection; using System.Threading.Tasks; using System.Windows; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.ImageManager; -using static PicView.Image_Logic.Navigation; -using static PicView.Interface_Logic.Interface; +using static PicView.Variables; +using static PicView.ImageManager; +using static PicView.Navigation; +using static PicView.Interface; -namespace PicView.Drag_and_Drop +namespace PicView { internal static class DragAndDrop { diff --git a/PicView/Error Handling/Error_Handling.cs b/PicView/Error Handling/Error_Handling.cs index 1a35c206d..32fe47c54 100644 --- a/PicView/Error Handling/Error_Handling.cs +++ b/PicView/Error Handling/Error_Handling.cs @@ -1,19 +1,18 @@ -using PicView.Helpers; -using PicView.PreLoading; +using PicView.PreLoading; using System; using System.IO; using System.Windows.Media.Imaging; -using static PicView.File_Logic.DeleteFiles; -using static PicView.File_Logic.FileLists; -using static PicView.Helpers.Helper; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.ImageManager; -using static PicView.Image_Logic.Navigation; -using static PicView.Image_Logic.Resize_and_Zoom; -using static PicView.Image_Logic.Rotate_and_Flip; -using static PicView.Interface_Logic.Interface; - -namespace PicView.Error_Handling +using static PicView.DeleteFiles; +using static PicView.FileLists; +using static PicView.Helper; +using static PicView.Variables; +using static PicView.ImageManager; +using static PicView.Navigation; +using static PicView.Resize_and_Zoom; +using static PicView.Rotate_and_Flip; +using static PicView.Interface; + +namespace PicView { internal static class Error_Handling { @@ -50,7 +49,7 @@ internal static bool PicErrorFix(int x) } else if (x < 0) { - var img = RenderToBitmapSource(PicPath, Path.GetExtension(PicPath)); + var img = RenderToBitmapSource(PicPath); if (img != null) { Pic(PicPath); diff --git a/PicView/File Logic/ArchiveExtraction.cs b/PicView/File Logic/ArchiveExtraction.cs index 99bf37080..f4a442305 100644 --- a/PicView/File Logic/ArchiveExtraction.cs +++ b/PicView/File Logic/ArchiveExtraction.cs @@ -2,12 +2,12 @@ using System.Diagnostics; using System.IO; using System.Threading.Tasks; -using static PicView.Error_Handling.Error_Handling; -using static PicView.File_Logic.DeleteFiles; -using static PicView.Helpers.Variables; -using static PicView.Interface_Logic.Interface; +using static PicView.Error_Handling; +using static PicView.DeleteFiles; +using static PicView.Variables; +using static PicView.Interface; -namespace PicView.File_Logic +namespace PicView { internal static class ArchiveExtraction { diff --git a/PicView/File Logic/Copy_Paste.cs b/PicView/File Logic/Copy_Paste.cs index 6154ae269..2a1c0fda5 100644 --- a/PicView/File Logic/Copy_Paste.cs +++ b/PicView/File Logic/Copy_Paste.cs @@ -7,14 +7,14 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; -using static PicView.Error_Handling.Error_Handling; -using static PicView.File_Logic.FileFunctions; -using static PicView.File_Logic.FileLists; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.Navigation; -using static PicView.Interface_Logic.Interface; - -namespace PicView.File_Logic +using static PicView.Error_Handling; +using static PicView.FileFunctions; +using static PicView.FileLists; +using static PicView.Variables; +using static PicView.Navigation; +using static PicView.Interface; + +namespace PicView { internal static class Copy_Paste { diff --git a/PicView/File Logic/DeleteFiles.cs b/PicView/File Logic/DeleteFiles.cs index 00f62dea1..d17e3171a 100644 --- a/PicView/File Logic/DeleteFiles.cs +++ b/PicView/File Logic/DeleteFiles.cs @@ -1,15 +1,14 @@ using Microsoft.VisualBasic.FileIO; using System; using System.IO; -using System.Text.RegularExpressions; -using static PicView.Error_Handling.Error_Handling; -using static PicView.Helpers.Helper; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.Navigation; -using static PicView.Interface_Logic.Interface; +using static PicView.Error_Handling; +using static PicView.Helper; +using static PicView.Interface; +using static PicView.Navigation; +using static PicView.Variables; -namespace PicView.File_Logic +namespace PicView { internal static class DeleteFiles { diff --git a/PicView/File Logic/FileAssociation.cs b/PicView/File Logic/FileAssociation.cs deleted file mode 100644 index b16bf35c0..000000000 --- a/PicView/File Logic/FileAssociation.cs +++ /dev/null @@ -1,43 +0,0 @@ -//using Microsoft.Win32; -//using System; -//using static PicView.lib.NativeMethods; - -//namespace PicView.lib -//{ -// internal static class FileAssociation -// { -// public static void SetAssociation(string Extension, string KeyName, string OpenWith, string FileDescription) -// { -// RegistryKey BaseKey; -// RegistryKey OpenMethod; -// RegistryKey Shell; -// RegistryKey CurrentUser; - -// BaseKey = Registry.ClassesRoot.CreateSubKey(Extension); -// BaseKey.SetValue("", KeyName); - -// OpenMethod = Registry.ClassesRoot.CreateSubKey(KeyName); -// OpenMethod.SetValue("", FileDescription); -// OpenMethod.CreateSubKey("DefaultIcon").SetValue("", "\"" + OpenWith + "\",0"); -// Shell = OpenMethod.CreateSubKey("Shell"); -// Shell.CreateSubKey("edit").CreateSubKey("command").SetValue("", "\"" + OpenWith + "\"" + " \"%1\""); -// Shell.CreateSubKey("open").CreateSubKey("command").SetValue("", "\"" + OpenWith + "\"" + " \"%1\""); -// BaseKey.Close(); -// OpenMethod.Close(); -// Shell.Close(); - -// CurrentUser = Registry.CurrentUser.CreateSubKey(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ucs"); -// CurrentUser = CurrentUser.OpenSubKey("UserChoice", RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.FullControl); -// CurrentUser.SetValue("Progid", KeyName, RegistryValueKind.String); -// // delete the key instead of trying to change it -// CurrentUser = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.ucs", true); -// CurrentUser.DeleteSubKey("UserChoice", false); -// CurrentUser.Close(); - -// // Tell explorer the file association has been changed -// SHChangeNotify(0x08000000, 0x0000, IntPtr.Zero, IntPtr.Zero); -// } -// } - - -//} diff --git a/PicView/File Logic/FileFunctions.cs b/PicView/File Logic/FileFunctions.cs index ab2d3ad82..8b3d6d21f 100644 --- a/PicView/File Logic/FileFunctions.cs +++ b/PicView/File Logic/FileFunctions.cs @@ -1,23 +1,14 @@ -using PicView.PreLoading; -using System; -using System.Diagnostics; +using System; using System.IO; -using System.Linq; -using System.Reflection; using System.Text.RegularExpressions; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using System.Windows.Media.Imaging; -using static PicView.Error_Handling.Error_Handling; -using static PicView.File_Logic.FileLists; -using static PicView.Helpers.Helper; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.Navigation; -using static PicView.Interface_Logic.Interface; - -namespace PicView.File_Logic +using static PicView.Helper; +using static PicView.Navigation; +using static PicView.Variables; + +namespace PicView { class FileFunctions { diff --git a/PicView/File Logic/FileLists.cs b/PicView/File Logic/FileLists.cs index 75ec7c649..fc3458f58 100644 --- a/PicView/File Logic/FileLists.cs +++ b/PicView/File Logic/FileLists.cs @@ -4,10 +4,11 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -using static PicView.File_Logic.ArchiveExtraction; -using static PicView.Helpers.Variables; +using static PicView.ArchiveExtraction; +using static PicView.Variables; +using static PicView.Error_Handling; -namespace PicView.File_Logic +namespace PicView { internal static class FileLists { @@ -262,29 +263,31 @@ internal static Task GetValues(string path) { // Make a backup of FolderIndex and PicPath if (FolderIndex > -1) - { xFolderIndex = FolderIndex; - } + if (!string.IsNullOrWhiteSpace(PicPath)) - { xPicPath = PicPath; - } - - // Start at first file - FolderIndex = 0; - - // Add zipped files as recent file - RecentFiles.SetZipped(path); // Set extracted files to Pics if (Directory.Exists(TempZipPath)) { + // Start at first file + FolderIndex = 0; + + // Add zipped files as recent file + RecentFiles.SetZipped(path); + var directory = Directory.GetDirectories(TempZipPath); if (directory.Length > 0) TempZipPath = directory[0]; Pics = FileList(TempZipPath); + if (Pics.Count > 0) + PicPath = Pics[0]; + else + Reload(true); } + else Reload(true); } else { @@ -293,9 +296,8 @@ internal static Task GetValues(string path) if (Pics == null) return; FolderIndex = Pics.IndexOf(path); + PicPath = path; } - - PicPath = path; }); } } diff --git a/PicView/File Logic/Open_Save.cs b/PicView/File Logic/Open_Save.cs index 09724084e..717f47faf 100644 --- a/PicView/File Logic/Open_Save.cs +++ b/PicView/File Logic/Open_Save.cs @@ -1,13 +1,13 @@ using System; using System.Diagnostics; using System.IO; -using static PicView.Error_Handling.Error_Handling; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.ImageManager; -using static PicView.Image_Logic.Navigation; -using static PicView.Interface_Logic.Interface; +using static PicView.Error_Handling; +using static PicView.Variables; +using static PicView.ImageManager; +using static PicView.Navigation; +using static PicView.Interface; -namespace PicView.File_Logic +namespace PicView { internal static class Open_Save { diff --git a/PicView/File Logic/RecentFiles.cs b/PicView/File Logic/RecentFiles.cs index b7da95d4e..0f0941107 100644 --- a/PicView/File Logic/RecentFiles.cs +++ b/PicView/File Logic/RecentFiles.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.IO; -namespace PicView.File_Logic +namespace PicView { /// /// Class to handle Most Recently Used files diff --git a/PicView/File Logic/Wallpaper.cs b/PicView/File Logic/Wallpaper.cs index 02bb87b22..0adacffbe 100644 --- a/PicView/File Logic/Wallpaper.cs +++ b/PicView/File Logic/Wallpaper.cs @@ -1,14 +1,13 @@ using Microsoft.Win32; -using PicView.Image_Logic; using PicView.Native; using System; using System.ComponentModel; using System.IO; using System.Threading.Tasks; using System.Timers; -using static PicView.Helpers.Variables; +using static PicView.Variables; -namespace PicView.File_Logic +namespace PicView { public static class Wallpaper // Taken from a Microsoft sample... { diff --git a/PicView/Helpers/AnimationHelper.cs b/PicView/Helpers/AnimationHelper.cs index 4c6cef263..554a8854a 100644 --- a/PicView/Helpers/AnimationHelper.cs +++ b/PicView/Helpers/AnimationHelper.cs @@ -5,7 +5,7 @@ using System.Windows.Media.Animation; using System.Windows.Shapes; -namespace PicView.Helpers +namespace PicView { internal static class AnimationHelper { diff --git a/PicView/Helpers/Helper.cs b/PicView/Helpers/Helper.cs index 30ec7a87c..5d78c6c34 100644 --- a/PicView/Helpers/Helper.cs +++ b/PicView/Helpers/Helper.cs @@ -2,9 +2,9 @@ using System.Diagnostics; using System.IO; using System.Windows; -using static PicView.Helpers.Variables; +using static PicView.Variables; -namespace PicView.Helpers +namespace PicView { internal static class Helper { @@ -92,11 +92,12 @@ internal static void Print(string path) p.Start(); } - internal static void SetWindowBorderColor() + internal static void UpdateColor() { + Application.Current.Resources["ChosenColor"] = AnimationHelper.GetPrefferedColorOver(); + if (Properties.Settings.Default.WindowBorderColorEnabled) { - Application.Current.Resources["ChosenColor"] = AnimationHelper.GetPrefferedColorOver(); var bgBrush = Application.Current.Resources["WindowBackgroundColorBrush"] as System.Windows.Media.SolidColorBrush; bgBrush.Color = AnimationHelper.GetPrefferedColorOver(); } diff --git a/PicView/Helpers/Variables.cs b/PicView/Helpers/Variables.cs index 622ea44d3..ef1f8c8d4 100644 --- a/PicView/Helpers/Variables.cs +++ b/PicView/Helpers/Variables.cs @@ -6,11 +6,11 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using static PicView.Helpers.Helper; -using static PicView.Image_Logic.Resize_and_Zoom; +using static PicView.Helper; +using static PicView.Resize_and_Zoom; using System.Timers; -namespace PicView.Helpers +namespace PicView { internal static class Variables { @@ -54,7 +54,7 @@ internal static class Variables + "|Comics|*.cbr;*.cb7;*.cbt;*.cbz;*.xz" // Comics + "|Camera files|*.orf;*.cr2;*.crw;*.dng;*.raf;*.ppm;*.raw;*.mrw;*.nef;*.pef;*.3xf;*.arw"; // Camera files - internal static MainWindow mainWindow = ((MainWindow) Application.Current.MainWindow); + internal static MainWindow mainWindow = ((MainWindow)Application.Current.MainWindow); /// /// File path of current image @@ -71,23 +71,18 @@ internal static class Variables /// internal static string TempZipPath { get; set; } - /// - /// Returns string with zoom % - /// - internal static string ZoomPercentage { get { return Math.Round(AspectRatio * 100) + "%"; } } - /// /// Returns zoom percentage. if 100%, return empty string /// - internal static string Zoomed + internal static string ZoomPercentage { get { var zoom = Math.Round(AspectRatio * 100); - if (zoom == 100) + if (st.ScaleX == 1) return string.Empty; - return " - " + zoom + "%"; + return zoom + "%"; } } @@ -103,7 +98,7 @@ internal static string StringAspect(int width, int height) var x = (width / gcd); var y = (height / gcd); - if (x == width && y == height) + if (x == width && y == height || x > 99) return ") "; return ", " + x + ":" + y + ") "; @@ -219,7 +214,7 @@ internal static bool FitToWindow internal static ClickArrow clickArrowRight; internal static X2 x2; internal static Minus minus; - internal static PicGallery picGallery; + internal static UserControls.PicGallery picGallery; internal static Point origin; internal static Point start; diff --git a/PicView/Image Logic/ImageManager.cs b/PicView/Image Logic/ImageManager.cs index e9d444aaa..288a0c650 100644 --- a/PicView/Image Logic/ImageManager.cs +++ b/PicView/Image Logic/ImageManager.cs @@ -3,9 +3,9 @@ using System.IO; using System.Windows; using System.Windows.Media.Imaging; -using static PicView.Helpers.Helper; +using static PicView.Helper; -namespace PicView.Image_Logic +namespace PicView { internal static class ImageManager { @@ -15,51 +15,34 @@ internal static class ImageManager /// Full path of the file /// file extension beggining with dot /// - internal static BitmapSource RenderToBitmapSource(string file, string extension) + internal static BitmapSource RenderToBitmapSource(string file) { if (string.IsNullOrWhiteSpace(file) || file.Length < 2) return null; - BitmapSource pic; - using (MagickImage magick = new MagickImage()) { // Set values for maximum quality magick.Quality = 100; magick.ColorSpace = ColorSpace.Transparent; - if (extension.ToLower() == ".svg") + var mrs = new MagickReadSettings() { - var mrs = new MagickReadSettings() - { - Density = new Density(300, 300), - }; + Density = new Density(300, 300), + }; - // Make background transparent - mrs.Format = MagickFormat.Svg; - mrs.BackgroundColor = MagickColors.Transparent; - try - { - magick.Read(file, mrs); - } - catch (MagickException) - { - return null; - } + // Make background transparent + mrs.BackgroundColor = MagickColors.Transparent; + try + { + magick.Read(file, mrs); } - else + catch (MagickException) { - try - { - magick.Read(file); - } - catch (MagickException) - { - return null; - } + return null; } - pic = magick.ToBitmapSource(); + var pic = magick.ToBitmapSource(); pic.Freeze(); return pic; } @@ -307,11 +290,19 @@ internal static bool TrySaveImage(int rotate, bool flipped, string path, string return true; } - internal static Size ImageSize (string file) + internal static Size? ImageSize (string file) { using (MagickImage magick = new MagickImage()) { - magick.Read(file); + try + { + magick.Read(file); + } + catch (MagickException) + { + return null; + } + return new Size(magick.Width, magick.Height); } } diff --git a/PicView/Image Logic/Navigation.cs b/PicView/Image Logic/Navigation.cs index 743276bd8..8319e8868 100644 --- a/PicView/Image Logic/Navigation.cs +++ b/PicView/Image Logic/Navigation.cs @@ -1,5 +1,4 @@ -using PicView.File_Logic; -using PicView.PreLoading; +using PicView.PreLoading; using System; using System.IO; using System.Net; @@ -7,17 +6,18 @@ using System.Windows; using System.Windows.Media.Imaging; using System.Windows.Threading; -using static PicView.Error_Handling.Error_Handling; -using static PicView.File_Logic.ArchiveExtraction; -using static PicView.File_Logic.DeleteFiles; -using static PicView.File_Logic.FileLists; -using static PicView.Helpers.Helper; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.ImageManager; -using static PicView.Image_Logic.Resize_and_Zoom; -using static PicView.Interface_Logic.Interface; - -namespace PicView.Image_Logic +using static PicView.Error_Handling; +using static PicView.ArchiveExtraction; +using static PicView.DeleteFiles; +using static PicView.FileLists; +using static PicView.Helper; +using static PicView.Variables; +using static PicView.ImageManager; +using static PicView.Resize_and_Zoom; +using static PicView.Interface; +using System.Windows.Media; + +namespace PicView { internal static class Navigation { @@ -155,32 +155,50 @@ internal static async void Pic(int x) // Use the Load() function load image from memory if available // if not, it will be null BitmapSource pic = Preloader.Load(Pics[x]); - var Extension = Path.GetExtension(Pics[x]); if (pic == null) { mainWindow.Title = mainWindow.Bar.Text = Loading; mainWindow.Bar.ToolTip = Loading; - if (!Properties.Settings.Default.ShowInterface) - AjaxLoadingStart(); + var size = ImageSize(Pics[x]); + if (size.HasValue) + ZoomFit(size.Value.Width, size.Value.Height); + + ImageSource thumb; + //if (picGallery != null) + //{ + // if (x < picGallery.Container.Children.Count) + // { + // var _ = picGallery.Container.Children[x] as UserControls.PicGalleryItem; + // thumb = _.img.Source; + // } + // else thumb = GetBitmapSourceThumb(Pics[x]); + //} + //else + thumb = GetBitmapSourceThumb(Pics[x]); + + if (thumb != null) + mainWindow.img.Source = thumb; // Dissallow changing image while loading canNavigate = false; if (freshStartup) // Load new value manually - await Task.Run(() => pic = RenderToBitmapSource(Pics[x], Extension)); - else do + await Task.Run(() => pic = RenderToBitmapSource(Pics[x])); + else + { + if (!Properties.Settings.Default.ShowInterface) + AjaxLoadingStart(); + do { - // Try again while loading? - pic = Preloader.Load(Pics[x]); + // Try again while loading? await Task.Delay(25); + pic = Preloader.Load(Pics[x]); } while (Preloader.IsLoading); - - - canNavigate = true; - + } + // If pic is still null, image can't be rendered if (pic == null) { @@ -188,12 +206,11 @@ internal static async void Pic(int x) return; } } + else + ZoomFit(pic.PixelWidth, pic.PixelHeight); // Show the image! :) - mainWindow.img.Source = pic; - - // Fit image to new values - ZoomFit(pic.PixelWidth, pic.PixelHeight); + mainWindow.img.Source = pic; // Scroll to top if scroll enabled if (IsScrollEnabled) @@ -204,12 +221,14 @@ internal static async void Pic(int x) // Flip(); // 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]; PicPath = Pics[x]; FolderIndex = x; + AjaxLoadingEnd(); // Preload images \\ if (PreloadDirection().HasValue) @@ -227,25 +246,23 @@ await Task.Run(() => }); } - AjaxLoadingEnd(); - Progress(x, Pics.Count); - - if (!freshStartup) - RecentFiles.Add(Pics[x]); - if (picGallery != null) { if (freshStartup) { - if (!picGallery.LoadComplete) - return; - - picGallery.Calculate_Paging(); - picGallery.ScrollTo(); + if (picGallery.LoadComplete) + { + picGallery.Calculate_Paging(); + picGallery.ScrollTo(); + } } else picGallery.ScrollTo(reverse); } + + Progress(x, Pics.Count); + if (!freshStartup) + RecentFiles.Add(Pics[x]); freshStartup = false; } @@ -376,6 +393,7 @@ await mainWindow.Dispatcher.BeginInvoke((Action)(() => })); Progress(FolderIndex, Pics.Count); FastPicRunning = true; + } /// diff --git a/PicView/Image Logic/Resize_and_Zoom.cs b/PicView/Image Logic/Resize_and_Zoom.cs index e7aae73ff..e1884123e 100644 --- a/PicView/Image Logic/Resize_and_Zoom.cs +++ b/PicView/Image Logic/Resize_and_Zoom.cs @@ -3,11 +3,11 @@ using System.Windows; using System.Windows.Input; using System.Windows.Media; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.Navigation; -using static PicView.Interface_Logic.Interface; +using static PicView.Variables; +using static PicView.Navigation; +using static PicView.Interface; -namespace PicView.Image_Logic +namespace PicView { internal static class Resize_and_Zoom { @@ -53,12 +53,10 @@ internal static async void AutoScrollTimerEvent(object sender, System.Timers.Ela { // Error checking if (autoScrollPos == null || autoScrollOrigin == null) - { return; - } // Start in dispatcher because timer is threaded - await Application.Current.MainWindow.Dispatcher.BeginInvoke((Action)(() => + await mainWindow.Dispatcher.BeginInvoke((Action)(() => { if (autoScrollOrigin.HasValue) { @@ -69,10 +67,8 @@ await Application.Current.MainWindow.Dispatcher.BeginInvoke((Action)(() => // + Environment.NewLine + "offset = " + offset, false); if (autoScrolling) - { // Tell the scrollviewer to scroll to calculated offset mainWindow.Scroller.ScrollToVerticalOffset(mainWindow.Scroller.VerticalOffset + offset); - } } })); } @@ -248,13 +244,13 @@ internal static void ResetZoom() isZoomed = false; // Reset size - ZoomFit(mainWindow.img.Source.Width, mainWindow.img.Source.Height); + ZoomFit(xWidth, xHeight); // Display non-zoomed values string[] titleString; if (canNavigate) { - titleString = TitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, FolderIndex); + titleString = TitleString((int)xWidth, (int)xHeight, FolderIndex); mainWindow.Title = titleString[0]; mainWindow.Bar.Text = titleString[1]; mainWindow.Bar.ToolTip = titleString[2]; @@ -262,7 +258,7 @@ internal static void ResetZoom() else { // Display values from web - titleString = TitleString((int)mainWindow.img.Source.Width, (int)mainWindow.img.Source.Height, PicPath); + titleString = TitleString((int)xWidth, (int)xHeight, PicPath); mainWindow.Title = titleString[0]; mainWindow.Bar.Text = titleString[1]; mainWindow.Bar.ToolTip = titleString[1]; @@ -307,32 +303,40 @@ internal static void Zoom(int i, bool zoomMode) var position = Mouse.GetPosition(mainWindow.img); // Use our position as starting point for zoom - mainWindow.img.RenderTransformOrigin = new Point(position.X / mainWindow.img.ActualWidth, position.Y / mainWindow.img.ActualHeight); + mainWindow.img.RenderTransformOrigin = new Point(position.X / xWidth, position.Y / xHeight); // Determine zoom speed - var zoomValue = st.ScaleX > 1.3 ? .04 : .01; + var zoomValue = st.ScaleX > 1.3 ? .03 : .01; if (st.ScaleX > 1.5) - zoomValue += .007; + zoomValue += .005; if (st.ScaleX > 1.7) - zoomValue += .009; + zoomValue += .007; if (st.ScaleX >= 1.0 && st.ScaleX + zoomValue >= 1.0 || st.ScaleX - zoomValue >= 1.0) { + zoomValue = i > 0 ? zoomValue : -zoomValue; // Start zoom - st.ScaleY = st.ScaleX = AspectRatio += i > 0 ? zoomValue : -zoomValue; + st.ScaleY = st.ScaleX += zoomValue; + AspectRatio += zoomValue; } if (st.ScaleX < 1.0) { // Don't zoom less than 1.0, does not work so good... - st.ScaleX = st.ScaleY = AspectRatio = 1.0; + st.ScaleX = st.ScaleY = 1.0; } + //zoomValue = i > 0 ? zoomValue : -zoomValue; + //st.ScaleY = st.ScaleX += zoomValue; + } isZoomed = true; // Displays zoompercentage in the center window - ToolTipStyle(ZoomPercentage, true); + if (!string.IsNullOrEmpty(ZoomPercentage)) + ToolTipStyle(ZoomPercentage, true); + else + CloseToolTipStyle(); // Display updated values string[] titleString; diff --git a/PicView/Image Logic/Rotate_and_Flip.cs b/PicView/Image Logic/Rotate_and_Flip.cs index 1b4b11f39..eff61a014 100644 --- a/PicView/Image Logic/Rotate_and_Flip.cs +++ b/PicView/Image Logic/Rotate_and_Flip.cs @@ -1,7 +1,7 @@ using System.Windows.Media; -using static PicView.Helpers.Variables; +using static PicView.Variables; -namespace PicView.Image_Logic +namespace PicView { internal static class Rotate_and_Flip { diff --git a/PicView/Image Logic/SlideShow.cs b/PicView/Image Logic/SlideShow.cs index 790565774..aadc19756 100644 --- a/PicView/Image Logic/SlideShow.cs +++ b/PicView/Image Logic/SlideShow.cs @@ -2,10 +2,10 @@ using System.IO; using System.Windows; using System.Windows.Input; -using static PicView.Helpers.Variables; -using static PicView.Interface_Logic.Interface; +using static PicView.Variables; +using static PicView.Interface; -namespace PicView.Image_Logic +namespace PicView { internal static class SlideShow { diff --git a/PicView/Interface Logic/ContextMenus.cs b/PicView/Interface Logic/ContextMenus.cs index f8ef7768f..cf034cd79 100644 --- a/PicView/Interface Logic/ContextMenus.cs +++ b/PicView/Interface Logic/ContextMenus.cs @@ -3,17 +3,17 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using static PicView.File_Logic.Copy_Paste; -using static PicView.File_Logic.DeleteFiles; -using static PicView.File_Logic.FileFunctions; -using static PicView.File_Logic.FileLists; -using static PicView.File_Logic.Open_Save; -using static PicView.File_Logic.Wallpaper; -using static PicView.Helpers.Helper; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.Navigation; - -namespace PicView.Interface_Logic +using static PicView.Copy_Paste; +using static PicView.DeleteFiles; +using static PicView.FileFunctions; +using static PicView.FileLists; +using static PicView.Open_Save; +using static PicView.Wallpaper; +using static PicView.Helper; +using static PicView.Variables; +using static PicView.Navigation; + +namespace PicView { internal static class ContextMenus { diff --git a/PicView/Interface Logic/Interface.cs b/PicView/Interface Logic/Interface.cs index 36ea5a53b..dc4c163b0 100644 --- a/PicView/Interface Logic/Interface.cs +++ b/PicView/Interface Logic/Interface.cs @@ -1,5 +1,5 @@  -using PicView.Helpers; + using PicView.UserControls; using PicView.Windows; using System; @@ -10,13 +10,13 @@ using System.Windows.Input; using System.Windows.Media.Animation; using System.Windows.Threading; -using static PicView.File_Logic.FileFunctions; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.Navigation; -using static PicView.Image_Logic.Resize_and_Zoom; +using static PicView.FileFunctions; +using static PicView.Variables; +using static PicView.Navigation; +using static PicView.Resize_and_Zoom; -namespace PicView.Interface_Logic +namespace PicView { internal static class Interface { @@ -45,7 +45,7 @@ internal static void AddTimers() fastPicTimer = new System.Timers.Timer() { - Interval = 100, + Interval = 1, Enabled = false }; fastPicTimer.Elapsed += FastPic; @@ -747,7 +747,10 @@ 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)).Append(Zoomed); + .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(); @@ -769,7 +772,10 @@ internal static string[] TitleString(int width, int height, int index) 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)).Append(" ").Append(Zoomed); + 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(); diff --git a/PicView/Interface Logic/PicGallery.cs b/PicView/Interface Logic/PicGallery.cs index 91af1baaa..7bb9fe364 100644 --- a/PicView/Interface Logic/PicGallery.cs +++ b/PicView/Interface Logic/PicGallery.cs @@ -5,13 +5,13 @@ using System.Linq; using System.Windows; using System.Windows.Media.Animation; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.ImageManager; -using static PicView.Image_Logic.Navigation; -using static PicView.Image_Logic.Resize_and_Zoom; -using static PicView.Interface_Logic.Interface; +using static PicView.Variables; +using static PicView.ImageManager; +using static PicView.Navigation; +using static PicView.Resize_and_Zoom; +using static PicView.Interface; -namespace PicView.Interface_Logic +namespace PicView { internal static class PicGallery { @@ -108,7 +108,8 @@ internal static async void PicGallery_PreviewItemClick(object source, MyEventArg { mainWindow.img.Source = e.GetImage(); var size = ImageSize(Pics[e.GetId()]); - ZoomFit(size.Width, size.Height); + if (size.HasValue) + ZoomFit(size.Value.Width, size.Value.Height); await System.Threading.Tasks.Task.Run(() => { diff --git a/PicView/Library/Styles/Colors.xaml b/PicView/Library/Styles/Colors.xaml index 542c90dae..24f9ea4b6 100644 --- a/PicView/Library/Styles/Colors.xaml +++ b/PicView/Library/Styles/Colors.xaml @@ -41,8 +41,16 @@ - - + #FF3A3A3A + #FF1B1B1B + + + + + #A7222222 + #A7171717 + + diff --git a/PicView/Library/Styles/Menu.xaml b/PicView/Library/Styles/Menu.xaml index 9a5e255fd..43760e43d 100644 --- a/PicView/Library/Styles/Menu.xaml +++ b/PicView/Library/Styles/Menu.xaml @@ -107,10 +107,10 @@ - - - - + + + + @@ -128,8 +128,10 @@ - --> - + + + + + diff --git a/PicView/Loading/Preloader.cs b/PicView/Loading/Preloader.cs index c04feb9bd..fd4f1c9fe 100644 --- a/PicView/Loading/Preloader.cs +++ b/PicView/Loading/Preloader.cs @@ -1,13 +1,11 @@ - -using PicView.Image_Logic; -using System; +using System; using System.Collections.Concurrent; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows.Media.Imaging; -using static PicView.File_Logic.FileLists; -using static PicView.Helpers.Variables; +using static PicView.FileLists; +using static PicView.Variables; namespace PicView.PreLoading { @@ -30,7 +28,7 @@ internal static void Add(string file) IsLoading = true; - var pic = ImageManager.RenderToBitmapSource(file, Path.GetExtension(file)); + var pic = ImageManager.RenderToBitmapSource(file); if (pic == null) { IsLoading = false; @@ -48,6 +46,10 @@ internal static void Add(int i) IsLoading = true; + //#if DEBUG + //System.Threading.Thread.Sleep(500); + //#endif + if (File.Exists(Pics[i])) { if (!Contains(Pics[i])) @@ -80,10 +82,8 @@ internal static void Remove(string key) { if (key == null) return; if (!Contains(key)) return; - - var value = Sources[key]; - Sources.TryRemove(key, out value); - value = null; + _ = Sources[key]; + Sources.TryRemove(key, out _); } /// @@ -102,7 +102,7 @@ internal static void Clear() internal static async void Clear(string[] array, bool fast = false) { // Set time to clear the images - var timeInSeconds = 120; + var timeInSeconds = 60; // clear faster if it contains a lot of images or if fast == true if (Sources.Count > 50) @@ -206,21 +206,18 @@ internal static void PreLoad(int index, bool reverse) i = index + 4 >= Pics.Count ? Pics.Count : index + 4; Add(i); - if (!freshStartup) - { - //Clean up behind - var arr = new string[3]; - i = index - 3 < 0 ? (Pics.Count - index) - 3 : index - 3; - if (i > -1 && i < Pics.Count) - arr[0] = Pics[i]; - i = i - 1 < 0 ? (Pics.Count - index) - 1 : i - 1; - if (i > -1 && i < Pics.Count) - arr[1] = Pics[i]; - i = i - 1 < 0 ? (Pics.Count - index) - 1 : i - 1; - if (i > -1 && i < Pics.Count) - arr[2] = Pics[i]; - Clear(arr); - } + //Clean up behind + var arr = new string[3]; + i = index - 3 < 0 ? (Pics.Count - index) - 3 : index - 3; + if (i > -1 && i < Pics.Count) + arr[0] = Pics[i]; + i = i - 1 < 0 ? (Pics.Count - index) - 1 : i - 1; + if (i > -1 && i < Pics.Count) + arr[1] = Pics[i]; + i = i - 1 < 0 ? (Pics.Count - index) - 1 : i - 1; + if (i > -1 && i < Pics.Count) + arr[2] = Pics[i]; + Clear(arr); } else { @@ -242,18 +239,15 @@ internal static void PreLoad(int index, bool reverse) i = index - 4 < 0 ? (index + 4) - Pics.Count : index - 4; Add(i); - if (!freshStartup) - { - //Clean up behind - var arr = new string[3]; - i = index + 3 > Pics.Count - 1 ? Pics.Count - 1 : index + 3; - arr[0] = Pics[i]; - i = index + 4 > Pics.Count - 1 ? Pics.Count - 1 : index + 4; - arr[1] = Pics[i]; - i = index + 5 > Pics.Count - 1 ? Pics.Count - 1 : index + 5; - arr[2] = Pics[i]; - Clear(arr); - } + //Clean up behind + var arr = new string[3]; + i = index + 3 > Pics.Count - 1 ? Pics.Count - 1 : index + 3; + arr[0] = Pics[i]; + i = index + 4 > Pics.Count - 1 ? Pics.Count - 1 : index + 4; + arr[1] = Pics[i]; + i = index + 5 > Pics.Count - 1 ? Pics.Count - 1 : index + 5; + arr[2] = Pics[i]; + Clear(arr); } } @@ -281,21 +275,18 @@ internal static void PreLoad(int index, bool reverse) i = index + 4 >= Pics.Count ? (index + 4) - Pics.Count : index + 4; Add(i); - if (!freshStartup) - { - //Clean up behind - var arr = new string[3]; - i = index - 3 < 0 ? (Pics.Count - index) - 3 : index - 3; - if (i > -1 && i < Pics.Count) - arr[0] = Pics[i]; - i = i - 1 < 0 ? (Pics.Count - index) - 1 : i - 1; - if (i > -1 && i < Pics.Count) - arr[1] = Pics[i]; - i = i - 1 < 0 ? (Pics.Count - index) - 1 : i - 1; - if (i > -1 && i < Pics.Count) - arr[2] = Pics[i]; - Clear(arr); - } + //Clean up behind + var arr = new string[3]; + i = index - 3 < 0 ? (Pics.Count - index) - 3 : index - 3; + if (i > -1 && i < Pics.Count) + arr[0] = Pics[i]; + i = i - 1 < 0 ? (Pics.Count - index) - 1 : i - 1; + if (i > -1 && i < Pics.Count) + arr[1] = Pics[i]; + i = i - 1 < 0 ? (Pics.Count - index) - 1 : i - 1; + if (i > -1 && i < Pics.Count) + arr[2] = Pics[i]; + Clear(arr); } else @@ -318,18 +309,15 @@ internal static void PreLoad(int index, bool reverse) i = index - 4 < 0 ? (index + 4) - Pics.Count : index - 4; Add(i); - if (!freshStartup) - { - //Clean up behind - var arr = new string[3]; - i = index + 3 > Pics.Count - 1 ? Pics.Count - 1 : index + 3; - arr[0] = Pics[i]; - i = index + 4 > Pics.Count - 1 ? Pics.Count - 1 : index + 4; - arr[1] = Pics[i]; - i = index + 5 > Pics.Count - 1 ? Pics.Count - 1 : index + 5; - arr[2] = Pics[i]; - Clear(arr); - } + //Clean up behind + var arr = new string[3]; + i = index + 3 > Pics.Count - 1 ? Pics.Count - 1 : index + 3; + arr[0] = Pics[i]; + i = index + 4 > Pics.Count - 1 ? Pics.Count - 1 : index + 4; + arr[1] = Pics[i]; + i = index + 5 > Pics.Count - 1 ? Pics.Count - 1 : index + 5; + arr[2] = Pics[i]; + Clear(arr); } } diff --git a/PicView/MainWindow.xaml.cs b/PicView/MainWindow.xaml.cs index 29a9810fc..e601d79ae 100644 --- a/PicView/MainWindow.xaml.cs +++ b/PicView/MainWindow.xaml.cs @@ -1,5 +1,4 @@ -using PicView.File_Logic; -using PicView.Native; +using PicView.Native; using PicView.ScreenLogic; using PicView.UserControls; using PicView.Windows; @@ -11,21 +10,21 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; -using static PicView.Drag_and_Drop.DragAndDrop; -using static PicView.Error_Handling.Error_Handling; -using static PicView.File_Logic.Copy_Paste; -using static PicView.File_Logic.DeleteFiles; -using static PicView.File_Logic.Open_Save; -using static PicView.Helpers.Helper; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.Navigation; -using static PicView.Image_Logic.Resize_and_Zoom; -using static PicView.Image_Logic.Rotate_and_Flip; -using static PicView.Image_Logic.SlideShow; -using static PicView.Interface_Logic.ContextMenus; -using static PicView.Interface_Logic.Interface; -using static PicView.Interface_Logic.PicGallery; +using static PicView.ContextMenus; +using static PicView.Copy_Paste; +using static PicView.DeleteFiles; +using static PicView.DragAndDrop; +using static PicView.Error_Handling; +using static PicView.Helper; +using static PicView.Interface; +using static PicView.Navigation; +using static PicView.Open_Save; +using static PicView.PicGallery; +using static PicView.Resize_and_Zoom; +using static PicView.Rotate_and_Flip; using static PicView.Shortcuts.Shortcuts; +using static PicView.SlideShow; +using static PicView.Variables; namespace PicView { @@ -86,7 +85,7 @@ private void MainWindow_ContentRendered(object sender, EventArgs e) Pic(args); } - SetWindowBorderColor(); + UpdateColor(); // Add UserControls :) LoadTooltipStyle(); @@ -128,7 +127,7 @@ private void MainWindow_ContentRendered(object sender, EventArgs e) // Load PicGallery, if needed if (Properties.Settings.Default.PicGallery > 0) { - picGallery = new PicGallery + picGallery = new UserControls.PicGallery { Opacity = 0, Visibility = Visibility.Collapsed diff --git a/PicView/PicVIew.csproj b/PicView/PicVIew.csproj index 61e430043..c9df25d43 100644 --- a/PicView/PicVIew.csproj +++ b/PicView/PicVIew.csproj @@ -135,7 +135,6 @@ - diff --git a/PicView/Properties/AssemblyInfo.cs b/PicView/Properties/AssemblyInfo.cs index 8a3e8855e..53bc33d8f 100644 --- a/PicView/Properties/AssemblyInfo.cs +++ b/PicView/Properties/AssemblyInfo.cs @@ -52,6 +52,6 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.8.4.6")] +[assembly: AssemblyFileVersion("0.9.0.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/PicView/Shortcuts/Shortcuts.cs b/PicView/Shortcuts/Shortcuts.cs index a15aedbf9..64ed09559 100644 --- a/PicView/Shortcuts/Shortcuts.cs +++ b/PicView/Shortcuts/Shortcuts.cs @@ -1,18 +1,18 @@ using PicView.Native; using System.Windows; using System.Windows.Input; -using static PicView.Error_Handling.Error_Handling; -using static PicView.File_Logic.Copy_Paste; -using static PicView.File_Logic.DeleteFiles; -using static PicView.File_Logic.Open_Save; -using static PicView.Helpers.Helper; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.Navigation; -using static PicView.Image_Logic.Resize_and_Zoom; -using static PicView.Image_Logic.Rotate_and_Flip; -using static PicView.Image_Logic.SlideShow; -using static PicView.Interface_Logic.Interface; -using static PicView.Interface_Logic.PicGallery; +using static PicView.Error_Handling; +using static PicView.Copy_Paste; +using static PicView.DeleteFiles; +using static PicView.Open_Save; +using static PicView.Helper; +using static PicView.Variables; +using static PicView.Navigation; +using static PicView.Resize_and_Zoom; +using static PicView.Rotate_and_Flip; +using static PicView.SlideShow; +using static PicView.Interface; +using static PicView.PicGallery; namespace PicView.Shortcuts { diff --git a/PicView/UserControls/CustomControls/ClickArrow.xaml b/PicView/UserControls/CustomControls/ClickArrow.xaml index 9d16e20c1..a01790d0b 100644 --- a/PicView/UserControls/CustomControls/ClickArrow.xaml +++ b/PicView/UserControls/CustomControls/ClickArrow.xaml @@ -9,13 +9,15 @@ x:Name="border" Width="50" Height="60" - BorderBrush="{StaticResource BorderBrush}" BorderThickness="1,1,0,1" CornerRadius="2,0,0,2"> + + + - + - + diff --git a/PicView/UserControls/CustomControls/ClickArrow.xaml.cs b/PicView/UserControls/CustomControls/ClickArrow.xaml.cs index 29d459c19..0e65a8152 100644 --- a/PicView/UserControls/CustomControls/ClickArrow.xaml.cs +++ b/PicView/UserControls/CustomControls/ClickArrow.xaml.cs @@ -1,7 +1,6 @@ -using PicView.Helpers; -using System; +using System; +using System.Windows; using System.Windows.Controls; -using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; @@ -11,64 +10,65 @@ public partial class ClickArrow : UserControl { private static ColorAnimation ccAnim; private static ColorAnimation ccAnim2; + private static Color bb; + private static Color bg; + private static Color bg2; + private static Color fg; + public ClickArrow(bool right) { InitializeComponent(); - ccAnim = new ColorAnimation - { - Duration = TimeSpan.FromSeconds(.32) - }; - ccAnim2 = new ColorAnimation - { - Duration = TimeSpan.FromSeconds(.2) - }; - canvas.MouseEnter += Arrow_MouseEnter; - canvas.MouseLeave += Arrow_MouseLeave; - canvas.PreviewMouseLeftButtonDown += Arrow_MouseLeftButtonDown; - if (!right) { Arrow.LayoutTransform = new ScaleTransform() { ScaleX = -1 }; - border.BorderThickness = new System.Windows.Thickness(0, 1, 1, 1); - border.CornerRadius = new System.Windows.CornerRadius(0, 2, 2, 0); + border.BorderThickness = new Thickness(0, 1, 1, 1); + border.CornerRadius = new CornerRadius(0, 2, 2, 0); + Canvas.SetLeft(Arrow, 12); } - } - - void Arrow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - ccAnim.From = AnimationHelper.GetPrefferedColorOver(); - ccAnim.To = AnimationHelper.GetPrefferedColorDown(); - ArrowFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); - ccAnim2.From = Color.FromArgb(167, 34, 34, 34); - ccAnim2.To = Color.FromArgb(255, 34, 34, 34); - CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); - } + MouseEnter += (sender, e) => + { + if (ccAnim == null) + { + ccAnim = new ColorAnimation + { + Duration = TimeSpan.FromSeconds(.32) + }; + ccAnim2 = new ColorAnimation + { + Duration = TimeSpan.FromSeconds(.2) + }; + bb = (Color)Application.Current.Resources["BorderColor"]; + bg = (Color)Application.Current.Resources["AltInterface"]; + bg2 = (Color)Application.Current.Resources["AltInterfaceW"]; + fg = (Color)Application.Current.Resources["MainColor"]; + } - void Arrow_MouseLeave(object sender, MouseEventArgs e) - { - ccAnim.From = AnimationHelper.GetPrefferedColorOver(); - ccAnim.To = Colors.White; - ArrowFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); + ccAnim.From = + ccAnim.To = AnimationHelper.GetPrefferedColorOver(); + ArrowFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); - ccAnim2.From = Color.FromArgb(200, 34, 34, 34); - ccAnim2.To = Color.FromArgb(167, 34, 34, 34); - CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); - } + ccAnim2.From = bg; + ccAnim2.To = bg2; + CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); + AnimationHelper.MouseEnterColorEvent(bb.A, bb.R, bb.G, bb.B, BorderBrushKey, true); - void Arrow_MouseEnter(object sender, MouseEventArgs e) - { - ccAnim.From = Colors.White; - ccAnim.To = AnimationHelper.GetPrefferedColorOver(); - ArrowFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); + }; + MouseLeave += (sender, e) => + { + ccAnim.From = AnimationHelper.GetPrefferedColorOver(); + ccAnim.To = fg; + ArrowFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); - ccAnim2.From = Color.FromArgb(167, 34, 34, 34); - ccAnim2.To = Color.FromArgb(200, 34, 34, 34); - CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); + ccAnim2.From = bg2; + ccAnim2.To = bg; + CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); + AnimationHelper.MouseLeaveColorEvent(bb.A, bb.R, bb.G, bb.B, BorderBrushKey, true); + }; } } -} +} \ No newline at end of file diff --git a/PicView/UserControls/CustomControls/Minus.xaml b/PicView/UserControls/CustomControls/Minus.xaml index 51dc010d8..eb589e7aa 100644 --- a/PicView/UserControls/CustomControls/Minus.xaml +++ b/PicView/UserControls/CustomControls/Minus.xaml @@ -11,18 +11,20 @@ - + + + + - + diff --git a/PicView/UserControls/CustomControls/Minus.xaml.cs b/PicView/UserControls/CustomControls/Minus.xaml.cs index 9c8c9da3e..2f1f8dce0 100644 --- a/PicView/UserControls/CustomControls/Minus.xaml.cs +++ b/PicView/UserControls/CustomControls/Minus.xaml.cs @@ -1,5 +1,8 @@ -using PicView.Helpers; +using System; +using System.Windows; using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Animation; namespace PicView.UserControls { @@ -8,17 +11,55 @@ namespace PicView.UserControls /// public partial class Minus : UserControl { + private static ColorAnimation ccAnim; + private static ColorAnimation ccAnim2; + private static Color bb; + private static Color bg; + private static Color bg2; + private static Color fg; + public Minus() { InitializeComponent(); MouseEnter += (sender, e) => { - AnimationHelper.MouseEnterColorEvent(255, 245, 245, 245, MinusFill, false); + if (ccAnim == null) + { + ccAnim = new ColorAnimation + { + Duration = TimeSpan.FromSeconds(.32) + }; + ccAnim2 = new ColorAnimation + { + Duration = TimeSpan.FromSeconds(.2) + }; + bb = (Color)Application.Current.Resources["BorderColor"]; + bg = (Color)Application.Current.Resources["AltInterface"]; + bg2 = (Color)Application.Current.Resources["AltInterfaceW"]; + fg = (Color)Application.Current.Resources["MainColor"]; + } + + ccAnim.From = + ccAnim.To = AnimationHelper.GetPrefferedColorOver(); + MinusFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); + + ccAnim2.From = bg; + ccAnim2.To = bg2; + CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); + AnimationHelper.MouseEnterColorEvent(bb.A, bb.R, bb.G, bb.B, BorderBrushKey, true); + }; MouseLeave += (sender, e) => { - AnimationHelper.MouseLeaveColorEvent(255, 245, 245, 245, MinusFill, false); + ccAnim.From = AnimationHelper.GetPrefferedColorOver(); + ccAnim.To = fg; + MinusFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); + + ccAnim2.From = bg2; + ccAnim2.To = bg; + CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); + AnimationHelper.MouseLeaveColorEvent(bb.A, bb.R, bb.G, bb.B, BorderBrushKey, true); }; } } diff --git a/PicView/UserControls/CustomControls/PicGallery.xaml b/PicView/UserControls/CustomControls/PicGallery.xaml index 8cad69853..d1e6fd0e0 100644 --- a/PicView/UserControls/CustomControls/PicGallery.xaml +++ b/PicView/UserControls/CustomControls/PicGallery.xaml @@ -27,7 +27,6 @@ VerticalScrollBarVisibility="Disabled"> diff --git a/PicView/UserControls/CustomControls/PicGallery.xaml.cs b/PicView/UserControls/CustomControls/PicGallery.xaml.cs index 34d757bea..733e27b75 100644 --- a/PicView/UserControls/CustomControls/PicGallery.xaml.cs +++ b/PicView/UserControls/CustomControls/PicGallery.xaml.cs @@ -9,8 +9,8 @@ using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Threading; -using static PicView.Helpers.Variables; -using static PicView.Image_Logic.ImageManager; +using static PicView.Variables; +using static PicView.ImageManager; namespace PicView.UserControls { @@ -174,12 +174,12 @@ await Task.Run(() => pic.Freeze(); Add(pic, i); } - if (i == Pics.Count - 1) { LoadComplete = true; isLoading = false; } + } }); } diff --git a/PicView/UserControls/CustomControls/PicGalleryItem.xaml b/PicView/UserControls/CustomControls/PicGalleryItem.xaml index 2668945c7..0af2ef6e2 100644 --- a/PicView/UserControls/CustomControls/PicGalleryItem.xaml +++ b/PicView/UserControls/CustomControls/PicGalleryItem.xaml @@ -25,8 +25,6 @@ Focusable="False"> diff --git a/PicView/UserControls/CustomControls/PicGalleryItem.xaml.cs b/PicView/UserControls/CustomControls/PicGalleryItem.xaml.cs index cbd340db2..7ccda32b4 100644 --- a/PicView/UserControls/CustomControls/PicGalleryItem.xaml.cs +++ b/PicView/UserControls/CustomControls/PicGalleryItem.xaml.cs @@ -1,5 +1,4 @@ -using PicView.Helpers; -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; diff --git a/PicView/UserControls/CustomControls/SexyToolTip.xaml b/PicView/UserControls/CustomControls/SexyToolTip.xaml index 0b7109b3d..5e888091b 100644 --- a/PicView/UserControls/CustomControls/SexyToolTip.xaml +++ b/PicView/UserControls/CustomControls/SexyToolTip.xaml @@ -1,20 +1,14 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + diff --git a/PicView/UserControls/CustomControls/X2.xaml b/PicView/UserControls/CustomControls/X2.xaml index 421f475ea..6b02ac7de 100644 --- a/PicView/UserControls/CustomControls/X2.xaml +++ b/PicView/UserControls/CustomControls/X2.xaml @@ -11,19 +11,21 @@ - + + + + - + diff --git a/PicView/UserControls/CustomControls/X2.xaml.cs b/PicView/UserControls/CustomControls/X2.xaml.cs index f74bb78ec..8f5382eca 100644 --- a/PicView/UserControls/CustomControls/X2.xaml.cs +++ b/PicView/UserControls/CustomControls/X2.xaml.cs @@ -1,5 +1,8 @@ -using PicView.Helpers; +using System; +using System.Windows; using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Animation; namespace PicView.UserControls { @@ -8,17 +11,55 @@ namespace PicView.UserControls /// public partial class X2 : UserControl { + private static ColorAnimation ccAnim; + private static ColorAnimation ccAnim2; + private static Color bb; + private static Color bg; + private static Color bg2; + private static Color fg; + public X2() { InitializeComponent(); MouseEnter += (sender, e) => { - AnimationHelper.MouseEnterColorEvent(255, 245, 245, 245, CrossFill, false); + if (ccAnim == null) + { + ccAnim = new ColorAnimation + { + Duration = TimeSpan.FromSeconds(.32) + }; + ccAnim2 = new ColorAnimation + { + Duration = TimeSpan.FromSeconds(.2) + }; + bb = (Color)Application.Current.Resources["BorderColor"]; + bg = (Color)Application.Current.Resources["AltInterface"]; + bg2 = (Color)Application.Current.Resources["AltInterfaceW"]; + fg = (Color)Application.Current.Resources["MainColor"]; + } + + ccAnim.From = + ccAnim.To = AnimationHelper.GetPrefferedColorOver(); + CrossFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); + + ccAnim2.From = bg; + ccAnim2.To = bg2; + CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); + AnimationHelper.MouseEnterColorEvent(bb.A, bb.R, bb.G, bb.B, BorderBrushKey, true); + }; MouseLeave += (sender, e) => { - AnimationHelper.MouseLeaveColorEvent(255, 245, 245, 245, CrossFill, false); + ccAnim.From = AnimationHelper.GetPrefferedColorOver(); + ccAnim.To = fg; + CrossFill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim); + + ccAnim2.From = bg2; + ccAnim2.To = bg; + CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2); + AnimationHelper.MouseLeaveColorEvent(bb.A, bb.R, bb.G, bb.B, BorderBrushKey, true); }; } } diff --git a/PicView/UserControls/Menus/FileMenu.xaml.cs b/PicView/UserControls/Menus/FileMenu.xaml.cs index 01d1c0b72..242ae0cab 100644 --- a/PicView/UserControls/Menus/FileMenu.xaml.cs +++ b/PicView/UserControls/Menus/FileMenu.xaml.cs @@ -1,7 +1,6 @@ -using PicView.Helpers; -using System.Windows.Controls; +using System.Windows.Controls; using System.Windows.Input; -using static PicView.Helpers.Variables; +using static PicView.Variables; namespace PicView.UserControls { diff --git a/PicView/UserControls/Menus/FunctionsMenu.xaml.cs b/PicView/UserControls/Menus/FunctionsMenu.xaml.cs index e287e4144..71cf954f5 100644 --- a/PicView/UserControls/Menus/FunctionsMenu.xaml.cs +++ b/PicView/UserControls/Menus/FunctionsMenu.xaml.cs @@ -1,7 +1,6 @@ -using PicView.Helpers; -using System.Windows.Controls; +using System.Windows.Controls; using System.Windows.Input; -using static PicView.Helpers.Variables; +using static PicView.Variables; namespace PicView.UserControls.Menus { diff --git a/PicView/UserControls/Menus/ImageSettings.xaml.cs b/PicView/UserControls/Menus/ImageSettings.xaml.cs index 4770175c3..f126860d2 100644 --- a/PicView/UserControls/Menus/ImageSettings.xaml.cs +++ b/PicView/UserControls/Menus/ImageSettings.xaml.cs @@ -1,7 +1,6 @@ -using PicView.Helpers; -using System.Windows.Input; +using System.Windows.Input; using System.Windows.Media; -using static PicView.Helpers.Variables; +using static PicView.Variables; namespace PicView.UserControls { diff --git a/PicView/UserControls/Menus/QuickSettingsMenu.xaml.cs b/PicView/UserControls/Menus/QuickSettingsMenu.xaml.cs index e993e0d45..c50dada50 100644 --- a/PicView/UserControls/Menus/QuickSettingsMenu.xaml.cs +++ b/PicView/UserControls/Menus/QuickSettingsMenu.xaml.cs @@ -1,9 +1,7 @@ -using PicView.File_Logic; -using PicView.Helpers; -using System.Windows.Controls; +using System.Windows.Controls; using System.Windows.Input; -using static PicView.File_Logic.Wallpaper; -using static PicView.Helpers.Variables; +using static PicView.Variables; +using static PicView.Wallpaper; namespace PicView.UserControls { diff --git a/PicView/Windows/About.xaml.cs b/PicView/Windows/About.xaml.cs index 51656948f..ca8dac951 100644 --- a/PicView/Windows/About.xaml.cs +++ b/PicView/Windows/About.xaml.cs @@ -1,13 +1,11 @@ - -using PicView.Helpers; -using System; +using System; using System.ComponentModel; using System.Diagnostics; using System.Reflection; using System.Windows; using System.Windows.Input; using System.Windows.Navigation; -using static PicView.Helpers.Variables; +using static PicView.Variables; namespace PicView.Windows { diff --git a/PicView/Windows/AllSettings.xaml b/PicView/Windows/AllSettings.xaml index ac50b97ba..f7b59f971 100644 --- a/PicView/Windows/AllSettings.xaml +++ b/PicView/Windows/AllSettings.xaml @@ -413,7 +413,7 @@ Margin="0,5" FontStyle="Italic" TextAlignment="Center"> - Color effects require a restart to take effect + Context menu hover color effects may require a restart to take effect diff --git a/PicView/Windows/AllSettings.xaml.cs b/PicView/Windows/AllSettings.xaml.cs index ab5db00b8..1d08f9728 100644 --- a/PicView/Windows/AllSettings.xaml.cs +++ b/PicView/Windows/AllSettings.xaml.cs @@ -1,12 +1,10 @@ - -using PicView.Helpers; -using System; +using System; using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using static PicView.Helpers.Variables; -using static PicView.Helpers.Helper; +using static PicView.Helper; +using static PicView.Variables; namespace PicView.Windows { @@ -830,7 +828,7 @@ private void SetBgColorEnabled(object sender, RoutedEventArgs e) private void Window_Closing(object sender, CancelEventArgs e) { SetSlidetimer(); - SetWindowBorderColor(); + UpdateColor(); Closing -= Window_Closing; e.Cancel = true; AnimationHelper.FadeWindow(this, 0, TimeSpan.FromSeconds(.5)); diff --git a/PicView/Windows/FakeWindow.xaml.cs b/PicView/Windows/FakeWindow.xaml.cs index 803a8e7ae..af87bafba 100644 --- a/PicView/Windows/FakeWindow.xaml.cs +++ b/PicView/Windows/FakeWindow.xaml.cs @@ -1,7 +1,7 @@ using System; using System.Windows; using System.Windows.Input; -using static PicView.Helpers.Variables; +using static PicView.Variables; namespace PicView.Windows { diff --git a/PicView/Windows/Help.xaml b/PicView/Windows/Help.xaml index f127b42c0..f3bd5d305 100644 --- a/PicView/Windows/Help.xaml +++ b/PicView/Windows/Help.xaml @@ -148,7 +148,7 @@ HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> - +