From 98657b0c7136bcd1c7a4b39ae668a8ab889c9be7 Mon Sep 17 00:00:00 2001 From: Ruben Date: Wed, 28 Aug 2019 23:25:44 +0200 Subject: [PATCH] Misc Updates --- PicView/Configs/Styles/Menu.xaml | 2 +- PicView/File Logic/Copy_Paste.cs | 47 +++++++++++++------ PicView/Image Logic/Resize_and_Zoom.cs | 22 ++++----- PicView/Image Logic/Rotate_and_Flip.cs | 1 - .../Instantiate/ContextMenus.cs | 28 +++++++++-- PicView/Interface Logic/SvgIcons.cs | 4 ++ PicView/MainWindow.xaml.cs | 30 ++++++------ PicView/Navigation/Navigation.cs | 3 ++ PicView/UserControls/Menus/ImageSettings.xaml | 2 +- .../UserControls/Menus/ImageSettings.xaml.cs | 4 +- 10 files changed, 92 insertions(+), 51 deletions(-) diff --git a/PicView/Configs/Styles/Menu.xaml b/PicView/Configs/Styles/Menu.xaml index 43760e43d..e7d4ebe48 100644 --- a/PicView/Configs/Styles/Menu.xaml +++ b/PicView/Configs/Styles/Menu.xaml @@ -202,7 +202,7 @@ - + diff --git a/PicView/File Logic/Copy_Paste.cs b/PicView/File Logic/Copy_Paste.cs index 6fcd32e6b..d571946e7 100644 --- a/PicView/File Logic/Copy_Paste.cs +++ b/PicView/File Logic/Copy_Paste.cs @@ -68,25 +68,41 @@ internal static void Paste() { var files = Clipboard.GetFileDropList().Cast().ToArray(); - if (!string.IsNullOrWhiteSpace(PicPath) && - Path.GetDirectoryName(files[0]) == Path.GetDirectoryName(PicPath)) - Pic(Pics.IndexOf(files[0])); - else - Pic(files[0]); - - if (files.Length > 0) + if (files != null) { - Parallel.For(1, files.Length, x => + if (files.Length >= 1) { - var myProcess = new Process + var x = files[0]; + + // If from same folder + if (!string.IsNullOrWhiteSpace(PicPath) && Path.GetDirectoryName(x) == Path.GetDirectoryName(PicPath)) { - StartInfo = { FileName = Assembly.GetExecutingAssembly().Location, Arguments = files[x] } - }; - myProcess.Start(); - }); + if (!Preloader.Contains(x)) + { + PreloadCount = 4; + Preloader.Add(x); + } + + Pic(Pics.IndexOf(x)); + } + else + Pic(x); + + if (files.Length > 1) + { + for (int i = 1; i < files.Length; i++) + { + using (var n = new Process ()) + { + n.StartInfo.FileName = Assembly.GetExecutingAssembly().Location; + n.StartInfo.Arguments = files[i]; + n.Start(); + } + } + } + } + return; } - - return; } // Clipboard Image @@ -152,6 +168,7 @@ internal static void Cut(string path) Clipboard.Clear(); Clipboard.SetDataObject(data, true); + // Force Preloader to add new images, to minimize slowdown errors PreloadCount = 4; ToolTipStyle("Added Image to move clipboard"); diff --git a/PicView/Image Logic/Resize_and_Zoom.cs b/PicView/Image Logic/Resize_and_Zoom.cs index eb476ae2d..43f7dcbbf 100644 --- a/PicView/Image Logic/Resize_and_Zoom.cs +++ b/PicView/Image Logic/Resize_and_Zoom.cs @@ -282,17 +282,17 @@ internal static void Zoom(int i, bool zoomMode) internal static void ZoomFit(double width, double height) { double maxWidth, maxHeight; - var interfaceHeight = 85; /// TopBar + mainWindow.LowerBar height + extra padding + var interfaceHeight = 90; /// 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 + // - 2 for window border else { maxWidth = Math.Min(MonitorInfo.Width - 2, width - 2); @@ -301,7 +301,7 @@ internal static void ZoomFit(double width, double height) } 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) @@ -314,26 +314,26 @@ internal static void ZoomFit(double width, double height) 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 - mainWindow.img.Height = xHeight = (height * AspectRatio); + // Fit image by aspect ratio calculation + // and update values mainWindow.img.Width = xWidth = (width * AspectRatio); + mainWindow.img.Height = xHeight = (height * AspectRatio); } if (FitToWindow) diff --git a/PicView/Image Logic/Rotate_and_Flip.cs b/PicView/Image Logic/Rotate_and_Flip.cs index 044d1a89b..87a01e304 100644 --- a/PicView/Image Logic/Rotate_and_Flip.cs +++ b/PicView/Image Logic/Rotate_and_Flip.cs @@ -5,7 +5,6 @@ namespace PicView { internal static class Rotate_and_Flip { - // Rotate and flip /// /// Rotates the image the specified degrees and updates imageSettingsMenu value /// diff --git a/PicView/Interface Logic/Instantiate/ContextMenus.cs b/PicView/Interface Logic/Instantiate/ContextMenus.cs index 1c96343a6..30a40d4b9 100644 --- a/PicView/Interface Logic/Instantiate/ContextMenus.cs +++ b/PicView/Interface Logic/Instantiate/ContextMenus.cs @@ -19,8 +19,6 @@ internal static class ContextMenus { internal static void AddContextMenus() { - #region Add ContextMenus - // Add main contextmenu cm = new ContextMenu(); var scbf = (SolidColorBrush)Application.Current.Resources["MainColorFadedBrush"]; @@ -247,6 +245,14 @@ internal static void AddContextMenus() { Header = "Setings" }; + var settingscmIcon = new System.Windows.Shapes.Path + { + Data = Geometry.Parse(SVGiconWrench), + Stretch = Stretch.Fill + }; + settingscmIcon.Width = settingscmIcon.Height = 12; + settingscmIcon.Fill = scbf; + settingscm.Icon = settingscmIcon; cm.Items.Add(settingscm); /////////////////////////// @@ -337,6 +343,14 @@ internal static void AddContextMenus() InputGestureText = "F3", ToolTip = "Opens the current image on your drive" }; + var lcdcmIcon = new System.Windows.Shapes.Path + { + Data = Geometry.Parse(SVGiconSearch), + Stretch = Stretch.Fill + }; + lcdcmIcon.Width = lcdcmIcon.Height = 12; + lcdcmIcon.Fill = scbf; + lcdcm.Icon = lcdcmIcon; lcdcm.Click += (s, x) => Open_In_Explorer(); cm.Items.Add(lcdcm); @@ -351,6 +365,14 @@ internal static void AddContextMenus() Header = "File Details", InputGestureText = "Ctrl + I" }; + var fildecmIcon = new System.Windows.Shapes.Path + { + Data = Geometry.Parse(SVGiconPaperDetails), + Stretch = Stretch.Fill + }; + fildecmIcon.Width = fildecmIcon.Height = 12; + fildecmIcon.Fill = scbf; + fildecm.Icon = fildecmIcon; fildecm.Click += (s, x) => NativeMethods.ShowFileProperties(PicPath); cm.Items.Add(fildecm); cm.Items.Add(new Separator()); @@ -554,8 +576,6 @@ internal static void AddContextMenus() break; } - #endregion Add ContextMenus - cm.Opened += (tt, yy) => Recentcm_MouseEnter(recentcm); } } diff --git a/PicView/Interface Logic/SvgIcons.cs b/PicView/Interface Logic/SvgIcons.cs index 21bf48f33..2de55879f 100644 --- a/PicView/Interface Logic/SvgIcons.cs +++ b/PicView/Interface Logic/SvgIcons.cs @@ -17,6 +17,10 @@ internal static class SvgIcons internal const string SVGiconPrint = "M448 1536h896v-256h-896v256zm0-640h896v-384h-160q-40 0-68-28t-28-68v-160h-640v640zm1152 64q0-26-19-45t-45-19-45 19-19 45 19 45 45 19 45-19 19-45zm128 0v416q0 13-9.5 22.5t-22.5 9.5h-224v160q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-160h-224q-13 0-22.5-9.5t-9.5-22.5v-416q0-79 56.5-135.5t135.5-56.5h64v-544q0-40 28-68t68-28h672q40 0 88 20t76 48l152 152q28 28 48 76t20 88v256h64q79 0 135.5 56.5t56.5 135.5z"; internal const string SVGiconPaper = "M288,48H136c-22.092,0-40,17.908-40,40v336c0,22.092,17.908,40,40,40h240c22.092,0,40-17.908,40-40V176L288,48z M272,192 V80l112, 112H272z"; internal const string SVGiconSort = "M666 481q-60 92-137 273-22-45-37-72.5t-40.5-63.5-51-56.5-63-35-81.5-14.5h-224q-14 0-23-9t-9-23v-192q0-14 9-23t23-9h224q250 0 410 225zm1126 799q0 14-9 23l-320 320q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-192q-32 0-85 .5t-81 1-73-1-71-5-64-10.5-63-18.5-58-28.5-59-40-55-53.5-56-69.5q59-93 136-273 22 45 37 72.5t40.5 63.5 51 56.5 63 35 81.5 14.5h256v-192q0-14 9-23t23-9q12 0 24 10l319 319q9 9 9 23zm0-896q0 14-9 23l-320 320q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-192h-256q-48 0-87 15t-69 45-51 61.5-45 77.5q-32 62-78 171-29 66-49.5 111t-54 105-64 100-74 83-90 68.5-106.5 42-128 16.5h-224q-14 0-23-9t-9-23v-192q0-14 9-23t23-9h224q48 0 87-15t69-45 51-61.5 45-77.5q32-62 78-171 29-66 49.5-111t54-105 64-100 74-83 90-68.5 106.5-42 128-16.5h256v-192q0-14 9-23t23-9q12 0 24 10l319 319q9 9 9 23z"; + internal const string SVGiconWrench = "M474.1 398.2L289.1 212c18.3-47 8.1-102.3-30.5-141.1C217.9 30 156.9 21.8 108.1 44.3l87.4 88-61 61.4-89.5-88c-24.3 49-14.1 110.4 26.5 151.3 38.6 38.9 93.5 49.1 140.3 30.7l185 186.2c8.1 8.2 20.3 8.2 28.5 0l46.8-47c10.2-8.3 10.2-22.6 2-28.7z"; + internal const string SVGiconSearch = "M442,386.7l-84.8-85.9c13.8-24.1,21-50.9,21-77.9c0-87.6-71.2-158.9-158.6-158.9C135.2,64,64,135.3,64,222.9 c0,87.6,71.2,158.9,158.6,158.9c27.9,0,55.5-7.7,80.1-22.4l84.4,85.6c1.9,1.9,4.6,3.1,7.3,3.1c2.7,0,5.4-1.1,7.3-3.1l43.3-43.8 C449,397.1,449,390.7,442,386.7z M222.6,125.9c53.4,0,96.8,43.5,96.8,97c0,53.5-43.4,97-96.8,97c-53.4,0-96.8-43.5-96.8-97 C125.8,169.4,169.2,125.9,222.6,125.9z"; + internal const string SVGiconPaperDetails = "M398.6,169.2c-0.9-2.2-2-4.3-3.5-6.1l-83.8-91.7c-1.9-2.1-4.2-3.6-6.7-4.9c-2.9-1.5-6.1-2.1-9.5-2.1H135.2 c-12.4,0-22.7,10.6-22.7,23.9v335.2c0,13.4,10.3,24.9,22.7,24.9h243.1c12.4,0,22.2-11.5,22.2-24.9V179.4 C400.5,175.8,400,172.3,398.6,169.2z M160.5,178.6c0-1.5,1.8-2.1,3.4-2.1h70.8c1.6,0,2.8,0.6,2.8,2.1v10.8c0,1.4-1.1,3.1-2.8,3.1 h-70.8c-1.6,0-3.4-1.7-3.4-3.1V178.6z M160.5,306.6c0-1.5,1.8-2.1,3.4-2.1h122.2c1.6,0,2.4,0.6,2.4,2.1v10.8c0,1.4-0.7,3.1-2.4,3.1 H163.9c-1.6,0-3.4-1.7-3.4-3.1V306.6z M320.5,381.4c0,1.4-0.7,3.1-2.4,3.1H163.9c-1.6,0-3.4-1.7-3.4-3.1v-10.8 c0-1.5,1.8-2.1,3.4-2.1h154.2c1.6,0,2.4,0.6,2.4,2.1V381.4z M352.5,253.4c0,1.4-0.7,3.1-2.4,3.1H163.9c-1.6,0-3.4-1.7-3.4-3.1 v-10.8c0-1.5,1.8-2.1,3.4-2.1h186.2c1.6,0,2.4,0.6,2.4,2.1V253.4z M305.6,177.5c-5.6,0-11.1-5.2-11.1-11.3v-66l71.2,77.3H305.6"; + } } diff --git a/PicView/MainWindow.xaml.cs b/PicView/MainWindow.xaml.cs index c660969e7..74e00a59f 100644 --- a/PicView/MainWindow.xaml.cs +++ b/PicView/MainWindow.xaml.cs @@ -40,22 +40,6 @@ public MainWindow() InitializeComponent(); Loaded += (s, e) => MainWindow_Loaded(s, e); ContentRendered += MainWindow_ContentRendered; - - // If normal window style - if (!Properties.Settings.Default.FitToWindow) - { - Top = Properties.Settings.Default.Top; - Left = Properties.Settings.Default.Left; - Height = Properties.Settings.Default.Height; - Width = Properties.Settings.Default.Width; - - if (Properties.Settings.Default.Maximized) - { - WindowState = WindowState.Maximized; - } - FitToWindow = false; - } - else FitToWindow = true; } #region Loaded and Rendered @@ -70,6 +54,20 @@ private void MainWindow_Loaded(object sender, RoutedEventArgs e) RightBorderRectangle.Visibility = Visibility.Collapsed; } + // If normal window style + if (!Properties.Settings.Default.FitToWindow) + { + Top = Properties.Settings.Default.Top; + Left = Properties.Settings.Default.Left; + Height = Properties.Settings.Default.Height; + Width = Properties.Settings.Default.Width; + + if (Properties.Settings.Default.Maximized) + WindowState = WindowState.Maximized; + + FitToWindow = false; + } + else FitToWindow = true; } private void MainWindow_ContentRendered(object sender, EventArgs e) diff --git a/PicView/Navigation/Navigation.cs b/PicView/Navigation/Navigation.cs index 92b9fab11..5ba435fd9 100644 --- a/PicView/Navigation/Navigation.cs +++ b/PicView/Navigation/Navigation.cs @@ -94,6 +94,9 @@ internal static async void Pic(string path) if (File.Exists(Pics[FolderIndex])) { + if (!freshStartup) + Preloader.Clear(); + // Navigate to picture using obtained index Pic(FolderIndex); } diff --git a/PicView/UserControls/Menus/ImageSettings.xaml b/PicView/UserControls/Menus/ImageSettings.xaml index fbef638bc..f61a831c6 100644 --- a/PicView/UserControls/Menus/ImageSettings.xaml +++ b/PicView/UserControls/Menus/ImageSettings.xaml @@ -50,7 +50,7 @@ BorderBrush="{x:Null}" FontWeight="Bold" Foreground="{x:Null}" - ToolTip="Flip image"> + ToolTip="Flip image [F]"> diff --git a/PicView/UserControls/Menus/ImageSettings.xaml.cs b/PicView/UserControls/Menus/ImageSettings.xaml.cs index 04669e43a..0429bd7b1 100644 --- a/PicView/UserControls/Menus/ImageSettings.xaml.cs +++ b/PicView/UserControls/Menus/ImageSettings.xaml.cs @@ -51,13 +51,13 @@ public ImageSettings() // Change FlipButton's icon when (un)checked private void FlipButton_Unchecked(object sender, System.Windows.RoutedEventArgs e) { - FlipButton.ToolTip = "Flip image"; + FlipButton.ToolTip = "Flip image [F]"; FlipPath.Data = Geometry.Parse("M192,96v64h248c4.4,0,8,3.6,8,8v240c0,4.4-3.6,8-8,8H136c-4.4,0-8-3.6-8-8v-48c0-4.4,3.6-8,8-8h248V224H192v64L64,192 L192, 96z"); } private void FlipButton_Checked(object sender, System.Windows.RoutedEventArgs e) { - FlipButton.ToolTip = "Unflip image"; + FlipButton.ToolTip = "Unflip image [F]"; FlipPath.Data = Geometry.Parse("M448,192l-128,96v-64H128v128h248c4.4,0,8,3.6,8,8v48c0,4.4-3.6,8-8,8H72c-4.4,0-8-3.6-8-8V168c0-4.4,3.6-8,8-8h248V96 L448, 192z"); }