Ejemplo n.º 1
0
        /// <summary>
        /// Handle logic if user wants to load from a folder
        /// </summary>
        /// <param name="folder"></param>
        internal static async Task PicFolder(string folder)
        {
            // TODO add new function that can go to next/prev folder

            ChangeFolder(true);

            // If searching subdirectories, it might freeze UI, so wrap it in task
            await Task.Run(() =>
            {
                Pics = FileList(folder);
            }).ConfigureAwait(true);

            if (Pics.Count > 0)
            {
                await LoadPicAt(0).ConfigureAwait(true);
            }
            else
            {
                Reload(true);
            }

            GetQuickSettingsMenu.GoToPic.GoToPicBox.Text = (FolderIndex + 1).ToString(CultureInfo.CurrentCulture);

            // Load new gallery values, if changing folder
            if (GetPicGallery != null && Properties.Settings.Default.FullscreenGallery)
            {
                if (GetPicGallery.Container.Children.Count == 0)
                {
                    await GalleryLoad.Load().ConfigureAwait(false);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handle logic if user wants to load from a folder
        /// </summary>
        /// <param name="folder"></param>
        internal static async void PicFolder(string folder)
        {
            ChangeFolder(true);

            // If searching subdirectories, it might freeze UI, so wrap it in task
            await System.Threading.Tasks.Task.Run(() =>
            {
                Pics = FileList(folder);
            }).ConfigureAwait(true);

            if (Pics.Count > 0)
            {
                Pic(0);
            }
            else
            {
                Reload(true);
            }

            GetQuickSettingsMenu.GoToPic.GoToPicBox.Text = (FolderIndex + 1).ToString(CultureInfo.CurrentCulture);

            // Load new gallery values, if changing folder
            if (GetPicGallery != null && Properties.Settings.Default.PicGallery == 2)
            {
                if (GetPicGallery.Container.Children.Count == 0)
                {
                    await GalleryLoad.Load().ConfigureAwait(false);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fullscreen/restore window
        /// </summary>
        internal static void Fullscreen_Restore(bool forceFullscreen = false)
        {
            if (forceFullscreen || !Properties.Settings.Default.Fullscreen)
            {
                // Show fullscreen logic

                // Save size to get back to it when restoring
                if (!Properties.Settings.Default.AutoFitWindow)
                {
                    Properties.Settings.Default.Top    = LoadWindows.GetMainWindow.Top;
                    Properties.Settings.Default.Left   = LoadWindows.GetMainWindow.Left;
                    Properties.Settings.Default.Height = LoadWindows.GetMainWindow.Height;
                    Properties.Settings.Default.Width  = LoadWindows.GetMainWindow.Width;
                }

                Properties.Settings.Default.Fullscreen = true;

                ShowTopandBottom(false);

                LoadWindows.GetMainWindow.Topmost = true;

                LoadWindows.GetMainWindow.ResizeMode    = ResizeMode.CanMinimize;
                LoadWindows.GetMainWindow.SizeToContent = SizeToContent.Manual;
                LoadWindows.GetMainWindow.Width         = MonitorInfo.Width;
                LoadWindows.GetMainWindow.Height        = MonitorInfo.Height;

                LoadWindows.GetMainWindow.Top  = MonitorInfo.WorkArea.Top;
                LoadWindows.GetMainWindow.Left = MonitorInfo.WorkArea.Left;

                // Handle if browsing gallery
                if (GalleryFunctions.IsOpen)
                {
                    GalleryLoad.LoadLayout();
                    GalleryScroll.ScrollTo();
                }
                else
                {
                    ShowNavigation(true);
                    ShowShortcuts(true);

                    if (GetGalleryShortcut != null)
                    {
                        GetGalleryShortcut.Opacity               =
                            GetClickArrowLeft.Opacity            =
                                GetClickArrowRight.Opacity       =
                                    Getx2.Opacity                =
                                        GetRestorebutton.Opacity =
                                            GetMinus.Opacity     = 1;
                    }
                }

                ConfigureSettings.ConfigColors.UpdateColor(true);
                Properties.Settings.Default.Save();
            }
            else
            {
                LoadWindows.GetMainWindow.Topmost = false;

                if (Properties.Settings.Default.ShowInterface)
                {
                    ShowNavigation(false);
                    ShowTopandBottom(true);
                    ShowShortcuts(false);
                }
                else
                {
                    ShowNavigation(true);
                    ShowTopandBottom(false);
                    ShowShortcuts(true);
                }

                if (AutoFitWindow)
                {
                    LoadWindows.GetMainWindow.SizeToContent = SizeToContent.WidthAndHeight;
                    LoadWindows.GetMainWindow.ResizeMode    = ResizeMode.NoResize;

                    if (GetQuickSettingsMenu != null)
                    {
                        GetQuickSettingsMenu.SetFit.IsChecked = true;
                    }

                    LoadWindows.GetMainWindow.WindowState = WindowState.Normal;

                    LoadWindows.GetMainWindow.Width  = double.NaN;
                    LoadWindows.GetMainWindow.Height = double.NaN;

                    LoadWindows.GetMainWindow.Top -= LoadWindows.GetMainWindow.LowerBar.ActualHeight / 2; // It works...
                }
                else
                {
                    LoadWindows.GetMainWindow.SizeToContent = SizeToContent.Manual;
                    LoadWindows.GetMainWindow.ResizeMode    = ResizeMode.CanResizeWithGrip;

                    if (GetQuickSettingsMenu != null)
                    {
                        GetQuickSettingsMenu.SetFit.IsChecked = false;
                    }

                    LoadWindows.GetMainWindow.Top    = Properties.Settings.Default.Top;
                    LoadWindows.GetMainWindow.Left   = Properties.Settings.Default.Left;
                    LoadWindows.GetMainWindow.Height = Properties.Settings.Default.Height;
                    LoadWindows.GetMainWindow.Width  = Properties.Settings.Default.Width;

                    LoadWindows.GetMainWindow.ParentContainer.Width  = double.NaN;
                    LoadWindows.GetMainWindow.ParentContainer.Height = double.NaN;
                }

                TryFitImage();
                ConfigureSettings.ConfigColors.UpdateColor(); // Regain border

                Properties.Settings.Default.Fullscreen = false;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Fullscreen/restore window
        /// </summary>
        internal static void Fullscreen_Restore(bool forceFullscreen = false)
        {
            if (forceFullscreen || !Properties.Settings.Default.Fullscreen)
            {
                // Show fullscreen logic
                RenderFullscreen();

                // Handle if browsing gallery
                if (GalleryFunctions.IsOpen)
                {
                    GalleryLoad.LoadLayout();
                    GalleryNavigation.ScrollTo();
                }

                ShowNavigation(Properties.Settings.Default.ShowAltInterfaceButtons);
                ShowShortcuts(Properties.Settings.Default.ShowAltInterfaceButtons);

                Properties.Settings.Default.Fullscreen = true;
            }
            else
            {
                GetMainWindow.Topmost = Properties.Settings.Default.TopMost;

                if (Properties.Settings.Default.ShowInterface)
                {
                    ShowNavigation(false);
                    ShowTopandBottom(true);
                    ShowShortcuts(false);
                }
                else
                {
                    ShowNavigation(true);
                    ShowTopandBottom(false);
                    ShowShortcuts(true);
                }

                if (AutoFitWindow)
                {
                    GetMainWindow.SizeToContent = SizeToContent.WidthAndHeight;
                    GetMainWindow.ResizeMode    = ResizeMode.NoResize;

                    if (GetQuickSettingsMenu != null)
                    {
                        GetQuickSettingsMenu.SetFit.IsChecked = true;
                    }

                    GetMainWindow.Width  = double.NaN;
                    GetMainWindow.Height = double.NaN;

                    GetMainWindow.Top -= GetMainWindow.LowerBar.ActualHeight / 2; // It works...
                }
                else
                {
                    GetMainWindow.SizeToContent = SizeToContent.Manual;
                    GetMainWindow.ResizeMode    = ResizeMode.CanResizeWithGrip;

                    if (GetQuickSettingsMenu != null)
                    {
                        GetQuickSettingsMenu.SetFit.IsChecked = false;
                    }

                    GetMainWindow.Top    = Properties.Settings.Default.Top;
                    GetMainWindow.Left   = Properties.Settings.Default.Left;
                    GetMainWindow.Height = Properties.Settings.Default.Height;
                    GetMainWindow.Width  = Properties.Settings.Default.Width;

                    GetMainWindow.ParentContainer.Width  = double.NaN;
                    GetMainWindow.ParentContainer.Height = double.NaN;
                }

                if (GetMainWindow.WindowState == WindowState.Maximized)
                {
                    GetMainWindow.WindowState = WindowState.Normal;
                    // Reset margin from fullscreen
                    GetMainWindow.ParentContainer.Margin = new Thickness(0);
                }

                if (Slideshow.SlideTimer != null && Slideshow.SlideTimer.Enabled)
                {
                    Slideshow.SlideTimer.Enabled = false;
                }

                Properties.Settings.Default.Fullscreen = false;
                TryFitImage();
                ConfigureSettings.ConfigColors.UpdateColor(); // Regain border
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads a picture from a given file path and does extra error checking
        /// </summary>
        /// <param name="path"></param>
        internal static async void Pic(string path)
        {
            // Set Loading
            SetLoadingString();

            // Handle if from web
            if (!File.Exists(path))
            {
                if (Uri.IsWellFormedUriString(path, UriKind.Absolute))
                {
                    LoadFromWeb.PicWeb(path);
                    return;
                }
                else if (Directory.Exists(path))
                {
                    ChangeFolder(true);
                    await GetValues(path).ConfigureAwait(true);
                }
                else
                {
                    Unload();
                    return;
                }
            }

            // If count not correct or just started, get values
            if (Pics.Count <= FolderIndex || FolderIndex < 0 || FreshStartup)
            {
                await GetValues(path).ConfigureAwait(true);
            }
            // If the file is in the same folder, navigate to it. If not, start manual loading procedure.
            else if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]) && Path.GetDirectoryName(path) != Path.GetDirectoryName(Pics[FolderIndex]))
            {
                // Reset old values and get new
                ChangeFolder(true);
                await GetValues(path).ConfigureAwait(true);
            }

            FolderIndex = Pics.IndexOf(path);

            // Fix large archive extraction error
            if (FolderIndex == -1)
            {
                var recovery = await RecoverFailedArchiveAsync().ConfigureAwait(true);

                if (!recovery)
                {
                    Reload(true);
                    return;
                }
                else
                {
                    LoadWindows.GetMainWindow.TitleText.Text    = Application.Current.Resources["Unzipping"] as string;
                    LoadWindows.GetMainWindow.TitleText.ToolTip = LoadWindows.GetMainWindow.TitleText.Text;
                    FolderIndex = 0;
                }
                LoadWindows.GetMainWindow.Focus();
            }

            if (!FreshStartup)
            {
                Preloader.Clear();
            }

#if DEBUG
            if (FreshStartup)
            {
                Trace.WriteLine("Pic(string path) entering Pic(int x)");
            }
#endif

            // Navigate to picture using obtained index
            Pic(FolderIndex);

            // Load new gallery values, if changing folder
            if (GetPicGallery != null && Properties.Settings.Default.PicGallery == 2 && !GalleryFunctions.IsLoading)
            {
                await GalleryLoad.Load().ConfigureAwait(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads a picture from a given file path and does extra error checking
        /// </summary>
        /// <param name="path"></param>
        internal static async Task LoadPiFrom(string path)
        {
            // Set Loading
            SetLoadingString();

            // Handle if from web
            if (!File.Exists(path))
            {
                if (Uri.IsWellFormedUriString(path, UriKind.Absolute))
                {
                    LoadFromWeb.PicWeb(path);
                    return;
                }
                else if (Directory.Exists(path))
                {
                    ChangeFolder(true);
                    await GetValues(path).ConfigureAwait(true);
                }
                else
                {
                    Unload();
                    return;
                }
            }

            // If count not correct or just started, get values
            if (Pics.Count <= FolderIndex || FolderIndex < 0 || FreshStartup)
            {
                await GetValues(path).ConfigureAwait(true);
            }
            // If the file is in the same folder, navigate to it. If not, start manual loading procedure.
            else if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]) && Path.GetDirectoryName(path) != Path.GetDirectoryName(Pics[FolderIndex]))
            {
                // Reset old values and get new
                ChangeFolder(true);
                await GetValues(path).ConfigureAwait(true);
            }

            FolderIndex = Pics.IndexOf(path);

            if (!FreshStartup)
            {
                Preloader.Clear();
            }

            if (FolderIndex != -1) // if it is -1, it means it being extracted and need to wait for it instead
            {
                // Navigate to picture using obtained index
                await LoadPicAt(FolderIndex).ConfigureAwait(false);
            }

            await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (Action)(async() =>
            {
                // Load new gallery values, if changing folder
                if (GetPicGallery != null && Properties.Settings.Default.FullscreenGallery)
                {
                    if (GetPicGallery.Container.Children.Count == 0)
                    {
                        await GalleryLoad.Load().ConfigureAwait(false);
                    }
                }
            }));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Loads a picture from a given file path and does extra error checking
        /// </summary>
        /// <param name="path"></param>
        internal static async void Pic(string path)
        {
            // Set Loading
            SetLoadingString();

            // Handle if from web
            if (!File.Exists(path))
            {
                if (Uri.IsWellFormedUriString(path, UriKind.Absolute))
                {
                    LoadFromWeb.PicWeb(path);
                    return;
                }
                else if (Directory.Exists(path))
                {
                    ChangeFolder(true);
                    await GetValues(path).ConfigureAwait(true);
                }
                else
                {
                    Unload();
                    return;
                }
            }

            // If count not correct or just started, get values
            if (Pics.Count <= FolderIndex || FolderIndex < 0 || FreshStartup)
            {
                await GetValues(path).ConfigureAwait(true);
            }
            // If the file is in the same folder, navigate to it. If not, start manual loading procedure.
            else if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]) && Path.GetDirectoryName(path) != Path.GetDirectoryName(Pics[FolderIndex]))
            {
                // Reset old values and get new
                ChangeFolder(true);
                await GetValues(path).ConfigureAwait(true);
            }

            FolderIndex = Pics.IndexOf(path);

            if (!FreshStartup)
            {
                Preloader.Clear();
            }

#if DEBUG
            if (FreshStartup)
            {
                Trace.WriteLine("Pic(string path) entering Pic(int x)");
            }
#endif

            // Navigate to picture using obtained index
            Pic(FolderIndex == -1 ? 0 : FolderIndex);

            // Load new gallery values, if changing folder
            if (GetPicGallery != null && Properties.Settings.Default.PicGallery == 2)
            {
                if (GetPicGallery.Container.Children.Count == 0)
                {
                    await GalleryLoad.Load().ConfigureAwait(false);
                }
            }
        }