예제 #1
0
 private void FakeWindow_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
     {
         GalleryNavigation.ScrollTo(e.Delta > 0, true);
     }
     else
     {
         GalleryNavigation.ScrollTo(e.Delta > 0, false, true);
     }
 }
예제 #2
0
        internal static async void OpenFullscreenGallery(bool startup = false)
        {
            if (Pics.Count < 1 && !startup)
            {
                return;
            }

            Properties.Settings.Default.PicGallery = 2;
            LoadLayout();

            if (GetFakeWindow == null)
            {
                GetFakeWindow = new FakeWindow();
                GetFakeWindow.grid.Children.Add(new Views.UserControls.Gallery.PicGalleryTopButtons
                {
                    Margin = new Thickness(1, 12, 0, 0),
                });
            }

            // Switch gallery container to the correct window
            if (GetMainWindow.ParentContainer.Children.Contains(GetPicGallery))
            {
                GetMainWindow.ParentContainer.Children.Remove(GetPicGallery);
                GetFakeWindow.grid.Children.Add(GetPicGallery);
            }
            else if (!GetFakeWindow.grid.Children.Contains(GetPicGallery))
            {
                GetFakeWindow.grid.Children.Add(GetPicGallery);
            }

            GetFakeWindow.Show();
            GalleryNavigation.ScrollTo();
            GetMainWindow.Focus();

            if (!FreshStartup)
            {
                ScaleImage.TryFitImage();
            }

            // Fix not showing up opacity bug..
            VisualStateManager.GoToElementState(GetPicGallery, "Opacity", false);
            VisualStateManager.GoToElementState(GetPicGallery.Container, "Opacity", false);
            GetPicGallery.Opacity = GetPicGallery.Container.Opacity = 1;

            if (GetPicGallery.Container.Children.Count == 0)
            {
                await Load().ConfigureAwait(false);
            }
        }
예제 #3
0
        /// <summary>
        /// Extra functionality and error checking when clicking
        /// on the navigation buttons
        /// </summary>
        /// <param name="arrow"></param>
        /// <param name="right"></param>
        internal static void PicButton(bool arrow, bool right)
        {
            if (!arrow) // Normal buttons
            {
                if (GalleryFunctions.IsOpen)
                {
                    GalleryNavigation.ScrollTo(!right);
                    return;
                }

                if (!CanNavigate)
                {
                    return;
                }

                if (right)
                {
                    RightbuttonClicked = true;
                    Pic();
                }
                else
                {
                    LeftbuttonClicked = true;
                    Pic(false, false);
                }
            }
            else // Alternative interface buttons
            {
                if (!CanNavigate)
                {
                    return;
                }

                if (right)
                {
                    ClickArrowRightClicked = true;
                    Pic();
                }
                else
                {
                    ClickArrowLeftClicked = true;
                    Pic(false, false);
                }
            }
        }
예제 #4
0
        internal static async void OpenHorizontalGallery()
        {
            if (Pics.Count < 1)
            {
                return;
            }

            Properties.Settings.Default.PicGallery = 1;
            LoadLayout();

            AnimationHelper.Fade(GetPicGallery, TimeSpan.FromSeconds(.3), TimeSpan.Zero, 0, 1);

            GetClickArrowLeft.Visibility                      =
                GetClickArrowRight.Visibility                 =
                    Getx2.Visibility                          =
                        GetMinus.Visibility                   =
                            GetRestorebutton.Visibility       =
                                GetGalleryShortcut.Visibility = Visibility.Hidden;

            if (GetFakeWindow != null)
            {
                if (GetFakeWindow.grid.Children.Contains(GetPicGallery))
                {
                    GetFakeWindow.grid.Children.Remove(GetPicGallery);
                    GetMainWindow.ParentContainer.Children.Add(GetPicGallery);
                }
            }

            GalleryNavigation.SetSelected(FolderIndex, true);
            GalleryNavigation.ScrollTo();

            if (GetPicGallery.Container.Children.Count == 0)
            {
                await Load().ConfigureAwait(false);
            }
            // Fix weird bug when changing folder and one item remains
            // TODO investigate if selected gallery item does not get removed?
            else if (GetPicGallery.Container.Children.Count == 1 && Pics.Count > 1)
            {
                GetPicGallery.Container.Children.Clear();
                await Load().ConfigureAwait(false);
            }
        }
