mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-05 00:20:16 -04:00
New color to brush converter
New boolean to visibility converter Base class to handle property changes notifications for all View Models Template selector to handle a different first item in listviews or gridviews
This commit is contained in:
@@ -1,25 +1,29 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class DatabaseVm : INotifyPropertyChanged
|
||||
public class DatabaseVm : NotifyPropertyChangedBase
|
||||
{
|
||||
private string _name;
|
||||
public Visibility SelectedVisibility { get; set; } = Visibility.Collapsed;
|
||||
private Visibility _selectedVisibility = Visibility.Collapsed;
|
||||
private bool _isOpen;
|
||||
|
||||
public bool IsOpen { get; set; }
|
||||
public string Name {
|
||||
get { return string.IsNullOrEmpty(_name) ? string.Empty : $"Database {_name} selected"; }
|
||||
set { _name = value; }
|
||||
public Visibility SelectedVisibility
|
||||
{
|
||||
get { return _selectedVisibility; }
|
||||
set { SetProperty(ref _selectedVisibility, value); }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void NotifyPropertyChanged(string propertyName)
|
||||
public bool IsOpen
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
get { return _isOpen; }
|
||||
set { SetProperty(ref _isOpen, value); }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return string.IsNullOrEmpty(_name) ? string.Empty : $"Database {_name} selected"; }
|
||||
set { SetProperty(ref _name, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -42,11 +42,10 @@ namespace ModernKeePass.ViewModels
|
||||
get { return GetEntryValue(PwDefs.NotesField); }
|
||||
set { SetEntryValue(PwDefs.NotesField, value); }
|
||||
}
|
||||
public System.Drawing.Color? BackgroundColor => _pwEntry?.BackgroundColor;
|
||||
|
||||
public SolidColorBrush BackgroundColor => CreateFromColor(_pwEntry?.BackgroundColor, Colors.Transparent);
|
||||
|
||||
public SolidColorBrush ForegroundColor => CreateFromColor(_pwEntry?.ForegroundColor, Colors.White);
|
||||
|
||||
public System.Drawing.Color? ForegroundColor => _pwEntry?.ForegroundColor;
|
||||
|
||||
public FontWeight FontWeight => _pwEntry == null ? FontWeights.Bold : FontWeights.Normal;
|
||||
|
||||
public Symbol IconSymbol
|
||||
@@ -82,15 +81,5 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
_pwEntry?.Strings.Set(key, new ProtectedString(true, newValue));
|
||||
}
|
||||
|
||||
private SolidColorBrush CreateFromColor(System.Drawing.Color? color, Windows.UI.Color defaultValue)
|
||||
{
|
||||
if (!color.HasValue || color.Value == System.Drawing.Color.Empty) return new SolidColorBrush(defaultValue);
|
||||
return new SolidColorBrush(Windows.UI.Color.FromArgb(
|
||||
color.Value.A,
|
||||
color.Value.R,
|
||||
color.Value.G,
|
||||
color.Value.B));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,13 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Mappings;
|
||||
using ModernKeePassLib;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class GroupVm : INotifyPropertyChanged
|
||||
public class GroupVm : NotifyPropertyChangedBase
|
||||
{
|
||||
public GroupVm ParentGroup { get; }
|
||||
public ObservableCollection<EntryVm> Entries { get; set; } = new ObservableCollection<EntryVm>();
|
||||
@@ -18,10 +17,7 @@ namespace ModernKeePass.ViewModels
|
||||
public int EntryCount => Entries.Count - 1;
|
||||
|
||||
public int GroupCount => Groups.Count - 1;
|
||||
|
||||
public Visibility DetailsVisibility => _pwGroup == null ? Visibility.Collapsed : Visibility.Visible;
|
||||
public Visibility NewVisibility => _pwGroup == null ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
|
||||
public Symbol IconSymbol
|
||||
{
|
||||
get
|
||||
@@ -74,12 +70,5 @@ namespace ModernKeePass.ViewModels
|
||||
_pwGroup.Entries.Remove(entry.Entry);
|
||||
Entries.Remove(entry);
|
||||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void NotifyPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,19 @@
|
||||
using System.ComponentModel;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class RecentItemVm: INotifyPropertyChanged
|
||||
public class RecentItemVm: NotifyPropertyChangedBase
|
||||
{
|
||||
private bool _isSelected;
|
||||
public string Token { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Visibility PasswordVisibility { get; set; } = Visibility.Collapsed;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void NotifyPropertyChanged(string propertyName)
|
||||
public bool IsSelected
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
get { return _isSelected; }
|
||||
internal set { SetProperty(ref _isSelected, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,16 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class MainVm : INotifyPropertyChanged
|
||||
public class MainVm : NotifyPropertyChangedBase
|
||||
{
|
||||
public IOrderedEnumerable<IGrouping<int, MainMenuItemVm>> MainMenuItems { get; set; }
|
||||
private IOrderedEnumerable<IGrouping<int, MainMenuItemVm>> _mainMenuItems;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void NotifyPropertyChanged(string propertyName)
|
||||
public IOrderedEnumerable<IGrouping<int, MainMenuItemVm>> MainMenuItems
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
get { return _mainMenuItems; }
|
||||
set { SetProperty(ref _mainMenuItems, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,37 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class RecentVm : INotifyPropertyChanged
|
||||
public class RecentVm : NotifyPropertyChangedBase
|
||||
{
|
||||
public ObservableCollection<RecentItemVm> RecentItems { get; set; }
|
||||
private RecentItemVm _selectedItem;
|
||||
private ObservableCollection<RecentItemVm> _recentItems;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void NotifyPropertyChanged(string propertyName)
|
||||
public ObservableCollection<RecentItemVm> RecentItems
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
get { return _recentItems; }
|
||||
set { SetProperty(ref _recentItems, value); }
|
||||
}
|
||||
|
||||
public RecentItemVm SelectedItem
|
||||
{
|
||||
get { return _selectedItem; }
|
||||
set
|
||||
{
|
||||
if (_selectedItem == value) return;
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.IsSelected = false;
|
||||
}
|
||||
|
||||
SetProperty(ref _selectedItem, value);
|
||||
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user