mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Entries and groups icons are now handled with int
Static mapping is changed to a converter
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using System;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using ModernKeePassLib;
|
||||
|
||||
namespace ModernKeePass.Mappings
|
||||
namespace ModernKeePass.Converters
|
||||
{
|
||||
public static class PwIconToSegoeMapping
|
||||
public class IntToSymbolConverter : IValueConverter
|
||||
{
|
||||
public static Symbol GetSymbolFromIcon(PwIcon icon)
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var icon = (PwIcon) value;
|
||||
switch (icon)
|
||||
{
|
||||
case PwIcon.Key: return Symbol.Permissions;
|
||||
@@ -29,7 +32,7 @@ namespace ModernKeePass.Mappings
|
||||
case PwIcon.Scanner: return Symbol.Scan;
|
||||
case PwIcon.CDRom: return Symbol.Rotate;
|
||||
case PwIcon.Monitor: return Symbol.Caption;
|
||||
case PwIcon.EMailBox:
|
||||
case PwIcon.EMailBox:
|
||||
case PwIcon.EMail: return Symbol.Mail;
|
||||
case PwIcon.Configuration: return Symbol.Setting;
|
||||
case PwIcon.ClipboardReady: return Symbol.Paste;
|
||||
@@ -56,7 +59,7 @@ namespace ModernKeePass.Mappings
|
||||
case PwIcon.Info: return Symbol.Help;
|
||||
//case PwIcon.Package: return Symbol.;
|
||||
case PwIcon.Folder:
|
||||
case PwIcon.FolderOpen:
|
||||
case PwIcon.FolderOpen:
|
||||
case PwIcon.FolderPackage: return Symbol.Folder;
|
||||
//case PwIcon.LockOpen: return Symbol.;
|
||||
case PwIcon.PaperLocked: return Symbol.ProtectedDocument;
|
||||
@@ -79,8 +82,9 @@ namespace ModernKeePass.Mappings
|
||||
}
|
||||
}
|
||||
|
||||
public static PwIcon GetIconFromSymbol(Symbol symbol)
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var symbol = (Symbol) value;
|
||||
switch (symbol)
|
||||
{
|
||||
/*case Symbol.Previous:
|
||||
@@ -474,4 +478,4 @@ namespace ModernKeePass.Mappings
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using System.Collections.Generic;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
namespace ModernKeePass.Interfaces
|
||||
@@ -7,9 +7,10 @@ namespace ModernKeePass.Interfaces
|
||||
{
|
||||
GroupVm ParentGroup { get; }
|
||||
GroupVm PreviousGroup { get; }
|
||||
Symbol IconSymbol { get; }
|
||||
int IconId { get; }
|
||||
string Id { get; }
|
||||
string Name { get; set; }
|
||||
IEnumerable<IPwEntity> BreadCrumb { get; }
|
||||
bool IsEditMode { get; }
|
||||
bool IsRecycleOnDelete { get; }
|
||||
|
||||
|
@@ -114,6 +114,7 @@
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Converters\IntToSymbolConverter.cs" />
|
||||
<Compile Include="Exceptions\DatabaseOpenedException.cs" />
|
||||
<Compile Include="Interfaces\ILicenseService.cs" />
|
||||
<Compile Include="Interfaces\IProxyInvocationHandler.cs" />
|
||||
@@ -185,7 +186,6 @@
|
||||
<Compile Include="Views\MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Mappings\PwIconToSegoeMapping.cs" />
|
||||
<Compile Include="Views\MainPageFrames\AboutPage.xaml.cs">
|
||||
<DependentUpon>AboutPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@@ -224,7 +224,7 @@ namespace ModernKeePass.Services
|
||||
{
|
||||
RecycleBin = RootGroup.AddNewGroup(title);
|
||||
RecycleBin.IsSelected = true;
|
||||
RecycleBin.IconSymbol = Symbol.Delete;
|
||||
RecycleBin.IconId = (int)PwIcon.TrashBin;
|
||||
}
|
||||
|
||||
private void CreateSampleData()
|
||||
|
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Mappings;
|
||||
using ModernKeePass.Services;
|
||||
using ModernKeePassLib;
|
||||
using ModernKeePassLib.Cryptography.PasswordGenerator;
|
||||
@@ -79,14 +77,12 @@ namespace ModernKeePass.ViewModels
|
||||
set { SetEntryValue(PwDefs.NotesField, value); }
|
||||
}
|
||||
|
||||
public Symbol IconSymbol
|
||||
public int IconId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_pwEntry == null) return Symbol.Add;
|
||||
if (HasExpired) return Symbol.Priority;
|
||||
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwEntry.IconId);
|
||||
return result == Symbol.More ? Symbol.Permissions : result;
|
||||
if (_pwEntry?.IconId != null) return (int) _pwEntry?.IconId;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,11 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Mappings;
|
||||
using ModernKeePass.Services;
|
||||
using ModernKeePassLib;
|
||||
|
||||
@@ -71,14 +68,14 @@ namespace ModernKeePass.ViewModels
|
||||
set { _pwGroup.Name = value; }
|
||||
}
|
||||
|
||||
public Symbol IconSymbol
|
||||
public int IconId
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = PwIconToSegoeMapping.GetSymbolFromIcon(_pwGroup.IconId);
|
||||
return result == Symbol.More ? Symbol.Folder : result;
|
||||
if (_pwGroup?.IconId != null) return (int) _pwGroup?.IconId;
|
||||
return -1;
|
||||
}
|
||||
set { _pwGroup.IconId = PwIconToSegoeMapping.GetIconFromSymbol(value); }
|
||||
set { _pwGroup.IconId = (PwIcon)value; }
|
||||
}
|
||||
|
||||
public bool IsEditMode
|
||||
|
@@ -19,6 +19,7 @@
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
|
||||
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
|
||||
<converters:IntToSymbolConverter x:Key="IntToSymbolConverter"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:GroupVm />
|
||||
@@ -128,7 +129,7 @@
|
||||
<ListView.Resources>
|
||||
<DataTemplate x:Name="IsRecycleBin">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="{Binding IconSymbol}" Margin="8,0,0,0">
|
||||
<SymbolIcon Symbol="{Binding IconId, Converter={StaticResource IntToSymbolConverter}}" Margin="8,0,0,0">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding Name}" />
|
||||
</ToolTipService.ToolTip>
|
||||
@@ -138,7 +139,7 @@
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Name="IsNotRecycleBin">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<SymbolIcon Symbol="{Binding IconSymbol}" Margin="8,0,0,0">
|
||||
<SymbolIcon Symbol="{Binding IconId, Converter={StaticResource IntToSymbolConverter}}" Margin="8,0,0,0">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding Name}" />
|
||||
</ToolTipService.ToolTip>
|
||||
@@ -237,7 +238,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="{Binding BackgroundColor, ConverterParameter={StaticResource MainColor}, Converter={StaticResource ColorToBrushConverter}}">
|
||||
<Viewbox MaxHeight="50" Width="100">
|
||||
<SymbolIcon Symbol="{Binding IconSymbol}" Foreground="{StaticResource TextColor}" />
|
||||
<SymbolIcon Symbol="{Binding IconId, Converter={StaticResource IntToSymbolConverter}}" Foreground="{StaticResource TextColor}" />
|
||||
</Viewbox>
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,10,0,0" >
|
||||
|
Reference in New Issue
Block a user