mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Update master key works
Key file creation works Code cleanup
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
using Windows.ApplicationModel;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class AboutViewModel
|
||||
{
|
||||
private readonly Package _package;
|
||||
|
||||
public string Name => _package.DisplayName;
|
||||
|
||||
public string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
var version = _package.Id.Version;
|
||||
return $"{version.Major}.{version.Minor}";
|
||||
}
|
||||
}
|
||||
|
||||
public AboutViewModel() : this(Package.Current) { }
|
||||
|
||||
public AboutViewModel(Package package)
|
||||
{
|
||||
_package = package;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,99 +0,0 @@
|
||||
using System;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.AccessCache;
|
||||
using ModernKeePass.Converters;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
using ModernKeePass.Domain.Enums;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class NewViewModel : OpenViewModel
|
||||
{
|
||||
private string _importFormatHelp;
|
||||
private readonly IDatabaseService _databaseService;
|
||||
private readonly IImportService _importService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
|
||||
public string Password { get; set; }
|
||||
|
||||
public bool IsImportChecked { get; set; }
|
||||
|
||||
public IStorageFile ImportFile { get; set; }
|
||||
|
||||
public string ImportFileExtensionFilter { get; set; } = "*";
|
||||
|
||||
public ImportFormat ImportFormat { get; set; }
|
||||
|
||||
public string ImportFormatHelp
|
||||
{
|
||||
get => _importFormatHelp;
|
||||
set
|
||||
{
|
||||
_importFormatHelp = value;
|
||||
OnPropertyChanged(nameof(ImportFormatHelp));
|
||||
}
|
||||
}
|
||||
|
||||
public NewViewModel()
|
||||
{ }
|
||||
|
||||
public NewViewModel(IDatabaseService databaseService, IImportService importService, ISettingsService settingsService)
|
||||
{
|
||||
_databaseService = databaseService;
|
||||
_importService = importService;
|
||||
_settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void PopulateInitialData()
|
||||
{
|
||||
if (_settingsService.GetSetting<bool>("Sample") && !IsImportChecked) CreateSampleData(_databaseService.RootGroupEntity);
|
||||
else if (IsImportChecked && ImportFile != null)
|
||||
{
|
||||
var token = StorageApplicationPermissions.FutureAccessList.Add(ImportFile);
|
||||
_importService.Import(ImportFormat, token, _databaseService.RootGroupEntity);
|
||||
StorageApplicationPermissions.FutureAccessList.Remove(token);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSampleData(GroupEntity groupEntity)
|
||||
{
|
||||
var converter = new IconToSymbolConverter();
|
||||
|
||||
groupEntity.SubGroups.Add(new GroupEntity
|
||||
{
|
||||
Name = "Banking",
|
||||
Icon = Icon.Calculator
|
||||
});
|
||||
|
||||
groupEntity.SubGroups.Add(new GroupEntity
|
||||
{
|
||||
Name = "Email",
|
||||
Icon = Icon.Mail
|
||||
});
|
||||
|
||||
groupEntity.SubGroups.Add(new GroupEntity
|
||||
{
|
||||
Name = "Internet",
|
||||
Icon = Icon.World
|
||||
});
|
||||
|
||||
groupEntity.Entries.Add(new EntryEntity
|
||||
{
|
||||
Name = "Sample Entry",
|
||||
UserName = "Username",
|
||||
Url = new Uri("https://keepass.info"),
|
||||
Password = "Password",
|
||||
Notes = "You may safely delete this sample"
|
||||
});
|
||||
|
||||
groupEntity.Entries.Add(new EntryEntity
|
||||
{
|
||||
Name = "Sample Entry #2",
|
||||
UserName = "Michael321",
|
||||
Url = new Uri("https://keepass.info/help/base/kb/testform.html"),
|
||||
Password = "12345"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
using Autofac;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.ViewModels.ListItems;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class RecentViewModel : NotifyPropertyChangedBase, IHasSelectableObject
|
||||
{
|
||||
private readonly IRecentService _recentService;
|
||||
private ISelectableModel _selectedItem;
|
||||
private ObservableCollection<RecentItemViewModel> _recentItems = new ObservableCollection<RecentItemViewModel>();
|
||||
|
||||
public ObservableCollection<RecentItemViewModel> RecentItems
|
||||
{
|
||||
get => _recentItems;
|
||||
set => SetProperty(ref _recentItems, value);
|
||||
}
|
||||
|
||||
public ISelectableModel SelectedItem
|
||||
{
|
||||
get => _selectedItem;
|
||||
set
|
||||
{
|
||||
if (_selectedItem == value) return;
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.IsSelected = false;
|
||||
}
|
||||
|
||||
SetProperty(ref _selectedItem, value);
|
||||
|
||||
if (_selectedItem == null) return;
|
||||
_selectedItem.IsSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ClearAllCommand { get; }
|
||||
|
||||
public RecentViewModel() : this (App.Container.Resolve<IRecentService>())
|
||||
{ }
|
||||
|
||||
public RecentViewModel(IRecentService recentService)
|
||||
{
|
||||
_recentService = recentService;
|
||||
ClearAllCommand = new RelayCommand(ClearAll);
|
||||
|
||||
RecentItems = new ObservableCollection<RecentItemViewModel>(
|
||||
_recentService.GetAll().GetAwaiter().GetResult().Select(r => new RecentItemViewModel
|
||||
{
|
||||
Name = r.Name,
|
||||
Token = r.Path
|
||||
})
|
||||
);
|
||||
if (RecentItems.Count > 0) SelectedItem = RecentItems[0];
|
||||
}
|
||||
|
||||
private void ClearAll()
|
||||
{
|
||||
_recentService.ClearAll();
|
||||
RecentItems.Clear();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
using Autofac;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class SaveViewModel
|
||||
{
|
||||
private readonly IDatabaseService _database;
|
||||
public SaveViewModel() : this(App.Container.Resolve<IDatabaseService>()) { }
|
||||
|
||||
public SaveViewModel(IDatabaseService database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Save(bool close = true)
|
||||
{
|
||||
_database.Save();
|
||||
if (close) _database.Close();
|
||||
}
|
||||
|
||||
public void Save(string token)
|
||||
{
|
||||
_database.SaveAs(new FileInfo
|
||||
{
|
||||
Path = token
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user