| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- using PicView.UI.Sizing;
- using PicView.UI.Windows;
- using System;
- using System.Windows;
- using System.Windows.Media.Animation;
- using static PicView.Library.Fields;
- using static PicView.UI.PicGallery.GalleryFunctions;
- using static PicView.UI.PicGallery.GalleryLoad;
- using static PicView.UI.PicGallery.GalleryScroll;
- using static PicView.UI.Sizing.WindowLogic;
- using static PicView.UI.UserControls.UC;
- namespace PicView.UI.PicGallery
- {
- internal static class GalleryToggle
- {
- #region Toggle
- internal static void Toggle(bool change = false)
- {
- if (Pics.Count < 1)
- {
- return;
- }
- var picGallery = Properties.Settings.Default.PicGallery;
- /// Toggle PicGallery, when not changed
- if (!change)
- {
- if (picGallery == 1)
- {
- if (!IsOpen)
- {
- OpenContainedGallery();
- }
- else
- {
- CloseContainedGallery();
- }
- }
- else
- {
- if (!IsOpen)
- {
- OpenFullscreenGallery();
- }
- else
- {
- CloseFullscreenGallery();
- }
- }
- }
- /// Toggle PicGallery, when changed
- else
- {
- if (picGallery == 1)
- {
- ChangeToPicGalleryTwo();
- }
- else
- {
- ChangeToPicGalleryOne();
- }
- }
- }
- #endregion Toggle
- #region Open
- internal static async void OpenContainedGallery()
- {
- if (Pics.Count < 1)
- {
- return;
- }
- Properties.Settings.Default.PicGallery = 1;
- LoadLayout();
- var da = new DoubleAnimation
- {
- Duration = TimeSpan.FromSeconds(.5),
- To = 1,
- From = 0
- };
- picGallery.BeginAnimation(UIElement.OpacityProperty, da);
- clickArrowLeft.Visibility =
- clickArrowRight.Visibility =
- x2.Visibility =
- minus.Visibility =
- galleryShortcut.Visibility = Visibility.Hidden;
- if (fakeWindow != null)
- {
- if (fakeWindow.grid.Children.Contains(picGallery))
- {
- fakeWindow.grid.Children.Remove(picGallery);
- mainWindow.bg.Children.Add(picGallery);
- }
- }
- ScrollTo();
- if (!IsLoading)
- {
- await Load().ConfigureAwait(false);
- }
- }
- internal static async void OpenFullscreenGallery()
- {
- if (Pics.Count < 1)
- {
- return;
- }
- Properties.Settings.Default.PicGallery = 2;
- LoadLayout();
- if (fakeWindow == null)
- {
- fakeWindow = new FakeWindow();
- }
- if (mainWindow.bg.Children.Contains(picGallery))
- {
- mainWindow.bg.Children.Remove(picGallery);
- fakeWindow.grid.Children.Add(picGallery);
- }
- else if (!fakeWindow.grid.Children.Contains(picGallery))
- {
- mainWindow.bg.Children.Remove(picGallery);
- fakeWindow.grid.Children.Add(picGallery);
- }
- fakeWindow.Show();
- ScrollTo();
- mainWindow.Focus();
- if (!FreshStartup)
- {
- ScaleImage.TryFitImage();
- }
- // Fix not showing up opacity bug..
- VisualStateManager.GoToElementState(picGallery, "Opacity", false);
- if (!IsLoading)
- {
- await Load().ConfigureAwait(false);
- }
- }
- #endregion Open
- #region Close
- internal static void CloseContainedGallery()
- {
- IsOpen = false;
- if (!Properties.Settings.Default.ShowInterface)
- {
- clickArrowLeft.Visibility =
- clickArrowRight.Visibility =
- x2.Visibility =
- minus.Visibility =
- galleryShortcut.Visibility = Visibility.Visible;
- }
- var da = new DoubleAnimation
- {
- Duration = TimeSpan.FromSeconds(.5),
- From = 1,
- To = 0,
- FillBehavior = FillBehavior.Stop
- };
- da.Completed += delegate
- {
- picGallery.Visibility = Visibility.Collapsed;
- picGallery.Opacity = 1;
- };
- picGallery.BeginAnimation(UIElement.OpacityProperty, da);
- }
- internal static void CloseFullscreenGallery()
- {
- Properties.Settings.Default.PicGallery = 1;
- IsOpen = false;
- fakeWindow.Hide();
- ConfigColors.UpdateColor();
- HideInterfaceLogic.ShowStandardInterface();
- }
- #endregion Close
- #region Change
- internal static void ChangeToPicGalleryOne()
- {
- Properties.Settings.Default.PicGallery = 1;
- LoadLayout();
- if (fakeWindow.grid.Children.Contains(picGallery))
- {
- fakeWindow.grid.Children.Remove(picGallery);
- mainWindow.bg.Children.Add(picGallery);
- }
- fakeWindow.Hide();
- }
- internal static void ChangeToPicGalleryTwo()
- {
- Properties.Settings.Default.PicGallery = 2;
- LoadLayout();
- if (fakeWindow != null)
- {
- if (!fakeWindow.grid.Children.Contains(picGallery))
- {
- mainWindow.bg.Children.Remove(picGallery);
- fakeWindow.grid.Children.Add(picGallery);
- }
- }
- else
- {
- mainWindow.bg.Children.Remove(picGallery);
- fakeWindow = new FakeWindow();
- fakeWindow.grid.Children.Add(picGallery);
- }
- fakeWindow.Show();
- ScrollTo();
- mainWindow.Focus();
- }
- #endregion Change
- }
- }
|