diff --git a/ModernKeePass/Converters/PluralizationConverter.cs b/ModernKeePass/Converters/PluralizationConverter.cs new file mode 100644 index 0000000..2a36655 --- /dev/null +++ b/ModernKeePass/Converters/PluralizationConverter.cs @@ -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(); + } + } +} diff --git a/ModernKeePass/MainPage.xaml b/ModernKeePass/MainPage.xaml index 728a129..095320e 100644 --- a/ModernKeePass/MainPage.xaml +++ b/ModernKeePass/MainPage.xaml @@ -26,13 +26,17 @@ + ItemsSource="{Binding Source={StaticResource MenuItemsSource}}" + IsSynchronizedWithCurrentItem="False"> - + + + + diff --git a/ModernKeePass/MainPage.xaml.cs b/ModernKeePass/MainPage.xaml.cs index 88b70c8..e59b7cb 100644 --- a/ModernKeePass/MainPage.xaml.cs +++ b/ModernKeePass/MainPage.xaml.cs @@ -26,26 +26,22 @@ namespace ModernKeePass base.OnNavigatedTo(e); var mainMenuItems = new ObservableCollection { - new MainMenuItem {Title = "Open", PageType = typeof(OpenDatabasePage), Destination = MenuFrame, Parameter = Frame}, - new MainMenuItem {Title = "New" /*, PageType = typeof(NewDatabasePage)*/, Destination = MenuFrame}, - new MainMenuItem {Title = "Save" , PageType = typeof(SaveDatabasePage), Destination = MenuFrame, Parameter = Frame}, - new MainMenuItem {Title = "Recent" /*, PageType = typeof(RecentDatabasesPage)*/, Destination = MenuFrame} + new MainMenuItem {Title = "Open", PageType = typeof(OpenDatabasePage), Destination = MenuFrame, Parameter = Frame, SymbolIcon = Symbol.Page2}, + new MainMenuItem {Title = "New" /*, PageType = typeof(NewDatabasePage)*/, Destination = MenuFrame, SymbolIcon = Symbol.Add}, + new MainMenuItem {Title = "Save" , PageType = typeof(SaveDatabasePage), Destination = MenuFrame, Parameter = Frame, SymbolIcon = Symbol.Save}, + new MainMenuItem {Title = "Recent" /*, PageType = typeof(RecentDatabasesPage)*/, Destination = MenuFrame, SymbolIcon = Symbol.Copy} }; var app = (App)Application.Current; if (app.Database != null && app.Database.IsOpen) - mainMenuItems.Add(new MainMenuItem { Title = app.Database.Name, PageType = typeof(GroupDetailPage), Destination = Frame, Parameter = app.Database.RootGroup, Group = 1}); + mainMenuItems.Add(new MainMenuItem { Title = app.Database.Name, PageType = typeof(GroupDetailPage), Destination = Frame, Parameter = app.Database.RootGroup, Group = 1, SymbolIcon = Symbol.ProtectedDocument}); var result = from item in mainMenuItems group item by item.Group into grp orderby grp.Key select grp; MenuItemsSource.Source = result; - //DataContext = new MainVm {MainMenuItems = mainMenuItems}; - - MenuListView.SelectedIndex = -1; } private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { var listView = sender as ListView; if (listView == null) return; - if (listView.SelectedIndex == -1) return; var selectedItem = listView.SelectedItem as MainMenuItem; selectedItem?.Destination.Navigate(selectedItem.PageType, selectedItem.Parameter); } diff --git a/ModernKeePass/Mappings/PwIconToSegoeMapping.cs b/ModernKeePass/Mappings/PwIconToSegoeMapping.cs new file mode 100644 index 0000000..1923dce --- /dev/null +++ b/ModernKeePass/Mappings/PwIconToSegoeMapping.cs @@ -0,0 +1,82 @@ +using Windows.UI.Xaml.Controls; +using ModernKeePassLib; + +namespace ModernKeePass.Mappings +{ + public static class PwIconToSegoeMapping + { + public static Symbol GetSymbolFromIcon(PwIcon icon) + { + switch (icon) + { + case PwIcon.Key: return Symbol.Permissions; + case PwIcon.World: return Symbol.World; + case PwIcon.Warning: return Symbol.Important; + case PwIcon.WorldComputer: + case PwIcon.DriveWindows: + case PwIcon.NetworkServer: return Symbol.MapDrive; + //case PwIcon.MarkedDirectory: return Symbol.; + case PwIcon.UserCommunication: return Symbol.ContactInfo; + //case PwIcon.Parts: return Symbol.; + case PwIcon.Notepad: return Symbol.Document; + //case PwIcon.WorldScoket: return Symbol.; + case PwIcon.Identity: return Symbol.Contact2; + //case PwIcon.PaperReady: return Symbol.; + case PwIcon.Digicam: return Symbol.Camera; + case PwIcon.IRCommunication: return Symbol.View; + case PwIcon.Energy: return Symbol.ZeroBars; + case PwIcon.Scanner: return Symbol.Scan; + case PwIcon.CDRom: return Symbol.Rotate; + case PwIcon.Monitor: return Symbol.Caption; + case PwIcon.EMailBox: + case PwIcon.EMail: return Symbol.Mail; + case PwIcon.Configuration: return Symbol.Setting; + case PwIcon.ClipboardReady: return Symbol.Paste; + case PwIcon.PaperNew: return Symbol.Page2; + //case PwIcon.Screen: return Symbol.Document; + case PwIcon.EnergyCareful: return Symbol.FourBars; + case PwIcon.Disk: return Symbol.Save; + //case PwIcon.Drive: return Symbol.; + //case PwIcon.PaperQ: return Symbol.; + //case PwIcon.TerminalEncrypted: return Symbol.; + //case PwIcon.Console: return Symbol.; + //case PwIcon.Printer: return Symbol.; + case PwIcon.ProgramIcons: return Symbol.GoToStart; + //case PwIcon.Run: return Symbol.; + case PwIcon.Settings: + case PwIcon.Tool: return Symbol.Repair; + //case PwIcon.Archive: return Symbol.; + case PwIcon.Count: return Symbol.MapDrive; + case PwIcon.Clock: return Symbol.Clock; + case PwIcon.EMailSearch: return Symbol.Find; + case PwIcon.PaperFlag: return Symbol.Flag; + //case PwIcon.Memory: return Symbol.; + case PwIcon.TrashBin: return Symbol.Delete; + case PwIcon.Expired: return Symbol.Cancel; + case PwIcon.Info: return Symbol.Help; + //case PwIcon.Package: return Symbol.; + case PwIcon.Folder: + case PwIcon.FolderOpen: + case PwIcon.FolderPackage: return Symbol.Folder; + //case PwIcon.LockOpen: return Symbol.; + case PwIcon.PaperLocked: return Symbol.ProtectedDocument; + case PwIcon.Checked: return Symbol.Accept; + case PwIcon.Pen: return Symbol.Edit; + case PwIcon.Thumbnail: return Symbol.BrowsePhotos; + case PwIcon.Book: return Symbol.Library; + case PwIcon.List: return Symbol.List; + case PwIcon.UserKey: return Symbol.ContactPresence; + case PwIcon.Home: return Symbol.Home; + case PwIcon.Star: return Symbol.OutlineStar; + //case PwIcon.Tux: return Symbol.; + //case PwIcon.Feather: return Symbol.; + //case PwIcon.Apple: return Symbol.; + //case PwIcon.Wiki: return Symbol.; + //case PwIcon.Money: return Symbol.; + case PwIcon.Certificate: return Symbol.PreviewLink; + case PwIcon.BlackBerry: return Symbol.CellPhone; + default: return Symbol.More; + } + } + } +} diff --git a/ModernKeePass/Models/MainMenuItem.cs b/ModernKeePass/Models/MainMenuItem.cs index 905a5cd..01f5be8 100644 --- a/ModernKeePass/Models/MainMenuItem.cs +++ b/ModernKeePass/Models/MainMenuItem.cs @@ -18,6 +18,7 @@ namespace ModernKeePass.Models public object Parameter { get; set; } public Frame Destination { get; set; } public int Group { get; set; } = 0; + public Symbol SymbolIcon { get; set; } public bool IsEnabled => PageType != null; public override string ToString() diff --git a/ModernKeePass/ModernKeePass.csproj b/ModernKeePass/ModernKeePass.csproj index ef63a57..8f8dbff 100644 --- a/ModernKeePass/ModernKeePass.csproj +++ b/ModernKeePass/ModernKeePass.csproj @@ -116,10 +116,12 @@ + MainPage.xaml + EntryDetailPage.xaml diff --git a/ModernKeePass/Pages/EntryDetailPage.xaml b/ModernKeePass/Pages/EntryDetailPage.xaml index d07d042..cbab525 100644 --- a/ModernKeePass/Pages/EntryDetailPage.xaml +++ b/ModernKeePass/Pages/EntryDetailPage.xaml @@ -25,29 +25,23 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/ModernKeePass/Pages/GroupDetailPage.xaml b/ModernKeePass/Pages/GroupDetailPage.xaml index 953b3db..da7c225 100644 --- a/ModernKeePass/Pages/GroupDetailPage.xaml +++ b/ModernKeePass/Pages/GroupDetailPage.xaml @@ -6,14 +6,27 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ViewModels="using:ModernKeePass.ViewModels" + xmlns:Converters="using:ModernKeePass.Converters" x:Name="pageRoot" x:Class="ModernKeePass.Pages.GroupDetailPage" mc:Ignorable="d" > + + + - + + + + + + @@ -24,14 +37,6 @@ - - - - + IsSynchronizedWithCurrentItem="False" > - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + +