mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
WIP Protect/Unprotect Additional Field on selection
This commit is contained in:
@@ -32,16 +32,19 @@ namespace ModernKeePass.ViewModels.ListItems
|
||||
}
|
||||
set
|
||||
{
|
||||
MessengerInstance.Send(new EntryFieldValueChangedMessage { FieldName = Name, FieldValue = value, IsProtected = IsProtected });
|
||||
Set(nameof(Value), ref _value, value);
|
||||
var protectedValue = IsProtected ? _cryptography.Protect(value).GetAwaiter().GetResult() : value;
|
||||
MessengerInstance.Send(new EntryFieldValueChangedMessage { FieldName = Name, FieldValue = protectedValue, IsProtected = IsProtected });
|
||||
Set(nameof(Value), ref _value, protectedValue);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsProtected
|
||||
{
|
||||
get { return _isProtected; }
|
||||
set
|
||||
{
|
||||
MessengerInstance.Send(new EntryFieldValueChangedMessage { FieldName = Name, FieldValue = Value, IsProtected = value });
|
||||
if (!string.IsNullOrEmpty(Name))
|
||||
MessengerInstance.Send(new EntryFieldValueChangedMessage { FieldName = Name, FieldValue = Value, IsProtected = value });
|
||||
Set(nameof(IsProtected), ref _isProtected, value);
|
||||
}
|
||||
}
|
||||
|
37
WinAppCommon/ViewModels/UserControls/ColorPickerVm.cs
Normal file
37
WinAppCommon/ViewModels/UserControls/ColorPickerVm.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class ColorPickerVm
|
||||
{
|
||||
public struct Color
|
||||
{
|
||||
public string ColorName { get; set; }
|
||||
public SolidColorBrush ColorBrush { get; set; }
|
||||
}
|
||||
|
||||
public List<Color> Colors { get; }
|
||||
|
||||
public Color SelectedItem { get; set; }
|
||||
|
||||
public ColorPickerVm()
|
||||
{
|
||||
Colors = new List<Color>();
|
||||
var type = typeof(Windows.UI.Colors);
|
||||
var properties = type.GetRuntimeProperties().ToArray();
|
||||
foreach (var propertyInfo in properties)
|
||||
{
|
||||
var color = new Color
|
||||
{
|
||||
ColorName = propertyInfo.Name,
|
||||
ColorBrush = new SolidColorBrush((Windows.UI.Color) propertyInfo.GetValue(null, null))
|
||||
};
|
||||
Colors.Add(color);
|
||||
if (color.ColorBrush.Color.Equals(SelectedColor.Color)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user