2017-09-27 18:01:21 +02:00
|
|
|
|
using System.Collections.ObjectModel;
|
2017-09-28 17:51:30 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Windows.UI.Xaml;
|
2017-09-10 13:49:11 -04:00
|
|
|
|
using Windows.UI.Xaml.Controls;
|
2017-09-28 17:51:30 +02:00
|
|
|
|
using Windows.UI.Xaml.Navigation;
|
2017-09-12 18:20:32 +02:00
|
|
|
|
using ModernKeePass.Pages;
|
2017-09-13 18:37:44 +02:00
|
|
|
|
using ModernKeePass.ViewModels;
|
2017-09-12 18:20:32 +02:00
|
|
|
|
|
2017-09-11 15:13:04 +02:00
|
|
|
|
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
2017-09-10 13:49:11 -04:00
|
|
|
|
|
|
|
|
|
namespace ModernKeePass
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-09-11 15:13:04 +02:00
|
|
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
2017-09-10 13:49:11 -04:00
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class MainPage : Page
|
|
|
|
|
{
|
|
|
|
|
public MainPage()
|
|
|
|
|
{
|
2017-09-26 18:18:00 +02:00
|
|
|
|
InitializeComponent();
|
2017-09-28 17:51:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnNavigatedTo(e);
|
2017-10-02 10:44:04 +02:00
|
|
|
|
var mainMenuItems = new ObservableCollection<MainMenuItemVm>
|
2017-09-11 18:25:00 +02:00
|
|
|
|
{
|
2017-10-02 10:44:04 +02:00
|
|
|
|
new MainMenuItemVm {Title = "Open", PageType = typeof(OpenDatabasePage), Destination = MenuFrame, Parameter = Frame, SymbolIcon = Symbol.Page2},
|
|
|
|
|
new MainMenuItemVm {Title = "New" /*, PageType = typeof(NewDatabasePage)*/, Destination = MenuFrame, SymbolIcon = Symbol.Add},
|
|
|
|
|
new MainMenuItemVm {Title = "Save" , PageType = typeof(SaveDatabasePage), Destination = MenuFrame, Parameter = Frame, SymbolIcon = Symbol.Save},
|
|
|
|
|
new MainMenuItemVm {Title = "Recent" , PageType = typeof(RecentDatabasesPage), Destination = MenuFrame, Parameter = Frame, SymbolIcon = Symbol.Copy}
|
2017-09-27 18:01:21 +02:00
|
|
|
|
};
|
2017-09-28 17:51:30 +02:00
|
|
|
|
var app = (App)Application.Current;
|
|
|
|
|
if (app.Database != null && app.Database.IsOpen)
|
2017-10-02 10:44:04 +02:00
|
|
|
|
mainMenuItems.Add(new MainMenuItemVm { Title = app.Database.Name, PageType = typeof(GroupDetailPage), Destination = Frame, Parameter = app.Database.RootGroup, Group = 1, SymbolIcon = Symbol.ProtectedDocument});
|
2017-09-29 17:23:35 -04:00
|
|
|
|
|
|
|
|
|
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");
|
2017-09-11 18:25:00 +02:00
|
|
|
|
}
|
2017-09-28 17:51:30 +02:00
|
|
|
|
|
2017-09-20 18:19:00 +02:00
|
|
|
|
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
2017-10-02 10:44:04 +02:00
|
|
|
|
var mainMenuItem = e.AddedItems[0] as MainMenuItemVm;
|
2017-09-29 17:23:35 -04:00
|
|
|
|
mainMenuItem?.Destination.Navigate(mainMenuItem.PageType, mainMenuItem.Parameter);
|
2017-09-25 18:34:27 +02:00
|
|
|
|
}
|
2017-09-10 13:49:11 -04:00
|
|
|
|
}
|
|
|
|
|
}
|