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); } }
public SettingsWindow() { Title = Application.Current.Resources["SettingsWindow"] + " - PicView"; MaxHeight = WindowSizing.MonitorInfo.WorkArea.Height; Width *= WindowSizing.MonitorInfo.DpiScaling; InitializeComponent(); ContentRendered += delegate { var colorAnimation = new ColorAnimation { Duration = TimeSpan.FromSeconds(.1) }; AddGenericEvents(colorAnimation); // SubDirRadio SubDirRadio.IsChecked = Properties.Settings.Default.IncludeSubDirectories; SubDirRadio.Click += delegate { Properties.Settings.Default.IncludeSubDirectories = !Properties.Settings.Default.IncludeSubDirectories; Error_Handling.Reload(); }; // BorderColorRadio BorderRadio.Click += UpdateUIValues.SetBorderColorEnabled; if (Properties.Settings.Default.WindowBorderColorEnabled) { BorderRadio.IsChecked = true; } WallpaperApply.MouseLeftButtonDown += delegate { var x = WallpaperStyle.Fill; if (Fit.IsSelected) { x = WallpaperStyle.Fit; } if (Center.IsSelected) { x = WallpaperStyle.Center; } if (Tile.IsSelected) { x = WallpaperStyle.Tile; } if (Fit.IsSelected) { x = WallpaperStyle.Fit; } SetWallpaper(x); }; SlideshowSlider.Value = Properties.Settings.Default.SlideTimer / 1000; SlideshowSlider.ValueChanged += (_, e) => Properties.Settings.Default.SlideTimer = e.NewValue * 1000; ZoomSlider.Value = Properties.Settings.Default.ZoomSpeed; ZoomSlider.ValueChanged += (_, e) => Properties.Settings.Default.ZoomSpeed = e.NewValue; LightThemeRadio.IsChecked = !Properties.Settings.Default.DarkTheme; DarkThemeRadio.IsChecked = Properties.Settings.Default.DarkTheme; DarkThemeRadio.Click += delegate { ChangeToDarkTheme(); LightThemeRadio.IsChecked = false; }; LightThemeRadio.Click += delegate { ChangeToLightTheme(); DarkThemeRadio.IsChecked = false; }; foreach (var language in Enum.GetValues(typeof(Languages))) { LanguageBox.Items.Add(new ComboBoxItem { Content = new CultureInfo(language.ToString()).DisplayName, IsSelected = language.ToString() == Properties.Settings.Default.UserLanguage, }); } LanguageBox.SelectionChanged += delegate { LoadLanguage.ChangeLanguage((LanguageBox.SelectedIndex)); }; AltUIRadio.IsChecked = Properties.Settings.Default.ShowAltInterfaceButtons; AltUIRadio.Click += delegate { Properties.Settings.Default.ShowAltInterfaceButtons = !Properties.Settings.Default.ShowAltInterfaceButtons; }; CtrlZoom.IsChecked = Properties.Settings.Default.CtrlZoom; ScrollZoom.IsChecked = !Properties.Settings.Default.CtrlZoom; CtrlZoom.Checked += (_, _) => Properties.Settings.Default.CtrlZoom = true; ScrollZoom.Checked += (_, _) => Properties.Settings.Default.CtrlZoom = false; ThemeRestart.MouseLeftButtonDown += (_, _) => GeneralSettings.RestartApp(); LanguageRestart.MouseLeftButtonDown += (_, _) => GeneralSettings.RestartApp(); TopmostRadio.Checked += (_, _) => ConfigureWindows.IsMainWindowTopMost = !Properties.Settings.Default.TopMost; TopmostRadio.Unchecked += (_, _) => ConfigureWindows.IsMainWindowTopMost = false; TopmostRadio.IsChecked = Properties.Settings.Default.TopMost; CenterRadio.Checked += (_, _) => Properties.Settings.Default.KeepCentered = true; CenterRadio.Unchecked += (_, _) => Properties.Settings.Default.KeepCentered = false; CenterRadio.IsChecked = Properties.Settings.Default.KeepCentered; fileAssocWin = new FileAssociationsWindow { Owner = this, Width = ActualWidth, Height = ActualHeight }; SetAsDefaultTxt.MouseLeftButtonDown += delegate { if (fileAssocWin.Visibility == Visibility.Visible) { fileAssocWin.Focus(); } else { // Show it with animation Effect = new BlurEffect { RenderingBias = RenderingBias.Quality, KernelType = KernelType.Gaussian, Radius = 9 }; fileAssocWin.BeginAnimation(OpacityProperty, new DoubleAnimation { From = 0, To = 1, Duration = TimeSpan.FromSeconds(.3) }); // Make it stay centered fileAssocWin.Left = Left + (Width - fileAssocWin.Width) / 2; fileAssocWin.Top = Top + (Height - fileAssocWin.Height) / 2; fileAssocWin.ShowDialog(); } }; IsVisibleChanged += (_, e) => { if (!(bool)e.NewValue && fileAssocWin.IsVisible) { fileAssocWin.HideLogic(); } }; switch (Properties.Settings.Default.ColorTheme) { case 1: BlueRadio.IsChecked = true; break; case 2: PinkRadio.IsChecked = true; break; case 3: OrangeRadio.IsChecked = true; break; case 4: GreenRadio.IsChecked = true; break; case 5: RedRadio.IsChecked = true; break; case 6: TealRadio.IsChecked = true; break; case 7: AquaRadio.IsChecked = true; break; case 8: GoldenRadio.IsChecked = true; break; case 9: PurpleRadio.IsChecked = true; break; case 10: CyanRadio.IsChecked = true; break; case 11: MagentaRadio.IsChecked = true; break; case 12: LimeRadio.IsChecked = true; break; } }; }