Implementing Recent Files WIP

Code refactoring
Entry coloring
This commit is contained in:
bg45
2017-09-29 17:23:35 -04:00
committed by BONNEVILLE Geoffroy
parent 817f25e8a8
commit 1ca3f29da0
12 changed files with 197 additions and 34 deletions

View File

@@ -29,21 +29,21 @@ namespace ModernKeePass
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}
new MainMenuItem {Title = "Recent" , PageType = typeof(RecentDatabasesPage), Destination = MenuFrame, Parameter = Frame, 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, SymbolIcon = Symbol.ProtectedDocument});
var result = from item in mainMenuItems group item by item.Group into grp orderby grp.Key select grp;
MenuItemsSource.Source = result;
var mainVm = DataContext as MainVm;
mainVm.MainMenuItems = from item in mainMenuItems group item by item.Group into grp orderby grp.Key select grp;
mainVm.NotifyPropertyChanged("MainMenuItems");
}
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var listView = sender as ListView;
if (listView == null) return;
var selectedItem = listView.SelectedItem as MainMenuItem;
selectedItem?.Destination.Navigate(selectedItem.PageType, selectedItem.Parameter);
var mainMenuItem = e.AddedItems[0] as MainMenuItem;
mainMenuItem?.Destination.Navigate(mainMenuItem.PageType, mainMenuItem.Parameter);
}
}
}