예제 #5
0
        internal static void ChangeToPicGalleryTwo()
        {
            Properties.Settings.Default.PicGallery = 2;
            LoadLayout();

            if (GetFakeWindow != null)
            {
                if (!GetFakeWindow.grid.Children.Contains(GetPicGallery))
                {
                    GetMainWindow.ParentContainer.Children.Remove(GetPicGallery);
                    GetFakeWindow.grid.Children.Add(GetPicGallery);
                }
            }
            else
            {
                GetMainWindow.ParentContainer.Children.Remove(GetPicGallery);
                GetFakeWindow = new FakeWindow();
                GetFakeWindow.grid.Children.Add(GetPicGallery);
            }

            GetFakeWindow.Show();
            GalleryNavigation.ScrollTo();
            GetMainWindow.Focus();
        }
예제 #6
0
        internal static void MainWindow_KeysDown(object sender, KeyEventArgs e)
        {
            // Don't allow keys when typing in text
            if (GetMainWindow.TitleText.IsKeyboardFocusWithin)
            {
                return;
            }

            var ctrlDown  = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
            var altDown   = (Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
            var shiftDown = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;

            #region CroppingKeys

            if (GetCropppingTool != null)
            {
                if (GetCropppingTool.IsVisible)
                {
                    if (e.Key == Key.Escape)
                    {
                        CropFunctions.CloseCrop();
                        e.Handled = true;
                        return;
                    }

                    if (e.Key == Key.Enter)
                    {
                        CropFunctions.PerformCrop();
                        e.Handled = true;
                        return;
                    }
                    e.Handled = true;
                    return;
                }
            }

            #endregion CroppingKeys

            #region Keys where it can be held down

            switch (e.Key)
            {
            case Key.BrowserForward:
            case Key.Right:
            case Key.D:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            GalleryNavigation.Right();
                            return;
                        }
                    }
                }
                if (!e.IsRepeat)
                {
                    // Go to first if Ctrl held down
                    if (ctrlDown)
                    {
                        Pic(true, true);
                    }
                    else
                    {
                        Pic();
                    }
                }
                else if (CanNavigate)
                {
                    FastPic(true);
                }
                return;

            case Key.BrowserBack:
            case Key.Left:
            case Key.A:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            GalleryNavigation.Left();
                            return;
                        }
                    }
                }
                if (!e.IsRepeat)
                {
                    // Go to last if Ctrl held down
                    if (ctrlDown)
                    {
                        Pic(false, true);
                    }
                    else
                    {
                        Pic(false);
                    }
                }
                else if (CanNavigate)
                {
                    FastPic(false);
                }
                return;

            case Key.PageUp:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        GalleryNavigation.ScrollTo(true, ctrlDown);
                        return;
                    }
                }
                if (Properties.Settings.Default.ScrollEnabled)
                {
                    GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset - 30);
                }

                return;

            case Key.PageDown:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        GalleryNavigation.ScrollTo(false, (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control);
                        return;
                    }
                }
                if (Properties.Settings.Default.ScrollEnabled)
                {
                    GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset + 30);
                }

                return;

            case Key.Up:
            case Key.W:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            GalleryNavigation.Up();
                        }
                        else
                        {
                            GalleryNavigation.ScrollTo(true, ctrlDown);
                        }
                    }
                    else
                    {
                        Rotate(true);
                    }
                }
                else
                {
                    Rotate(false);
                }
                if (Properties.Settings.Default.ScrollEnabled)
                {
                    GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset - 30);
                }
                return;

            case Key.Down:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            GalleryNavigation.Down();
                        }
                        else
                        {
                            GalleryNavigation.ScrollTo(false, ctrlDown);
                        }
                    }
                    else
                    {
                        Rotate(true);
                    }
                }
                else if (Properties.Settings.Default.ScrollEnabled)
                {
                    GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset + 30);
                }
                else
                {
                    Rotate(true);
                }
                return;

            case Key.S:
                if (ctrlDown)
                {
                    SaveFiles();
                }
                else if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            GalleryNavigation.Down();
                        }
                        else
                        {
                            GalleryNavigation.ScrollTo(false, ctrlDown);
                        }
                    }
                    else
                    {
                        Rotate(false);
                    }
                }
                else if (Properties.Settings.Default.ScrollEnabled)
                {
                    GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset + 30);
                }
                else
                {
                    Rotate(false);
                }
                return;

            // Zoom
            case Key.Add:
            case Key.OemPlus:
                Zoom(true);
                return;

            case Key.Subtract:
            case Key.OemMinus:
                Zoom(false);
                return;

            default: break;
            }

            #endregion Keys where it can be held down

            #region Key is not held down

            if (!e.IsRepeat)
            {
                switch (e.Key)
                {
                // Esc
                case Key.Escape:
                    if (UserControls_Open())
                    {
                        Close_UserControls();
                    }
                    else if (Properties.Settings.Default.Fullscreen)
                    {
                        if (GalleryFunctions.IsOpen)
                        {
                            Toggle();
                        }
                        else
                        {
                            Fullscreen_Restore();
                        }
                    }
                    else if (Slideshow.SlideTimer != null && Slideshow.SlideTimer.Enabled)
                    {
                        Slideshow.StopSlideshow();
                    }
                    else if (GalleryFunctions.IsOpen)
                    {
                        Toggle();
                    }
                    else if (IsDialogOpen)
                    {
                        IsDialogOpen = false;
                    }
                    else if (Color_Picking.IsRunning)
                    {
                        Color_Picking.StopRunning(false);
                    }
                    else if (GetResizeAndOptimize != null && GetResizeAndOptimize.IsVisible)
                    {
                        GetResizeAndOptimize.Hide();
                    }
                    else if (GetEffectsWindow != null && GetEffectsWindow.IsVisible)
                    {
                        GetEffectsWindow.Hide();
                    }
                    else if (GetImageInfoWindow != null && GetImageInfoWindow.IsVisible)
                    {
                        GetImageInfoWindow.Hide();
                    }
                    else if (GetInfoWindow != null && GetInfoWindow.IsVisible)
                    {
                        GetInfoWindow.Hide();
                    }
                    else if (GetSettingsWindow != null && GetSettingsWindow.IsVisible)
                    {
                        GetSettingsWindow.Hide();
                    }
                    else if (!cm.IsVisible)
                    {
                        SystemCommands.CloseWindow(GetMainWindow);
                    }
                    break;

                // Ctrl + Q
                case Key.Q:
                    if (ctrlDown)
                    {
                        SystemCommands.CloseWindow(GetMainWindow);
                    }
                    break;

                // O, Ctrl + O
                case Key.O:
                    Open();
                    break;

                // X, Ctrl + X
                case Key.X:
                    if (ctrlDown)
                    {
                        Cut(Pics[FolderIndex]);
                    }
                    else
                    {
                        ConfigureSettings.UpdateUIValues.SetScrolling(sender, e);
                    }
                    break;

                // F
                case Key.F:
                    Flip();
                    break;

                // Delete, Shift + Delete
                case Key.Delete:
                    DeleteFile(!shiftDown);
                    break;

                // Ctrl + C, Ctrl + Shift + C, Ctrl + Alt + C
                case Key.C:
                    if (ctrlDown)
                    {
                        if (GetResizeAndOptimize != null)
                        {
                            if (GetResizeAndOptimize.IsVisible)
                            {
                                return;     // Prevent paste errors
                            }
                        }

                        if (shiftDown)
                        {
                            Copyfile();
                        }
                        else if (altDown)
                        {
                            System.Threading.Tasks.Task task = Base64.SendToClipboard();
                        }
                        else
                        {
                            CopyBitmap();
                        }
                    }
                    else if (!GalleryFunctions.IsOpen)
                    {
                        CropFunctions.StartCrop();
                    }
                    break;

                // Ctrl + V
                case Key.V:
                    if (ctrlDown)
                    {
                        Paste();
                    }
                    break;

                // Ctrl + I
                case Key.I:
                    if (ctrlDown)
                    {
                        SystemIntegration.NativeMethods.ShowFileProperties(Pics[FolderIndex]);
                    }
                    break;

                // Ctrl + P
                case Key.P:
                    if (ctrlDown)
                    {
                        Print(Pics[FolderIndex]);
                    }
                    break;

                // Ctrl + R
                case Key.R:
                    if (ctrlDown)
                    {
                        Reload();
                    }
                    break;

                // L
                case Key.L:
                    ConfigureSettings.UpdateUIValues.SetLooping(sender, e);
                    break;

#if DEBUG
                // E || Enter
                case Key.E:
                case Key.Enter:
                    if (GalleryFunctions.IsOpen)
                    {
                        GalleryNavigation.LoadSelected();
                    }
                    else if (Properties.Settings.Default.PicGallery == 1 &&
                             !GetQuickSettingsMenu.IsVisible &&
                             !GetToolsAndEffectsMenu.IsVisible &&
                             !GetFileMenu.IsVisible &&
                             !GetImageSettingsMenu.IsVisible)
                    {
                        OpenHorizontalGallery();
                    }
                    break;
#endif

                // T
                case Key.T:
                    ConfigureSettings.ConfigColors.ChangeBackground(sender, e);
                    break;

                // G
                case Key.G:
                    OpenWith(Pics[FolderIndex]);
                    break;

                // Space
                case Key.Space:
                    if (GetPicGallery != null)
                    {
                        if (GalleryFunctions.IsOpen)
                        {
                            GalleryNavigation.ScrollTo();
                            return;
                        }
                    }
                    CenterWindowOnScreen();
                    break;

                // 1
                case Key.D1:
                    if (QuickSettingsMenuOpen || GalleryFunctions.IsOpen ||
                        Properties.Settings.Default.Fullscreen)
                    {
                        break;
                    }

                    Tooltip.ShowTooltipMessage(Application.Current.Resources["CenterImageInWindow"]);
                    ConfigureSettings.UpdateUIValues.SetScalingBehaviour(false, false);
                    break;

                // 2
                case Key.D2:
                    if (QuickSettingsMenuOpen || GalleryFunctions.IsOpen ||
                        Properties.Settings.Default.Fullscreen)
                    {
                        break;
                    }

                    Tooltip.ShowTooltipMessage(Application.Current.Resources["CenterImageInWindowFillHeight"]);
                    ConfigureSettings.UpdateUIValues.SetScalingBehaviour(false, true);
                    break;

                // 3
                case Key.D3:
                    if (QuickSettingsMenuOpen || GalleryFunctions.IsOpen ||
                        Properties.Settings.Default.Fullscreen)
                    {
                        break;
                    }

                    Tooltip.ShowTooltipMessage(Application.Current.Resources["CenterApplicationToWindow"]);
                    ConfigureSettings.UpdateUIValues.SetScalingBehaviour(true, false);
                    break;

                // 4
                case Key.D4:
                    if (QuickSettingsMenuOpen || GalleryFunctions.IsOpen ||
                        Properties.Settings.Default.Fullscreen)
                    {
                        break;
                    }

                    Tooltip.ShowTooltipMessage(Application.Current.Resources["CenterApplicationToWindowFillHeight"]);
                    ConfigureSettings.UpdateUIValues.SetScalingBehaviour(true, true);
                    break;

                // F1
                case Key.F1:
                    InfoWindow();
                    break;

                // F2
                case Key.F2:
                    EditTitleBar.EditTitleBar_Text();
                    break;

                // F3
                case Key.F3:
                    Open_In_Explorer();
                    break;

                // F4
                case Key.F4:
                    AllSettingsWindow();
                    break;

                // F5
                case Key.F5:
                    Slideshow.StartSlideshow();
                    break;

                // F6
                case Key.F6:
                    EffectsWindow();
                    break;

                // F7
                case Key.F7:
                    ResetZoom();
                    break;

#if DEBUG
                // F8
                case Key.F8:
                    Unload();
                    break;
#endif
                // F11
                case Key.F11:
                    Fullscreen_Restore();
                    break;

                // Home
                case Key.Home:
                    GetMainWindow.Scroller.ScrollToHome();
                    break;

                // End
                case Key.End:
                    GetMainWindow.Scroller.ScrollToEnd();
                    break;

                default: break;
                }
            }

            #endregion Key is not held down

            #region Alt + keys

            // Alt doesn't work in switch? Waiting for key up is confusing in this case

            if (altDown && !e.IsRepeat)
            {
                // Alt + Z
                if ((e.SystemKey == Key.Z) && !GalleryFunctions.IsOpen)
                {
                    HideInterfaceLogic.ToggleInterface();
                }

                // Alt + Enter
                else if ((e.SystemKey == Key.Enter))
                {
                    if (Properties.Settings.Default.PicGallery != 2)
                    {
                        Fullscreen_Restore();
                    }
                }
            }

            #endregion Alt + keys
        }
