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