12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178 |
- 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<string>(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<string>(CopyFileTask);
- CopyFilePathCommand = FunctionsHelper.CreateReactiveCommand<string>(CopyFilePathTask);
- FilePropertiesCommand = FunctionsHelper.CreateReactiveCommand<string>(ShowFilePropertiesTask);
- CopyImageCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.CopyImage);
- CopyBase64Command = FunctionsHelper.CreateReactiveCommand<string>(CopyBase64Task);
- CutCommand = FunctionsHelper.CreateReactiveCommand<string>(CutFileTask);
- PasteCommand = FunctionsHelper.CreateReactiveCommand(() => { Task.Run(FunctionsMapper.Paste); });
- OpenWithCommand = FunctionsHelper.CreateReactiveCommand<string>(OpenWithTask);
- RenameCommand = FunctionsHelper.CreateReactiveCommand(FunctionsMapper.Rename);
- ResizeCommand = FunctionsHelper.CreateReactiveCommand<int>(ResizeImageByPercentage);
- ConvertCommand = FunctionsHelper.CreateReactiveCommand<int>(ConvertFileExtension);
- DuplicateFileCommand = FunctionsHelper.CreateReactiveCommand<string>(DuplicateFileTask);
- PrintCommand = FunctionsHelper.CreateReactiveCommand<string>(PrintTask);
- DeleteFileCommand = FunctionsHelper.CreateReactiveCommand<string>(DeleteFileTask);
- RecycleFileCommand = FunctionsHelper.CreateReactiveCommand<string>(RecycleFileTask);
- LocateOnDiskCommand = FunctionsHelper.CreateReactiveCommand<string>(LocateOnDiskTask);
- SetAsWallpaperCommand = FunctionsHelper.CreateReactiveCommand<string>(SetAsWallpaperTask);
- SetAsWallpaperTiledCommand = FunctionsHelper.CreateReactiveCommand<string>(SetAsWallpaperTiledTask);
- SetAsWallpaperStretchedCommand = FunctionsHelper.CreateReactiveCommand<string>(SetAsWallpaperStretchedTask);
- SetAsWallpaperCenteredCommand = FunctionsHelper.CreateReactiveCommand<string>(SetAsWallpaperCenteredTask);
- SetAsWallpaperFilledCommand = FunctionsHelper.CreateReactiveCommand<string>(SetAsWallpaperFilledTask);
- SetAsLockScreenCommand = FunctionsHelper.CreateReactiveCommand<string>(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<string>(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<int>(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<Unit, Unit>? ExitCommand { get; }
- public ReactiveCommand<Unit, Unit>? MinimizeCommand { get; }
- public ReactiveCommand<Unit, Unit>? MaximizeCommand { get; }
- public ReactiveCommand<Unit, Unit>? RestoreCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleFullscreenCommand { get; }
- public ReactiveCommand<Unit, Unit>? NextCommand { get; }
- public ReactiveCommand<Unit, Unit>? NextButtonCommand { get; }
- public ReactiveCommand<Unit, Unit>? NextArrowButtonCommand { get; }
- public ReactiveCommand<Unit, Unit>? PreviousCommand { get; }
- public ReactiveCommand<Unit, Unit>? PreviousButtonCommand { get; }
- public ReactiveCommand<Unit, Unit>? PreviousArrowButtonCommand { get; }
- public ReactiveCommand<Unit, Unit>? NextFolderCommand { get; }
- public ReactiveCommand<Unit, Unit>? PreviousFolderCommand { get; }
- public ReactiveCommand<Unit, Unit>? FirstCommand { get; }
- public ReactiveCommand<Unit, Unit>? LastCommand { get; }
- public ReactiveCommand<Unit, Unit>? Skip10Command { get; }
- public ReactiveCommand<Unit, Unit>? Prev10Command { get; }
- public ReactiveCommand<Unit, Unit>? Skip100Command { get; }
- public ReactiveCommand<Unit, Unit>? Prev100Command { get; }
- public ReactiveCommand<Unit, Unit>? OpenFileCommand { get; }
- public ReactiveCommand<Unit, Unit>? SaveFileCommand { get; }
- public ReactiveCommand<Unit, Unit>? SaveFileAsCommand { get; }
- public ReactiveCommand<Unit, Unit>? OpenLastFileCommand { get; }
- public ReactiveCommand<Unit, Unit>? PasteCommand { get; }
- public ReactiveCommand<string, Unit>? CopyFileCommand { get; }
- public ReactiveCommand<string, Unit>? CopyBase64Command { get; }
- public ReactiveCommand<string, Unit>? CopyFilePathCommand { get; }
- public ReactiveCommand<string, Unit>? FilePropertiesCommand { get; }
- public ReactiveCommand<Unit, Unit>? CopyImageCommand { get; }
- public ReactiveCommand<string, Unit>? CutCommand { get; }
- public ReactiveCommand<Unit, Unit>? ReloadCommand { get; }
- public ReactiveCommand<string, Unit>? PrintCommand { get; }
- public ReactiveCommand<string, Unit>? DeleteFileCommand { get; }
- public ReactiveCommand<string, Unit>? RecycleFileCommand { get; }
- public ReactiveCommand<Unit, Unit>? CloseMenuCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleFileMenuCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleImageMenuCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleSettingsMenuCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleToolsMenuCommand { get; }
- public ReactiveCommand<string, Unit>? LocateOnDiskCommand { get; }
- public ReactiveCommand<string, Unit>? OpenWithCommand { get; }
- public ReactiveCommand<Unit, Unit>? RenameCommand { get; }
- public ReactiveCommand<Unit, Unit>? NewWindowCommand { get; }
- public ReactiveCommand<string, Unit>? DuplicateFileCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleLoopingCommand { get; }
- public ReactiveCommand<Unit, Unit>? RotateLeftCommand { get; }
- public ReactiveCommand<Unit, Unit>? RotateLeftButtonCommand { get; }
- public ReactiveCommand<Unit, Unit>? RotateRightCommand { get; }
- public ReactiveCommand<string, Unit>? RotateToCommand { get; }
- public ReactiveCommand<Unit, Unit>? RotateRightButtonCommand { get; }
- public ReactiveCommand<Unit, Unit>? RotateRightWindowBorderButtonCommand { get; }
- public ReactiveCommand<Unit, Unit>? FlipCommand { get; }
- public ReactiveCommand<Unit, Unit>? StretchCommand { get; }
- public ReactiveCommand<Unit, Unit>? CropCommand { get; }
- public ReactiveCommand<Unit, Unit>? ChangeAutoFitCommand { get; }
- public ReactiveCommand<Unit, Unit>? ChangeTopMostCommand { get; }
- public ReactiveCommand<Unit, Unit>? ChangeCtrlZoomCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleUsingTouchpadCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleUICommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleOpeningInSameWindowCommand { get; }
- public ReactiveCommand<Unit, Unit>? ChangeBackgroundCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleBottomNavBarCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleBottomGalleryShownInHiddenUICommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleFadeInButtonsOnHoverCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleTaskbarProgressCommand { get; }
- public ReactiveCommand<Unit, Unit>? ShowExifWindowCommand { get; }
- public ReactiveCommand<Unit, Unit>? ShowAboutWindowCommand { get; }
- public ReactiveCommand<Unit, Unit>? ShowSettingsWindowCommand { get; }
- public ReactiveCommand<Unit, Unit>? ShowKeybindingsWindowCommand { get; }
- public ReactiveCommand<Unit, Unit>? ShowBatchResizeWindowCommand { get; }
- public ReactiveCommand<Unit, Unit>? ShowSingleImageResizeWindowCommand { get; }
- public ReactiveCommand<Unit, Unit>? ShowEffectsWindowCommand { get; }
- public ReactiveCommand<Unit, Unit>? SetExifRating0Command { get; }
- public ReactiveCommand<Unit, Unit>? SetExifRating1Command { get; }
- public ReactiveCommand<Unit, Unit>? SetExifRating2Command { get; }
- public ReactiveCommand<Unit, Unit>? SetExifRating3Command { get; }
- public ReactiveCommand<Unit, Unit>? SetExifRating4Command { get; }
- public ReactiveCommand<Unit, Unit>? SetExifRating5Command { get; }
- public ReactiveCommand<Unit, Unit>? OpenGoogleLinkCommand { get; }
- public ReactiveCommand<Unit, Unit>? OpenBingLinkCommand { get; }
- public ReactiveCommand<Unit, Unit>? OptimizeImageCommand { get; }
- public ReactiveCommand<int, Unit>? ResizeCommand { get; }
- public ReactiveCommand<int, Unit>? ConvertCommand { get; }
- public ReactiveCommand<Unit, Unit>? SortFilesByNameCommand { get; }
- public ReactiveCommand<Unit, Unit>? SortFilesBySizeCommand { get; }
- public ReactiveCommand<Unit, Unit>? SortFilesByExtensionCommand { get; }
- public ReactiveCommand<Unit, Unit>? SortFilesByCreationTimeCommand { get; }
- public ReactiveCommand<Unit, Unit>? SortFilesByLastAccessTimeCommand { get; }
- public ReactiveCommand<Unit, Unit>? SortFilesRandomlyCommand { get; }
- public ReactiveCommand<Unit, Unit>? SortFilesAscendingCommand { get; }
- public ReactiveCommand<Unit, Unit>? SortFilesDescendingCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleGalleryCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleBottomGalleryCommand { get; }
- public ReactiveCommand<Unit, Unit>? CloseGalleryCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleScrollCommand { get; }
- public ReactiveCommand<Unit, Unit>? ToggleSubdirectoriesCommand { get; }
- public ReactiveCommand<Unit, Unit>? ColorPickerCommand { get; }
- public ReactiveCommand<int, Unit>? SlideshowCommand { get; }
- public ReactiveCommand<string, Unit>? SetAsWallpaperCommand { get; }
- public ReactiveCommand<string, Unit>? SetAsWallpaperFilledCommand { get; }
- public ReactiveCommand<string, Unit>? SetAsWallpaperStretchedCommand { get; }
- public ReactiveCommand<string, Unit>? SetAsWallpaperTiledCommand { get; }
- public ReactiveCommand<string, Unit>? SetAsWallpaperCenteredCommand { get; }
- public ReactiveCommand<string, Unit>? SetAsLockScreenCommand { get; }
- public ReactiveCommand<string, Unit>? GalleryItemStretchCommand { get; }
- public ReactiveCommand<Unit, Unit>? ResetSettingsCommand { get; }
- public ReactiveCommand<Unit, Unit>? ShowSideBySideCommand { get; }
- public ReactiveCommand<Unit, Unit>? RestartCommand { get; }
-
- public ReactiveCommand<Unit, Unit>? ShowSettingsFileCommand { get; }
-
- public ReactiveCommand<Unit, Unit>? ShowKeybindingsFileCommand { get; }
-
- public ReactiveCommand<Unit, Unit>? 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
- }
|