예제 #7
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
            }
        }
예제 #8
0
        /// <summary>
        /// Goes to next, previous, first or last file in folder
        /// </summary>
        /// <param name="next">Whether it's forward or not</param>
        /// <param name="end">Whether to go to last or first,
        /// depending on the next value</param>
        internal static async void Pic(bool next = true, bool end = false)
        {
            // Exit if not intended to change picture
            if (!CanNavigate)
            {
                return;
            }

            // exit if browsing PicGallery
            if (GetPicGallery != null)
            {
                if (Properties.Settings.Default.FullscreenGallery == false)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        return;
                    }
                }
            }

            // Make backup
            var indexBackup = FolderIndex;

            if (!end) // Go to next or previous
            {
                if (next)
                {
                    // loop next
                    if (Properties.Settings.Default.Looping || Slideshow.SlideTimer != null && Slideshow.SlideTimer.Enabled)
                    {
                        FolderIndex = FolderIndex == Pics.Count - 1 ? 0 : FolderIndex + 1;
                    }
                    else
                    {
                        // Go to next if able
                        if (FolderIndex + 1 == Pics.Count)
                        {
                            return;
                        }

                        FolderIndex++;
                    }
                    Reverse = false;
                }
                else
                {
                    // Loop prev
                    if (Properties.Settings.Default.Looping || Slideshow.SlideTimer != null && Slideshow.SlideTimer.Enabled)
                    {
                        FolderIndex = FolderIndex == 0 ? Pics.Count - 1 : FolderIndex - 1;
                    }
                    else
                    {
                        // Go to prev if able
                        if (FolderIndex - 1 < 0)
                        {
                            return;
                        }

                        FolderIndex--;
                    }
                    Reverse = true;
                }
            }
            else // Go to first or last
            {
                FolderIndex = next ? Pics.Count - 1 : 0;
                indexBackup = FolderIndex;

                // Reset preloader values to prevent errors
                if (Pics.Count > 20)
                {
                    Preloader.Clear();
                }
            }

            // Go to the image!
            await LoadPicAt(FolderIndex).ConfigureAwait(true);

            // Update PicGallery selected item, if needed
            if (GalleryFunctions.IsOpen)
            {
                await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() =>
                {
                    if (GetPicGallery.Container.Children.Count > FolderIndex && GetPicGallery.Container.Children.Count > indexBackup)
                    {
                        if (indexBackup != FolderIndex)
                        {
                            GalleryNavigation.SetSelected(indexBackup, false);
                        }

                        GalleryNavigation.SetSelected(FolderIndex, true);
                        GalleryNavigation.ScrollTo();
                    }
                    else
                    {
                        // TODO Find way to get PicGalleryItem an alternative way...
                    }
                }));
            }

            CloseToolTipMessage();
        }
