mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 08:00:16 -04:00
Moved application code to the Application layer
Imported Win10 project Code cleanup WIP - Use common UWP services for Win8.1 and Win10
This commit is contained in:
44
ModernKeePass10/ViewModels/OpenViewModel.cs
Normal file
44
ModernKeePass10/ViewModels/OpenViewModel.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Threading.Tasks;
|
||||
using Autofac;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class OpenViewModel: NotifyPropertyChangedBase
|
||||
{
|
||||
private readonly IRecentService _recentService;
|
||||
private string _name;
|
||||
private string _databaseFilePath;
|
||||
|
||||
public bool IsFileSelected => !string.IsNullOrEmpty(DatabaseFilePath);
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
private set => SetProperty(ref _name, value);
|
||||
}
|
||||
|
||||
public string DatabaseFilePath
|
||||
{
|
||||
get => _databaseFilePath;
|
||||
private set => SetProperty(ref _databaseFilePath, value);
|
||||
}
|
||||
|
||||
public OpenViewModel(): this(App.Container.Resolve<IRecentService>())
|
||||
{ }
|
||||
public OpenViewModel(IRecentService recentService)
|
||||
{
|
||||
_recentService = recentService;
|
||||
}
|
||||
|
||||
public async Task OpenFile(FileInfo fileInfo)
|
||||
{
|
||||
Name = fileInfo.Name;
|
||||
DatabaseFilePath = fileInfo.Path;
|
||||
OnPropertyChanged(nameof(IsFileSelected));
|
||||
await _recentService.Add(fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user