Ejemplo n.º 1
0
        internal static void CloseHorizontalGallery()
        {
            IsOpen = false;

            // Restore interface elements if needed
            if (!Properties.Settings.Default.ShowInterface || Properties.Settings.Default.Fullscreen)
            {
                HideInterfaceLogic.ShowNavigation(true);
                HideInterfaceLogic.ShowShortcuts(true);
            }

            var da = new DoubleAnimation
            {
                Duration     = TimeSpan.FromSeconds(.5),
                From         = 1,
                To           = 0,
                FillBehavior = FillBehavior.Stop
            };

            da.Completed += delegate
            {
                GetPicGallery.Visibility = Visibility.Collapsed;
            };

            GetPicGallery.BeginAnimation(UIElement.OpacityProperty, da);
        }
Ejemplo n.º 2
0
        internal static async void ItemClick(int id)
        {
            // Deselect current item
            GalleryNavigation.SetSelected(FolderIndex, false);

            // Change image
            await LoadPicAt(id).ConfigureAwait(false);

            await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() =>
            {
                if (Properties.Settings.Default.FullscreenGallery == false)
                {
                    GetPicGallery.Visibility = Visibility.Collapsed; // prevent it from popping up again

                    // Restore interface elements if needed
                    if (!Properties.Settings.Default.ShowInterface || Properties.Settings.Default.Fullscreen)
                    {
                        HideInterfaceLogic.ShowNavigation(true);
                        HideInterfaceLogic.ShowShortcuts(true);
                    }
                }

                // Select next item
                GalleryNavigation.SetSelected(id, true);
            }));
        }
Ejemplo n.º 3
0
        internal static void CloseFullscreenGallery()
        {
            Properties.Settings.Default.PicGallery = 1;
            IsOpen = false;
            GetFakeWindow.Hide();

            ConfigureSettings.ConfigColors.UpdateColor();

            HideInterfaceLogic.ShowStandardInterface();

            // Restore settings
            AutoFitWindow = Properties.Settings.Default.AutoFitWindow;
        }
Ejemplo n.º 4
0
        internal static void ItemClick(int id)
        {
            // Deselect current item
            SetUnselected(FolderIndex);

            // Change image
            Pic(id);

            if (Properties.Settings.Default.PicGallery == 1)
            {
                GetPicGallery.Visibility = Visibility.Collapsed; // prevent it from popping up again

                // Restore interface elements if needed
                if (!Properties.Settings.Default.ShowInterface || Properties.Settings.Default.Fullscreen)
                {
                    HideInterfaceLogic.ShowNavigation(true);
                    HideInterfaceLogic.ShowShortcuts(true);
                }
            }

            // Select next item
            SetSelected(id);
        }
Ejemplo n.º 5
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
        }
