mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 08:00:16 -04:00
Added icons to main menu
Added icons to entries and groups with a mapping Created a Converter to handle pluralization Several UI enhancements
This commit is contained in:
25
ModernKeePass/Converters/PluralizationConverter.cs
Normal file
25
ModernKeePass/Converters/PluralizationConverter.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace ModernKeePass.Converters
|
||||
{
|
||||
public class PluralizationConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var pluralizationOptionString = parameter as string;
|
||||
var pluralizationOptions = pluralizationOptionString?.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (pluralizationOptions == null || pluralizationOptions.Length != 2) return string.Empty;
|
||||
var count = value is int ? (int) value : 0;
|
||||
var text = count == 1 ? pluralizationOptions[0] : pluralizationOptions[1];
|
||||
return $"{count} {text}";
|
||||
}
|
||||
|
||||
// No need to implement this
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user