Răsfoiți Sursa

Update fullscreen with interface and allow it to run contained gallery

Ruben 5 ani în urmă
părinte
comite
3d9cbe3aa3

+ 8 - 1
PicView/Shortcuts/MainShortcuts.cs

@@ -298,7 +298,14 @@ namespace PicView.Shortcuts
                             }
                             else
                             {
-                                Fullscreen_Restore();
+                                if (GalleryFunctions.IsOpen)
+                                {
+                                    Toggle();
+                                }
+                                else
+                                {
+                                    Fullscreen_Restore();
+                                }
                             }
                             return;
                         }

+ 26 - 24
PicView/UI/Loading/StartLoading.cs

@@ -96,45 +96,47 @@ namespace PicView.UI.Loading
             if (arg == null)
             {
                 Unload();
-                if (Properties.Settings.Default.Maximized)
+            }
+            else
+            {
+                Pic(arg.ToString());
+            }
+
+            AddUIElementsAndUpdateValues();
+
+            if (Properties.Settings.Default.Fullscreen)
+            {
+                if (!ScaleImage.TryFitImage(arg.ToString()))
                 {
-                    Maximize();
+                    SetDefaultSize();
                 }
-                else
+
+                Fullscreen_Restore(true);
+            }
+            else if (Properties.Settings.Default.Maximized)
+            {
+                if (!ScaleImage.TryFitImage(arg.ToString()))
                 {
                     SetDefaultSize();
                 }
+
+                Maximize();
             }
             else
             {
-                if (Properties.Settings.Default.Fullscreen)
+                if (AutoFitWindow)
                 {
-                    Fullscreen_Restore(true);
-                }
-                else if (Properties.Settings.Default.Maximized)
-                {
-                    Maximize();
-                }
-                else
-                {
-                    if (AutoFitWindow)
-                    {
-                        if (!ScaleImage.TryFitImage(arg.ToString()))
-                        {
-                            SetDefaultSize();
-                        }
-                    }
-                    else
+                    if (!ScaleImage.TryFitImage(arg.ToString()))
                     {
                         SetDefaultSize();
                     }
                 }
-
-                Pic(arg.ToString());
+                else
+                {
+                    SetDefaultSize();
+                }
             }
 
-            AddUIElementsAndUpdateValues();
-
 #if DEBUG
             Trace.WriteLine("Start Completed ");
 #endif

+ 11 - 10
PicView/UI/PicGallery/GalleryClick.cs

@@ -1,6 +1,5 @@
 using PicView.ChangeImage;
 using System;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
@@ -15,6 +14,10 @@ using static PicView.UI.UserControls.UC;
 
 namespace PicView.UI.PicGallery
 {
+    /// <summary>
+    /// Logick for what happens when user clicks on
+    /// thumbnail gallery item
+    /// </summary>
     internal static class GalleryClick
     {
         internal static void Click(int id)
@@ -64,7 +67,8 @@ namespace PicView.UI.PicGallery
                     To = to[0],
                     Duration = duration,
                     AccelerationRatio = acceleration,
-                    DecelerationRatio = deceleration
+                    DecelerationRatio = deceleration,
+                    FillBehavior = FillBehavior.Stop
                 };
 
                 var da0 = new DoubleAnimation
@@ -73,7 +77,8 @@ namespace PicView.UI.PicGallery
                     To = to[1],
                     Duration = duration,
                     AccelerationRatio = acceleration,
-                    DecelerationRatio = deceleration
+                    DecelerationRatio = deceleration,
+                    FillBehavior = FillBehavior.Stop
                 };
 
                 da.Completed += delegate
@@ -82,7 +87,6 @@ namespace PicView.UI.PicGallery
                     picGallery.grid.Children.Remove(border);
                     img = null;
                     IsOpen = false;
-                    
                 };
 
                 border.BeginAnimation(FrameworkElement.WidthProperty, da);
@@ -123,13 +127,10 @@ namespace PicView.UI.PicGallery
                 picGallery.Visibility = Visibility.Collapsed; // prevent it from popping up again
 
                 // Restore interface elements if needed
-                if (!Properties.Settings.Default.ShowInterface)
+                if (!Properties.Settings.Default.ShowInterface || Properties.Settings.Default.Fullscreen)
                 {
-                    clickArrowLeft.Visibility =
-                    clickArrowRight.Visibility =
-                    x2.Visibility =
-                    minus.Visibility =
-                    galleryShortcut.Visibility = Visibility.Visible;
+                    HideInterfaceLogic.ShowNavigation(true);
+                    HideInterfaceLogic.ShowShortcuts(true);
                 }
             }
 

+ 6 - 1
PicView/UI/PicGallery/GalleryLoad.cs