Ejemplo n.º 6
0
        internal static void AddContextMenus()
        {
            // Add main contextmenu
            cm = new ContextMenu();
            var scbf = (SolidColorBrush)Application.Current.Resources["MainColorFadedBrush"];

            ///////////////////////////
            ///////////////////////////
            ///     Open           \\\\
            ///////////////////////////
            ///////////////////////////
            var opencm = new MenuItem
            {
                Header           = Application.Current.Resources["Open"] as string,
                InputGestureText = $"{Application.Current.Resources["Ctrl"] as string} + O"
            };
            var opencmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconFile),
                Stretch = Stretch.Fill
            };

            opencmIcon.Width = opencmIcon.Height = 12;
            opencmIcon.Fill  = scbf;
            opencm.Icon      = opencmIcon;
            opencm.Click    += (s, x) => Open();
            cm.Items.Add(opencm);

            ///////////////////////////
            ///////////////////////////
            ///     Save           \\\\
            ///////////////////////////
            ///////////////////////////
            var savecm = new MenuItem()
            {
                Header           = Application.Current.Resources["Save"] as string,
                InputGestureText = $"{Application.Current.Resources["Ctrl"] as string} + S"
            };
            var savecmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconSave),
                Stretch = Stretch.Fill
            };

            savecmIcon.Width = savecmIcon.Height = 12;
            savecmIcon.Fill  = scbf;
            savecm.Icon      = savecmIcon;
            savecm.Click    += (s, x) => SaveFiles();
            cm.Items.Add(savecm);

            ///////////////////////////
            ///////////////////////////
            ///     Print          \\\\
            ///////////////////////////
            ///////////////////////////
            var printcm = new MenuItem
            {
                Header           = Application.Current.Resources["Print"] as string,
                InputGestureText = $"{Application.Current.Resources["Ctrl"] as string} + P"
            };
            var printcmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconPrint),
                Stretch = Stretch.Fill
            };

            printcmIcon.Width = printcmIcon.Height = 12;
            printcmIcon.Fill  = scbf;
            printcm.Icon      = printcmIcon;
            printcm.Click    += (s, x) => Print(Pics[FolderIndex]);
            cm.Items.Add(printcm);

            ///////////////////////////
            ///////////////////////////
            ///     Open With      \\\\
            ///////////////////////////
            ///////////////////////////
            var openwcm = new MenuItem
            {
                Header           = Application.Current.Resources["OpenWith"] as string,
                InputGestureText = "E"
            };
            var openwIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconSend),
                Stretch = Stretch.Fill
            };

            openwIcon.Width = openwIcon.Height = 12;
            openwIcon.Fill  = scbf;
            openwcm.Icon    = openwIcon;
            openwcm.Click  += (s, x) => OpenWith(Pics[FolderIndex]);
            cm.Items.Add(openwcm);

            ///////////////////////////
            ///////////////////////////
            ///     Recent Files   \\\\
            ///////////////////////////
            ///////////////////////////
            cm.Items.Add(new Separator());
            var recentcm = new MenuItem
            {
                Header = Application.Current.Resources["RecentFiles"] as string,
            };
            var recentcmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconPaper),
                Stretch = Stretch.Fill
            };

            recentcmIcon.Width = recentcmIcon.Height = 12;
            recentcmIcon.Fill  = scbf;
            recentcm.Icon      = recentcmIcon;
            cm.Items.Add(recentcm);

            ///////////////////////////
            ///////////////////////////
            ///     Sort Files     \\\\
            ///////////////////////////
            ///////////////////////////
            var sortcm = new MenuItem
            {
                Header = Application.Current.Resources["SortFilesBy"] as string,
            };
            var sortcmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconSort),
                Stretch = Stretch.Fill
            };

            sortcmIcon.Width = sortcmIcon.Height = 12;
            sortcmIcon.Fill  = scbf;
            sortcm.Icon      = sortcmIcon;

            ///////////////////////////
            ///   File Name        \\\\
            ///////////////////////////
            var sortcmChild0       = new MenuItem();
            var sortcmChild0Header = new RadioButton
            {
                Content         = Application.Current.Resources["FileName"] as string,
                BorderThickness = new Thickness(0, 0, 0, 0),
                MinWidth        = 125,
                IsChecked       = Properties.Settings.Default.SortPreference == 0
            };

            sortcmChild0Header.Click += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(0); cm.IsOpen = false; };
            sortcmChild0.Click       += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(0); cm.IsOpen = false; };
            sortcmChild0.Header       = sortcmChild0Header;
            sortcm.Items.Add(sortcmChild0);

            ///////////////////////////
            ///   File Size        \\\\
            ///////////////////////////
            var sortcmChild1       = new MenuItem();
            var sortcmChild1Header = new RadioButton
            {
                Content         = Application.Current.Resources["FileSize"] as string,
                BorderThickness = new Thickness(0, 0, 0, 0),
                MinWidth        = 125,
                IsChecked       = Properties.Settings.Default.SortPreference == 1
            };

            sortcmChild1Header.Click += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(1); cm.IsOpen = false; };
            sortcmChild1.Click       += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(1); cm.IsOpen = false; };
            sortcmChild1.Header       = sortcmChild1Header;
            sortcm.Items.Add(sortcmChild1);

            ///////////////////////////
            ///   Creation Time     \\\\
            ///////////////////////////
            var sortcmChild2       = new MenuItem();
            var sortcmChild2Header = new RadioButton
            {
                Content         = Application.Current.Resources["CreationTime"] as string,
                BorderThickness = new Thickness(0, 0, 0, 0),
                MinWidth        = 125,
                IsChecked       = Properties.Settings.Default.SortPreference == 2
            };

            sortcmChild2Header.Click += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(2); cm.IsOpen = false; };
            sortcmChild2.Click       += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(2); cm.IsOpen = false; };
            sortcmChild2.Header       = sortcmChild2Header;
            sortcm.Items.Add(sortcmChild2);

            ///////////////////////////
            ///   File extension   \\\\
            ///////////////////////////
            var sortcmChild3       = new MenuItem();
            var sortcmChild3Header = new RadioButton
            {
                Content         = Application.Current.Resources["FileExtension"] as string,
                BorderThickness = new Thickness(0, 0, 0, 0),
                MinWidth        = 125,
                IsChecked       = Properties.Settings.Default.SortPreference == 3
            };

            sortcmChild3Header.Click += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(3); cm.IsOpen = false; };
            sortcmChild3.Click       += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(3); cm.IsOpen = false; };
            sortcmChild3.Header       = sortcmChild3Header;
            sortcm.Items.Add(sortcmChild3);

            ///////////////////////////
            ///   Last Access Time \\\\
            ///////////////////////////
            var sortcmChild4       = new MenuItem();
            var sortcmChild4Header = new RadioButton
            {
                Content         = Application.Current.Resources["LastAccessTime"] as string,
                BorderThickness = new Thickness(0, 0, 0, 0),
                MinWidth        = 125,
                IsChecked       = Properties.Settings.Default.SortPreference == 4
            };

            sortcmChild4Header.Click += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(4); cm.IsOpen = false; };
            sortcmChild4.Click       += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(4); cm.IsOpen = false; };
            sortcmChild4.Header       = sortcmChild4Header;
            sortcm.Items.Add(sortcmChild4);

            ///////////////////////////
            ///   Last Write Time  \\\\
            ///////////////////////////
            var sortcmChild5       = new MenuItem();
            var sortcmChild5Header = new RadioButton
            {
                Content         = Application.Current.Resources["LastWriteTime"] as string,
                BorderThickness = new Thickness(0, 0, 0, 0),
                MinWidth        = 125,
                IsChecked       = Properties.Settings.Default.SortPreference == 5
            };

            sortcmChild5Header.Click += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(5); cm.IsOpen = false; };
            sortcmChild5.Click       += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(5); cm.IsOpen = false; };
            sortcmChild5.Header       = sortcmChild5Header;
            sortcm.Items.Add(sortcmChild5);

            ///////////////////////////
            ///   Random        \\\\
            ///////////////////////////
            var sortcmChild6       = new MenuItem();
            var sortcmChild6Header = new RadioButton
            {
                Content         = Application.Current.Resources["Random"] as string,
                BorderThickness = new Thickness(0, 0, 0, 0),
                MinWidth        = 125,
                IsChecked       = Properties.Settings.Default.SortPreference == 6
            };

            sortcmChild6Header.Click += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(6); cm.IsOpen = false; };
            sortcmChild6.Click       += delegate { ConfigureSettings.UpdateUIValues.ChangeSorting(6); cm.IsOpen = false; };
            sortcmChild6.Header       = sortcmChild6Header;
            sortcm.Items.Add(sortcmChild6);
            cm.Items.Add(sortcm);

            ///////////////////////////
            ///////////////////////////
            ///     Settings       \\\\
            ///////////////////////////
            ///////////////////////////
            var settingscm = new MenuItem
            {
                Header = Application.Current.Resources["Settings"] as string,
            };
            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);

            ///////////////////////////
            ///   Looping          \\\\
            ///////////////////////////
            var settingscmLoop = new MenuItem
            {
                InputGestureText = "L"
            };
            var settingscmLoopHeader = new CheckBox
            {
                IsChecked           = Properties.Settings.Default.Looping,
                Content             = Application.Current.Resources["Looping"] as string,
                FontSize            = 13,
                MinWidth            = 125,
                HorizontalAlignment = HorizontalAlignment.Left,
                Width  = double.NaN,
                Height = double.NaN
            };

            settingscmLoop.Header       = settingscmLoopHeader;
            settingscmLoop.Click       += (s, x) => { ConfigureSettings.UpdateUIValues.SetLooping(s, x); };
            settingscmLoopHeader.Click += (s, x) => { ConfigureSettings.UpdateUIValues.SetLooping(s, x); };
            settingscm.Items.Add(settingscmLoop);

            ///////////////////////////
            ///   Scroll         \\\\
            ///////////////////////////
            var settingscmScroll = new MenuItem
            {
                InputGestureText = "X"
            };
            var settingscmScrollHeader = new CheckBox
            {
                IsChecked           = Properties.Settings.Default.ScrollEnabled,
                Content             = Application.Current.Resources["Scrolling"] as string,
                FontSize            = 13,
                MinWidth            = 125,
                HorizontalAlignment = HorizontalAlignment.Left,
                Width  = double.NaN,
                Height = double.NaN
            };

            settingscmScrollHeader.Click += ConfigureSettings.UpdateUIValues.SetScrolling;
            settingscmScroll.Header       = settingscmScrollHeader;
            settingscmScroll.Click       += (s, x) => { ConfigureSettings.UpdateUIValues.SetScrolling(s, x); settingscmScrollHeader.IsChecked = (bool)settingscmScrollHeader.IsChecked ? false : true; };
            settingscm.Items.Add(settingscmScroll);

            ///////////////////////////
            ///   Alt interface    \\\\
            ///////////////////////////
            var altcm = new MenuItem
            {
                InputGestureText = "Alt + Z"
            };
            var altcmHeader = new CheckBox
            {
                Content             = Application.Current.Resources["ShowHideUI"] as string,
                IsChecked           = Properties.Settings.Default.ShowInterface,
                FontSize            = 13,
                MinWidth            = 125,
                HorizontalAlignment = HorizontalAlignment.Left,
                Width  = double.NaN,
                Height = double.NaN
            };

            altcmHeader.Click += delegate
            {
                if (GalleryFunctions.IsOpen)
                {
                    altcmHeader.IsChecked = Properties.Settings.Default.ShowInterface;
                    return;
                }
                HideInterfaceLogic.ToggleInterface();
            };
            altcm.Header = altcmHeader;
            altcm.Click += delegate { HideInterfaceLogic.ToggleInterface(); };
            settingscm.Items.Add(altcm);

            ///////////////////////////
            ///   Transparent bg   \\\\
            ///////////////////////////
            var transcm = new MenuItem
            {
                InputGestureText = "T"
            };
            var transcmHeader = new Button
            {
                Content             = Application.Current.Resources["ChangeBg"] as string,
                ToolTip             = Application.Current.Resources["ChangeBgTooltip"] as string,
                FontSize            = 13,
                Width               = double.NaN,
                Height              = double.NaN,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            transcmHeader.Click += ConfigureSettings.ConfigColors.ChangeBackground;
            transcm.Header       = transcmHeader;
            transcm.Click       += ConfigureSettings.ConfigColors.ChangeBackground;
            settingscm.Items.Add(transcm);

            cm.Items.Add(new Separator());

            ///////////////////////////
            ///////////////////////////
            ///  Set as            \\\\
            ///////////////////////////
            ///////////////////////////

            var setAsCm = new MenuItem
            {
                Header = Application.Current.Resources["SetAs"] as string,
            };

            var setAsCmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconCamera),
                Stretch = Stretch.Fill
            };

            setAsCmIcon.Width = setAsCmIcon.Height = 12;
            setAsCmIcon.Fill  = scbf;
            setAsCm.Icon      = setAsCmIcon;

            var wallcm = new MenuItem
            {
                Header = Application.Current.Resources["SetAsWallpaper"] as string,
            };

            wallcm.Click += (s, x) => SetWallpaper(WallpaperStyle.Fill);
            var wallcmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconCamera),
                Stretch = Stretch.Fill
            };

            wallcmIcon.Width = wallcmIcon.Height = 12;
            wallcmIcon.Fill  = scbf;
            wallcm.Icon      = wallcmIcon;
            setAsCm.Items.Add(wallcm);

            var lockCm = new MenuItem
            {
                Header = Application.Current.Resources["SetAsLockScreenImage"] as string,
            };

            lockCm.Click += async delegate { await Lockscreen.ChangeLockScreenBackground(Pics[FolderIndex]).ConfigureAwait(false); };
            var lockCmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconCamera),
                Stretch = Stretch.Fill
            };

            lockCmIcon.Width = lockCmIcon.Height = 12;
            lockCmIcon.Fill  = scbf;
            lockCm.Icon      = lockCmIcon;
            setAsCm.Items.Add(lockCm);

            cm.Items.Add(setAsCm);

            ///////////////////////////
            ///////////////////////////
            ///   Locate on disk   \\\\
            ///////////////////////////
            ///////////////////////////
            var lcdcm = new MenuItem
            {
                Header           = Application.Current.Resources["ShowInFolder"] as string,
                InputGestureText = "F3"
            };
            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);

            ///////////////////////////
            ///////////////////////////
            ///   Image Info       \\\\
            ///////////////////////////
            ///////////////////////////
            var fildecm = new MenuItem
            {
                Header = Application.Current.Resources["ImageInfo"] as string,
            };
            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    += (_, _) => LoadWindows.ImageInfoWindow();
            cm.Items.Add(fildecm);
            cm.Items.Add(new Separator());

            ///////////////////////////
            ///////////////////////////
            ///   Copy             \\\\
            ///////////////////////////
            ///////////////////////////
            var cpm = new MenuItem
            {
                Header = Application.Current.Resources["Copy"] as string,
            };

            var cpmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconCopy),
                Stretch = Stretch.Fill
            };

            cpmIcon.Width = cpmIcon.Height = 12;
            cpmIcon.Fill  = scbf;
            cpm.Icon      = cpmIcon;

            ///////////////////////////
            ///   Copy file        \\\\
            ///////////////////////////
            var cppcm = new MenuItem
            {
                Header  = Application.Current.Resources["CopyFile"] as string,
                ToolTip = Application.Current.Resources["CopyFile"] as string
                          + $" [{Application.Current.Resources["Ctrl"] as string}] + C]",
            };

            cppcm.Click += (s, x) => Copyfile();
            cpm.Items.Add(cppcm);

            ///////////////////////////
            ///   Copy base64      \\\\
            ///////////////////////////
            var cpxcm = new MenuItem
            {
                Header  = Application.Current.Resources["Copy"] as string + " base64",
                ToolTip = Application.Current.Resources["Copy"] as string + " base64"
                          + $" [{Application.Current.Resources["Ctrl"] as string} + " +
                          $"{Application.Current.Resources["Shift"] as string}  + C]",
            };

            cpxcm.Click += async delegate { await Base64.SendToClipboard().ConfigureAwait(false); };
            cpm.Items.Add(cpxcm);

            ///////////////////////////
            ///   Copy bitmap      \\\\
            ///////////////////////////
            var cpxbm = new MenuItem
            {
                Header  = Application.Current.Resources["CopyImage"] as string,
                ToolTip = Application.Current.Resources["CopyImageTooltip"] as string
                          + $" [{Application.Current.Resources["Ctrl"] as string} + " +
                          $"{Application.Current.Resources["Alt"] as string}  + C]",
            };

            cpxbm.Click += (s, x) => CopyBitmap();
            cpm.Items.Add(cpxbm);

            ///////////////////////////
            ///   Copy file path   \\\\
            ///////////////////////////
            var cppfm = new MenuItem
            {
                Header = Application.Current.Resources["FileCopyPath"] as string,
            };

            cppfm.Click += (s, x) => CopyText();
            cpm.Items.Add(cppfm);

            cm.Items.Add(cpm);

            ///////////////////////////
            ///////////////////////////
            ///   Cut File         \\\\
            ///////////////////////////
            ///////////////////////////
            var cpccm = new MenuItem
            {
                Header           = Application.Current.Resources["FileCut"] as string,
                InputGestureText = $"{Application.Current.Resources["Ctrl"] as string} + X"
            };
            var cpccmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconScissor),
                Stretch = Stretch.Fill
            };

            cpccmIcon.Width = cpccmIcon.Height = 12;
            cpccmIcon.Fill  = scbf;
            cpccm.Icon      = cpccmIcon;
            cpccm.Click    += (s, x) => Cut(Pics[FolderIndex]);
            cm.Items.Add(cpccm);

            ///////////////////////////
            ///////////////////////////
            ///   Paste File       \\\\
            ///////////////////////////
            ///////////////////////////
            var pastecm = new MenuItem
            {
                Header           = Application.Current.Resources["FilePaste"] as string,
                InputGestureText = $"{Application.Current.Resources["Ctrl"] as string} + V"
            };
            var pastecmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconPaste),
                Stretch = Stretch.Fill,
                Width   = 12,
                Height  = 12,
                Fill    = scbf
            };

            pastecm.Icon   = pastecmIcon;
            pastecm.Click += (s, x) => Paste();
            cm.Items.Add(pastecm);

            ///////////////////////////
            ///////////////////////////
            ///   Delete File      \\\\
            ///////////////////////////
            ///////////////////////////
            var MovetoRecycleBin = new MenuItem
            {
                Header           = Application.Current.Resources["DeleteFile"] as string,
                InputGestureText = Application.Current.Resources["Delete"] as string,
            };
            var MovetoRecycleBinIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconRecycle),
                Stretch = Stretch.Fill,
                Width   = 12,
                Height  = 12,
                Fill    = scbf
            };

            MovetoRecycleBin.Icon   = MovetoRecycleBinIcon;
            MovetoRecycleBin.Click += delegate { DeleteFile(Pics[FolderIndex], true); };
            cm.Items.Add(MovetoRecycleBin);

            ///////////////////////////
            ///////////////////////////
            ///   Close            \\\\
            ///////////////////////////
            ///////////////////////////
            cm.Items.Add(new Separator());
            var clcm = new MenuItem
            {
                Header           = Application.Current.Resources["Close"] as string,
                InputGestureText = Application.Current.Resources["Esc"] as string,
                StaysOpenOnClick = false
            };
            var mclcmIcon = new System.Windows.Shapes.Path
            {
                Data    = Geometry.Parse(SVGiconClose),
                Stretch = Stretch.Fill,
                Width   = 12,
                Height  = 12,
                Fill    = scbf
            };

            clcm.Icon   = mclcmIcon;
            clcm.Click += (s, x) => { cm.Visibility = Visibility.Collapsed; SystemCommands.CloseWindow(LoadWindows.GetMainWindow); };
            cm.Items.Add(clcm);

            // Add to elements
            LoadWindows.GetMainWindow.MainImage.ContextMenu = LoadWindows.GetMainWindow.ParentContainer.ContextMenu = cm;
            cm.Opened += (tt, yy) => Recentcm_Opened(recentcm);