예제 #9
0
        /// <summary>
        /// Goes to next, previous, first or last file in folder
        /// </summary>
        /// <param name="next">Whether it's forward or not</param>
        /// <param name="end">Whether to go to last or first,
        /// depending on the next value</param>
        internal static void Pic(bool next = true, bool end = false)
        {
            // Exit if not intended to change picture
            if (!CanNavigate)
            {
                return;
            }

            // exit if browsing PicGallery
            if (GetPicGallery != null)
            {
                if (Properties.Settings.Default.PicGallery == 1)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        return;
                    }
                }
            }

            // Make backup
            var indexBackup = FolderIndex;

            if (!end) // Go to next or previous
            {
                if (next)
                {
                    // loop next
                    if (Properties.Settings.Default.Looping || Slideshow.SlideTimer != null && Slideshow.SlideTimer.Enabled)
                    {
                        FolderIndex = FolderIndex == Pics.Count - 1 ? 0 : FolderIndex + 1;
                    }
                    else
                    {
                        // Go to next if able
                        if (FolderIndex + 1 == Pics.Count)
                        {
                            return;
                        }

                        FolderIndex++;
                    }
                    Reverse = false;
                }
                else
                {
                    // Loop prev
                    if (Properties.Settings.Default.Looping || Slideshow.SlideTimer != null && Slideshow.SlideTimer.Enabled)
                    {
                        FolderIndex = FolderIndex == 0 ? Pics.Count - 1 : FolderIndex - 1;
                    }
                    else
                    {
                        // Go to prev if able
                        if (FolderIndex - 1 < 0)
                        {
                            return;
                        }

                        FolderIndex--;
                    }
                    Reverse = true;
                }
            }
            else // Go to first or last
            {
                FolderIndex = next ? Pics.Count - 1 : 0;
                indexBackup = FolderIndex;

                // Reset preloader values to prevent errors
                if (Pics.Count > 20)
                {
                    Preloader.Clear();
                }
            }

            // Go to the image!
            Pic(FolderIndex);

            // Update PicGallery selected item, if needed
            if (GalleryFunctions.IsOpen)
            {
                if (GetPicGallery.Container.Children.Count > FolderIndex && GetPicGallery.Container.Children.Count > indexBackup)
                {
                    if (indexBackup != FolderIndex)
                    {
                        GalleryNavigation.SetUnselected(indexBackup);
                    }

                    GalleryNavigation.SetSelected(FolderIndex);
                    GalleryNavigation.ScrollTo();
                }
                else
                {
                    // TODO Find way to get PicGalleryItem an alternative way...
                }
            }

            CloseToolTipMessage();
        }