using System.Reactive; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Layout; using Avalonia.Media; using PicView.Avalonia.Clipboard; using PicView.Avalonia.Converters; using PicView.Avalonia.FileSystem; using PicView.Avalonia.Functions; using PicView.Avalonia.Gallery; using PicView.Avalonia.ImageTransformations.Rotation; using PicView.Avalonia.Interfaces; using PicView.Avalonia.LockScreen; using PicView.Avalonia.Navigation; using PicView.Avalonia.UI; using PicView.Avalonia.Wallpaper; using PicView.Avalonia.WindowBehavior; using PicView.Core.FileSorting; using PicView.Core.Gallery; using PicView.Core.ProcessHandling; using PicView.Core.Sizing; using PicView.Core.ViewModels; using ReactiveUI; using ImageViewer = PicView.Avalonia.Views.ImageViewer; namespace PicView.Avalonia.ViewModels; public class MainViewModel : ReactiveObject { public readonly IPlatformSpecificService? PlatformService; public readonly IPlatformWindowService? PlatformWindowService; public TranslationViewModel Translation { get; } = new(); public SettingsViewModel? SettingsViewModel { get; set; } public ImageCropperViewModel? Crop { get; set; } public PicViewerModel PicViewer { get; } = new(); public ExifViewModel Exif { get; } = new(); public FileAssociationsViewModel? AssociationsViewModel { get; set; } public MainViewModel(IPlatformSpecificService? platformSpecificService, IPlatformWindowService? platformWindowService) { FunctionsMapper.Vm = this; PlatformService = platformSpecificService; PlatformWindowService = platformWindowService; #region Window commands ExitCommand = FunctionsHelper.CreateReactiveCommand(WindowFunctions.Close); MinimizeCommand = FunctionsHelper.CreateReactiveCommand(WindowFunctions.Minimize); MaximizeCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Maximize); RestoreCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Restore); ToggleFullscreenCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleFullscreen); NewWindowCommand = FunctionsHelper.CreateReactiveCommand(ProcessHelper.StartNewProcess); ShowExifWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowExifWindow); ShowSettingsWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowSettingsWindow); ShowKeybindingsWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowKeybindingsWindow); ShowAboutWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowAboutWindow); ShowBatchResizeWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowBatchResizeWindow); ShowSingleImageResizeWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowSingleImageResizeWindow); ShowEffectsWindowCommand = FunctionsHelper.CreateReactiveCommand(PlatformWindowService.ShowEffectsWindow); #endregion Window commands #region Navigation Commands NextCommand = FunctionsHelper.CreateReactiveCommand(() => { Task.Run(FunctionsMapper.Next); }); NextButtonCommand = FunctionsHelper.CreateReactiveCommand(() => { UIHelper.NextButtonNavigation(this); }); NextArrowButtonCommand = FunctionsHelper.CreateReactiveCommand(() => { UIHelper.NextArrowButtonNavigation(this); }); NextFolderCommand = FunctionsHelper.CreateReactiveCommand(() => { Task.Run(FunctionsMapper.NextFolder); }); PreviousCommand = FunctionsHelper.CreateReactiveCommand(() => { Task.Run(FunctionsMapper.Prev); }); PreviousButtonCommand = FunctionsHelper.CreateReactiveCommand(() => { UIHelper.PreviousButtonNavigation(this); }); PreviousArrowButtonCommand = FunctionsHelper.CreateReactiveCommand(() => { UIHelper.PreviousArrowButtonNavigation(this); }); PreviousFolderCommand = FunctionsHelper.CreateReactiveCommand(() => { Task.Run(FunctionsMapper.PrevFolder); }); Skip10Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Next10); Skip100Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Next100); Prev10Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Prev10); Prev100Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Prev100); FirstCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.First); LastCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Last); ReloadCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Reload); #endregion Navigation Commands #region Sort Commands SortFilesByNameCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SortFilesByName); SortFilesByCreationTimeCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SortFilesByCreationTime); SortFilesByLastAccessTimeCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SortFilesByLastAccessTime); SortFilesBySizeCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SortFilesBySize); SortFilesByExtensionCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SortFilesByExtension); SortFilesRandomlyCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SortFilesRandomly); SortFilesAscendingCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SortFilesAscending); SortFilesDescendingCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SortFilesDescending); #endregion Sort Commands #region Menus CloseMenuCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.CloseMenus); ToggleFileMenuCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleFileMenu); ToggleImageMenuCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleImageMenu); ToggleSettingsMenuCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleSettingsMenu); ToggleToolsMenuCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleToolsMenu); #endregion Menus #region Image commands RotateLeftCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.RotateLeft); RotateLeftButtonCommand = FunctionsHelper.CreateReactiveCommand(async () => { await RotationNavigation.RotateLeft(this, RotationButton.RotateLeftButton); }); RotateRightCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.RotateRight); RotateRightButtonCommand = FunctionsHelper.CreateReactiveCommand(async () => { await RotationNavigation.RotateRight(this, RotationButton.RotateRightButton); }); RotateToCommand = FunctionsHelper.CreateReactiveCommand(RotateToTask); RotateRightWindowBorderButtonCommand = FunctionsHelper.CreateReactiveCommand(async () => { await RotationNavigation.RotateRight(this, RotationButton.WindowBorderButton); }); FlipCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Flip); StretchCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Stretch); CropCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Crop); ToggleScrollCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleScroll); OptimizeImageCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.OptimizeImage); ChangeBackgroundCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ChangeBackground); ShowSideBySideCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SideBySide); #endregion Image commands #region File commands OpenFileCommand = FunctionsHelper.CreateReactiveCommand(() => { Task.Run(FunctionsMapper.Open); }); OpenLastFileCommand = FunctionsHelper.CreateReactiveCommand(() => { Task.Run(FunctionsMapper.OpenLastFile); }); SaveFileCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Save); SaveFileAsCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SaveAs); CopyFileCommand = FunctionsHelper.CreateReactiveCommand(CopyFileTask); CopyFilePathCommand = FunctionsHelper.CreateReactiveCommand(CopyFilePathTask); FilePropertiesCommand = FunctionsHelper.CreateReactiveCommand(ShowFilePropertiesTask); CopyImageCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.CopyImage); CopyBase64Command = FunctionsHelper.CreateReactiveCommand(CopyBase64Task); CutCommand = FunctionsHelper.CreateReactiveCommand(CutFileTask); PasteCommand = FunctionsHelper.CreateReactiveCommand(() => { Task.Run(FunctionsMapper.Paste); }); OpenWithCommand = FunctionsHelper.CreateReactiveCommand(OpenWithTask); RenameCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Rename); ResizeCommand = FunctionsHelper.CreateReactiveCommand(ResizeImageByPercentage); ConvertCommand = FunctionsHelper.CreateReactiveCommand(ConvertFileExtension); DuplicateFileCommand = FunctionsHelper.CreateReactiveCommand(DuplicateFileTask); PrintCommand = FunctionsHelper.CreateReactiveCommand(PrintTask); DeleteFileCommand = FunctionsHelper.CreateReactiveCommand(DeleteFileTask); RecycleFileCommand = FunctionsHelper.CreateReactiveCommand(RecycleFileTask); LocateOnDiskCommand = FunctionsHelper.CreateReactiveCommand(LocateOnDiskTask); SetAsWallpaperCommand = FunctionsHelper.CreateReactiveCommand(SetAsWallpaperTask); SetAsWallpaperTiledCommand = FunctionsHelper.CreateReactiveCommand(SetAsWallpaperTiledTask); SetAsWallpaperStretchedCommand = FunctionsHelper.CreateReactiveCommand(SetAsWallpaperStretchedTask); SetAsWallpaperCenteredCommand = FunctionsHelper.CreateReactiveCommand(SetAsWallpaperCenteredTask); SetAsWallpaperFilledCommand = FunctionsHelper.CreateReactiveCommand(SetAsWallpaperFilledTask); SetAsLockScreenCommand = FunctionsHelper.CreateReactiveCommand(SetAsLockScreenTask); #endregion File commands #region EXIF commands SetExifRating0Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Set0Star); SetExifRating1Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Set1Star); SetExifRating2Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Set2Star); SetExifRating3Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Set3Star); SetExifRating4Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Set4Star); SetExifRating5Command = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Set5Star); OpenGoogleLinkCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.OpenGoogleMaps); OpenBingLinkCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.OpenBingMaps); #endregion EXIF commands #region Gallery Commands ToggleGalleryCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleGallery); ToggleBottomGalleryCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.OpenCloseBottomGallery); CloseGalleryCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.CloseGallery); GalleryItemStretchCommand = FunctionsHelper.CreateReactiveCommand(SetGalleryItemStretch); #endregion Gallery Commands #region UI Commands ToggleUICommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleInterface); ToggleBottomNavBarCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleBottomToolbar); ToggleBottomGalleryShownInHiddenUICommand = FunctionsHelper.CreateReactiveCommand(async () => { await HideInterfaceLogic.ToggleBottomGalleryShownInHiddenUI(this); }); ToggleFadeInButtonsOnHoverCommand = FunctionsHelper.CreateReactiveCommand(async () => { await HideInterfaceLogic.ToggleFadeInButtonsOnHover(this); }); ChangeCtrlZoomCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ChangeCtrlZoom); ColorPickerCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ColorPicker); SlideshowCommand = FunctionsHelper.CreateReactiveCommand(StartSlideShowTask); ToggleTaskbarProgressCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleTaskbarProgress); ToggleConstrainBackgroundColorCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleConstrainBackgroundColor); #endregion UI Commands #region Settings commands ChangeAutoFitCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.AutoFitWindow); ChangeTopMostCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.SetTopMost); ToggleSubdirectoriesCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleSubdirectories); ToggleLoopingCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleLooping); ResetSettingsCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ResetSettings); RestartCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Restart); ToggleUsingTouchpadCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleUsingTouchpad); ToggleOpeningInSameWindowCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ToggleOpeningInSameWindow); ShowSettingsFileCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ShowSettingsFile); ShowKeybindingsFileCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.ShowKeybindingsFile); #endregion Settings commands } public MainViewModel() { // Only use for unit test } #region Gallery public Thickness GalleryMargin { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsBottomGalleryShown { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsBottomGalleryShownInHiddenUI { get; set => this.RaiseAndSetIfChanged(ref field, value); } public GalleryMode GalleryMode { get; set => this.RaiseAndSetIfChanged(ref field, value); } = GalleryMode.Closed; public Stretch GalleryStretch { get; set => this.RaiseAndSetIfChanged(ref field, value); } public int SelectedGalleryItemIndex { get; set => this.RaiseAndSetIfChanged(ref field, value); } public VerticalAlignment GalleryVerticalAlignment { get; set => this.RaiseAndSetIfChanged(ref field, value); } = VerticalAlignment.Bottom; public Orientation GalleryOrientation { set => this.RaiseAndSetIfChanged(ref field, value); get; } public bool IsFullGalleryOpen { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double GalleryWidth { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double GalleryHeight { get { if (!Settings.Gallery.IsBottomGalleryShown || IsSingleImage || Slideshow.IsRunning) { return 0; } if (Settings.WindowProperties.Fullscreen) { return Settings.Gallery.IsBottomGalleryShown ? GetBottomGalleryItemHeight + (SizeDefaults.ScrollbarSize - 1) : 0; } if (!Settings.Gallery.ShowBottomGalleryInHiddenUI && !IsUIShown) { return 0; } return GetBottomGalleryItemHeight + (SizeDefaults.ScrollbarSize - 1); } } public double GetGalleryItemWidth { get; set => this.RaiseAndSetIfChanged(ref field, value); } = double.NaN; public double GetGalleryItemHeight { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double GetFullGalleryItemHeight { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double GetBottomGalleryItemHeight { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double MaxFullGalleryItemHeight { get => GalleryDefaults.MaxFullGalleryItemHeight; } public double MinFullGalleryItemHeight { get => GalleryDefaults.MinFullGalleryItemHeight; } public double MaxBottomGalleryItemHeight { get => GalleryDefaults.MaxBottomGalleryItemHeight; } public double MinBottomGalleryItemHeight { get => GalleryDefaults.MinBottomGalleryItemHeight; } public Thickness GalleryItemMargin { get; set => this.RaiseAndSetIfChanged(ref field, value); } #region Gallery Stretch IsChecked public bool IsUniformBottomChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsUniformFullChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsUniformMenuChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsUniformToFillBottomChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsUniformToFillFullChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsUniformToFillMenuChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsFillBottomChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsFillFullChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsFillMenuChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsNoneBottomChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsNoneFullChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsNoneMenuChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsSquareBottomChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsSquareFullChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsSquareMenuChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsFillSquareBottomChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsFillSquareFullChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsFillSquareMenuChecked { get; set => this.RaiseAndSetIfChanged(ref field, value); } #endregion #endregion Gallery #region Commands public ReactiveCommand? ExitCommand { get; } public ReactiveCommand? MinimizeCommand { get; } public ReactiveCommand? MaximizeCommand { get; } public ReactiveCommand? RestoreCommand { get; } public ReactiveCommand? ToggleFullscreenCommand { get; } public ReactiveCommand? NextCommand { get; } public ReactiveCommand? NextButtonCommand { get; } public ReactiveCommand? NextArrowButtonCommand { get; } public ReactiveCommand? PreviousCommand { get; } public ReactiveCommand? PreviousButtonCommand { get; } public ReactiveCommand? PreviousArrowButtonCommand { get; } public ReactiveCommand? NextFolderCommand { get; } public ReactiveCommand? PreviousFolderCommand { get; } public ReactiveCommand? FirstCommand { get; } public ReactiveCommand? LastCommand { get; } public ReactiveCommand? Skip10Command { get; } public ReactiveCommand? Prev10Command { get; } public ReactiveCommand? Skip100Command { get; } public ReactiveCommand? Prev100Command { get; } public ReactiveCommand? OpenFileCommand { get; } public ReactiveCommand? SaveFileCommand { get; } public ReactiveCommand? SaveFileAsCommand { get; } public ReactiveCommand? OpenLastFileCommand { get; } public ReactiveCommand? PasteCommand { get; } public ReactiveCommand? CopyFileCommand { get; } public ReactiveCommand? CopyBase64Command { get; } public ReactiveCommand? CopyFilePathCommand { get; } public ReactiveCommand? FilePropertiesCommand { get; } public ReactiveCommand? CopyImageCommand { get; } public ReactiveCommand? CutCommand { get; } public ReactiveCommand? ReloadCommand { get; } public ReactiveCommand? PrintCommand { get; } public ReactiveCommand? DeleteFileCommand { get; } public ReactiveCommand? RecycleFileCommand { get; } public ReactiveCommand? CloseMenuCommand { get; } public ReactiveCommand? ToggleFileMenuCommand { get; } public ReactiveCommand? ToggleImageMenuCommand { get; } public ReactiveCommand? ToggleSettingsMenuCommand { get; } public ReactiveCommand? ToggleToolsMenuCommand { get; } public ReactiveCommand? LocateOnDiskCommand { get; } public ReactiveCommand? OpenWithCommand { get; } public ReactiveCommand? RenameCommand { get; } public ReactiveCommand? NewWindowCommand { get; } public ReactiveCommand? DuplicateFileCommand { get; } public ReactiveCommand? ToggleLoopingCommand { get; } public ReactiveCommand? RotateLeftCommand { get; } public ReactiveCommand? RotateLeftButtonCommand { get; } public ReactiveCommand? RotateRightCommand { get; } public ReactiveCommand? RotateToCommand { get; } public ReactiveCommand? RotateRightButtonCommand { get; } public ReactiveCommand? RotateRightWindowBorderButtonCommand { get; } public ReactiveCommand? FlipCommand { get; } public ReactiveCommand? StretchCommand { get; } public ReactiveCommand? CropCommand { get; } public ReactiveCommand? ChangeAutoFitCommand { get; } public ReactiveCommand? ChangeTopMostCommand { get; } public ReactiveCommand? ChangeCtrlZoomCommand { get; } public ReactiveCommand? ToggleUsingTouchpadCommand { get; } public ReactiveCommand? ToggleUICommand { get; } public ReactiveCommand? ToggleOpeningInSameWindowCommand { get; } public ReactiveCommand? ChangeBackgroundCommand { get; } public ReactiveCommand? ToggleBottomNavBarCommand { get; } public ReactiveCommand? ToggleBottomGalleryShownInHiddenUICommand { get; } public ReactiveCommand? ToggleFadeInButtonsOnHoverCommand { get; } public ReactiveCommand? ToggleTaskbarProgressCommand { get; } public ReactiveCommand? ShowExifWindowCommand { get; } public ReactiveCommand? ShowAboutWindowCommand { get; } public ReactiveCommand? ShowSettingsWindowCommand { get; } public ReactiveCommand? ShowKeybindingsWindowCommand { get; } public ReactiveCommand? ShowBatchResizeWindowCommand { get; } public ReactiveCommand? ShowSingleImageResizeWindowCommand { get; } public ReactiveCommand? ShowEffectsWindowCommand { get; } public ReactiveCommand? SetExifRating0Command { get; } public ReactiveCommand? SetExifRating1Command { get; } public ReactiveCommand? SetExifRating2Command { get; } public ReactiveCommand? SetExifRating3Command { get; } public ReactiveCommand? SetExifRating4Command { get; } public ReactiveCommand? SetExifRating5Command { get; } public ReactiveCommand? OpenGoogleLinkCommand { get; } public ReactiveCommand? OpenBingLinkCommand { get; } public ReactiveCommand? OptimizeImageCommand { get; } public ReactiveCommand? ResizeCommand { get; } public ReactiveCommand? ConvertCommand { get; } public ReactiveCommand? SortFilesByNameCommand { get; } public ReactiveCommand? SortFilesBySizeCommand { get; } public ReactiveCommand? SortFilesByExtensionCommand { get; } public ReactiveCommand? SortFilesByCreationTimeCommand { get; } public ReactiveCommand? SortFilesByLastAccessTimeCommand { get; } public ReactiveCommand? SortFilesRandomlyCommand { get; } public ReactiveCommand? SortFilesAscendingCommand { get; } public ReactiveCommand? SortFilesDescendingCommand { get; } public ReactiveCommand? ToggleGalleryCommand { get; } public ReactiveCommand? ToggleBottomGalleryCommand { get; } public ReactiveCommand? CloseGalleryCommand { get; } public ReactiveCommand? ToggleScrollCommand { get; } public ReactiveCommand? ToggleSubdirectoriesCommand { get; } public ReactiveCommand? ColorPickerCommand { get; } public ReactiveCommand? SlideshowCommand { get; } public ReactiveCommand? SetAsWallpaperCommand { get; } public ReactiveCommand? SetAsWallpaperFilledCommand { get; } public ReactiveCommand? SetAsWallpaperStretchedCommand { get; } public ReactiveCommand? SetAsWallpaperTiledCommand { get; } public ReactiveCommand? SetAsWallpaperCenteredCommand { get; } public ReactiveCommand? SetAsLockScreenCommand { get; } public ReactiveCommand? GalleryItemStretchCommand { get; } public ReactiveCommand? ResetSettingsCommand { get; } public ReactiveCommand? ShowSideBySideCommand { get; } public ReactiveCommand? RestartCommand { get; } public ReactiveCommand? ShowSettingsFileCommand { get; } public ReactiveCommand? ShowKeybindingsFileCommand { get; } public ReactiveCommand? ToggleConstrainBackgroundColorCommand { get; } #endregion Commands #region Fields #region Sorting Order public SortFilesBy SortOrder { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsAscending { get; set => this.RaiseAndSetIfChanged(ref field, value); } #endregion Sorting Order #region Booleans public bool ShouldCropBeEnabled { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool ShouldOptimizeImageBeEnabled { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsAvoidingZoomingOut { get; set { Settings.Zoom.AvoidZoomingOut = value; this.RaiseAndSetIfChanged(ref field, value); } } public IImage? ChangeCtrlZoomImage { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsLoading { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsUIShown { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsTopToolbarShown { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsBottomToolbarShown { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsShowingTaskbarProgress { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsFullscreen { get; set { this.RaiseAndSetIfChanged(ref field, value); ShouldRestore = IsFullscreen || IsMaximized; ShouldMaximizeBeShown = !IsFullscreen && !IsMaximized; } } public bool IsMaximized { get; set { this.RaiseAndSetIfChanged(ref field, value); ShouldRestore = IsFullscreen || IsMaximized; ShouldMaximizeBeShown = !IsFullscreen && !IsMaximized; } } public bool ShouldRestore { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool ShouldMaximizeBeShown { get; set => this.RaiseAndSetIfChanged(ref field, value); } = true; public bool IsTopMost { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsConstrainingBackgroundColor { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsIncludingSubdirectories { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsScrollingEnabled { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsStretched { get; set { this.RaiseAndSetIfChanged(ref field, value); Settings.ImageScaling.StretchImage = value; WindowResizing.SetSize(this); } } public bool IsLooping { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsAutoFit { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsStayingCentered { get; set { this.RaiseAndSetIfChanged(ref field, value); Settings.WindowProperties.KeepCentered = value; } } public bool IsOpeningInSameWindow { get; set { this.RaiseAndSetIfChanged(ref field, value); Settings.UIProperties.OpenInSameWindow = value; } } public bool IsShowingConfirmationOnEsc { get; set { this.RaiseAndSetIfChanged(ref field, value); Settings.UIProperties.ShowConfirmationOnEsc = value; } } public bool IsEditableTitlebarOpen { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsUsingTouchpad { get; set { this.RaiseAndSetIfChanged(ref field, value); Settings.Zoom.IsUsingTouchPad = value; } } public bool IsSingleImage { get; set => this.RaiseAndSetIfChanged(ref field, value); } #endregion Booleans public Brush? ImageBackground { get; set => this.RaiseAndSetIfChanged(ref field, value); } public Brush? ConstrainedImageBackground { get; set => this.RaiseAndSetIfChanged(ref field, value); } public Thickness RightControlOffSetMargin { get; set => this.RaiseAndSetIfChanged(ref field, value); } public Thickness TopScreenMargin { get; set => this.RaiseAndSetIfChanged(ref field, value); } public Thickness BottomScreenMargin { get; set => this.RaiseAndSetIfChanged(ref field, value); } public CornerRadius BottomCornerRadius { get; set => this.RaiseAndSetIfChanged(ref field, value); } public int BackgroundChoice { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double WindowMinSize { get { return SizeDefaults.WindowMinSize; } } public double TitlebarHeight { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double BottombarHeight { get; set => this.RaiseAndSetIfChanged(ref field, value); } public UserControl? CurrentView { get; set => this.RaiseAndSetIfChanged(ref field, value); } public ImageViewer? ImageViewer; public uint EXIFRating { get; set => this.RaiseAndSetIfChanged(ref field, value); } public int GetIndex { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double GetSlideshowSpeed { get; set { var roundedValue = Math.Round(value, 2); this.RaiseAndSetIfChanged(ref field, roundedValue); Settings.UIProperties.SlideShowTimer = roundedValue; } } public double GetNavSpeed { get => Math.Round(field, 2); set { this.RaiseAndSetIfChanged(ref field, value); Settings.UIProperties.NavSpeed = value; } } public double GetZoomSpeed { get; set { var roundedValue = Math.Round(value, 2); this.RaiseAndSetIfChanged(ref field, roundedValue); Settings.Zoom.ZoomSpeed = roundedValue; } } #region Window Properties public SizeToContent SizeToContent { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool CanResize { get; set => this.RaiseAndSetIfChanged(ref field, value); } #endregion Window Properties #region Size public double TitleMaxWidth { get; set => this.RaiseAndSetIfChanged(ref field, value); } #endregion Size #region Zoom public double RotationAngle { get; set => this.RaiseAndSetIfChanged(ref field, value); } public double ZoomValue { get; set => this.RaiseAndSetIfChanged(ref field, value); } public ScrollBarVisibility ToggleScrollBarVisibility { get; set => this.RaiseAndSetIfChanged(ref field, value); } #endregion Zoom #region Menus public bool IsFileMenuVisible { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsImageMenuVisible { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsSettingsMenuVisible { get; set => this.RaiseAndSetIfChanged(ref field, value); } public bool IsToolsMenuVisible { get; set => this.RaiseAndSetIfChanged(ref field, value); } #endregion Menus #endregion Fields #region Methods #region Tasks private async Task ResizeImageByPercentage(int percentage) => await ConversionHelper.ResizeImageByPercentage(percentage, this).ConfigureAwait(false); private async Task ConvertFileExtension(int index) => await ConversionHelper.ConvertFileExtension(index, this).ConfigureAwait(false); private async Task CopyFileTask(string path) => await ClipboardFileOperations.CopyFileToClipboard(path, this).ConfigureAwait(false); private static async Task CopyFilePathTask(string path) => await ClipboardTextOperations.CopyTextToClipboard(path).ConfigureAwait(false); private async Task CopyBase64Task(string path) => await ClipboardImageOperations.CopyBase64ToClipboard(path, this).ConfigureAwait(false); private async Task CutFileTask(string path) => await ClipboardFileOperations.CutFile(path, this).ConfigureAwait(false); private async Task DeleteFileTask(string path) => await Task.Run(() => FileManager.DeleteFileWithOptionalDialog(false, path, PlatformService)).ConfigureAwait(false); private async Task RecycleFileTask(string path) => await Task.Run(() => FileManager.DeleteFileWithOptionalDialog(true, path, PlatformService)).ConfigureAwait(false); private async Task DuplicateFileTask(string path) => await ClipboardFileOperations.Duplicate(path, this).ConfigureAwait(false); private async Task ShowFilePropertiesTask(string path) => await FileManager.ShowFileProperties(path, this).ConfigureAwait(false); private async Task PrintTask(string path) => await FileManager.Print(path, this).ConfigureAwait(false); private async Task OpenWithTask(string path) => await FileManager.OpenWith(path, this).ConfigureAwait(false); private async Task LocateOnDiskTask(string path) => await FileManager.LocateOnDisk(path, this).ConfigureAwait(false); private async Task SetAsWallpaperTask(string path) => await SetAsWallpaperTask(path, WallpaperStyle.Fill).ConfigureAwait(false); private async Task SetAsWallpaperFilledTask(string path) => await SetAsWallpaperTask(path, WallpaperStyle.Fill).ConfigureAwait(false); private async Task SetAsWallpaperFittedTask(string path) => await SetAsWallpaperTask(path, WallpaperStyle.Fit).ConfigureAwait(false); private async Task SetAsWallpaperTiledTask(string path) => await SetAsWallpaperTask(path, WallpaperStyle.Tile).ConfigureAwait(false); private async Task SetAsWallpaperStretchedTask(string path) => await SetAsWallpaperTask(path, WallpaperStyle.Stretch).ConfigureAwait(false); private async Task SetAsWallpaperCenteredTask(string path) => await SetAsWallpaperTask(path, WallpaperStyle.Center).ConfigureAwait(false); private async Task SetAsWallpaperTask(string path, WallpaperStyle style) => await WallpaperManager.SetAsWallpaper(path, style, this).ConfigureAwait(false); private async Task SetAsLockScreenTask(string path) => await LockScreenHelper.SetAsLockScreenTask(path, this).ConfigureAwait(false); private void SetGalleryItemStretch(string value) => GalleryHelper.SetGalleryItemStretch(value, this); public async Task StartSlideShowTask(int milliseconds) => await Slideshow.StartSlideshow(this, milliseconds); public async Task RotateToTask(string angle) { if (int.TryParse(angle, out var result)) { await RotationNavigation.RotateTo(this, result); } } #endregion #endregion Methods }