@@ -25,7 +25,12 @@ namespace PicView.UI.PicGallery
             // TODO Make this code more clean and explain what's going on?
             if (Properties.Settings.Default.PicGallery == 1)
             {
-                if (Properties.Settings.Default.ShowInterface)
+                if (Properties.Settings.Default.Fullscreen)
+                {
+                    picGallery.Width = SystemParameters.PrimaryScreenWidth;
+                    picGallery.Height = SystemParameters.PrimaryScreenHeight;
+                }
+                else if (Properties.Settings.Default.ShowInterface)
                 {
                     picGallery.Width = TheMainWindow.Width - 15;
                     picGallery.Height = TheMainWindow.ActualHeight - 70;

+ 0 - 8
PicView/UI/PicGallery/GalleryScroll.cs

@@ -62,14 +62,6 @@ namespace PicView.UI.PicGallery
             }
         }
 
-        //static int Total_pages
-        // {
-        //     get
-        //     {
-        //         return (int)Math.Floor((double)Pics.Count / Items_per_page);
-        //     }
-        // }
-
         #endregion int calculations
 
         #region ScrollTo

+ 4 - 6
PicView/UI/PicGallery/GalleryToggle.cs

@@ -160,13 +160,11 @@ namespace PicView.UI.PicGallery
         {
             IsOpen = false;
 
-            if (!Properties.Settings.Default.ShowInterface)
+            // Restore interface elements if needed
+            if (!Properties.Settings.Default.ShowInterface || Properties.Settings.Default.Fullscreen)
             {
-                clickArrowLeft.Visibility =
-                clickArrowRight.Visibility =
-                x2.Visibility =
-                minus.Visibility =
-                galleryShortcut.Visibility = Visibility.Visible;
+                HideInterfaceLogic.ShowNavigation(true);
+                HideInterfaceLogic.ShowShortcuts(true);
             }
 
             var da = new DoubleAnimation

+ 15 - 20
PicView/UI/Sizing/WindowLogic.cs

@@ -1,4 +1,5 @@
 using PicView.SystemIntegration;
+using PicView.UI.PicGallery;
 using PicView.UI.Windows;
 using System;
 using System.Windows;
@@ -74,13 +75,7 @@ namespace PicView.UI.Sizing
                 if (e.ClickCount == 2)
                 {
                     Maximize_Restore();
-                    //EditTitleBar.Refocus();
-                    //e.Handled = true;
                 }
-                //if (e.ClickCount == 2)
-                //{
-                //    mainWindow.Bar.Bar.SelectAll();
-                //}
                 return;
             }
 
@@ -200,26 +195,19 @@ namespace PicView.UI.Sizing
         /// <summary>
         /// Fullscreen/restore window
         /// </summary>
-        internal static void Fullscreen_Restore(bool startup = false)
+        internal static void Fullscreen_Restore(bool forceFullscreen = false)
         {
-            if (startup || !Properties.Settings.Default.Fullscreen)
+            if (forceFullscreen || !Properties.Settings.Default.Fullscreen)
             {
-                if (!AutoFitWindow)
-                {
-                    Properties.Settings.Default.Save();
-                }
-
                 Properties.Settings.Default.Fullscreen = true;
-                // Update new setting and sizing
-                //FitToWindow = false;
 
                 ShowTopandBottom(false);
-                ShowNavigation(false);
-                ShowShortcuts(false);
+                ShowNavigation(true);
+                ShowShortcuts(true);
 
                 TheMainWindow.ResizeMode = ResizeMode.CanMinimize;
                 TheMainWindow.SizeToContent = SizeToContent.Manual;
-                TheMainWindow.Width = TheMainWindow.ParentContainer.Width = SystemParameters.PrimaryScreenWidth;
+                TheMainWindow.Width = SystemParameters.PrimaryScreenWidth;
                 TheMainWindow.Height = SystemParameters.PrimaryScreenHeight;
 
                 TheMainWindow.Top = 0;
@@ -227,7 +215,14 @@ namespace PicView.UI.Sizing
 
                 TheMainWindow.Topmost = true;
 
+                if (GalleryFunctions.IsOpen)
+                {
+                    picGallery.Width = SystemParameters.PrimaryScreenWidth;
+                    picGallery.Height = SystemParameters.PrimaryScreenHeight;
+                }
+
                 ConfigColors.UpdateColor(true);
+                Properties.Settings.Default.Save();
             }
             else
             {
@@ -258,8 +253,8 @@ namespace PicView.UI.Sizing
 
                     TheMainWindow.WindowState = WindowState.Normal;
 
-                    TheMainWindow.Width = TheMainWindow.ParentContainer.Width = double.NaN;
-                    TheMainWindow.Height = TheMainWindow.ParentContainer.Height = double.NaN;
+                    TheMainWindow.Width = double.NaN;
+                    TheMainWindow.Height = double.NaN;
 
                     TheMainWindow.Top -= TheMainWindow.LowerBar.ActualHeight / 2; // It works...
                 }