#if DEBUG
            Trace.WriteLine("Contextmenu loaded");
#endif
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Hides/shows interface elements with a fade animation
        /// </summary>
        /// <param name="show"></param>
        internal static async void FadeControlsAsync(bool show, double time = .5)
        {
            if (Properties.Settings.Default.ShowInterface && !Properties.Settings.Default.Fullscreen ||
                GetClickArrowRight == null ||
                GetClickArrowLeft == null ||
                Getx2 == null ||
                GetGalleryShortcut == null ||
                Scroll.IsAutoScrolling ||
                Properties.Settings.Default.FullscreenGallery == false && GalleryFunctions.IsOpen)
            {
                return;
            }

            if (GetCropppingTool != null)
            {
                if (GetCropppingTool.IsVisible)
                {
                    return;
                }
            }

            await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (Action)(() =>
            {
                if (!Properties.Settings.Default.ShowAltInterfaceButtons)
                {
                    HideInterfaceLogic.ShowNavigation(false);
                    HideInterfaceLogic.ShowShortcuts(false);
                    return;
                }
                else if (!GetClickArrowLeft.IsVisible)
                {
                    HideInterfaceLogic.ShowNavigation(true);
                    HideInterfaceLogic.ShowShortcuts(true);
                }

                if (Properties.Settings.Default.ScrollEnabled && ConfigureWindows.GetMainWindow.Scroller.ScrollableHeight > 0)
                {
                    ScrollbarFade(show);
                }

                // Don't run, if already being animated || prevent lag
                if (Getx2.Opacity > 0 && Getx2.Opacity < 1)
                {
                    return;
                }

                TimeSpan timespan = TimeSpan.FromSeconds(time);

                if (!show)
                {
                    AnimationHelper.Fade(GetClickArrowLeft, 0, timespan);
                    AnimationHelper.Fade(GetClickArrowRight, 0, timespan);
                    AnimationHelper.Fade(GetGalleryShortcut, 0, timespan);
                    AnimationHelper.Fade(Getx2, 0, timespan);
                    AnimationHelper.Fade(GetMinus, 0, timespan);
                    AnimationHelper.Fade(GetRestorebutton, 0, timespan);
                    return;
                }
                else if (Scroll.IsAutoScrolling)
                {
                    GetClickArrowLeft.Opacity =
                        GetClickArrowRight.Opacity =
                            GetGalleryShortcut.Opacity =
                                Getx2.Opacity =
                                    GetMinus.Opacity = 0;
                    return;
                }

                AnimationHelper.Fade(GetClickArrowLeft, 1, timespan);
                AnimationHelper.Fade(GetClickArrowRight, 1, timespan);
                AnimationHelper.Fade(GetGalleryShortcut, 1, timespan);
                AnimationHelper.Fade(Getx2, 1, timespan);
                AnimationHelper.Fade(GetMinus, 1, timespan);
                AnimationHelper.Fade(GetRestorebutton, 1, timespan);
            }));
        }