public FullscreenButton() { InitializeComponent(); PreviewMouseLeftButtonDown += delegate { PreviewMouseButtonDownAnim(FullscreenButtonBrush); }; MouseEnter += delegate { if (Properties.Settings.Default.Fullscreen) { ToolTip = Application.Current.Resources["RestoreDown"]; } else { ToolTip = Application.Current.Resources["Fullscreen"]; } ButtonMouseOverAnim(FullscreenButtonBrush, true); }; MouseLeave += delegate { ButtonMouseLeaveAnim(FullscreenButtonBrush, true); }; TheButton.Click += delegate { ConfigureWindows.Fullscreen_Restore(); }; if (!Properties.Settings.Default.DarkTheme) { AnimationHelper.LightThemeMouseEvent(this, IconBrush); } }
internal static void Start() { #if DEBUG Trace.WriteLine("ContentRendered started"); #endif #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 ConfigureSettings.ConfigColors.UpdateColor(); ConfigureWindows.GetMainWindow.Topmost = Properties.Settings.Default.TopMost; // Load UI and events AddUIElementsAndUpdateValues(); #if DEBUG Trace.WriteLine("Start Completed "); #endif if (Properties.Settings.Default.AutoFitWindow) { ConfigureWindows.CenterWindowOnScreen(); ConfigureWindows.GetMainWindow.SizeToContent = SizeToContent.WidthAndHeight; } }
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) }; } } }
internal static void LoadLayout() { if (UC.GetPicGallery == null) { UC.GetPicGallery = new Views.UserControls.PicGallery { Opacity = 0, Visibility = Visibility.Collapsed }; ConfigureWindows.GetMainWindow.ParentContainer.Children.Add(UC.GetPicGallery); Panel.SetZIndex(UC.GetPicGallery, 999); } if (GalleryNavigation.picGalleryItem_Size == 0) { SetSize(); } if (Properties.Settings.Default.FullscreenGallery == false) { if (Properties.Settings.Default.Fullscreen) { UC.GetPicGallery.Width = WindowSizing.MonitorInfo.Width; UC.GetPicGallery.Height = WindowSizing.MonitorInfo.Height; } else { UC.GetPicGallery.Width = ConfigureWindows.GetMainWindow.ParentContainer.ActualWidth; UC.GetPicGallery.Height = ConfigureWindows.GetMainWindow.ParentContainer.ActualHeight; } UC.GetPicGallery.HorizontalAlignment = HorizontalAlignment.Stretch; UC.GetPicGallery.Scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; UC.GetPicGallery.Scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; UC.GetPicGallery.x2.Visibility = Visibility.Visible; UC.GetPicGallery.Container.Margin = new Thickness(0, 65, 0, 0); } else { UC.GetPicGallery.Width = (GalleryNavigation.picGalleryItem_Size + 25) * WindowSizing.MonitorInfo.DpiScaling; UC.GetPicGallery.Height = WindowSizing.MonitorInfo.WorkArea.Height; ConfigureWindows.GetMainWindow.SizeToContent = SizeToContent.WidthAndHeight; ConfigureWindows.GetMainWindow.ResizeMode = ResizeMode.CanMinimize; ConfigureWindows.CenterWindowOnScreen(); UC.GetPicGallery.HorizontalAlignment = HorizontalAlignment.Right; UC.GetPicGallery.Scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; UC.GetPicGallery.Scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; UC.GetPicGallery.x2.Visibility = Visibility.Collapsed; UC.GetPicGallery.Container.Margin = new Thickness(0, 0, 0, 0); ShowNavigation(false); ShowTopandBottom(false); ConfigureSettings.ConfigColors.UpdateColor(true); } UC.GetPicGallery.Visibility = Visibility.Visible; UC.GetPicGallery.Opacity = 1; UC.GetPicGallery.Container.Orientation = Orientation.Vertical; IsOpen = true; }
public ToolsAndEffectsMenu() { InitializeComponent(); // ResizeButton ResizeButton.MouseEnter += delegate { ButtonMouseOverAnim(ResizeText); ButtonMouseOverAnim(ResizeFill); AnimationHelper.MouseEnterBgTexColor(ResizeButtonBrush); }; ResizeButton.MouseLeave += delegate { ButtonMouseLeaveAnim(ResizeText); ButtonMouseLeaveAnim(ResizeFill); AnimationHelper.MouseLeaveBgTexColor(ResizeButtonBrush); }; ResizeButton.Click += delegate { UC.Close_UserControls(); ConfigureWindows.ResizeAndOptimizeWindow(); }; // EffectsButton EffectsButton.MouseEnter += delegate { ButtonMouseOverAnim(EffectsText); ButtonMouseOverAnim(EffectsFill); AnimationHelper.MouseEnterBgTexColor(EffectsButtonBrush); }; EffectsButton.MouseLeave += delegate { ButtonMouseLeaveAnim(EffectsText); ButtonMouseLeaveAnim(EffectsFill); AnimationHelper.MouseLeaveBgTexColor(EffectsButtonBrush); }; EffectsButton.Click += delegate { UC.Close_UserControls(); ConfigureWindows.EffectsWindow(); }; // CropButton CropButton.PreviewMouseLeftButtonDown += delegate { PreviewMouseButtonDownAnim(CropButtonBrush); }; CropButton.MouseEnter += delegate { ButtonMouseOverAnim(CropText); ButtonMouseOverAnim(CropFill); AnimationHelper.MouseEnterBgTexColor(CropButtonBrush); }; CropButton.MouseLeave += delegate { ButtonMouseLeaveAnim(CropText); ButtonMouseLeaveAnim(CropFill); AnimationHelper.MouseLeaveBgTexColor(CropButtonBrush); }; CropButton.Click += delegate { UC.Close_UserControls(); CropFunctions.StartCrop(); }; // ColorPickerButton ColorPickerButton.PreviewMouseLeftButtonDown += delegate { PreviewMouseButtonDownAnim(ColorPickerBrush); }; ColorPickerButton.MouseEnter += delegate { ButtonMouseOverAnim(ColorPickerText); ButtonMouseOverAnim(ColorPickerFill); AnimationHelper.MouseEnterBgTexColor(ColorPickerBrush); }; ColorPickerButton.MouseLeave += delegate { ButtonMouseLeaveAnim(ColorPickerText); ButtonMouseLeaveAnim(ColorPickerFill); AnimationHelper.MouseLeaveBgTexColor(ColorPickerBrush); }; ColorPickerButton.Click += delegate { UC.Close_UserControls(); Color_Picking.IsRunning = true; Color_Picking.Start(); }; // ImageInfoButton ImageInfoButton.PreviewMouseLeftButtonDown += delegate { PreviewMouseButtonDownAnim(ImageInfoBrush); }; ImageInfoButton.MouseEnter += delegate { ButtonMouseOverAnim(ImageInfoText); ButtonMouseOverAnim(ImageInfoFill); AnimationHelper.MouseEnterBgTexColor(ImageInfoBrush); }; ImageInfoButton.MouseLeave += delegate { ButtonMouseLeaveAnim(ImageInfoText); ButtonMouseLeaveAnim(ImageInfoFill); AnimationHelper.MouseLeaveBgTexColor(ImageInfoBrush); }; ImageInfoButton.Click += delegate { UC.Close_UserControls(); ConfigureWindows.ImageInfoWindow(); }; }
public QuickSettingsMenu() { InitializeComponent(); ToggleScroll.IsChecked = Properties.Settings.Default.ScrollEnabled; ToggleScroll.Click += (s, x) => ConfigureSettings.UpdateUIValues.SetScrolling(Properties.Settings.Default.ScrollEnabled); SettingsButton.TheButton.Click += delegate { ConfigureWindows.AllSettingsWindow(); Close_UserControls(); }; InfoButton.TheButton.Click += delegate { Close_UserControls(); ConfigureWindows.InfoWindow(); }; ToggleFill.IsChecked = Properties.Settings.Default.FillImage; ToggleFill.Click += ConfigureSettings.UpdateUIValues.SetAutoFill; ToggleLooping.IsChecked = Properties.Settings.Default.Looping; ToggleLooping.Click += ConfigureSettings.UpdateUIValues.SetLooping; SetFit.IsChecked = Properties.Settings.Default.AutoFitWindow; SetFit.Click += ConfigureSettings.UpdateUIValues.SetAutoFit; ZoomButton.TheButton.Click += delegate { if (ZoomSliderParent.Visibility == Visibility.Collapsed || ZoomSliderParent.Opacity == 0) { ZoomSliderParent.Visibility = Visibility.Visible; AnimationHelper.Fade(ZoomSliderParent, 1, TimeSpan.FromSeconds(.4)); } else { AnimationHelper.Fade(ZoomSliderParent, 0, TimeSpan.FromSeconds(.3)); } }; ZoomSlider.ValueChanged += delegate { UILogic.TransformImage.ZoomLogic.Zoom(ZoomSlider.Value); }; #region Animation events // Toggle Scroll ToggleScroll.PreviewMouseLeftButtonDown += delegate { PreviewMouseButtonDownAnim(ToggleScrollFill); }; ToggleScroll.MouseEnter += delegate { ButtonMouseOverAnim(ToggleScrollFill); }; ToggleScroll.MouseEnter += delegate { AnimationHelper.MouseEnterBgTexColor(ToggleScrollBrush); }; ToggleScroll.MouseLeave += delegate { ButtonMouseLeaveAnim(ToggleScrollFill); }; ToggleScroll.MouseLeave += delegate { AnimationHelper.MouseLeaveBgTexColor(ToggleScrollBrush); }; // Toggle Loop ToggleLooping.PreviewMouseLeftButtonDown += delegate { PreviewMouseButtonDownAnim(ToggleLoopFill); }; ToggleLooping.MouseEnter += delegate { ButtonMouseOverAnim(ToggleLoopFill); }; ToggleLooping.MouseEnter += delegate { AnimationHelper.MouseEnterBgTexColor(ToggleLoopBrush); }; ToggleLooping.MouseLeave += delegate { ButtonMouseLeaveAnim(ToggleLoopFill); }; ToggleLooping.MouseLeave += delegate { AnimationHelper.MouseLeaveBgTexColor(ToggleLoopBrush); }; // Set Fit SetFit.PreviewMouseLeftButtonDown += delegate { PreviewMouseButtonDownAnim(SetFitFill); }; SetFit.MouseEnter += delegate { ButtonMouseOverAnim(SetFitFill); }; SetFit.MouseEnter += delegate { AnimationHelper.MouseEnterBgTexColor(SetFitBrush); }; SetFit.MouseLeave += delegate { ButtonMouseLeaveAnim(SetFitFill); }; SetFit.MouseLeave += delegate { AnimationHelper.MouseLeaveBgTexColor(SetFitBrush); }; // ToggleFill ToggleFill.PreviewMouseLeftButtonDown += delegate { PreviewMouseButtonDownAnim(ToggleFillFill); }; ToggleFill.MouseEnter += delegate { ButtonMouseOverAnim(ToggleFillFill); }; ToggleFill.MouseEnter += delegate { AnimationHelper.MouseEnterBgTexColor(ToggleFillBrush); }; ToggleFill.MouseLeave += delegate { ButtonMouseLeaveAnim(ToggleFillFill); }; ToggleFill.MouseLeave += delegate { AnimationHelper.MouseLeaveBgTexColor(ToggleFillBrush); }; #endregion Animation events }
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); } }