mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Added icons to entries and groups with a mapping Created a Converter to handle pluralization Several UI enhancements
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using System.ComponentModel;
|
|
using Windows.UI.Xaml.Controls;
|
|
using ModernKeePass.Mappings;
|
|
using ModernKeePassLib;
|
|
using ModernKeePassLib.Security;
|
|
|
|
namespace ModernKeePass.ViewModels
|
|
{
|
|
public class EntryVm : INotifyPropertyChanged
|
|
{
|
|
public string Title
|
|
{
|
|
get { return GetEntryValue(PwDefs.TitleField); }
|
|
set { SetEntryValue(PwDefs.TitleField, value); }
|
|
}
|
|
public string UserName
|
|
{
|
|
get { return GetEntryValue(PwDefs.UserNameField); }
|
|
set { SetEntryValue(PwDefs.UserNameField, value); }
|
|
}
|
|
public string Password
|
|
{
|
|
get { return GetEntryValue(PwDefs.PasswordField); }
|
|
set { SetEntryValue(PwDefs.PasswordField, value); }
|
|
}
|
|
public string Url
|
|
{
|
|
get { return GetEntryValue(PwDefs.UrlField); }
|
|
set { SetEntryValue(PwDefs.UrlField, value); }
|
|
}
|
|
public string Notes
|
|
{
|
|
get { return GetEntryValue(PwDefs.NotesField); }
|
|
set { SetEntryValue(PwDefs.NotesField, value); }
|
|
}
|
|
|
|
public Symbol IconSymbol
|
|
{
|
|
get
|
|
{
|
|
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwEntry.IconId);
|
|
return result == Symbol.More ? Symbol.Permissions : result;
|
|
}
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
private readonly PwEntry _pwEntry;
|
|
|
|
public EntryVm() { }
|
|
public EntryVm(PwEntry entry)
|
|
{
|
|
_pwEntry = entry;
|
|
}
|
|
|
|
private string GetEntryValue(string key)
|
|
{
|
|
return _pwEntry.Strings.GetSafe(key).ReadString();
|
|
}
|
|
|
|
private void SetEntryValue(string key, string newValue)
|
|
{
|
|
_pwEntry.Strings.Set(key, new ProtectedString(true, newValue));
|
|
}
|
|
}
|
|
}
|