MainViewModel.cs 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  1. using System.Diagnostics;
  2. using System.Reactive;
  3. using System.Reactive.Linq;
  4. using Avalonia;
  5. using Avalonia.Controls;
  6. using Avalonia.Controls.Primitives;
  7. using Avalonia.Layout;
  8. using Avalonia.Media;
  9. using PicView.Avalonia.Clipboard;
  10. using PicView.Avalonia.Converters;
  11. using PicView.Avalonia.Gallery;
  12. using PicView.Avalonia.ImageHandling;
  13. using PicView.Avalonia.ImageTransformations;
  14. using PicView.Avalonia.Interfaces;
  15. using PicView.Avalonia.Navigation;
  16. using PicView.Avalonia.UI;
  17. using PicView.Avalonia.Wallpaper;
  18. using PicView.Avalonia.WindowBehavior;
  19. using PicView.Core.Calculations;
  20. using PicView.Core.Config;
  21. using PicView.Core.FileHandling;
  22. using PicView.Core.Gallery;
  23. using PicView.Core.Localization;
  24. using PicView.Core.ProcessHandling;
  25. using ReactiveUI;
  26. using ImageViewer = PicView.Avalonia.Views.ImageViewer;
  27. namespace PicView.Avalonia.ViewModels;
  28. public class MainViewModel : ViewModelBase
  29. {
  30. public readonly IPlatformSpecificService? PlatformService;
  31. #region Image
  32. private object? _imageSource;
  33. public object? ImageSource
  34. {
  35. get => _imageSource;
  36. set => this.RaiseAndSetIfChanged(ref _imageSource, value);
  37. }
  38. private object? _secondaryImageSource;
  39. public object? SecondaryImageSource
  40. {
  41. get => _secondaryImageSource;
  42. set => this.RaiseAndSetIfChanged(ref _secondaryImageSource, value);
  43. }
  44. private ImageType _imageType;
  45. public ImageType ImageType
  46. {
  47. get => _imageType;
  48. set => this.RaiseAndSetIfChanged(ref _imageType, value);
  49. }
  50. private double _imageWidth;
  51. public double ImageWidth
  52. {
  53. get => _imageWidth;
  54. set => this.RaiseAndSetIfChanged(ref _imageWidth, value);
  55. }
  56. private double _imageHeight;
  57. public double ImageHeight
  58. {
  59. get => _imageHeight;
  60. set => this.RaiseAndSetIfChanged(ref _imageHeight, value);
  61. }
  62. private double _imageSecondaryWidth;
  63. public double SecondaryImageWidth
  64. {
  65. get => _imageSecondaryWidth;
  66. set => this.RaiseAndSetIfChanged(ref _imageSecondaryWidth, value);
  67. }
  68. private Brush? _imageBackground;
  69. public Brush? ImageBackground
  70. {
  71. get => _imageBackground;
  72. set => this.RaiseAndSetIfChanged(ref _imageBackground, value);
  73. }
  74. private bool _isShowingSideBySide = SettingsHelper.Settings.ImageScaling.ShowImageSideBySide;
  75. public bool IsShowingSideBySide
  76. {
  77. get => _isShowingSideBySide;
  78. set => this.RaiseAndSetIfChanged(ref _isShowingSideBySide, value);
  79. }
  80. private double _scrollViewerWidth = double.NaN;
  81. public double ScrollViewerWidth
  82. {
  83. get => _scrollViewerWidth;
  84. set => this.RaiseAndSetIfChanged(ref _scrollViewerWidth, value);
  85. }
  86. private double _scrollViewerHeight = double.NaN;
  87. public double ScrollViewerHeight
  88. {
  89. get => _scrollViewerHeight;
  90. set => this.RaiseAndSetIfChanged(ref _scrollViewerHeight, value);
  91. }
  92. #endregion
  93. #region Gallery
  94. private Thickness _galleryMargin;
  95. public Thickness GalleryMargin
  96. {
  97. get => _galleryMargin;
  98. set => this.RaiseAndSetIfChanged(ref _galleryMargin, value);
  99. }
  100. private bool _isGalleryShown = SettingsHelper.Settings.UIProperties.ShowInterface && SettingsHelper.Settings.Gallery.IsBottomGalleryShown;
  101. public bool IsGalleryShown
  102. {
  103. get => _isGalleryShown;
  104. set => this.RaiseAndSetIfChanged(ref _isGalleryShown, value);
  105. }
  106. private bool _isBottomGalleryShownInHiddenUi = SettingsHelper.Settings.Gallery.ShowBottomGalleryInHiddenUI;
  107. public bool IsBottomGalleryShownInHiddenUI
  108. {
  109. get => _isBottomGalleryShownInHiddenUi;
  110. set => this.RaiseAndSetIfChanged(ref _isBottomGalleryShownInHiddenUi, value);
  111. }
  112. private GalleryMode _galleryMode = GalleryMode.Closed;
  113. public GalleryMode GalleryMode
  114. {
  115. get => _galleryMode;
  116. set => this.RaiseAndSetIfChanged(ref _galleryMode, value);
  117. }
  118. private Stretch _galleryStretch;
  119. public Stretch GalleryStretch
  120. {
  121. get => _galleryStretch;
  122. set => this.RaiseAndSetIfChanged(ref _galleryStretch, value);
  123. }
  124. private int _selectedGalleryItemIndex;
  125. public int SelectedGalleryItemIndex
  126. {
  127. get => _selectedGalleryItemIndex;
  128. set => this.RaiseAndSetIfChanged(ref _selectedGalleryItemIndex, value);
  129. }
  130. private VerticalAlignment _galleryVerticalAlignment = VerticalAlignment.Bottom;
  131. public VerticalAlignment GalleryVerticalAlignment
  132. {
  133. get => _galleryVerticalAlignment;
  134. set => this.RaiseAndSetIfChanged(ref _galleryVerticalAlignment, value);
  135. }
  136. private Orientation _galleryOrientation;
  137. public Orientation GalleryOrientation
  138. {
  139. set => this.RaiseAndSetIfChanged(ref _galleryOrientation, value);
  140. get => _galleryOrientation;
  141. }
  142. private bool _isGalleryCloseIconVisible;
  143. public bool IsGalleryCloseIconVisible
  144. {
  145. get => _isGalleryCloseIconVisible;
  146. set => this.RaiseAndSetIfChanged(ref _isGalleryCloseIconVisible, value);
  147. }
  148. private double _galleryWidth;
  149. public double GalleryWidth
  150. {
  151. get => _galleryWidth;
  152. set => this.RaiseAndSetIfChanged(ref _galleryWidth, value);
  153. }
  154. public double GalleryHeight
  155. {
  156. get
  157. {
  158. if (!SettingsHelper.Settings.Gallery.IsBottomGalleryShown)
  159. {
  160. return 0;
  161. }
  162. if (SettingsHelper.Settings.WindowProperties.Fullscreen)
  163. {
  164. return SettingsHelper.Settings.Gallery.IsBottomGalleryShown ? GetBottomGalleryItemHeight + SizeDefaults.ScrollbarSize : 0;
  165. }
  166. if (!SettingsHelper.Settings.Gallery.ShowBottomGalleryInHiddenUI && !IsUIShown)
  167. {
  168. return 0;
  169. }
  170. return GetBottomGalleryItemHeight + SizeDefaults.ScrollbarSize;
  171. }
  172. }
  173. private double _getGalleryItemWidth = double.NaN;
  174. public double GetGalleryItemWidth
  175. {
  176. get => _getGalleryItemWidth;
  177. set => this.RaiseAndSetIfChanged(ref _getGalleryItemWidth, value);
  178. }
  179. private double _getGalleryItemHeight;
  180. public double GetGalleryItemHeight
  181. {
  182. get => _getGalleryItemHeight;
  183. set => this.RaiseAndSetIfChanged(ref _getGalleryItemHeight, value);
  184. }
  185. private double _getFullGalleryItemHeight = SettingsHelper.Settings.Gallery.ExpandedGalleryItemSize;
  186. public double GetFullGalleryItemHeight
  187. {
  188. get => _getFullGalleryItemHeight;
  189. set => this.RaiseAndSetIfChanged(ref _getFullGalleryItemHeight, value);
  190. }
  191. private double _getBottomGalleryItemHeight = SettingsHelper.Settings.Gallery.BottomGalleryItemSize;
  192. public double GetBottomGalleryItemHeight
  193. {
  194. get => _getBottomGalleryItemHeight;
  195. set => this.RaiseAndSetIfChanged(ref _getBottomGalleryItemHeight, value);
  196. }
  197. public double MaxFullGalleryItemHeight
  198. {
  199. get => GalleryDefaults.MaxFullGalleryItemHeight;
  200. }
  201. public double MinFullGalleryItemHeight
  202. {
  203. get => GalleryDefaults.MinFullGalleryItemHeight;
  204. }
  205. public double MaxBottomGalleryItemHeight
  206. {
  207. get => GalleryDefaults.MaxBottomGalleryItemHeight;
  208. }
  209. public double MinBottomGalleryItemHeight
  210. {
  211. get => GalleryDefaults.MinBottomGalleryItemHeight;
  212. }
  213. private Thickness _galleryItemMargin;
  214. public Thickness GalleryItemMargin
  215. {
  216. get => _galleryItemMargin;
  217. set => this.RaiseAndSetIfChanged(ref _galleryItemMargin, value);
  218. }
  219. #region Gallery Stretch IsChecked
  220. private bool _isUniformBottomChecked;
  221. public bool IsUniformBottomChecked
  222. {
  223. get => _isUniformBottomChecked;
  224. set => this.RaiseAndSetIfChanged(ref _isUniformBottomChecked, value);
  225. }
  226. private bool _isUniformFullChecked;
  227. public bool IsUniformFullChecked
  228. {
  229. get => _isUniformFullChecked;
  230. set => this.RaiseAndSetIfChanged(ref _isUniformFullChecked, value);
  231. }
  232. private bool _isUniformMenuChecked;
  233. public bool IsUniformMenuChecked
  234. {
  235. get => _isUniformMenuChecked;
  236. set => this.RaiseAndSetIfChanged(ref _isUniformMenuChecked, value);
  237. }
  238. private bool _isUniformToFillBottomChecked;
  239. public bool IsUniformToFillBottomChecked
  240. {
  241. get => _isUniformToFillBottomChecked;
  242. set => this.RaiseAndSetIfChanged(ref _isUniformToFillBottomChecked, value);
  243. }
  244. private bool _isUniformToFillFullChecked;
  245. public bool IsUniformToFillFullChecked
  246. {
  247. get => _isUniformToFillFullChecked;
  248. set => this.RaiseAndSetIfChanged(ref _isUniformToFillFullChecked, value);
  249. }
  250. private bool _isUniformToFillMenuMenuChecked;
  251. public bool IsUniformToFillMenuChecked
  252. {
  253. get => _isUniformToFillMenuMenuChecked;
  254. set => this.RaiseAndSetIfChanged(ref _isUniformToFillMenuMenuChecked, value);
  255. }
  256. private bool _isFillBottomChecked;
  257. public bool IsFillBottomChecked
  258. {
  259. get => _isFillBottomChecked;
  260. set => this.RaiseAndSetIfChanged(ref _isFillBottomChecked, value);
  261. }
  262. private bool _isFillFullChecked;
  263. public bool IsFillFullChecked
  264. {
  265. get => _isFillFullChecked;
  266. set => this.RaiseAndSetIfChanged(ref _isFillFullChecked, value);
  267. }
  268. private bool _isFillMenuMenuChecked;
  269. public bool IsFillMenuChecked
  270. {
  271. get => _isFillMenuMenuChecked;
  272. set => this.RaiseAndSetIfChanged(ref _isFillMenuMenuChecked, value);
  273. }
  274. private bool _isNoneBottomChecked;
  275. public bool IsNoneBottomChecked
  276. {
  277. get => _isNoneBottomChecked;
  278. set => this.RaiseAndSetIfChanged(ref _isNoneBottomChecked, value);
  279. }
  280. private bool _isNoneFullChecked;
  281. public bool IsNoneFullChecked
  282. {
  283. get => _isNoneFullChecked;
  284. set => this.RaiseAndSetIfChanged(ref _isNoneFullChecked, value);
  285. }
  286. private bool _isNoneMenuChecked;
  287. public bool IsNoneMenuChecked
  288. {
  289. get => _isNoneMenuChecked;
  290. set => this.RaiseAndSetIfChanged(ref _isNoneMenuChecked, value);
  291. }
  292. private bool _isSquareBottomChecked;
  293. public bool IsSquareBottomChecked
  294. {
  295. get => _isSquareBottomChecked;
  296. set => this.RaiseAndSetIfChanged(ref _isSquareBottomChecked, value);
  297. }
  298. private bool _isSquareFullChecked;
  299. public bool IsSquareFullChecked
  300. {
  301. get => _isSquareFullChecked;
  302. set => this.RaiseAndSetIfChanged(ref _isSquareFullChecked, value);
  303. }
  304. private bool _isSquareMenuChecked;
  305. public bool IsSquareMenuChecked
  306. {
  307. get => _isSquareMenuChecked;
  308. set => this.RaiseAndSetIfChanged(ref _isSquareMenuChecked, value);
  309. }
  310. private bool _isFillSquareBottomChecked;
  311. public bool IsFillSquareBottomChecked
  312. {
  313. get => _isFillSquareBottomChecked;
  314. set => this.RaiseAndSetIfChanged(ref _isFillSquareBottomChecked, value);
  315. }
  316. private bool _isFillSquareFullChecked;
  317. public bool IsFillSquareFullChecked
  318. {
  319. get => _isFillSquareFullChecked;
  320. set => this.RaiseAndSetIfChanged(ref _isFillSquareFullChecked, value);
  321. }
  322. private bool _isFillSquareMenuChecked;
  323. public bool IsFillSquareMenuChecked
  324. {
  325. get => _isFillSquareMenuChecked;
  326. set => this.RaiseAndSetIfChanged(ref _isFillSquareMenuChecked, value);
  327. }
  328. #endregion
  329. #endregion Gallery
  330. #region Commands
  331. public ReactiveCommand<Unit, Unit>? ExitCommand { get; }
  332. public ReactiveCommand<Unit, Unit>? MinimizeCommand { get; }
  333. public ReactiveCommand<Unit, Unit>? MaximizeCommand { get; }
  334. public ReactiveCommand<Unit, Unit>? ToggleFullscreenCommand { get; }
  335. public ReactiveCommand<Unit, Unit>? NextCommand { get; }
  336. public ReactiveCommand<Unit, Unit>? NextButtonCommand { get; }
  337. public ReactiveCommand<Unit, Unit>? NextArrowButtonCommand { get; }
  338. public ReactiveCommand<Unit, Unit>? PreviousCommand { get; }
  339. public ReactiveCommand<Unit, Unit>? PreviousButtonCommand { get; }
  340. public ReactiveCommand<Unit, Unit>? PreviousArrowButtonCommand { get; }
  341. public ReactiveCommand<Unit, Unit>? NextFolderCommand { get; }
  342. public ReactiveCommand<Unit, Unit>? PreviousFolderCommand { get; }
  343. public ReactiveCommand<Unit, Unit>? FirstCommand { get; }
  344. public ReactiveCommand<Unit, Unit>? LastCommand { get; }
  345. public ReactiveCommand<Unit, Unit>? OpenFileCommand { get; }
  346. public ReactiveCommand<Unit, Unit>? SaveFileCommand { get; }
  347. public ReactiveCommand<Unit, Unit>? OpenLastFileCommand { get; }
  348. public ReactiveCommand<Unit, Unit>? PasteCommand { get; }
  349. public ReactiveCommand<string, Unit>? CopyFileCommand { get; }
  350. public ReactiveCommand<string, Unit>? CopyBase64Command { get; }
  351. public ReactiveCommand<string, Unit>? CopyFilePathCommand { get; }
  352. public ReactiveCommand<string, Unit>? FilePropertiesCommand { get; }
  353. public ReactiveCommand<Unit, Unit>? CopyImageCommand { get; }
  354. public ReactiveCommand<string, Unit>? CutCommand { get; }
  355. public ReactiveCommand<Unit, Unit>? ReloadCommand { get; }
  356. public ReactiveCommand<string, Unit>? PrintCommand { get; }
  357. public ReactiveCommand<string, Unit>? DeleteFileCommand { get; }
  358. public ReactiveCommand<string, Unit>? RecycleFileCommand { get; }
  359. public ReactiveCommand<Unit, Unit>? CloseMenuCommand { get; }
  360. public ReactiveCommand<Unit, Unit>? ToggleFileMenuCommand { get; }
  361. public ReactiveCommand<Unit, Unit>? ToggleImageMenuCommand { get; }
  362. public ReactiveCommand<Unit, Unit>? ToggleSettingsMenuCommand { get; }
  363. public ReactiveCommand<Unit, Unit>? ToggleToolsMenuCommand { get; }
  364. public ReactiveCommand<string, Unit>? LocateOnDiskCommand { get; }
  365. public ReactiveCommand<string, Unit>? OpenWithCommand { get; }
  366. public ReactiveCommand<Unit, Unit>? RenameCommand { get; }
  367. public ReactiveCommand<Unit, Unit>? NewWindowCommand { get; }
  368. public ReactiveCommand<string, Unit>? DuplicateFileCommand { get; }
  369. public ReactiveCommand<Unit, Unit>? ToggleLoopingCommand { get; }
  370. public ReactiveCommand<Unit, Unit>? RotateLeftCommand { get; }
  371. public ReactiveCommand<Unit, Unit>? RotateLeftButtonCommand { get; }
  372. public ReactiveCommand<Unit, Unit>? RotateRightCommand { get; }
  373. public ReactiveCommand<Unit, Unit>? RotateRightButtonCommand { get; }
  374. public ReactiveCommand<Unit, Unit>? RotateRightWindowBorderButtonCommand { get; }
  375. public ReactiveCommand<Unit, Unit>? FlipCommand { get; }
  376. public ReactiveCommand<Unit, Unit>? StretchCommand { get; }
  377. public ReactiveCommand<Unit, Unit>? CropCommand { get; }
  378. public ReactiveCommand<Unit, Unit>? ChangeAutoFitCommand { get; }
  379. public ReactiveCommand<Unit, Unit>? ChangeTopMostCommand { get; }
  380. public ReactiveCommand<Unit, Unit>? ChangeCtrlZoomCommand { get; }
  381. public ReactiveCommand<Unit, Unit>? ToggleUICommand { get; }
  382. public ReactiveCommand<Unit, Unit>? ChangeBackgroundCommand { get; }
  383. public ReactiveCommand<Unit, Unit>? ToggleBottomNavBarCommand { get; }
  384. public ReactiveCommand<Unit, Unit>? ToggleBottomGalleryShownInHiddenUICommand { get; }
  385. public ReactiveCommand<Unit, Unit>? ToggleTaskbarProgressCommand { get; }
  386. public ReactiveCommand<Unit, Unit>? ShowExifWindowCommand { get; }
  387. public ReactiveCommand<Unit, Unit>? ShowAboutWindowCommand { get; }
  388. public ReactiveCommand<Unit, Unit>? ShowSettingsWindowCommand { get; }
  389. public ReactiveCommand<Unit, Unit>? ShowKeybindingsWindowCommand { get; }
  390. public ReactiveCommand<Unit, Unit>? ShowBatchResizeWindowCommand { get; }
  391. public ReactiveCommand<Unit, Unit>? ShowSingleImageResizeWindowCommand { get; }
  392. public ReactiveCommand<Unit, Unit>? SetExifRating0Command { get; }
  393. public ReactiveCommand<Unit, Unit>? SetExifRating1Command { get; }
  394. public ReactiveCommand<Unit, Unit>? SetExifRating2Command { get; }
  395. public ReactiveCommand<Unit, Unit>? SetExifRating3Command { get; }
  396. public ReactiveCommand<Unit, Unit>? SetExifRating4Command { get; }
  397. public ReactiveCommand<Unit, Unit>? SetExifRating5Command { get; }
  398. public ReactiveCommand<Unit, Unit>? OpenGoogleLinkCommand { get; }
  399. public ReactiveCommand<Unit, Unit>? OpenBingLinkCommand { get; }
  400. public ReactiveCommand<Unit, Unit>? OptimizeImageCommand { get; }
  401. public ReactiveCommand<int, Unit>? ResizeCommand { get; }
  402. public ReactiveCommand<int, Unit>? ConvertCommand { get; }
  403. public ReactiveCommand<Unit, Unit>? SortFilesByNameCommand { get; }
  404. public ReactiveCommand<Unit, Unit>? SortFilesBySizeCommand { get; }
  405. public ReactiveCommand<Unit, Unit>? SortFilesByExtensionCommand { get; }
  406. public ReactiveCommand<Unit, Unit>? SortFilesByCreationTimeCommand { get; }
  407. public ReactiveCommand<Unit, Unit>? SortFilesByLastAccessTimeCommand { get; }
  408. public ReactiveCommand<Unit, Unit>? SortFilesRandomlyCommand { get; }
  409. public ReactiveCommand<Unit, Unit>? SortFilesAscendingCommand { get; }
  410. public ReactiveCommand<Unit, Unit>? SortFilesDescendingCommand { get; }
  411. public ReactiveCommand<Unit, Unit>? ToggleGalleryCommand { get; }
  412. public ReactiveCommand<Unit, Unit>? ToggleBottomGalleryCommand { get; }
  413. public ReactiveCommand<Unit, Unit>? CloseGalleryCommand { get; }
  414. public ReactiveCommand<Unit, Unit>? ToggleScrollCommand { get; }
  415. public ReactiveCommand<Unit, Unit>? ToggleSubdirectoriesCommand { get; }
  416. public ReactiveCommand<Unit, Unit>? ColorPickerCommand { get; }
  417. public ReactiveCommand<int, Unit>? SlideshowCommand { get; }
  418. public ReactiveCommand<string, Unit>? SetAsWallpaperCommand { get; }
  419. public ReactiveCommand<string, Unit>? SetAsWallpaperFilledCommand { get; }
  420. public ReactiveCommand<string, Unit>? SetAsWallpaperStretchedCommand { get; }
  421. public ReactiveCommand<string, Unit>? SetAsWallpaperTiledCommand { get; }
  422. public ReactiveCommand<string, Unit>? SetAsWallpaperCenteredCommand { get; }
  423. public ReactiveCommand<string, Unit>? SetAsLockScreenCommand { get; }
  424. public ReactiveCommand<string, Unit>? GalleryItemStretchCommand { get; }
  425. public ReactiveCommand<Unit, Unit>? ResetSettingsCommand { get; }
  426. public ReactiveCommand<Unit, Unit>? ShowSideBySideCommand { get; }
  427. public ReactiveCommand<Unit, Unit>? RestartCommand { get; }
  428. #endregion Commands
  429. #region Fields
  430. #region Booleans
  431. private bool _isAvoidingZoomingOut = SettingsHelper.Settings.Zoom.AvoidZoomingOut;
  432. public bool IsAvoidingZoomingOut
  433. {
  434. get => _isAvoidingZoomingOut;
  435. set
  436. {
  437. SettingsHelper.Settings.Zoom.AvoidZoomingOut = value;
  438. this.RaiseAndSetIfChanged(ref _isAvoidingZoomingOut, value);
  439. }
  440. }
  441. private IImage? _changeCtrlZoomImage;
  442. public IImage? ChangeCtrlZoomImage
  443. {
  444. get => _changeCtrlZoomImage;
  445. set => this.RaiseAndSetIfChanged(ref _changeCtrlZoomImage, value);
  446. }
  447. private bool _isLoading;
  448. public bool IsLoading
  449. {
  450. get => _isLoading;
  451. set => this.RaiseAndSetIfChanged(ref _isLoading, value);
  452. }
  453. private bool _isUIShown = SettingsHelper.Settings.UIProperties.ShowInterface;
  454. public bool IsUIShown
  455. {
  456. get => _isUIShown;
  457. set => this.RaiseAndSetIfChanged(ref _isUIShown, value);
  458. }
  459. private bool _isTopToolbarShown = SettingsHelper.Settings.UIProperties.ShowInterface;
  460. public bool IsTopToolbarShown
  461. {
  462. get => _isTopToolbarShown;
  463. set => this.RaiseAndSetIfChanged(ref _isTopToolbarShown, value);
  464. }
  465. private bool _isBottomToolbarShown = SettingsHelper.Settings.UIProperties.ShowBottomNavBar &&
  466. SettingsHelper.Settings.UIProperties.ShowInterface;
  467. public bool IsBottomToolbarShown
  468. {
  469. get => _isBottomToolbarShown;
  470. set => this.RaiseAndSetIfChanged(ref _isBottomToolbarShown, value);
  471. }
  472. private bool _isBottomToolbarShownSetting = SettingsHelper.Settings.UIProperties.ShowBottomNavBar;
  473. public bool IsBottomToolbarShownSetting
  474. {
  475. get => _isBottomToolbarShownSetting;
  476. set => this.RaiseAndSetIfChanged(ref _isBottomToolbarShownSetting, value);
  477. }
  478. private bool _isShowingTaskbarProgress = SettingsHelper.Settings.UIProperties.IsTaskbarProgressEnabled;
  479. public bool IsShowingTaskbarProgress
  480. {
  481. get => _isShowingTaskbarProgress;
  482. set => this.RaiseAndSetIfChanged(ref _isShowingTaskbarProgress, value);
  483. }
  484. private bool _isFullscreen = SettingsHelper.Settings.WindowProperties.Fullscreen;
  485. public bool IsFullscreen
  486. {
  487. get => _isFullscreen;
  488. set => this.RaiseAndSetIfChanged(ref _isFullscreen, value);
  489. }
  490. private bool _isTopMost = SettingsHelper.Settings.WindowProperties.TopMost;
  491. public bool IsTopMost
  492. {
  493. get => _isTopMost;
  494. set => this.RaiseAndSetIfChanged(ref _isTopMost, value);
  495. }
  496. private bool _isIncludingSubdirectories = SettingsHelper.Settings.Sorting.IncludeSubDirectories;
  497. public bool IsIncludingSubdirectories
  498. {
  499. get => _isIncludingSubdirectories;
  500. set => this.RaiseAndSetIfChanged(ref _isIncludingSubdirectories, value);
  501. }
  502. private bool _isScrollingEnabled;
  503. public bool IsScrollingEnabled
  504. {
  505. get => _isScrollingEnabled;
  506. set => this.RaiseAndSetIfChanged(ref _isScrollingEnabled, value);
  507. }
  508. private bool _isStretched = SettingsHelper.Settings.ImageScaling.StretchImage;
  509. public bool IsStretched
  510. {
  511. get => _isStretched;
  512. set
  513. {
  514. this.RaiseAndSetIfChanged(ref _isStretched, value);
  515. SettingsHelper.Settings.ImageScaling.StretchImage = value;
  516. WindowResizing.SetSize(this);
  517. }
  518. }
  519. private bool _isLooping = SettingsHelper.Settings.UIProperties.Looping;
  520. public bool IsLooping
  521. {
  522. get => _isLooping;
  523. set => this.RaiseAndSetIfChanged(ref _isLooping, value);
  524. }
  525. private bool _isAutoFit = SettingsHelper.Settings.WindowProperties.AutoFit;
  526. public bool IsAutoFit
  527. {
  528. get => _isAutoFit;
  529. set => this.RaiseAndSetIfChanged(ref _isAutoFit, value);
  530. }
  531. private bool _isStayingCentered = SettingsHelper.Settings.WindowProperties.KeepCentered;
  532. public bool IsStayingCentered
  533. {
  534. get => _isStayingCentered;
  535. set
  536. {
  537. this.RaiseAndSetIfChanged(ref _isStayingCentered, value);
  538. SettingsHelper.Settings.WindowProperties.KeepCentered = value;
  539. }
  540. }
  541. private bool _isFileSavingDialogShown = SettingsHelper.Settings.UIProperties.ShowFileSavingDialog;
  542. public bool IsFileSavingDialogShown
  543. {
  544. get => _isFileSavingDialogShown;
  545. set
  546. {
  547. this.RaiseAndSetIfChanged(ref _isFileSavingDialogShown, value);
  548. SettingsHelper.Settings.UIProperties.ShowFileSavingDialog = value;
  549. }
  550. }
  551. private bool _isOpeningInSameWindow = SettingsHelper.Settings.UIProperties.OpenInSameWindow;
  552. public bool IsOpeningInSameWindow
  553. {
  554. get => _isOpeningInSameWindow;
  555. set
  556. {
  557. this.RaiseAndSetIfChanged(ref _isOpeningInSameWindow, value);
  558. SettingsHelper.Settings.UIProperties.OpenInSameWindow = value;
  559. }
  560. }
  561. private bool _isEditableTitlebarOpen;
  562. public bool IsEditableTitlebarOpen
  563. {
  564. get => _isEditableTitlebarOpen;
  565. set => this.RaiseAndSetIfChanged(ref _isEditableTitlebarOpen, value);
  566. }
  567. #endregion Booleans
  568. public double WindowMinSize
  569. {
  570. get
  571. {
  572. return SizeDefaults.WindowMinSize;
  573. }
  574. }
  575. private double _titlebarHeight = SettingsHelper.Settings.WindowProperties.Fullscreen
  576. || !SettingsHelper.Settings.UIProperties.ShowInterface ? 0 : SizeDefaults.TitlebarHeight;
  577. public double TitlebarHeight
  578. {
  579. set => this.RaiseAndSetIfChanged(ref _titlebarHeight, value);
  580. get => _titlebarHeight;
  581. }
  582. private double _bottombarHeight = SettingsHelper.Settings.WindowProperties.Fullscreen
  583. || !SettingsHelper.Settings.UIProperties.ShowInterface ? 0 : SizeDefaults.BottombarHeight;
  584. public double BottombarHeight
  585. {
  586. set => this.RaiseAndSetIfChanged(ref _bottombarHeight, value);
  587. get => _bottombarHeight;
  588. }
  589. private int _scaleX = 1;
  590. // Used to flip the flip button
  591. public int ScaleX
  592. {
  593. get => _scaleX;
  594. set => this.RaiseAndSetIfChanged(ref _scaleX, value);
  595. }
  596. private UserControl? _currentView;
  597. public UserControl? CurrentView
  598. {
  599. get => _currentView;
  600. set => this.RaiseAndSetIfChanged(ref _currentView, value);
  601. }
  602. public ImageViewer? ImageViewer;
  603. private uint _exifRating;
  604. public uint EXIFRating
  605. {
  606. get => _exifRating;
  607. set => this.RaiseAndSetIfChanged(ref _exifRating, value);
  608. }
  609. private int _getIndex;
  610. public int GetIndex
  611. {
  612. get => _getIndex;
  613. set => this.RaiseAndSetIfChanged(ref _getIndex, value);
  614. }
  615. private double _getSlideshowSpeed = SettingsHelper.Settings.UIProperties.SlideShowTimer;
  616. public double GetSlideshowSpeed
  617. {
  618. get => _getSlideshowSpeed;
  619. set
  620. {
  621. var roundedValue = Math.Round(value, 2);
  622. this.RaiseAndSetIfChanged(ref _getSlideshowSpeed, roundedValue);
  623. SettingsHelper.Settings.UIProperties.SlideShowTimer = roundedValue;
  624. }
  625. }
  626. private double _getNavSpeed = SettingsHelper.Settings.UIProperties.NavSpeed;
  627. public double GetNavSpeed
  628. {
  629. get => Math.Round(_getNavSpeed, 2);
  630. set
  631. {
  632. this.RaiseAndSetIfChanged(ref _getNavSpeed, value);
  633. SettingsHelper.Settings.UIProperties.NavSpeed = value;
  634. }
  635. }
  636. private double _getZoomSpeed = SettingsHelper.Settings.Zoom.ZoomSpeed;
  637. public double GetZoomSpeed
  638. {
  639. get => _getZoomSpeed;
  640. set
  641. {
  642. var roundedValue = Math.Round(value, 2);
  643. this.RaiseAndSetIfChanged(ref _getZoomSpeed, roundedValue);
  644. SettingsHelper.Settings.Zoom.ZoomSpeed = roundedValue;
  645. }
  646. }
  647. #region strings
  648. private string? _getIsShowingUITranslation;
  649. public string? GetIsShowingUITranslation
  650. {
  651. get => _getIsShowingUITranslation;
  652. set => this.RaiseAndSetIfChanged(ref _getIsShowingUITranslation, value);
  653. }
  654. private string? _getIsShowingBottomToolbarTranslation;
  655. public string? GetIsShowingBottomToolbarTranslation
  656. {
  657. get => _getIsShowingBottomToolbarTranslation;
  658. set => this.RaiseAndSetIfChanged(ref _getIsShowingBottomToolbarTranslation, value);
  659. }
  660. private string? _getIsFlipped;
  661. public string? GetIsFlippedTranslation
  662. {
  663. get => ScaleX == -1 ? UnFlip : Flip;
  664. set => this.RaiseAndSetIfChanged(ref _getIsFlipped, value);
  665. }
  666. private string? _getIsShowingBottomGalleryTranslation;
  667. public string? GetIsShowingBottomGalleryTranslation
  668. {
  669. get => _getIsShowingBottomGalleryTranslation;
  670. set => this.RaiseAndSetIfChanged(ref _getIsShowingBottomGalleryTranslation, value);
  671. }
  672. private string? _getIsLoopingTranslation;
  673. public string? GetIsLoopingTranslation
  674. {
  675. get => _getIsLoopingTranslation;
  676. set => this.RaiseAndSetIfChanged(ref _getIsLoopingTranslation, value);
  677. }
  678. private string? _getIsScrollingTranslation;
  679. public string? GetIsScrollingTranslation
  680. {
  681. get => _getIsScrollingTranslation;
  682. set => this.RaiseAndSetIfChanged(ref _getIsScrollingTranslation, value);
  683. }
  684. private string? _getIsCtrlZoomTranslation;
  685. public string? GetIsCtrlZoomTranslation
  686. {
  687. get => _getIsCtrlZoomTranslation;
  688. set => this.RaiseAndSetIfChanged(ref _getIsCtrlZoomTranslation, value);
  689. }
  690. private string? _getPrintSizeInch;
  691. public string? GetPrintSizeInch
  692. {
  693. get => _getPrintSizeInch;
  694. set => this.RaiseAndSetIfChanged(ref _getPrintSizeInch, value);
  695. }
  696. private string? _getPrintSizeCm;
  697. public string? GetPrintSizeCm
  698. {
  699. get => _getPrintSizeCm;
  700. set => this.RaiseAndSetIfChanged(ref _getPrintSizeCm, value);
  701. }
  702. private string? _getSizeMp;
  703. public string? GetSizeMp
  704. {
  705. get => _getSizeMp;
  706. set => this.RaiseAndSetIfChanged(ref _getSizeMp, value);
  707. }
  708. private string? _getResolution;
  709. public string? GetResolution
  710. {
  711. get => _getResolution;
  712. set => this.RaiseAndSetIfChanged(ref _getResolution, value);
  713. }
  714. private string? _getBitDepth;
  715. public string? GetBitDepth
  716. {
  717. get => _getBitDepth;
  718. set => this.RaiseAndSetIfChanged(ref _getBitDepth, value);
  719. }
  720. private string? _getAspectRatio;
  721. public string? GetAspectRatio
  722. {
  723. get => _getAspectRatio;
  724. set => this.RaiseAndSetIfChanged(ref _getAspectRatio, value);
  725. }
  726. private string? _getLatitude;
  727. public string? GetLatitude
  728. {
  729. get => _getLatitude;
  730. set => this.RaiseAndSetIfChanged(ref _getLatitude, value);
  731. }
  732. private string? _getLongitude;
  733. public string? GetLongitude
  734. {
  735. get => _getLongitude;
  736. set => this.RaiseAndSetIfChanged(ref _getLongitude, value);
  737. }
  738. private string? _getAltitude;
  739. public string? GetAltitude
  740. {
  741. get => _getAltitude;
  742. set => this.RaiseAndSetIfChanged(ref _getAltitude, value);
  743. }
  744. private string? _googleLink;
  745. public string? GoogleLink
  746. {
  747. get => _googleLink;
  748. set => this.RaiseAndSetIfChanged(ref _googleLink, value);
  749. }
  750. private string? _bingLink;
  751. public string? BingLink
  752. {
  753. get => _bingLink;
  754. set => this.RaiseAndSetIfChanged(ref _bingLink, value);
  755. }
  756. private string? _getAuthors;
  757. public string? GetAuthors
  758. {
  759. get => _getAuthors;
  760. set => this.RaiseAndSetIfChanged(ref _getAuthors, value);
  761. }
  762. private string? _getDateTaken;
  763. public string? GetDateTaken
  764. {
  765. get => _getDateTaken;
  766. set => this.RaiseAndSetIfChanged(ref _getDateTaken, value);
  767. }
  768. private string? _getCopyright;
  769. public string? GetCopyright
  770. {
  771. get => _getCopyright;
  772. set => this.RaiseAndSetIfChanged(ref _getCopyright, value);
  773. }
  774. private string? _getTitle;
  775. public string? GetTitle
  776. {
  777. get => _getTitle;
  778. set => this.RaiseAndSetIfChanged(ref _getTitle, value);
  779. }
  780. private string? _getSubject;
  781. public string? GetSubject
  782. {
  783. get => _getSubject;
  784. set => this.RaiseAndSetIfChanged(ref _getSubject, value);
  785. }
  786. private string? _getSoftware;
  787. public string? GetSoftware
  788. {
  789. get => _getSoftware;
  790. set => this.RaiseAndSetIfChanged(ref _getSoftware, value);
  791. }
  792. private string? _getResolutionUnit;
  793. public string? GetResolutionUnit
  794. {
  795. get => _getResolutionUnit;
  796. set => this.RaiseAndSetIfChanged(ref _getResolutionUnit, value);
  797. }
  798. private string? _getColorRepresentation;
  799. public string? GetColorRepresentation
  800. {
  801. get => _getColorRepresentation;
  802. set => this.RaiseAndSetIfChanged(ref _getColorRepresentation, value);
  803. }
  804. private string? _getCompression;
  805. public string? GetCompression
  806. {
  807. get => _getCompression;
  808. set => this.RaiseAndSetIfChanged(ref _getCompression, value);
  809. }
  810. private string? _getCompressedBitsPixel;
  811. public string? GetCompressedBitsPixel
  812. {
  813. get => _getCompressedBitsPixel;
  814. set => this.RaiseAndSetIfChanged(ref _getCompressedBitsPixel, value);
  815. }
  816. private string? _getCameraMaker;
  817. public string? GetCameraMaker
  818. {
  819. get => _getCameraMaker;
  820. set => this.RaiseAndSetIfChanged(ref _getCameraMaker, value);
  821. }
  822. private string? _getCameraModel;
  823. public string? GetCameraModel
  824. {
  825. get => _getCameraModel;
  826. set => this.RaiseAndSetIfChanged(ref _getCameraModel, value);
  827. }
  828. private string? _GetExposureProgram;
  829. public string? GetExposureProgram
  830. {
  831. get => _GetExposureProgram;
  832. set => this.RaiseAndSetIfChanged(ref _GetExposureProgram, value);
  833. }
  834. private string? _getExposureTime;
  835. public string? GetExposureTime
  836. {
  837. get => _getExposureTime;
  838. set => this.RaiseAndSetIfChanged(ref _getExposureTime, value);
  839. }
  840. private string? _GetExposureBias;
  841. public string? GetExposureBias
  842. {
  843. get => _GetExposureBias;
  844. set => this.RaiseAndSetIfChanged(ref _GetExposureBias, value);
  845. }
  846. private string? _GetFNumber;
  847. public string? GetFNumber
  848. {
  849. get => _GetFNumber;
  850. set => this.RaiseAndSetIfChanged(ref _GetFNumber, value);
  851. }
  852. private string? _getMaxAperture;
  853. public string? GetMaxAperture
  854. {
  855. get => _getMaxAperture;
  856. set => this.RaiseAndSetIfChanged(ref _getMaxAperture, value);
  857. }
  858. private string? _getDigitalZoom;
  859. public string? GetDigitalZoom
  860. {
  861. get => _getDigitalZoom;
  862. set => this.RaiseAndSetIfChanged(ref _getDigitalZoom, value);
  863. }
  864. private string? _getFocalLength35Mm;
  865. public string? GetFocalLength35Mm
  866. {
  867. get => _getFocalLength35Mm;
  868. set => this.RaiseAndSetIfChanged(ref _getFocalLength35Mm, value);
  869. }
  870. private string? _getFocalLength;
  871. public string? GetFocalLength
  872. {
  873. get => _getFocalLength;
  874. set => this.RaiseAndSetIfChanged(ref _getFocalLength, value);
  875. }
  876. private string? _getISOSpeed;
  877. public string? GetISOSpeed
  878. {
  879. get => _getISOSpeed;
  880. set => this.RaiseAndSetIfChanged(ref _getISOSpeed, value);
  881. }
  882. private string? _getMeteringMode;
  883. public string? GetMeteringMode
  884. {
  885. get => _getMeteringMode;
  886. set => this.RaiseAndSetIfChanged(ref _getMeteringMode, value);
  887. }
  888. private string? _getContrast;
  889. public string? GetContrast
  890. {
  891. get => _getContrast;
  892. set => this.RaiseAndSetIfChanged(ref _getContrast, value);
  893. }
  894. private string? _getSaturation;
  895. public string? GetSaturation
  896. {
  897. get => _getSaturation;
  898. set => this.RaiseAndSetIfChanged(ref _getSaturation, value);
  899. }
  900. private string? _getSharpness;
  901. public string? GetSharpness
  902. {
  903. get => _getSharpness;
  904. set => this.RaiseAndSetIfChanged(ref _getSharpness, value);
  905. }
  906. private string? _getWhiteBalance;
  907. public string? GetWhiteBalance
  908. {
  909. get => _getWhiteBalance;
  910. set => this.RaiseAndSetIfChanged(ref _getWhiteBalance, value);
  911. }
  912. private string? _getFlashMode;
  913. public string? GetFlashMode
  914. {
  915. get => _getFlashMode;
  916. set => this.RaiseAndSetIfChanged(ref _getFlashMode, value);
  917. }
  918. private string? _getFlashEnergy;
  919. public string? GetFlashEnergy
  920. {
  921. get => _getFlashEnergy;
  922. set => this.RaiseAndSetIfChanged(ref _getFlashEnergy, value);
  923. }
  924. private string? _getLightSource;
  925. public string? GetLightSource
  926. {
  927. get => _getLightSource;
  928. set => this.RaiseAndSetIfChanged(ref _getLightSource, value);
  929. }
  930. private string? _getBrightness;
  931. public string? GetBrightness
  932. {
  933. get => _getBrightness;
  934. set => this.RaiseAndSetIfChanged(ref _getBrightness, value);
  935. }
  936. private string? _getPhotometricInterpretation;
  937. public string? GetPhotometricInterpretation
  938. {
  939. get => _getPhotometricInterpretation;
  940. set => this.RaiseAndSetIfChanged(ref _getPhotometricInterpretation, value);
  941. }
  942. private string? _getOrientation;
  943. public string? GetOrientation
  944. {
  945. get => _getOrientation;
  946. set => this.RaiseAndSetIfChanged(ref _getOrientation, value);
  947. }
  948. private string? _getExifVersion;
  949. public string? GetExifVersion
  950. {
  951. get => _getExifVersion;
  952. set => this.RaiseAndSetIfChanged(ref _getExifVersion, value);
  953. }
  954. private string? _GetLensModel;
  955. public string? GetLensModel
  956. {
  957. get => _GetLensModel;
  958. set => this.RaiseAndSetIfChanged(ref _GetLensModel, value);
  959. }
  960. private string? _getLensMaker;
  961. public string? GetLensMaker
  962. {
  963. get => _getLensMaker;
  964. set => this.RaiseAndSetIfChanged(ref _getLensMaker, value);
  965. }
  966. #endregion strings
  967. #region Window Properties
  968. private string? _title = "Loading...";
  969. public string? Title
  970. {
  971. get => _title;
  972. set => this.RaiseAndSetIfChanged(ref _title, value);
  973. }
  974. private string? _titleTooltip = "Loading...";
  975. public string? TitleTooltip
  976. {
  977. get => _titleTooltip;
  978. set => this.RaiseAndSetIfChanged(ref _titleTooltip, value);
  979. }
  980. private string? _windowTitle = "PicView";
  981. public string? WindowTitle
  982. {
  983. get => _windowTitle;
  984. set => this.RaiseAndSetIfChanged(ref _windowTitle, value);
  985. }
  986. private SizeToContent _sizeToContent;
  987. public SizeToContent SizeToContent
  988. {
  989. get => _sizeToContent;
  990. set => this.RaiseAndSetIfChanged(ref _sizeToContent, value);
  991. }
  992. private bool _canResize;
  993. public bool CanResize
  994. {
  995. get => _canResize;
  996. set => this.RaiseAndSetIfChanged(ref _canResize, value);
  997. }
  998. private bool _isRotationAnimationEnabled;
  999. public bool IsRotationAnimationEnabled
  1000. {
  1001. get => _isRotationAnimationEnabled;
  1002. set => this.RaiseAndSetIfChanged(ref _isRotationAnimationEnabled, value);
  1003. }
  1004. #endregion Window Properties
  1005. #region Size
  1006. private double _titleMaxWidth;
  1007. public double TitleMaxWidth
  1008. {
  1009. get => _titleMaxWidth;
  1010. set => this.RaiseAndSetIfChanged(ref _titleMaxWidth, value);
  1011. }
  1012. #endregion Size
  1013. #region Zoom
  1014. private double _rotationAngle;
  1015. public double RotationAngle
  1016. {
  1017. get => _rotationAngle;
  1018. set => this.RaiseAndSetIfChanged(ref _rotationAngle, value);
  1019. }
  1020. private double _zoomValue;
  1021. public double ZoomValue
  1022. {
  1023. get => _zoomValue;
  1024. set => this.RaiseAndSetIfChanged(ref _zoomValue, value);
  1025. }
  1026. private ScrollBarVisibility _toggleScrollBarVisibility;
  1027. public ScrollBarVisibility ToggleScrollBarVisibility
  1028. {
  1029. get => _toggleScrollBarVisibility;
  1030. set => this.RaiseAndSetIfChanged(ref _toggleScrollBarVisibility, value);
  1031. }
  1032. #endregion Zoom
  1033. #region Menus
  1034. private bool _isFileMenuVisible;
  1035. public bool IsFileMenuVisible
  1036. {
  1037. get => _isFileMenuVisible;
  1038. set => this.RaiseAndSetIfChanged(ref _isFileMenuVisible, value);
  1039. }
  1040. private bool _isImageMenuVisible;
  1041. public bool IsImageMenuVisible
  1042. {
  1043. get => _isImageMenuVisible;
  1044. set => this.RaiseAndSetIfChanged(ref _isImageMenuVisible, value);
  1045. }
  1046. private bool _isSettingsMenuVisible;
  1047. public bool IsSettingsMenuVisible
  1048. {
  1049. get => _isSettingsMenuVisible;
  1050. set => this.RaiseAndSetIfChanged(ref _isSettingsMenuVisible, value);
  1051. }
  1052. private bool _isToolsMenuVisible;
  1053. public bool IsToolsMenuVisible
  1054. {
  1055. get => _isToolsMenuVisible;
  1056. set => this.RaiseAndSetIfChanged(ref _isToolsMenuVisible, value);
  1057. }
  1058. #endregion Menus
  1059. #endregion Fields
  1060. #region Services
  1061. public ImageIterator? ImageIterator;
  1062. #endregion Services
  1063. #region Methods
  1064. #region Sorting Order
  1065. private FileListHelper.SortFilesBy _sortOrder;
  1066. public FileListHelper.SortFilesBy SortOrder
  1067. {
  1068. get => _sortOrder;
  1069. set => this.RaiseAndSetIfChanged(ref _sortOrder, value);
  1070. }
  1071. private bool _isAscending = SettingsHelper.Settings.Sorting.Ascending;
  1072. public bool IsAscending
  1073. {
  1074. get => _isAscending;
  1075. set => this.RaiseAndSetIfChanged(ref _isAscending, value);
  1076. }
  1077. #endregion Sorting Order
  1078. private async Task ResizeImageByPercentage(int percentage)
  1079. {
  1080. SetTitleHelper.SetLoadingTitle(this);
  1081. var success = await ConversionHelper.ResizeImageByPercentage(FileInfo, percentage);
  1082. if (success)
  1083. {
  1084. if (ImageIterator is not null)
  1085. {
  1086. await ImageIterator.QuickReload().ConfigureAwait(false);
  1087. }
  1088. }
  1089. else
  1090. {
  1091. SetTitleHelper.SetTitle(this);
  1092. }
  1093. }
  1094. private async Task ConvertFileExtension(int index)
  1095. {
  1096. if (FileInfo is null)
  1097. {
  1098. return;
  1099. }
  1100. var newPath = await ConversionHelper.ConvertTask(FileInfo, index);
  1101. if (!string.IsNullOrWhiteSpace(newPath))
  1102. {
  1103. await NavigationHelper.LoadPicFromStringAsync(newPath, this);
  1104. }
  1105. }
  1106. private async Task CopyFileTask(string path)
  1107. {
  1108. if (string.IsNullOrWhiteSpace(path))
  1109. {
  1110. return;
  1111. }
  1112. if (PlatformService is null)
  1113. {
  1114. return;
  1115. }
  1116. await ClipboardHelper.CopyFileToClipboard(path, this);
  1117. }
  1118. private async Task CopyFilePathTask(string path)
  1119. {
  1120. if (string.IsNullOrWhiteSpace(path))
  1121. {
  1122. return;
  1123. }
  1124. if (PlatformService is null)
  1125. {
  1126. return;
  1127. }
  1128. await ClipboardHelper.CopyTextToClipboard(path);
  1129. }
  1130. private async Task CopyBase64Task(string path)
  1131. {
  1132. if (PlatformService is null)
  1133. {
  1134. return;
  1135. }
  1136. await ClipboardHelper.CopyBase64ToClipboard(path, this);
  1137. }
  1138. private async Task CutFileTask(string path)
  1139. {
  1140. if (string.IsNullOrWhiteSpace(path))
  1141. {
  1142. return;
  1143. }
  1144. if (PlatformService is null)
  1145. {
  1146. return;
  1147. }
  1148. await ClipboardHelper.CutFile(path, this);
  1149. }
  1150. private async Task DeleteFileTask(string path)
  1151. {
  1152. if (string.IsNullOrWhiteSpace(path))
  1153. {
  1154. return;
  1155. }
  1156. await Task.Run(() =>
  1157. {
  1158. FileDeletionHelper.DeleteFileWithErrorMsg(path, recycle: false);
  1159. });
  1160. }
  1161. private async Task RecycleFileTask(string path)
  1162. {
  1163. if (string.IsNullOrWhiteSpace(path))
  1164. {
  1165. return;
  1166. }
  1167. await Task.Run(() =>
  1168. {
  1169. FileDeletionHelper.DeleteFileWithErrorMsg(path, recycle: true);
  1170. });
  1171. }
  1172. private async Task DuplicateFileTask(string path)
  1173. {
  1174. if (string.IsNullOrWhiteSpace(path))
  1175. {
  1176. return;
  1177. }
  1178. IsLoading = true;
  1179. if (path == FileInfo.FullName)
  1180. {
  1181. await FunctionsHelper.DuplicateFile();
  1182. }
  1183. else
  1184. {
  1185. await Task.Run(() =>
  1186. {
  1187. FileHelper.DuplicateAndReturnFileName(path);
  1188. });
  1189. }
  1190. IsLoading = false;
  1191. }
  1192. private async Task ShowFilePropertiesTask(string path)
  1193. {
  1194. if (string.IsNullOrWhiteSpace(path))
  1195. {
  1196. return;
  1197. }
  1198. if (PlatformService is null)
  1199. {
  1200. return;
  1201. }
  1202. await Task.Run(() =>
  1203. {
  1204. PlatformService.ShowFileProperties(path);
  1205. });
  1206. }
  1207. private async Task PrintTask(string path)
  1208. {
  1209. if (string.IsNullOrWhiteSpace(path))
  1210. {
  1211. return;
  1212. }
  1213. if (PlatformService is null)
  1214. {
  1215. return;
  1216. }
  1217. await Task.Run(() =>
  1218. {
  1219. PlatformService?.Print(path);
  1220. });
  1221. }
  1222. private async Task OpenWithTask(string path)
  1223. {
  1224. if (string.IsNullOrWhiteSpace(path))
  1225. {
  1226. return;
  1227. }
  1228. if (PlatformService is null)
  1229. {
  1230. return;
  1231. }
  1232. await Task.Run(() =>
  1233. {
  1234. PlatformService?.OpenWith(path);
  1235. });
  1236. }
  1237. private async Task LocateOnDiskTask(string path)
  1238. {
  1239. if (string.IsNullOrWhiteSpace(path))
  1240. {
  1241. return;
  1242. }
  1243. if (PlatformService is null)
  1244. {
  1245. return;
  1246. }
  1247. await Task.Run(() =>
  1248. {
  1249. PlatformService?.LocateOnDisk(path);
  1250. });
  1251. }
  1252. public async Task SetAsWallpaperTask(string path)
  1253. {
  1254. if (string.IsNullOrWhiteSpace(path))
  1255. {
  1256. return;
  1257. }
  1258. if (PlatformService is null)
  1259. {
  1260. return;
  1261. }
  1262. await Task.Run(() =>
  1263. {
  1264. PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Fit));
  1265. });
  1266. }
  1267. public async Task SetAsWallpaperFilledTask(string path)
  1268. {
  1269. if (string.IsNullOrWhiteSpace(path))
  1270. {
  1271. return;
  1272. }
  1273. if (PlatformService is null)
  1274. {
  1275. return;
  1276. }
  1277. await Task.Run(() =>
  1278. {
  1279. PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Fill));
  1280. });
  1281. }
  1282. public async Task SetAsWallpaperTiledTask(string path)
  1283. {
  1284. if (string.IsNullOrWhiteSpace(path))
  1285. {
  1286. return;
  1287. }
  1288. if (PlatformService is null)
  1289. {
  1290. return;
  1291. }
  1292. await Task.Run(() =>
  1293. {
  1294. PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Tile));
  1295. });
  1296. }
  1297. public async Task SetAsWallpaperStretchedTask(string path)
  1298. {
  1299. if (string.IsNullOrWhiteSpace(path))
  1300. {
  1301. return;
  1302. }
  1303. if (PlatformService is null)
  1304. {
  1305. return;
  1306. }
  1307. await Task.Run(() =>
  1308. {
  1309. PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Stretch));
  1310. });
  1311. }
  1312. public async Task SetAsWallpaperCenteredTask(string path)
  1313. {
  1314. if (string.IsNullOrWhiteSpace(path))
  1315. {
  1316. return;
  1317. }
  1318. if (PlatformService is null)
  1319. {
  1320. return;
  1321. }
  1322. await Task.Run(() =>
  1323. {
  1324. PlatformService?.SetAsWallpaper(path, WallpaperManager.GetWallpaperStyle(WallpaperStyle.Center));
  1325. });
  1326. }
  1327. private async Task SetAsLockScreenTask(string path)
  1328. {
  1329. if (string.IsNullOrWhiteSpace(path))
  1330. {
  1331. return;
  1332. }
  1333. if (PlatformService is null)
  1334. {
  1335. return;
  1336. }
  1337. IsLoading = true;
  1338. var file = await ImageFunctions.ConvertToCommonSupportedFormatAsync(path).ConfigureAwait(false);
  1339. var process = new Process
  1340. {
  1341. StartInfo = new ProcessStartInfo
  1342. {
  1343. Verb = "runas",
  1344. UseShellExecute = true,
  1345. FileName = "PicView.exe",
  1346. Arguments = "lockscreen," + file,
  1347. WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
  1348. }
  1349. };
  1350. process.Start();
  1351. await TooltipHelper.ShowTooltipMessageAsync(TranslationHelper.Translation.Applying, true);
  1352. await process.WaitForExitAsync();
  1353. IsLoading = false;
  1354. }
  1355. public async Task GalleryItemStretchTask(string value)
  1356. {
  1357. if (value.Equals("Square", StringComparison.OrdinalIgnoreCase))
  1358. {
  1359. if (GalleryFunctions.IsFullGalleryOpen)
  1360. {
  1361. await GalleryStretchMode.ChangeFullGalleryStretchSquare(this);
  1362. }
  1363. else
  1364. {
  1365. await GalleryStretchMode.ChangeBottomGalleryStretchSquare(this);
  1366. }
  1367. return;
  1368. }
  1369. if (value.Equals("FillSquare", StringComparison.OrdinalIgnoreCase))
  1370. {
  1371. if (GalleryFunctions.IsFullGalleryOpen)
  1372. {
  1373. await GalleryStretchMode.ChangeFullGalleryStretchSquareFill(this);
  1374. }
  1375. else
  1376. {
  1377. await GalleryStretchMode.ChangeBottomGalleryStretchSquareFill(this);
  1378. }
  1379. return;
  1380. }
  1381. if (Enum.TryParse<Stretch>(value, out var stretch))
  1382. {
  1383. if (GalleryFunctions.IsFullGalleryOpen)
  1384. {
  1385. await GalleryStretchMode.ChangeFullGalleryItemStretch(this, stretch);
  1386. }
  1387. else
  1388. {
  1389. await GalleryStretchMode.ChangeBottomGalleryItemStretch(this, stretch);
  1390. }
  1391. }
  1392. }
  1393. public async Task StartSlideShowTask(int milliseconds)
  1394. {
  1395. if (milliseconds <= 0)
  1396. {
  1397. await Avalonia.Navigation.Slideshow.StartSlideshow(this);
  1398. }
  1399. else
  1400. {
  1401. await Avalonia.Navigation.Slideshow.StartSlideshow(this, milliseconds);
  1402. }
  1403. }
  1404. #endregion Methods
  1405. public MainViewModel(IPlatformSpecificService? platformSpecificService)
  1406. {
  1407. FunctionsHelper.Vm = this;
  1408. PlatformService = platformSpecificService;
  1409. #region Window commands
  1410. ExitCommand = ReactiveCommand.CreateFromTask(WindowFunctions.Close);
  1411. MinimizeCommand = ReactiveCommand.CreateFromTask(WindowFunctions.Minimize);
  1412. MaximizeCommand = ReactiveCommand.CreateFromTask(WindowFunctions.MaximizeRestore);
  1413. ToggleFullscreenCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleFullscreen);
  1414. NewWindowCommand = ReactiveCommand.Create(ProcessHelper.StartNewProcess);
  1415. ShowExifWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowExifWindow);
  1416. ShowSettingsWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowSettingsWindow);
  1417. ShowKeybindingsWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowKeybindingsWindow);
  1418. ShowAboutWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowAboutWindow);
  1419. ShowBatchResizeWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowBatchResizeWindow);
  1420. ShowSingleImageResizeWindowCommand = ReactiveCommand.Create(platformSpecificService.ShowSingleImageResizeWindow);
  1421. #endregion Window commands
  1422. #region Navigation Commands
  1423. NextCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Next);
  1424. NextButtonCommand = ReactiveCommand.CreateFromTask(async () =>
  1425. {
  1426. await NavigationHelper.NavigateAndPositionCursor(next:true, arrow: false, vm: this);
  1427. });
  1428. NextArrowButtonCommand = ReactiveCommand.CreateFromTask(async () =>
  1429. {
  1430. await NavigationHelper.NavigateAndPositionCursor(next:true, arrow: true, vm: this);
  1431. });
  1432. NextFolderCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.NextFolder);
  1433. PreviousCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Prev);
  1434. PreviousButtonCommand = ReactiveCommand.CreateFromTask(async () =>
  1435. {
  1436. await NavigationHelper.NavigateAndPositionCursor(next:false, arrow: false, vm: this);
  1437. });
  1438. PreviousArrowButtonCommand = ReactiveCommand.CreateFromTask(async () =>
  1439. {
  1440. await NavigationHelper.NavigateAndPositionCursor(next:false, arrow: true, vm: this);
  1441. });
  1442. PreviousFolderCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.PrevFolder);
  1443. FirstCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.First);
  1444. LastCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Last);
  1445. ReloadCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Reload);
  1446. #endregion Navigation Commands
  1447. #region Sort Commands
  1448. SortFilesByNameCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesByName);
  1449. SortFilesByCreationTimeCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesByCreationTime);
  1450. SortFilesByLastAccessTimeCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesByLastAccessTime);
  1451. SortFilesBySizeCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesBySize);
  1452. SortFilesByExtensionCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesByExtension);
  1453. SortFilesRandomlyCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesRandomly);
  1454. SortFilesAscendingCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesAscending);
  1455. SortFilesDescendingCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SortFilesDescending);
  1456. #endregion Sort Commands
  1457. #region Menus
  1458. CloseMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.CloseMenus);
  1459. ToggleFileMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleFileMenu);
  1460. ToggleImageMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleImageMenu);
  1461. ToggleSettingsMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleSettingsMenu);
  1462. ToggleToolsMenuCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleToolsMenu);
  1463. #endregion Menus
  1464. #region Image commands
  1465. RotateLeftCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.RotateLeft);
  1466. RotateLeftButtonCommand = ReactiveCommand.CreateFromTask(async () =>
  1467. {
  1468. await Rotation.RotateLeft(this, Rotation.RotationButton.RotateLeftButton);
  1469. });
  1470. RotateRightCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.RotateRight);
  1471. RotateRightButtonCommand = ReactiveCommand.CreateFromTask(async () =>
  1472. {
  1473. await Rotation.RotateRight(this, Rotation.RotationButton.RotateRightButton);
  1474. });
  1475. RotateRightWindowBorderButtonCommand = ReactiveCommand.CreateFromTask(async () =>
  1476. {
  1477. await Rotation.RotateRight(this, Rotation.RotationButton.WindowBorderButton);
  1478. });
  1479. FlipCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Flip);
  1480. StretchCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Stretch);
  1481. CropCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Crop);
  1482. ToggleScrollCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleScroll);
  1483. OptimizeImageCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OptimizeImage);
  1484. ChangeBackgroundCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ChangeBackground);
  1485. ShowSideBySideCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SideBySide);
  1486. #endregion Image commands
  1487. #region File commands
  1488. OpenFileCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Open, Observable.Return(true));
  1489. OpenLastFileCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OpenLastFile);
  1490. SaveFileCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Save);
  1491. CopyFileCommand = ReactiveCommand.CreateFromTask<string>(CopyFileTask);
  1492. CopyFilePathCommand = ReactiveCommand.CreateFromTask<string>(CopyFilePathTask);
  1493. FilePropertiesCommand = ReactiveCommand.CreateFromTask<string>(ShowFilePropertiesTask);
  1494. CopyImageCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.CopyImage);
  1495. CopyBase64Command = ReactiveCommand.CreateFromTask<string>(CopyBase64Task);
  1496. CutCommand = ReactiveCommand.CreateFromTask<string>(CutFileTask);
  1497. PasteCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Paste);
  1498. OpenWithCommand = ReactiveCommand.CreateFromTask<string>(OpenWithTask);
  1499. RenameCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Rename);
  1500. ResizeCommand = ReactiveCommand.CreateFromTask<int>(ResizeImageByPercentage);
  1501. ConvertCommand = ReactiveCommand.CreateFromTask<int>(ConvertFileExtension);
  1502. DuplicateFileCommand = ReactiveCommand.CreateFromTask<string>(DuplicateFileTask);
  1503. PrintCommand = ReactiveCommand.CreateFromTask<string>(PrintTask);
  1504. DeleteFileCommand = ReactiveCommand.CreateFromTask<string>(DeleteFileTask);
  1505. RecycleFileCommand = ReactiveCommand.CreateFromTask<string>(RecycleFileTask);
  1506. LocateOnDiskCommand = ReactiveCommand.CreateFromTask<string>(LocateOnDiskTask);
  1507. SetAsWallpaperCommand = ReactiveCommand.CreateFromTask<string>(SetAsWallpaperTask);
  1508. SetAsWallpaperTiledCommand = ReactiveCommand.CreateFromTask<string>(SetAsWallpaperTiledTask);
  1509. SetAsWallpaperStretchedCommand = ReactiveCommand.CreateFromTask<string>(SetAsWallpaperStretchedTask);
  1510. SetAsWallpaperCenteredCommand = ReactiveCommand.CreateFromTask<string>(SetAsWallpaperCenteredTask);
  1511. SetAsWallpaperFilledCommand = ReactiveCommand.CreateFromTask<string>(SetAsWallpaperFilledTask);
  1512. SetAsLockScreenCommand = ReactiveCommand.CreateFromTask<string>(SetAsLockScreenTask);
  1513. #endregion File commands
  1514. #region EXIF commands
  1515. SetExifRating0Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set0Star);
  1516. SetExifRating1Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set1Star);
  1517. SetExifRating2Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set2Star);
  1518. SetExifRating3Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set3Star);
  1519. SetExifRating4Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set4Star);
  1520. SetExifRating5Command = ReactiveCommand.CreateFromTask(FunctionsHelper.Set5Star);
  1521. OpenGoogleLinkCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OpenGoogleMaps);
  1522. OpenBingLinkCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OpenBingMaps);
  1523. #endregion EXIF commands
  1524. #region Gallery Commands
  1525. ToggleGalleryCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleGallery);
  1526. ToggleBottomGalleryCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.OpenCloseBottomGallery);
  1527. CloseGalleryCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.CloseGallery);
  1528. GalleryItemStretchCommand = ReactiveCommand.CreateFromTask<string>(GalleryItemStretchTask);
  1529. #endregion Gallery Commands
  1530. #region UI Commands
  1531. ToggleUICommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleInterface);
  1532. ToggleBottomNavBarCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleBottomToolbar);
  1533. ToggleBottomGalleryShownInHiddenUICommand = ReactiveCommand.CreateFromTask(async() =>
  1534. {
  1535. await HideInterfaceLogic.ToggleBottomGalleryShownInHiddenUI(this);
  1536. });
  1537. ChangeCtrlZoomCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ChangeCtrlZoom);
  1538. ColorPickerCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ColorPicker);
  1539. SlideshowCommand = ReactiveCommand.CreateFromTask<int>(StartSlideShowTask);
  1540. ToggleTaskbarProgressCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleTaskbarProgress);
  1541. #endregion UI Commands
  1542. #region Settings commands
  1543. ChangeAutoFitCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.AutoFitWindow);
  1544. ChangeTopMostCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.SetTopMost);
  1545. ToggleSubdirectoriesCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleSubdirectories);
  1546. ToggleLoopingCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleLooping);
  1547. ResetSettingsCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ResetSettings);
  1548. RestartCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Restart);
  1549. #endregion Settings commands
  1550. }
  1551. public MainViewModel()
  1552. {
  1553. // Only use for unit test
  1554. }
  1555. }