using System.Diagnostics; using System.Reactive; using System.Reactive.Linq; 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.Gallery; using PicView.Avalonia.ImageHandling; using PicView.Avalonia.ImageTransformations; using PicView.Avalonia.Interfaces; using PicView.Avalonia.Navigation; using PicView.Avalonia.UI; using PicView.Avalonia.Wallpaper; using PicView.Avalonia.WindowBehavior; using PicView.Core.Calculations; using PicView.Core.Config; using PicView.Core.FileHandling; using PicView.Core.Gallery; using PicView.Core.Localization; using PicView.Core.ProcessHandling; using ReactiveUI; using ImageViewer = PicView.Avalonia.Views.ImageViewer; namespace PicView.Avalonia.ViewModels; public class MainViewModel : ViewModelBase { public readonly IPlatformSpecificService? PlatformService; #region Image private object? _imageSource; public object? ImageSource { get => _imageSource; set => this.RaiseAndSetIfChanged(ref _imageSource, value); } private object? _secondaryImageSource; public object? SecondaryImageSource { get => _secondaryImageSource; set => this.RaiseAndSetIfChanged(ref _secondaryImageSource, value); } private ImageType _imageType; public ImageType ImageType { get => _imageType; set => this.RaiseAndSetIfChanged(ref _imageType, value); } private double _imageWidth; public double ImageWidth { get => _imageWidth; set => this.RaiseAndSetIfChanged(ref _imageWidth, value); } private double _imageHeight; public double ImageHeight { get => _imageHeight; set => this.RaiseAndSetIfChanged(ref _imageHeight, value); } private double _imageSecondaryWidth; public double SecondaryImageWidth { get => _imageSecondaryWidth; set => this.RaiseAndSetIfChanged(ref _imageSecondaryWidth, value); } private Brush? _imageBackground; public Brush? ImageBackground { get => _imageBackground; set => this.RaiseAndSetIfChanged(ref _imageBackground, value); } private bool _isShowingSideBySide = SettingsHelper.Settings.ImageScaling.ShowImageSideBySide; public bool IsShowingSideBySide { get => _isShowingSideBySide; set => this.RaiseAndSetIfChanged(ref _isShowingSideBySide, value); } private double _scrollViewerWidth = double.NaN; public double ScrollViewerWidth { get => _scrollViewerWidth; set => this.RaiseAndSetIfChanged(ref _scrollViewerWidth, value); } private double _scrollViewerHeight = double.NaN; public double ScrollViewerHeight { get => _scrollViewerHeight; set => this.RaiseAndSetIfChanged(ref _scrollViewerHeight, value); } #endregion #region Gallery private Thickness _galleryMargin; public Thickness GalleryMargin { get => _galleryMargin; set => this.RaiseAndSetIfChanged(ref _galleryMargin, value); } private bool _isGalleryShown = SettingsHelper.Settings.UIProperties.ShowInterface && SettingsHelper.Settings.Gallery.IsBottomGalleryShown; public bool IsGalleryShown { get => _isGalleryShown; set => this.RaiseAndSetIfChanged(ref _isGalleryShown, value); } private bool _isBottomGalleryShownInHiddenUi = SettingsHelper.Settings.Gallery.ShowBottomGalleryInHiddenUI; public bool IsBottomGalleryShownInHiddenUI { get => _isBottomGalleryShownInHiddenUi; set => this.RaiseAndSetIfChanged(ref _isBottomGalleryShownInHiddenUi, value); } private GalleryMode _galleryMode = GalleryMode.Closed; public GalleryMode GalleryMode { get => _galleryMode; set => this.RaiseAndSetIfChanged(ref _galleryMode, value); } private Stretch _galleryStretch; public Stretch GalleryStretch { get => _galleryStretch; set => this.RaiseAndSetIfChanged(ref _galleryStretch, value); } private int _selectedGalleryItemIndex; public int SelectedGalleryItemIndex { get => _selectedGalleryItemIndex; set => this.RaiseAndSetIfChanged(ref _selectedGalleryItemIndex, value); } private VerticalAlignment _galleryVerticalAlignment = VerticalAlignment.Bottom; public VerticalAlignment GalleryVerticalAlignment { get => _galleryVerticalAlignment; set => this.RaiseAndSetIfChanged(ref _galleryVerticalAlignment, value); } private Orientation _galleryOrientation; public Orientation GalleryOrientation { set => this.RaiseAndSetIfChanged(ref _galleryOrientation, value); get => _galleryOrientation; } private bool _isGalleryCloseIconVisible; public bool IsGalleryCloseIconVisible { get => _isGalleryCloseIconVisible; set => this.RaiseAndSetIfChanged(ref _isGalleryCloseIconVisible, value); } private double _galleryWidth; public double GalleryWidth { get => _galleryWidth; set => this.RaiseAndSetIfChanged(ref _galleryWidth, value); } public double GalleryHeight { get { if (!SettingsHelper.Settings.Gallery.IsBottomGalleryShown) { return 0; } if (SettingsHelper.Settings.WindowProperties.Fullscreen) { return SettingsHelper.Settings.Gallery.IsBottomGalleryShown ? GetBottomGalleryItemHeight + SizeDefaults.ScrollbarSize : 0; } if (!SettingsHelper.Settings.Gallery.ShowBottomGalleryInHiddenUI && !IsUIShown) { return 0; } return GetBottomGalleryItemHeight + SizeDefaults.ScrollbarSize; } } private double _getGalleryItemWidth = double.NaN; public double GetGalleryItemWidth { get => _getGalleryItemWidth; set => this.RaiseAndSetIfChanged(ref _getGalleryItemWidth, value); } private double _getGalleryItemHeight; public double GetGalleryItemHeight { get => _getGalleryItemHeight; set => this.RaiseAndSetIfChanged(ref _getGalleryItemHeight, value); } private double _getFullGalleryItemHeight = SettingsHelper.Settings.Gallery.ExpandedGalleryItemSize; public double GetFullGalleryItemHeight { get => _getFullGalleryItemHeight; set => this.RaiseAndSetIfChanged(ref _getFullGalleryItemHeight, value); } private double _getBottomGalleryItemHeight = SettingsHelper.Settings.Gallery.BottomGalleryItemSize; public double GetBottomGalleryItemHeight { get => _getBottomGalleryItemHeight; set => this.RaiseAndSetIfChanged(ref _getBottomGalleryItemHeight, 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; } private Thickness _galleryItemMargin; public Thickness GalleryItemMargin { get => _galleryItemMargin; set => this.RaiseAndSetIfChanged(ref _galleryItemMargin, value); } #region Gallery Stretch IsChecked private bool _isUniformBottomChecked; public bool IsUniformBottomChecked { get => _isUniformBottomChecked; set => this.RaiseAndSetIfChanged(ref _isUniformBottomChecked, value); } private bool _isUniformFullChecked; public bool IsUniformFullChecked { get => _isUniformFullChecked; set => this.RaiseAndSetIfChanged(ref _isUniformFullChecked, value); } private bool _isUniformMenuChecked; public bool IsUniformMenuChecked { get => _isUniformMenuChecked; set => this.RaiseAndSetIfChanged(ref _isUniformMenuChecked, value); } private bool _isUniformToFillBottomChecked; public bool IsUniformToFillBottomChecked { get => _isUniformToFillBottomChecked; set => this.RaiseAndSetIfChanged(ref _isUniformToFillBottomChecked, value); } private bool _isUniformToFillFullChecked; public bool IsUniformToFillFullChecked { get => _isUniformToFillFullChecked; set => this.RaiseAndSetIfChanged(ref _isUniformToFillFullChecked, value); } private bool _isUniformToFillMenuMenuChecked; public bool IsUniformToFillMenuChecked { get => _isUniformToFillMenuMenuChecked; set => this.RaiseAndSetIfChanged(ref _isUniformToFillMenuMenuChecked, value); } private bool _isFillBottomChecked; public bool IsFillBottomChecked { get => _isFillBottomChecked; set => this.RaiseAndSetIfChanged(ref _isFillBottomChecked, value); } private bool _isFillFullChecked; public bool IsFillFullChecked { get => _isFillFullChecked; set => this.RaiseAndSetIfChanged(ref _isFillFullChecked, value); } private bool _isFillMenuMenuChecked; public bool IsFillMenuChecked { get => _isFillMenuMenuChecked; set => this.RaiseAndSetIfChanged(ref _isFillMenuMenuChecked, value); } private bool _isNoneBottomChecked; public bool IsNoneBottomChecked { get => _isNoneBottomChecked; set => this.RaiseAndSetIfChanged(ref _isNoneBottomChecked, value); } private bool _isNoneFullChecked; public bool IsNoneFullChecked { get => _isNoneFullChecked; set => this.RaiseAndSetIfChanged(ref _isNoneFullChecked, value); } private bool _isNoneMenuChecked; public bool IsNoneMenuChecked { get => _isNoneMenuChecked; set => this.RaiseAndSetIfChanged(ref _isNoneMenuChecked, value); } private bool _isSquareBottomChecked; public bool IsSquareBottomChecked { get => _isSquareBottomChecked; set => this.RaiseAndSetIfChanged(ref _isSquareBottomChecked, value); } private bool _isSquareFullChecked; public bool IsSquareFullChecked { get => _isSquareFullChecked; set => this.RaiseAndSetIfChanged(ref _isSquareFullChecked, value); } private bool _isSquareMenuChecked; public bool IsSquareMenuChecked { get => _isSquareMenuChecked; set => this.RaiseAndSetIfChanged(ref _isSquareMenuChecked, value); } private bool _isFillSquareBottomChecked; public bool IsFillSquareBottomChecked { get => _isFillSquareBottomChecked; set => this.RaiseAndSetIfChanged(ref _isFillSquareBottomChecked, value); } private bool _isFillSquareFullChecked; public bool IsFillSquareFullChecked { get => _isFillSquareFullChecked; set => this.RaiseAndSetIfChanged(ref _isFillSquareFullChecked, value); } private bool _isFillSquareMenuChecked; public bool IsFillSquareMenuChecked { get => _isFillSquareMenuChecked; set => this.RaiseAndSetIfChanged(ref _isFillSquareMenuChecked, value); } #endregion #endregion Gallery #region Commands public ReactiveCommand? ExitCommand { get; } public ReactiveCommand? MinimizeCommand { get; } public ReactiveCommand? MaximizeCommand { 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? OpenFileCommand { get; } public ReactiveCommand? SaveFileCommand { 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? 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? ToggleUICommand { get; } public ReactiveCommand? ChangeBackgroundCommand { get; } public ReactiveCommand? ToggleBottomNavBarCommand { get; } public ReactiveCommand? ToggleBottomGalleryShownInHiddenUICommand { 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? 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; } #endregion Commands #region Fields #region Booleans private bool _isAvoidingZoomingOut = SettingsHelper.Settings.Zoom.AvoidZoomingOut; public bool IsAvoidingZoomingOut { get => _isAvoidingZoomingOut; set { SettingsHelper.Settings.Zoom.AvoidZoomingOut = value; this.RaiseAndSetIfChanged(ref _isAvoidingZoomingOut, value); } } private IImage? _changeCtrlZoomImage; public IImage? ChangeCtrlZoomImage { get => _changeCtrlZoomImage; set => this.RaiseAndSetIfChanged(ref _changeCtrlZoomImage, value); } private bool _isLoading; public bool IsLoading { get => _isLoading; set => this.RaiseAndSetIfChanged(ref _isLoading, value); } private bool _isUIShown = SettingsHelper.Settings.UIProperties.ShowInterface; public bool IsUIShown { get => _isUIShown; set => this.RaiseAndSetIfChanged(ref _isUIShown, value); } private bool _isTopToolbarShown = SettingsHelper.Settings.UIProperties.ShowInterface; public bool IsTopToolbarShown { get => _isTopToolbarShown; set => this.RaiseAndSetIfChanged(ref _isTopToolbarShown, value); } private bool _isBottomToolbarShown = SettingsHelper.Settings.UIProperties.ShowBottomNavBar && SettingsHelper.Settings.UIProperties.ShowInterface; public bool IsBottomToolbarShown { get => _isBottomToolbarShown; set => this.RaiseAndSetIfChanged(ref _isBottomToolbarShown, value); } private bool _isBottomToolbarShownSetting = SettingsHelper.Settings.UIProperties.ShowBottomNavBar; public bool IsBottomToolbarShownSetting { get => _isBottomToolbarShownSetting; set => this.RaiseAndSetIfChanged(ref _isBottomToolbarShownSetting, value); } private bool _isShowingTaskbarProgress = SettingsHelper.Settings.UIProperties.IsTaskbarProgressEnabled; public bool IsShowingTaskbarProgress { get => _isShowingTaskbarProgress; set => this.RaiseAndSetIfChanged(ref _isShowingTaskbarProgress, value); } private bool _isFullscreen = SettingsHelper.Settings.WindowProperties.Fullscreen; public bool IsFullscreen { get => _isFullscreen; set => this.RaiseAndSetIfChanged(ref _isFullscreen, value); } private bool _isTopMost = SettingsHelper.Settings.WindowProperties.TopMost; public bool IsTopMost { get => _isTopMost; set => this.RaiseAndSetIfChanged(ref _isTopMost, value); } private bool _isIncludingSubdirectories = SettingsHelper.Settings.Sorting.IncludeSubDirectories; public bool IsIncludingSubdirectories { get => _isIncludingSubdirectories; set => this.RaiseAndSetIfChanged(ref _isIncludingSubdirectories, value); } private bool _isScrollingEnabled; public bool IsScrollingEnabled { get => _isScrollingEnabled; set => this.RaiseAndSetIfChanged(ref _isScrollingEnabled, value); } private bool _isStretched = SettingsHelper.Settings.ImageScaling.StretchImage; public bool IsStretched { get => _isStretched; set { this.RaiseAndSetIfChanged(ref _isStretched, value); SettingsHelper.Settings.ImageScaling.StretchImage = value; WindowResizing.SetSize(this); } } private bool _isLooping = SettingsHelper.Settings.UIProperties.Looping; public bool IsLooping { get => _isLooping; set => this.RaiseAndSetIfChanged(ref _isLooping, value); } private bool _isAutoFit = SettingsHelper.Settings.WindowProperties.AutoFit; public bool IsAutoFit { get => _isAutoFit; set => this.RaiseAndSetIfChanged(ref _isAutoFit, value); } private bool _isStayingCentered = SettingsHelper.Settings.WindowProperties.KeepCentered; public bool IsStayingCentered { get => _isStayingCentered; set { this.RaiseAndSetIfChanged(ref _isStayingCentered, value); SettingsHelper.Settings.WindowProperties.KeepCentered = value; } } private bool _isFileSavingDialogShown = SettingsHelper.Settings.UIProperties.ShowFileSavingDialog; public bool IsFileSavingDialogShown { get => _isFileSavingDialogShown; set { this.RaiseAndSetIfChanged(ref _isFileSavingDialogShown, value); SettingsHelper.Settings.UIProperties.ShowFileSavingDialog = value; } } private bool _isOpeningInSameWindow = SettingsHelper.Settings.UIProperties.OpenInSameWindow; public bool IsOpeningInSameWindow { get => _isOpeningInSameWindow; set { this.RaiseAndSetIfChanged(ref _isOpeningInSameWindow, value); SettingsHelper.Settings.UIProperties.OpenInSameWindow = value; } } private bool _isEditableTitlebarOpen; public bool IsEditableTitlebarOpen { get => _isEditableTitlebarOpen; set => this.RaiseAndSetIfChanged(ref _isEditableTitlebarOpen, value); } #endregion Booleans public double WindowMinSize { get { return SizeDefaults.WindowMinSize; } } private double _titlebarHeight = SettingsHelper.Settings.WindowProperties.Fullscreen || !SettingsHelper.Settings.UIProperties.ShowInterface ? 0 : SizeDefaults.TitlebarHeight; public double TitlebarHeight { set => this.RaiseAndSetIfChanged(ref _titlebarHeight, value); get => _titlebarHeight; } private double _bottombarHeight = SettingsHelper.Settings.WindowProperties.Fullscreen || !SettingsHelper.Settings.UIProperties.ShowInterface ? 0 : SizeDefaults.BottombarHeight; public double BottombarHeight { set => this.RaiseAndSetIfChanged(ref _bottombarHeight, value); get => _bottombarHeight; } private int _scaleX = 1; // Used to flip the flip button public int ScaleX { get => _scaleX; set => this.RaiseAndSetIfChanged(ref _scaleX, value); } private UserControl? _currentView; public UserControl? CurrentView { get => _currentView; set => this.RaiseAndSetIfChanged(ref _currentView, value); } public ImageViewer? ImageViewer; private uint _exifRating; public uint EXIFRating { get => _exifRating; set => this.RaiseAndSetIfChanged(ref _exifRating, value); } private int _getIndex; public int GetIndex { get => _getIndex; set => this.RaiseAndSetIfChanged(ref _getIndex, value); } private double _getSlideshowSpeed = SettingsHelper.Settings.UIProperties.SlideShowTimer; public double GetSlideshowSpeed { get => _getSlideshowSpeed; set { var roundedValue = Math.Round(value, 2); this.RaiseAndSetIfChanged(ref _getSlideshowSpeed, roundedValue); SettingsHelper.Settings.UIProperties.SlideShowTimer = roundedValue; } } private double _getNavSpeed = SettingsHelper.Settings.UIProperties.NavSpeed; public double GetNavSpeed { get => Math.Round(_getNavSpeed, 2); set { this.RaiseAndSetIfChanged(ref _getNavSpeed, value); SettingsHelper.Settings.UIProperties.NavSpeed = value; } } private double _getZoomSpeed = SettingsHelper.Settings.Zoom.ZoomSpeed; public double GetZoomSpeed { get => _getZoomSpeed; set { var roundedValue = Math.Round(value, 2); this.RaiseAndSetIfChanged(ref _getZoomSpeed, roundedValue); SettingsHelper.Settings.Zoom.ZoomSpeed = roundedValue; } } #region strings private string? _getIsShowingUITranslation; public string? GetIsShowingUITranslation { get => _getIsShowingUITranslation; set => this.RaiseAndSetIfChanged(ref _getIsShowingUITranslation, value); } private string? _getIsShowingBottomToolbarTranslation; public string? GetIsShowingBottomToolbarTranslation { get => _getIsShowingBottomToolbarTranslation; set => this.RaiseAndSetIfChanged(ref _getIsShowingBottomToolbarTranslation, value); } private string? _getIsFlipped; public string? GetIsFlippedTranslation { get => ScaleX == -1 ? UnFlip : Flip; set => this.RaiseAndSetIfChanged(ref _getIsFlipped, value); } private string? _getIsShowingBottomGalleryTranslation; public string? GetIsShowingBottomGalleryTranslation { get => _getIsShowingBottomGalleryTranslation; set => this.RaiseAndSetIfChanged(ref _getIsShowingBottomGalleryTranslation, value); } private string? _getIsLoopingTranslation; public string? GetIsLoopingTranslation { get => _getIsLoopingTranslation; set => this.RaiseAndSetIfChanged(ref _getIsLoopingTranslation, value); } private string? _getIsScrollingTranslation; public string? GetIsScrollingTranslation { get => _getIsScrollingTranslation; set => this.RaiseAndSetIfChanged(ref _getIsScrollingTranslation, value); } private string? _getIsCtrlZoomTranslation; public string? GetIsCtrlZoomTranslation { get => _getIsCtrlZoomTranslation; set => this.RaiseAndSetIfChanged(ref _getIsCtrlZoomTranslation, value); } private string? _getPrintSizeInch; public string? GetPrintSizeInch { get => _getPrintSizeInch; set => this.RaiseAndSetIfChanged(ref _getPrintSizeInch, value); } private string? _getPrintSizeCm; public string? GetPrintSizeCm { get => _getPrintSizeCm; set => this.RaiseAndSetIfChanged(ref _getPrintSizeCm, value); } private string? _getSizeMp; public string? GetSizeMp { get => _getSizeMp; set => this.RaiseAndSetIfChanged(ref _getSizeMp, value); } private string? _getResolution; public string? GetResolution { get => _getResolution; set => this.RaiseAndSetIfChanged(ref _getResolution, value); } private string? _getBitDepth; public string? GetBitDepth { get => _getBitDepth; set => this.RaiseAndSetIfChanged(ref _getBitDepth, value); } private string? _getAspectRatio; public string? GetAspectRatio { get => _getAspectRatio; set => this.RaiseAndSetIfChanged(ref _getAspectRatio, value); } private string? _getLatitude; public string? GetLatitude { get => _getLatitude; set => this.RaiseAndSetIfChanged(ref _getLatitude, value); } private string? _getLongitude; public string? GetLongitude { get => _getLongitude; set => this.RaiseAndSetIfChanged(ref _getLongitude, value); } private string? _getAltitude; public string? GetAltitude { get => _getAltitude; set => this.RaiseAndSetIfChanged(ref _getAltitude, value); } private string? _googleLink; public string? GoogleLink { get => _googleLink; set => this.RaiseAndSetIfChanged(ref _googleLink, value); } private string? _bingLink; public string? BingLink { get => _bingLink; set => this.RaiseAndSetIfChanged(ref _bingLink, value); } private string? _getAuthors; public string? GetAuthors { get => _getAuthors; set => this.RaiseAndSetIfChanged(ref _getAuthors, value); } private string? _getDateTaken; public string? GetDateTaken { get => _getDateTaken; set => this.RaiseAndSetIfChanged(ref _getDateTaken, value); } private string? _getCopyright; public string? GetCopyright { get => _getCopyright; set => this.RaiseAndSetIfChanged(ref _getCopyright, value); } private string? _getTitle; public string? GetTitle { get => _getTitle; set => this.RaiseAndSetIfChanged(ref _getTitle, value); } private string? _getSubject; public string? GetSubject { get => _getSubject; set => this.RaiseAndSetIfChanged(ref _getSubject, value); } private string? _getSoftware; public string? GetSoftware { get => _getSoftware; set => this.RaiseAndSetIfChanged(ref _getSoftware, value); } private string? _getResolutionUnit; public string? GetResolutionUnit { get => _getResolutionUnit; set => this.RaiseAndSetIfChanged(ref _getResolutionUnit, value); } private string? _getColorRepresentation; public string? GetColorRepresentation { get => _getColorRepresentation; set => this.RaiseAndSetIfChanged(ref _getColorRepresentation, value); } private string? _getCompression; public string? GetCompression { get => _getCompression; set => this.RaiseAndSetIfChanged(ref _getCompression, value); } private string? _getCompressedBitsPixel; public string? GetCompressedBitsPixel { get => _getCompressedBitsPixel; set => this.RaiseAndSetIfChanged(ref _getCompressedBitsPixel, value); } private string? _getCameraMaker; public string? GetCameraMaker { get => _getCameraMaker; set => this.RaiseAndSetIfChanged(ref _getCameraMaker, value); } private string? _getCameraModel; public string? GetCameraModel { get => _getCameraModel; set => this.RaiseAndSetIfChanged(ref _getCameraModel, value); } private string? _GetExposureProgram; public string? GetExposureProgram { get => _GetExposureProgram; set => this.RaiseAndSetIfChanged(ref _GetExposureProgram, value); } private string? _getExposureTime; public string? GetExposureTime { get => _getExposureTime; set => this.RaiseAndSetIfChanged(ref _getExposureTime, value); } private string? _GetExposureBias; public string? GetExposureBias { get => _GetExposureBias; set => this.RaiseAndSetIfChanged(ref _GetExposureBias, value); } private string? _GetFNumber; public string? GetFNumber { get => _GetFNumber; set => this.RaiseAndSetIfChanged(ref _GetFNumber, value); } private string? _getMaxAperture; public string? GetMaxAperture { get => _getMaxAperture; set => this.RaiseAndSetIfChanged(ref _getMaxAperture, value); } private string? _getDigitalZoom; public string? GetDigitalZoom { get => _getDigitalZoom; set => this.RaiseAndSetIfChanged(ref _getDigitalZoom, value); } private string? _getFocalLength35Mm; public string? GetFocalLength35Mm { get => _getFocalLength35Mm; set => this.RaiseAndSetIfChanged(ref _getFocalLength35Mm, value); } private string? _getFocalLength; public string? GetFocalLength { get => _getFocalLength; set => this.RaiseAndSetIfChanged(ref _getFocalLength, value); } private string? _getISOSpeed; public string? GetISOSpeed { get => _getISOSpeed; set => this.RaiseAndSetIfChanged(ref _getISOSpeed, value); } private string? _getMeteringMode; public string? GetMeteringMode { get => _getMeteringMode; set => this.RaiseAndSetIfChanged(ref _getMeteringMode, value); } private string? _getContrast; public string? GetContrast { get => _getContrast; set => this.RaiseAndSetIfChanged(ref _getContrast, value); } private string? _getSaturation; public string? GetSaturation { get => _getSaturation; set => this.RaiseAndSetIfChanged(ref _getSaturation, value); } private string? _getSharpness; public string? GetSharpness { get => _getSharpness; set => this.RaiseAndSetIfChanged(ref _getSharpness, value); } private string? _getWhiteBalance; public string? GetWhiteBalance { get => _getWhiteBalance; set => this.RaiseAndSetIfChanged(ref _getWhiteBalance, value); } private string? _getFlashMode; public string? GetFlashMode { get => _getFlashMode; set => this.RaiseAndSetIfChanged(ref _getFlashMode, value); } private string? _getFlashEnergy; public string? GetFlashEnergy { get => _getFlashEnergy; set => this.RaiseAndSetIfChanged(ref _getFlashEnergy, value); } private string? _getLightSource; public string? GetLightSource { get => _getLightSource; set => this.RaiseAndSetIfChanged(ref _getLightSource, value); } private string? _getBrightness; public string? GetBrightness { get => _getBrightness; set => this.RaiseAndSetIfChanged(ref _getBrightness, value); } private string? _getPhotometricInterpretation; public string? GetPhotometricInterpretation { get => _getPhotometricInterpretation; set => this.RaiseAndSetIfChanged(ref _getPhotometricInterpretation, value); } private string? _getOrientation; public string? GetOrientation { get => _getOrientation; set => this.RaiseAndSetIfChanged(ref _getOrientation, value); } private string? _getExifVersion; public string? GetExifVersion { get => _getExifVersion; set => this.RaiseAndSetIfChanged(ref _getExifVersion, value); } private string? _GetLensModel; public string? GetLensModel { get => _GetLensModel; set => this.RaiseAndSetIfChanged(ref _GetLensModel, value); } private string? _getLensMaker; public string? GetLensMaker { get => _getLensMaker; set => this.RaiseAndSetIfChanged(ref _getLensMaker, value); } #endregion strings #region Window Properties private string? _title = "Loading..."; public string? Title { get => _title; set => this.RaiseAndSetIfChanged(ref _title, value); } private string? _titleTooltip = "Loading..."; public string? TitleTooltip { get => _titleTooltip; set => this.RaiseAndSetIfChanged(ref _titleTooltip, value); } private string? _windowTitle = "PicView"; public string? WindowTitle { get => _windowTitle; set => this.RaiseAndSetIfChanged(ref _windowTitle, value); } private SizeToContent _sizeToContent; public SizeToContent SizeToContent { get => _sizeToContent; set => this.RaiseAndSetIfChanged(ref _sizeToContent, value); } private bool _canResize; public bool CanResize { get => _canResize; set => this.RaiseAndSetIfChanged(ref _canResize, value); } private bool _isRotationAnimationEnabled; public bool IsRotationAnimationEnabled { get => _isRotationAnimationEnabled; set => this.RaiseAndSetIfChanged(ref _isRotationAnimationEnabled, value); } #endregion Window Properties #region Size private double _titleMaxWidth; public double TitleMaxWidth { get => _titleMaxWidth; set => this.RaiseAndSetIfChanged(ref _titleMaxWidth, value); } #endregion Size #region Zoom private double _rotationAngle; public double RotationAngle { get => _rotationAngle; set => this.RaiseAndSetIfChanged(ref _rotationAngle, value); } private double _zoomValue; public double ZoomValue { get => _zoomValue; set => this.RaiseAndSetIfChanged(ref _zoomValue, value); } private ScrollBarVisibility _toggleScrollBarVisibility; public ScrollBarVisibility ToggleScrollBarVisibility { get => _toggleScrollBarVisibility; set => this.RaiseAndSetIfChanged(ref _toggleScrollBarVisibility, value); } #endregion Zoom #region Menus private bool _isFileMenuVisible; public bool IsFileMenuVisible { get => _isFileMenuVisible; set => this.RaiseAndSetIfChanged(ref _isFileMenuVisible, value); } private bool _isImageMenuVisible; public bool IsImageMenuVisible { get => _isImageMenuVisible; set => this.RaiseAndSetIfChanged(ref _isImageMenuVisible, value); } private bool _isSettingsMenuVisible; public bool IsSettingsMenuVisible { get => _isSettingsMenuVisible; set => this.RaiseAndSetIfChanged(ref _isSettingsMenuVisible, value); } private bool _isToolsMenuVisible; public bool IsToolsMenuVisible { get => _isToolsMenuVisible; set => this.RaiseAndSetIfChanged(ref _isToolsMenuVisible, value); } #endregion Menus #endregion Fields #region Services public ImageIterator? ImageIterator; #endregion Services #region Methods #region Sorting Order private FileListHelper.SortFilesBy _sortOrder; public FileListHelper.SortFilesBy SortOrder { get => _sortOrder; set => this.RaiseAndSetIfChanged(ref _sortOrder, value); } private bool _isAscending = SettingsHelper.Settings.Sorting.Ascending; public bool IsAscending { get => _isAscending; set => this.RaiseAndSetIfChanged(ref _isAscending, value); } #endregion Sorting Order private async Task ResizeImageByPercentage(int percentage) { SetTitleHelper.SetLoadingTitle(this); var success = await ConversionHelper.ResizeImageByPercentage(FileInfo, percentage); if (success) { if (ImageIterator is not null) { await ImageIterator.QuickReload().ConfigureAwait(false); } } else { SetTitleHelper.SetTitle(this); } } private async Task ConvertFileExtension(int index) { if (FileInfo is null) { return; } var newPath = await ConversionHelper.ConvertTask(FileInfo, index); if (!string.IsNullOrWhiteSpace(newPath)) { await NavigationHelper.LoadPicFromStringAsync(newPath, this); } } private async Task CopyFileTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await ClipboardHelper.CopyFileToClipboard(path, this); } private async Task CopyFilePathTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await ClipboardHelper.CopyTextToClipboard(path); } private async Task CopyBase64Task(string path) { if (PlatformService is null) { return; } await ClipboardHelper.CopyBase64ToClipboard(path, this); } private async Task CutFileTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await ClipboardHelper.CutFile(path, this); } private async Task DeleteFileTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } await Task.Run(() => { FileDeletionHelper.DeleteFileWithErrorMsg(path, recycle: false); }); } private async Task RecycleFileTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } await Task.Run(() => { FileDeletionHelper.DeleteFileWithErrorMsg(path, recycle: true); }); } private async Task DuplicateFileTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } IsLoading = true; if (path == FileInfo.FullName) { await FunctionsHelper.DuplicateFile(); } else { await Task.Run(() => { FileHelper.DuplicateAndReturnFileName(path); }); } IsLoading = false; } private async Task ShowFilePropertiesTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService.ShowFileProperties(path); }); } private async Task PrintTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService?.Print(path); }); } private async Task OpenWithTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService?.OpenWith(path); }); } private async Task LocateOnDiskTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService?.LocateOnDisk(path); }); } public async Task SetAsWallpaperTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Fit)); }); } public async Task SetAsWallpaperFilledTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Fill)); }); } public async Task SetAsWallpaperTiledTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Tile)); }); } public async Task SetAsWallpaperStretchedTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Stretch)); }); } public async Task SetAsWallpaperCenteredTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } await Task.Run(() => { PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Center)); }); } private async Task SetAsLockScreenTask(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } if (PlatformService is null) { return; } IsLoading = true; var file = await ImageFunctions.ConvertToCommonSupportedFormatAsync(path).ConfigureAwait(false); var process = new Process { StartInfo = new ProcessStartInfo { Verb = "runas", UseShellExecute = true, FileName = "PicView.exe", Arguments = "lockscreen," + file, WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory } }; process.Start(); await TooltipHelper.ShowTooltipMessageAsync(TranslationHelper.Translation.Applying, true); await process.WaitForExitAsync(); IsLoading = false; } public async Task GalleryItemStretchTask(string value) { if (value.Equals("Square", StringComparison.OrdinalIgnoreCase)) { if (GalleryFunctions.IsFullGalleryOpen) { await GalleryStretchMode.ChangeFullGalleryStretchSquare(this); } else { await GalleryStretchMode.ChangeBottomGalleryStretchSquare(this); } return; } if (value.Equals("FillSquare", StringComparison.OrdinalIgnoreCase)) { if (GalleryFunctions.IsFullGalleryOpen) { await GalleryStretchMode.ChangeFullGalleryStretchSquareFill(this); } else { await GalleryStretchMode.ChangeBottomGalleryStretchSquareFill(this); } return; } if (Enum.TryParse(value, out var stretch)) { if (GalleryFunctions.IsFullGalleryOpen) { await GalleryStretchMode.ChangeFullGalleryItemStretch(this, stretch); } else { await GalleryStretchMode.ChangeBottomGalleryItemStretch(this, stretch); } } } public async Task StartSlideShowTask(int milliseconds) { if (milliseconds <= 0) { await Avalonia.Navigation.Slideshow.StartSlideshow(this); } else { await Avalonia.Navigation.Slideshow.StartSlideshow(this, milliseconds); } } #endregion Methods public MainViewModel(IPlatformSpecificService? platformSpecificService) { FunctionsHelper.Vm = this; PlatformService = platformSpecificService; #region Window commands ExitCommand = ReactiveCommand.CreateFromTask(WindowFunctions.Close); MinimizeCommand = ReactiveCommand.CreateFromTask(WindowFunctions.Minimize); MaximizeCommand = ReactiveCommand.CreateFromTask(WindowFunctions.MaximizeRestore); ToggleFullscreenCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleFullscreen); NewWindowCommand = ReactiveCommand.Create(ProcessHelper.StartNewProcess); ShowExifWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowExifWindow); ShowSettingsWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowSettingsWindow); ShowKeybindingsWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowKeybindingsWindow); ShowAboutWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowAboutWindow); ShowBatchResizeWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowBatchResizeWindow); ShowSingleImageResizeWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowSingleImageResizeWindow); #endregion Window commands #region Navigation Commands NextCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Next); NextButtonCommand = ReactiveCommand.CreateFromTask(async () => { await NavigationHelper.NavigateAndPositionCursor(next:true, arrow: false, vm: this); }); NextArrowButtonCommand = ReactiveCommand.CreateFromTask(async () => { await NavigationHelper.NavigateAndPositionCursor(next:true, arrow: true, vm: this); }); NextFolderCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.NextFolder); PreviousCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Prev); PreviousButtonCommand = ReactiveCommand.CreateFromTask(async () => { await NavigationHelper.NavigateAndPositionCursor(next:false, arrow: false, vm: this); }); PreviousArrowButtonCommand = ReactiveCommand.CreateFromTask(async () => { await NavigationHelper.NavigateAndPositionCursor(next:false, arrow: true, vm: this); }); PreviousFolderCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.PrevFolder); FirstCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.First); LastCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Last); ReloadCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Reload); #endregion Navigation Commands #region Sort Commands SortFilesByNameCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesByName); SortFilesByCreationTimeCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesByCreationTime); SortFilesByLastAccessTimeCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesByLastAccessTime); SortFilesBySizeCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesBySize); SortFilesByExtensionCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesByExtension); SortFilesRandomlyCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesRandomly); SortFilesAscendingCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesAscending); SortFilesDescendingCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesDescending); #endregion Sort Commands #region Menus CloseMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.CloseMenus); ToggleFileMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleFileMenu); ToggleImageMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleImageMenu); ToggleSettingsMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleSettingsMenu); ToggleToolsMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleToolsMenu); #endregion Menus #region Image commands RotateLeftCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.RotateLeft); RotateLeftButtonCommand = ReactiveCommand.CreateFromTask(async () => { await Rotation.RotateLeft(this, Rotation.RotationButton.RotateLeftButton); }); RotateRightCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.RotateRight); RotateRightButtonCommand = ReactiveCommand.CreateFromTask(async () => { await Rotation.RotateRight(this, Rotation.RotationButton.RotateRightButton); }); RotateRightWindowBorderButtonCommand = ReactiveCommand.CreateFromTask(async () => { await Rotation.RotateRight(this, Rotation.RotationButton.WindowBorderButton); }); FlipCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Flip); StretchCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Stretch); CropCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Crop); ToggleScrollCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleScroll); OptimizeImageCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OptimizeImage); ChangeBackgroundCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ChangeBackground); ShowSideBySideCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SideBySide); #endregion Image commands #region File commands OpenFileCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Open, Observable.Return(true)); OpenLastFileCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OpenLastFile); SaveFileCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Save); CopyFileCommand = ReactiveCommand.CreateFromTask(CopyFileTask); CopyFilePathCommand = ReactiveCommand.CreateFromTask(CopyFilePathTask); FilePropertiesCommand = ReactiveCommand.CreateFromTask(ShowFilePropertiesTask); CopyImageCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.CopyImage); CopyBase64Command = ReactiveCommand.CreateFromTask(CopyBase64Task); CutCommand = ReactiveCommand.CreateFromTask(CutFileTask); PasteCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Paste); OpenWithCommand = ReactiveCommand.CreateFromTask(OpenWithTask); RenameCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Rename); ResizeCommand = ReactiveCommand.CreateFromTask(ResizeImageByPercentage); ConvertCommand = ReactiveCommand.CreateFromTask(ConvertFileExtension); DuplicateFileCommand = ReactiveCommand.CreateFromTask(DuplicateFileTask); PrintCommand = ReactiveCommand.CreateFromTask(PrintTask); DeleteFileCommand = ReactiveCommand.CreateFromTask(DeleteFileTask); RecycleFileCommand = ReactiveCommand.CreateFromTask(RecycleFileTask); LocateOnDiskCommand = ReactiveCommand.CreateFromTask(LocateOnDiskTask); SetAsWallpaperCommand = ReactiveCommand.CreateFromTask(SetAsWallpaperTask); SetAsWallpaperTiledCommand = ReactiveCommand.CreateFromTask(SetAsWallpaperTiledTask); SetAsWallpaperStretchedCommand = ReactiveCommand.CreateFromTask(SetAsWallpaperStretchedTask); SetAsWallpaperCenteredCommand = ReactiveCommand.CreateFromTask(SetAsWallpaperCenteredTask); SetAsWallpaperFilledCommand = ReactiveCommand.CreateFromTask(SetAsWallpaperFilledTask); SetAsLockScreenCommand = ReactiveCommand.CreateFromTask(SetAsLockScreenTask); #endregion File commands #region EXIF commands SetExifRating0Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set0Star); SetExifRating1Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set1Star); SetExifRating2Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set2Star); SetExifRating3Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set3Star); SetExifRating4Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set4Star); SetExifRating5Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set5Star); OpenGoogleLinkCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OpenGoogleMaps); OpenBingLinkCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OpenBingMaps); #endregion EXIF commands #region Gallery Commands ToggleGalleryCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleGallery); ToggleBottomGalleryCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OpenCloseBottomGallery); CloseGalleryCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.CloseGallery); GalleryItemStretchCommand = ReactiveCommand.CreateFromTask(GalleryItemStretchTask); #endregion Gallery Commands #region UI Commands ToggleUICommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleInterface); ToggleBottomNavBarCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleBottomToolbar); ToggleBottomGalleryShownInHiddenUICommand = ReactiveCommand.CreateFromTask(async() => { await HideInterfaceLogic.ToggleBottomGalleryShownInHiddenUI(this); }); ChangeCtrlZoomCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ChangeCtrlZoom); ColorPickerCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ColorPicker); SlideshowCommand = ReactiveCommand.CreateFromTask(StartSlideShowTask); ToggleTaskbarProgressCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleTaskbarProgress); #endregion UI Commands #region Settings commands ChangeAutoFitCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.AutoFitWindow); ChangeTopMostCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SetTopMost); ToggleSubdirectoriesCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleSubdirectories); ToggleLoopingCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleLooping); ResetSettingsCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ResetSettings); RestartCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Restart); #endregion Settings commands } public MainViewModel() { // Only use for unit test } }