public PicGalleryTopButtons() { InitializeComponent(); RestoreButton.MouseEnter += delegate { MouseOverAnimations.AltInterfaceMouseOver(PolyFill, RestoreBg, BorderBrushKey); }; RestoreButton.MouseLeave += delegate { MouseOverAnimations.AltInterfaceMouseLeave(PolyFill, RestoreBg, BorderBrushKey); }; RestoreButton.MouseLeftButtonDown += delegate { GalleryToggle.Toggle(); }; RestoreButton.ToolTip = Application.Current.Resources["RestoreDown"]; CloseButton.MouseLeftButtonDown += delegate { SystemCommands.CloseWindow(ConfigureWindows.GetMainWindow); }; CloseButton.ToolTip = Application.Current.Resources["Close"]; MinButton.MouseLeftButtonDown += delegate { SystemCommands.MinimizeWindow(ConfigureWindows.GetMainWindow); }; }
internal static void Start() { #if DEBUG Trace.WriteLine("ContentRendered started"); #endif ConfigureSettings.ConfigColors.UpdateColor(); #region Add dictionaries Application.Current.Resources.MergedDictionaries.Add( new ResourceDictionary { Source = new Uri(@"/PicView;component/Themes/Styles/Menu.xaml", UriKind.Relative) } ); Application.Current.Resources.MergedDictionaries.Add( new ResourceDictionary { Source = new Uri(@"/PicView;component/Themes/Styles/ToolTip.xaml", UriKind.Relative) } ); Application.Current.Resources.MergedDictionaries.Add( new ResourceDictionary { Source = new Uri(@"/PicView;component/Themes/Styles/Slider.xaml", UriKind.Relative) } ); #endregion Add dictionaries MonitorInfo = MonitorSize.GetMonitorSize(); AutoFitWindow = Properties.Settings.Default.AutoFitWindow; IsScrollEnabled = Properties.Settings.Default.ScrollEnabled; Pics = new List <string>(); // Load image if possible var arg = Application.Current.Properties["ArbitraryArgName"]; if (arg == null) { Unload(); // Reset PicGallery and don't allow it to run, // if only 1 image Properties.Settings.Default.PicGallery = 1; // Don't start it in fullscreen with no image Properties.Settings.Default.Fullscreen = false; } else { // Determine prefered UI for startup if (Properties.Settings.Default.Fullscreen) { Fullscreen_Restore(true); } else if (Properties.Settings.Default.PicGallery == 2) { GalleryToggle.OpenFullscreenGallery(true); } else if (AutoFitWindow) { ScaleImage.TryFitImage(arg.ToString()); } else if (Properties.Settings.Default.Width != 0) { LoadWindows.GetMainWindow.Top = Properties.Settings.Default.Top; LoadWindows.GetMainWindow.Left = Properties.Settings.Default.Left; LoadWindows.GetMainWindow.Width = Properties.Settings.Default.Width; LoadWindows.GetMainWindow.Height = Properties.Settings.Default.Height; } Pic(arg.ToString()); } // Load UI and events AddUIElementsAndUpdateValues(); #if DEBUG Trace.WriteLine("Start Completed "); #endif }
internal static void PreStart() { #if DEBUG Trace.Listeners.Add(new TextWriterTraceListener("Debug.log")); Trace.Unindent(); Trace.WriteLine(SetTitle.AppName + " started at " + DateTime.Now); #endif // theese two line have to be exactly onload HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(ConfigureWindows.GetMainWindow).Handle); source.AddHook(new HwndSourceHook(NativeMethods.WndProc)); if (!Properties.Settings.Default.ShowInterface) { ConfigureWindows.GetMainWindow.TitleBar.Visibility = ConfigureWindows.GetMainWindow.LowerBar.Visibility = Visibility.Collapsed; } FreshStartup = true; Pics = new List <string>(); // Load sizing properties MonitorInfo = MonitorSize.GetMonitorSize(); AutoFitWindow = Properties.Settings.Default.AutoFitWindow; IsScrollEnabled = Properties.Settings.Default.ScrollEnabled; // Set min size to DPI scaling ConfigureWindows.GetMainWindow.MinWidth *= MonitorInfo.DpiScaling; ConfigureWindows.GetMainWindow.MinHeight *= MonitorInfo.DpiScaling; // Load image if possible var arg = Application.Current.Properties["ArbitraryArgName"]; if (arg == null) { Unload(); // Reset PicGallery and don't allow it to run, // if only 1 image Properties.Settings.Default.PicGallery = 1; // Don't start it in fullscreen with no image Properties.Settings.Default.Fullscreen = false; // Determine proper startup size if (Properties.Settings.Default.Width != 0) { SetLastWindowSize(); } else { ConfigureWindows.GetMainWindow.Width = 750 * MonitorInfo.DpiScaling; ConfigureWindows.GetMainWindow.MinHeight = 700 * MonitorInfo.DpiScaling; } } else if (File.Exists(arg.ToString())) { var file = arg.ToString(); // Determine prefered UI for startup if (Properties.Settings.Default.Fullscreen) { ConfigureWindows.Fullscreen_Restore(true); } else if (Properties.Settings.Default.PicGallery == 2) { GalleryToggle.OpenFullscreenGallery(true); } else if (AutoFitWindow) { ScaleImage.TryFitImage(file); } else if (Properties.Settings.Default.Width != 0) { SetLastWindowSize(); } Pic(file); } else { // Set file associations var process = Process.GetCurrentProcess(); var args = arg.ToString().Split(','); foreach (var item in args) { NativeMethods.SetAssociation(item, process.Id.ToString(CultureInfo.InvariantCulture), item, process.MainModule.FileName); } Environment.Exit(0); } if (Properties.Settings.Default.UserLanguage != "en") { try { Application.Current.Resources.MergedDictionaries[0] = new ResourceDictionary { Source = new Uri(@"/PicView;component/Translations/" + Properties.Settings.Default.UserLanguage + ".xaml", UriKind.Relative) }; } catch (Exception) { Application.Current.Resources.MergedDictionaries[0] = new ResourceDictionary { Source = new Uri(@"/PicView;component/Translations/en.xaml", UriKind.Relative) }; } } }
/// <summary> /// Start adding events /// </summary> internal static void Go() { // keyboard and Mouse_Keys Keys ConfigureWindows.GetMainWindow.KeyDown += MainWindow_KeysDown; ConfigureWindows.GetMainWindow.KeyUp += MainWindow_KeysUp; ConfigureWindows.GetMainWindow.MouseDown += MainWindow_MouseDown; // MinButton ConfigureWindows.GetMainWindow.MinButton.TheButton.Click += (_, _) => SystemCommands.MinimizeWindow(ConfigureWindows.GetMainWindow); // CloseButton ConfigureWindows.GetMainWindow.CloseButton.TheButton.Click += (_, _) => SystemCommands.CloseWindow(ConfigureWindows.GetMainWindow); // FileMenuButton ConfigureWindows.GetMainWindow.FileMenuButton.PreviewMouseLeftButtonDown += (_, _) => PreviewMouseButtonDownAnim(ConfigureWindows.GetMainWindow.FolderFill); ConfigureWindows.GetMainWindow.FileMenuButton.MouseEnter += (_, _) => ButtonMouseOverAnim(ConfigureWindows.GetMainWindow.FolderFill); ConfigureWindows.GetMainWindow.FileMenuButton.MouseEnter += (_, _) => AnimationHelper.MouseEnterBgTexColor(ConfigureWindows.GetMainWindow.FileMenuBg); ConfigureWindows.GetMainWindow.FileMenuButton.MouseLeave += (_, _) => ButtonMouseLeaveAnim(ConfigureWindows.GetMainWindow.FolderFill); ConfigureWindows.GetMainWindow.FileMenuButton.MouseLeave += (_, _) => AnimationHelper.MouseLeaveBgTexColor(ConfigureWindows.GetMainWindow.FileMenuBg); ConfigureWindows.GetMainWindow.FileMenuButton.Click += Toggle_open_menu; GetFileMenu.Open.Click += (_, _) => Open(); GetFileMenu.FileLocation.Click += (_, _) => Open_In_Explorer(); GetFileMenu.Print.Click += (_, _) => Print(Pics[FolderIndex]); GetFileMenu.SaveButton.Click += (_, _) => SaveFiles(); GetFileMenu.OpenBorder.MouseLeftButtonUp += (_, _) => Open(); GetFileMenu.FileLocationBorder.MouseLeftButtonUp += (_, _) => Open_In_Explorer(); GetFileMenu.PrintBorder.MouseLeftButtonUp += (_, _) => Print(Pics[FolderIndex]); GetFileMenu.SaveBorder.MouseLeftButtonUp += (_, _) => SaveFiles(); // image_button ConfigureWindows.GetMainWindow.image_button.PreviewMouseLeftButtonDown += (_, _) => PreviewMouseButtonDownAnim(ConfigureWindows.GetMainWindow.ImagePath1Fill, ConfigureWindows.GetMainWindow.ImagePath2Fill, ConfigureWindows.GetMainWindow.ImagePath3Fill); ConfigureWindows.GetMainWindow.image_button.MouseEnter += (_, _) => ButtonMouseOverAnim(ConfigureWindows.GetMainWindow.ImagePath1Fill, ConfigureWindows.GetMainWindow.ImagePath2Fill, ConfigureWindows.GetMainWindow.ImagePath3Fill); ConfigureWindows.GetMainWindow.image_button.MouseEnter += (_, _) => AnimationHelper.MouseEnterBgTexColor(ConfigureWindows.GetMainWindow.ImageMenuBg); ConfigureWindows.GetMainWindow.image_button.MouseLeave += (_, _) => ButtonMouseLeaveAnim(ConfigureWindows.GetMainWindow.ImagePath1Fill, ConfigureWindows.GetMainWindow.ImagePath2Fill, ConfigureWindows.GetMainWindow.ImagePath3Fill); ConfigureWindows.GetMainWindow.image_button.MouseLeave += (_, _) => AnimationHelper.MouseLeaveBgTexColor(ConfigureWindows.GetMainWindow.ImageMenuBg); ConfigureWindows.GetMainWindow.image_button.Click += Toggle_image_menu; // imageSettingsMenu Buttons GetImageSettingsMenu.Contained_Gallery.Click += delegate { Close_UserControls(); GalleryToggle.OpenHorizontalGallery(); }; GetImageSettingsMenu.Fullscreen_Gallery.Click += delegate { Close_UserControls(); GalleryToggle.OpenFullscreenGallery(); }; // SettingsButton ConfigureWindows.GetMainWindow.SettingsButton.PreviewMouseLeftButtonDown += (_, _) => PreviewMouseButtonDownAnim(ConfigureWindows.GetMainWindow.SettingsButtonFill); ConfigureWindows.GetMainWindow.SettingsButton.MouseEnter += (_, _) => ButtonMouseOverAnim(ConfigureWindows.GetMainWindow.SettingsButtonFill); ConfigureWindows.GetMainWindow.SettingsButton.MouseEnter += (_, _) => AnimationHelper.MouseEnterBgTexColor(ConfigureWindows.GetMainWindow.SettingsMenuBg); ConfigureWindows.GetMainWindow.SettingsButton.MouseLeave += (_, _) => ButtonMouseLeaveAnim(ConfigureWindows.GetMainWindow.SettingsButtonFill); ConfigureWindows.GetMainWindow.SettingsButton.MouseLeave += (_, _) => AnimationHelper.MouseLeaveBgTexColor(ConfigureWindows.GetMainWindow.SettingsMenuBg); ConfigureWindows.GetMainWindow.SettingsButton.Click += Toggle_quick_settings_menu; //FunctionButton var MagicBrush = ConfigureWindows.GetMainWindow.TryFindResource("MagicBrush") as SolidColorBrush; ConfigureWindows.GetMainWindow.FunctionMenuButton.PreviewMouseLeftButtonDown += (_, _) => PreviewMouseButtonDownAnim(MagicBrush); ConfigureWindows.GetMainWindow.FunctionMenuButton.MouseEnter += (_, _) => ButtonMouseOverAnim(MagicBrush); ConfigureWindows.GetMainWindow.FunctionMenuButton.MouseEnter += (_, _) => AnimationHelper.MouseEnterBgTexColor(ConfigureWindows.GetMainWindow.EffectsMenuBg); ConfigureWindows.GetMainWindow.FunctionMenuButton.MouseLeave += (_, _) => ButtonMouseLeaveAnim(MagicBrush); ConfigureWindows.GetMainWindow.FunctionMenuButton.MouseLeave += (_, _) => AnimationHelper.MouseLeaveBgTexColor(ConfigureWindows.GetMainWindow.EffectsMenuBg); ConfigureWindows.GetMainWindow.FunctionMenuButton.Click += Toggle_Functions_menu; // ClickArrows GetClickArrowLeft.MouseLeftButtonDown += (_, _) => PicButton(true, false); GetClickArrowRight.MouseLeftButtonDown += (_, _) => PicButton(true, true); // x2 Getx2.MouseLeftButtonDown += (_, _) => SystemCommands.CloseWindow(ConfigureWindows.GetMainWindow); // Minus GetMinus.MouseLeftButtonDown += (_, _) => SystemCommands.MinimizeWindow(ConfigureWindows.GetMainWindow); // GalleryShortcut GetGalleryShortcut.MouseLeftButtonDown += (_, _) => GalleryToggle.OpenHorizontalGallery(); // TitleText ConfigureWindows.GetMainWindow.TitleText.GotKeyboardFocus += EditTitleBar.EditTitleBar_Text; ConfigureWindows.GetMainWindow.TitleText.InnerTextBox.PreviewKeyDown += CustomTextBoxShortcuts.CustomTextBox_KeyDown; ConfigureWindows.GetMainWindow.TitleText.PreviewMouseLeftButtonDown += EditTitleBar.Bar_PreviewMouseLeftButtonDown; ConfigureWindows.GetMainWindow.TitleText.PreviewMouseRightButtonDown += EditTitleBar.Bar_PreviewMouseRightButtonDown; // MainImage ConfigureWindows.GetMainWindow.MainImage.PreviewMouseLeftButtonDown += DragAndDrop.DragToExplorer.DragFile; ConfigureWindows.GetMainWindow.MainImage.MouseLeftButtonDown += MainImage_MouseLeftButtonDown; ConfigureWindows.GetMainWindow.MainImage.MouseLeftButtonUp += MainImage_MouseLeftButtonUp; ConfigureWindows.GetMainWindow.MainImage.MouseMove += MainImage_MouseMove; // ParentContainer ConfigureWindows.GetMainWindow.ParentContainer.MouseLeftButtonDown += Bg_MouseLeftButtonDown; ConfigureWindows.GetMainWindow.ParentContainer.Drop += Image_Drop; ConfigureWindows.GetMainWindow.ParentContainer.DragEnter += Image_DragEnter; ConfigureWindows.GetMainWindow.ParentContainer.DragLeave += Image_DragLeave; ConfigureWindows.GetMainWindow.ParentContainer.MouseMove += Interface_MouseMove; ConfigureWindows.GetMainWindow.ParentContainer.MouseLeave += Interface_MouseLeave; ConfigureWindows.GetMainWindow.ParentContainer.PreviewMouseWheel += MainImage_MouseWheel; // TooltipStyle GetToolTipMessage.MouseWheel += MainImage_MouseWheel; // TitleBar ConfigureWindows.GetMainWindow.TitleBar.MouseLeftButtonDown += ConfigureWindows.Move; ConfigureWindows.GetMainWindow.TitleBar.MouseLeave += ConfigureWindows.Restore_From_Move; // Lower Bar ConfigureWindows.GetMainWindow.LowerBar.Drop += Image_Drop; ConfigureWindows.GetMainWindow.LowerBar.MouseLeftButtonDown += ConfigureWindows.MoveAlt; // This ConfigureWindows.GetMainWindow.Closing += ConfigureWindows.Window_Closing; ConfigureWindows.GetMainWindow.StateChanged += ConfigureWindows.MainWindow_StateChanged; //LocationChanged += MainWindow_LocationChanged; Microsoft.Win32.SystemEvents.DisplaySettingsChanged += ConfigureWindows.SystemEvents_DisplaySettingsChanged; #if DEBUG Trace.WriteLine("Events loaded"); #endif }
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) { return; } } if (!e.IsRepeat) { // Go to first if Ctrl held down if (ctrlDown && !GalleryFunctions.IsOpen) { 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) { return; } } if (!e.IsRepeat) { // Go to last if Ctrl held down if (ctrlDown && !GalleryFunctions.IsOpen) { 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) { 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) { 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 && !GalleryFunctions.IsOpen) { SaveFiles(); } else if (GetPicGallery != null) { if (GalleryFunctions.IsOpen) { 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) { GalleryToggle.Toggle(); } else { Fullscreen_Restore(); } } else if (Slideshow.SlideTimer != null && Slideshow.SlideTimer.Enabled) { Slideshow.StopSlideshow(); } else if (GalleryFunctions.IsOpen) { GalleryToggle.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 && !GalleryFunctions.IsOpen) { Cut(Pics[FolderIndex]); } else { ConfigureSettings.UpdateUIValues.SetScrolling(sender, e); } break; // F case Key.F: if (!GalleryFunctions.IsOpen) { Flip(); } break; // Delete, Shift + Delete case Key.Delete: if (!GalleryFunctions.IsOpen) { DeleteFile(!shiftDown); } break; // Ctrl + C, Ctrl + Shift + C, Ctrl + Alt + C case Key.C: if (ctrlDown && !GalleryFunctions.IsOpen) { 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 && !GalleryFunctions.IsOpen) { Paste(); } break; // Ctrl + I case Key.I: if (ctrlDown && !GalleryFunctions.IsOpen) { SystemIntegration.NativeMethods.ShowFileProperties(Pics[FolderIndex]); } break; // Ctrl + P case Key.P: if (ctrlDown && !GalleryFunctions.IsOpen) { Print(Pics[FolderIndex]); } break; // Ctrl + R case Key.R: if (ctrlDown && !GalleryFunctions.IsOpen) { Reload(); } break; // L case Key.L: ConfigureSettings.UpdateUIValues.SetLooping(sender, e); break; // E case Key.E: if (!GalleryFunctions.IsOpen) { OpenWith(Pics[FolderIndex]); } break; // T case Key.T: if (!GalleryFunctions.IsOpen) { ConfigureSettings.ConfigColors.ChangeBackground(sender, e); } break; // G case Key.G: if (Properties.Settings.Default.PicGallery == 1 && !GetQuickSettingsMenu.IsVisible && !GetToolsAndEffectsMenu.IsVisible && !GetFileMenu.IsVisible && !GetImageSettingsMenu.IsVisible) { GalleryToggle.Toggle(); } 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: if (!GalleryFunctions.IsOpen) { 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 }
internal static void LoadedEvemt() { #if DEBUG Trace.Listeners.Add(new TextWriterTraceListener("Debug.log")); Trace.Unindent(); Trace.WriteLine(SetTitle.AppName + " started at " + DateTime.Now); #endif // theese two line have to be exactly onload HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(ConfigureWindows.GetMainWindow).Handle); source.AddHook(new HwndSourceHook(NativeMethods.WndProc)); LoadLanguage.DetermineLanguage(); if (!Properties.Settings.Default.ShowInterface) { ConfigureWindows.GetMainWindow.TitleBar.Visibility = ConfigureWindows.GetMainWindow.LowerBar.Visibility = Visibility.Collapsed; } FreshStartup = true; Pics = new List <string>(); // Load sizing properties MonitorInfo = MonitorSize.GetMonitorSize(); AutoFitWindow = Properties.Settings.Default.AutoFitWindow; IsScrollEnabled = Properties.Settings.Default.ScrollEnabled; // Set min size to DPI scaling ConfigureWindows.GetMainWindow.MinWidth *= MonitorInfo.DpiScaling; ConfigureWindows.GetMainWindow.MinHeight *= MonitorInfo.DpiScaling; // Load image if possible var arg = Application.Current.Properties["ArbitraryArgName"]; if (arg == null) { Unload(); // Reset PicGallery and don't allow it to run, // if only 1 image Properties.Settings.Default.FullscreenGallery = false; // Don't start it in fullscreen with no image Properties.Settings.Default.Fullscreen = false; // Determine proper startup size if (Properties.Settings.Default.Width != 0) { SetLastWindowSize(); } else { ConfigureWindows.GetMainWindow.Width = ConfigureWindows.GetMainWindow.MinWidth; ConfigureWindows.GetMainWindow.Height = ConfigureWindows.GetMainWindow.MinHeight; } } else if (arg.ToString().StartsWith('.')) { // Set file associations var process = Process.GetCurrentProcess(); if (arg.ToString() == ".remove") { var removestring = ".jpeg,.jpe,.jpg,.png,.bmp,.ico,.gif,.webp,.jfif,.tiff,.wbmp,.psd,.psb,.svg,.3fr,.arw,.cr2,.crw,.dcr,.dng,.erf,.kdc,.mef,.mdc,.mos,.mrw,.nef,.nrw,.orf,.pef,.raf,.raw,.rw2,.srf,.x3f,.cut,.exr,.emf,.dds,.dib,.hdr,.heic,.tga,.pcx,.pgm,.wmf,.wpg,.xbm,.xcf.xpm"; var rmArgs = removestring.Split(','); foreach (var item in rmArgs) { NativeMethods.DeleteAssociation(item, process.Id.ToString(CultureInfo.InvariantCulture), process.MainModule.FileName); } } else { var args = arg.ToString().Split(','); foreach (var item in args) { NativeMethods.SetAssociation(item, process.Id.ToString(CultureInfo.InvariantCulture)); } } Environment.Exit(0); } else { var file = arg.ToString(); // Determine prefered UI for startup if (Properties.Settings.Default.Fullscreen) { ConfigureWindows.Fullscreen_Restore(true); } else if (Properties.Settings.Default.FullscreenGallery) { GalleryToggle.OpenFullscreenGallery(true); } else if (AutoFitWindow) { ScaleImage.TryFitImage(file); } else if (Properties.Settings.Default.Width != 0) { SetLastWindowSize(); } _ = LoadPiFrom(file); } }