mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Adds some VM tests
New tooltip in Textbox with button control New welcome page in Settings (shown when noting is selected) Settings are now grouped
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
@@ -117,6 +116,7 @@ namespace ModernKeePass.ViewModels
|
||||
var pwEntry = new PwEntry(true, true);
|
||||
_pwGroup.AddEntry(pwEntry, true);
|
||||
var newEntry = new EntryVm(pwEntry, this) {IsEditMode = true};
|
||||
newEntry.GeneratePassword();
|
||||
Entries.Add(newEntry);
|
||||
return newEntry;
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public int Group { get; set; } = 0;
|
||||
public string Group { get; set; } = "_";
|
||||
public Type PageType { get; set; }
|
||||
public Symbol SymbolIcon { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
@@ -12,12 +12,12 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class MainVm : NotifyPropertyChangedBase, IHasSelectableObject
|
||||
{
|
||||
private IOrderedEnumerable<IGrouping<int, MainMenuItemVm>> _mainMenuItems;
|
||||
private IOrderedEnumerable<IGrouping<string, MainMenuItemVm>> _mainMenuItems;
|
||||
private MainMenuItemVm _selectedItem;
|
||||
|
||||
public string Name { get; } = Package.Current.DisplayName;
|
||||
|
||||
public IOrderedEnumerable<IGrouping<int, MainMenuItemVm>> MainMenuItems
|
||||
public IOrderedEnumerable<IGrouping<string, MainMenuItemVm>> MainMenuItems
|
||||
{
|
||||
get { return _mainMenuItems; }
|
||||
set { SetProperty(ref _mainMenuItems, value); }
|
||||
@@ -86,7 +86,7 @@ namespace ModernKeePass.ViewModels
|
||||
PageType = typeof(GroupDetailPage),
|
||||
Destination = referenceFrame,
|
||||
Parameter = database.RootGroup,
|
||||
Group = 1,
|
||||
Group = "Databases",
|
||||
SymbolIcon = Symbol.ProtectedDocument
|
||||
});
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Common;
|
||||
@@ -7,7 +6,7 @@ using ModernKeePass.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class OpenVm: INotifyPropertyChanged
|
||||
public class OpenVm: NotifyPropertyChangedBase
|
||||
{
|
||||
public bool ShowPasswordBox => _database?.Status == (int) DatabaseHelper.DatabaseStatus.Opening;
|
||||
|
||||
@@ -23,19 +22,12 @@ namespace ModernKeePass.ViewModels
|
||||
if (database == null || database.Status != (int) DatabaseHelper.DatabaseStatus.Opening) return;
|
||||
OpenFile(database.DatabaseFile);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void NotifyPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public void OpenFile(StorageFile file)
|
||||
{
|
||||
_database.DatabaseFile = file;
|
||||
NotifyPropertyChanged("Name");
|
||||
NotifyPropertyChanged("ShowPasswordBox");
|
||||
OnPropertyChanged("Name");
|
||||
OnPropertyChanged("ShowPasswordBox");
|
||||
AddToRecentList(file);
|
||||
}
|
||||
|
||||
|
@@ -7,11 +7,19 @@ using ModernKeePass.Pages;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class SettingsVM : NotifyPropertyChangedBase, IHasSelectableObject
|
||||
public class SettingsVm : NotifyPropertyChangedBase, IHasSelectableObject
|
||||
{
|
||||
private ListMenuItemVm _selectedItem;
|
||||
|
||||
public ObservableCollection<ListMenuItemVm> MenuItems { get; set; }
|
||||
//public ObservableCollection<ListMenuItemVm> MenuItems { get; set; }
|
||||
private IOrderedEnumerable<IGrouping<string, ListMenuItemVm>> _menuItems;
|
||||
|
||||
public IOrderedEnumerable<IGrouping<string, ListMenuItemVm>> MenuItems
|
||||
{
|
||||
get { return _menuItems; }
|
||||
set { SetProperty(ref _menuItems, value); }
|
||||
}
|
||||
|
||||
public ISelectableModel SelectedItem
|
||||
{
|
||||
get { return _selectedItem; }
|
||||
@@ -32,15 +40,17 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsVM()
|
||||
public SettingsVm()
|
||||
{
|
||||
MenuItems = new ObservableCollection<ListMenuItemVm>
|
||||
var menuItems = new ObservableCollection<ListMenuItemVm>
|
||||
{
|
||||
new ListMenuItemVm { Title = "Database", SymbolIcon = Symbol.Setting, PageType = typeof(SettingsDatabasePage), IsSelected = true },
|
||||
new ListMenuItemVm { Title = "Security", SymbolIcon = Symbol.Permissions, PageType = typeof(SettingsSecurityPage) },
|
||||
new ListMenuItemVm { Title = "General", Group = "Database", SymbolIcon = Symbol.Setting, PageType = typeof(SettingsDatabasePage), IsSelected = true },
|
||||
new ListMenuItemVm { Title = "Security", Group = "Database", SymbolIcon = Symbol.Permissions, PageType = typeof(SettingsSecurityPage) },
|
||||
//new ListMenuItemVm { Title = "General", SymbolIcon = Symbol.Edit, PageType = typeof(SettingsGeneralPage) }
|
||||
};
|
||||
SelectedItem = MenuItems.FirstOrDefault(m => m.IsSelected);
|
||||
SelectedItem = menuItems.FirstOrDefault(m => m.IsSelected);
|
||||
|
||||
MenuItems = from item in menuItems group item by item.Group into grp orderby grp.Key select grp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user