|
@@ -1,9 +1,12 @@
|
|
using System;
|
|
using System;
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
+using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Media.Imaging;
|
|
using Microsoft.Win32;
|
|
using Microsoft.Win32;
|
|
|
|
+using Newtonsoft.Json.Linq;
|
|
using PixiEditor.Exceptions;
|
|
using PixiEditor.Exceptions;
|
|
using PixiEditor.Helpers;
|
|
using PixiEditor.Helpers;
|
|
using PixiEditor.Models.Controllers;
|
|
using PixiEditor.Models.Controllers;
|
|
@@ -26,6 +29,10 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
|
|
|
|
|
|
public RelayCommand ExportFileCommand { get; set; } // Command that is used to save file
|
|
public RelayCommand ExportFileCommand { get; set; } // Command that is used to save file
|
|
|
|
|
|
|
|
+ public RelayCommand OpenRecentCommand { get; set; }
|
|
|
|
+
|
|
|
|
+ public ObservableCollection<string> RecentlyOpened { get; set; } = new ObservableCollection<string>();
|
|
|
|
+
|
|
public FileViewModel(ViewModelMain owner)
|
|
public FileViewModel(ViewModelMain owner)
|
|
: base(owner)
|
|
: base(owner)
|
|
{
|
|
{
|
|
@@ -33,7 +40,23 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
|
|
SaveDocumentCommand = new RelayCommand(SaveDocument, Owner.DocumentIsNotNull);
|
|
SaveDocumentCommand = new RelayCommand(SaveDocument, Owner.DocumentIsNotNull);
|
|
OpenFileCommand = new RelayCommand(Open);
|
|
OpenFileCommand = new RelayCommand(Open);
|
|
ExportFileCommand = new RelayCommand(ExportFile, CanSave);
|
|
ExportFileCommand = new RelayCommand(ExportFile, CanSave);
|
|
|
|
+ OpenRecentCommand = new RelayCommand(OpenRecent);
|
|
Owner.OnStartupEvent += Owner_OnStartupEvent;
|
|
Owner.OnStartupEvent += Owner_OnStartupEvent;
|
|
|
|
+ RecentlyOpened = new ObservableCollection<string>(PreferencesSettings.GetPreference<JArray>(nameof(RecentlyOpened), new JArray()).ToObject<string[]>());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void OpenRecent(object parameter)
|
|
|
|
+ {
|
|
|
|
+ string path = (string)parameter;
|
|
|
|
+
|
|
|
|
+ if (!File.Exists(path))
|
|
|
|
+ {
|
|
|
|
+ NoticeDialog.Show("The file does no longer exist at that path");
|
|
|
|
+ RecentlyOpened.Remove(path);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OpenDocument((string)parameter);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|