public SlideshowButton() { InitializeComponent(); Loaded += delegate { TheButton.PreviewMouseLeftButtonDown += (s, x) => PreviewMouseButtonDownAnim(SlideshowButtonBrush); TheButton.MouseEnter += (s, x) => ButtonMouseOverAnim(SlideshowButtonBrush, true); TheButton.MouseLeave += (s, x) => ButtonMouseLeaveAnimBgColor(SlideshowButtonBrush, false); TheButton.Click += delegate { UC.Close_UserControls(); Slideshow.StartSlideshow(); }; var s = Application.Current.Resources["StartSlideshow"] as string; s += " [F5]"; ToolTip = s; }; }
public SlideshowButton() { InitializeComponent(); Loaded += delegate { TheButton.PreviewMouseLeftButtonDown += (s, x) => PreviewMouseButtonDownAnim(SlideshowButtonBrush); TheButton.MouseEnter += (s, x) => ButtonMouseOverAnim(SlideshowButtonBrush, true); TheButton.MouseLeave += (s, x) => ButtonMouseLeaveAnimBgColor(SlideshowButtonBrush, false); TheButton.Click += delegate { UC.Close_UserControls(); Slideshow.StartSlideshow(); }; var s = Application.Current.Resources["StartSlideshow"] as string; s += " [F5]"; ToolTip = s; if (!Properties.Settings.Default.DarkTheme) { AnimationHelper.LightThemeMouseEvent(this, SlideshowBrush); } }; }
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 }