2020-05-05 16:59:49 +02:00
|
|
|
|
using Windows.ApplicationModel.DataTransfer;
|
2017-10-13 15:46:41 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
2017-09-11 18:25:00 +02:00
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
using Windows.UI.Xaml.Navigation;
|
2020-04-17 16:56:07 +02:00
|
|
|
|
using ModernKeePass.Application.Entry.Models;
|
2020-04-15 12:02:30 +02:00
|
|
|
|
using ModernKeePass.Models;
|
2017-09-12 18:20:32 +02:00
|
|
|
|
using ModernKeePass.ViewModels;
|
2017-09-11 18:25:00 +02:00
|
|
|
|
|
2017-09-12 18:20:32 +02:00
|
|
|
|
// The Group Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234229
|
2017-09-11 18:25:00 +02:00
|
|
|
|
|
2017-12-08 19:38:33 +01:00
|
|
|
|
namespace ModernKeePass.Views
|
2017-09-11 18:25:00 +02:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-09-12 18:20:32 +02:00
|
|
|
|
/// A page that displays an overview of a single group, including a preview of the items
|
|
|
|
|
/// within the group.
|
2017-09-11 18:25:00 +02:00
|
|
|
|
/// </summary>
|
2017-10-12 17:45:37 +02:00
|
|
|
|
public sealed partial class GroupDetailPage
|
2017-09-11 18:25:00 +02:00
|
|
|
|
{
|
2020-04-01 12:48:36 +02:00
|
|
|
|
public GroupDetailVm Model => (GroupDetailVm)DataContext;
|
2017-10-12 18:37:49 +02:00
|
|
|
|
|
2020-04-27 11:14:29 +02:00
|
|
|
|
public GroupDetailPage()
|
2017-09-11 18:25:00 +02:00
|
|
|
|
{
|
2017-09-15 11:47:43 +02:00
|
|
|
|
InitializeComponent();
|
2017-09-11 18:25:00 +02:00
|
|
|
|
}
|
2017-09-12 18:20:32 +02:00
|
|
|
|
|
2017-09-11 18:25:00 +02:00
|
|
|
|
#region NavigationHelper registration
|
2020-04-23 19:00:38 +02:00
|
|
|
|
|
2020-04-25 22:03:47 +02:00
|
|
|
|
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
2017-09-11 18:25:00 +02:00
|
|
|
|
{
|
2020-04-21 17:13:39 +02:00
|
|
|
|
var navigationItem = e.Parameter as NavigationItem;
|
|
|
|
|
if (navigationItem != null)
|
2020-04-25 22:03:47 +02:00
|
|
|
|
{
|
|
|
|
|
await Model.Initialize(navigationItem.Id);
|
|
|
|
|
Model.IsEditMode = navigationItem.IsNew;
|
|
|
|
|
}
|
2017-09-11 18:25:00 +02:00
|
|
|
|
}
|
2020-04-21 19:12:26 +02:00
|
|
|
|
|
2017-09-11 18:25:00 +02:00
|
|
|
|
#endregion
|
2017-10-31 18:49:18 +01:00
|
|
|
|
|
2017-10-11 14:30:07 +02:00
|
|
|
|
#region Event Handlers
|
|
|
|
|
|
2017-10-02 18:40:54 +02:00
|
|
|
|
private void groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
2017-09-15 15:58:51 +02:00
|
|
|
|
{
|
2018-06-14 18:38:05 +02:00
|
|
|
|
var listView = sender as ListView;
|
|
|
|
|
switch (listView?.SelectedIndex)
|
2017-10-02 18:40:54 +02:00
|
|
|
|
{
|
2017-10-13 15:46:41 +02:00
|
|
|
|
case -1:
|
|
|
|
|
return;
|
|
|
|
|
default:
|
2020-03-30 19:43:04 +02:00
|
|
|
|
var group = listView?.SelectedItem as Application.Group.Models.GroupVm;
|
2020-04-27 11:14:29 +02:00
|
|
|
|
Model.GoToGroup(group?.Id);
|
2017-10-13 15:46:41 +02:00
|
|
|
|
break;
|
2017-10-02 18:40:54 +02:00
|
|
|
|
}
|
2017-09-15 15:58:51 +02:00
|
|
|
|
}
|
2017-09-17 10:00:03 -04:00
|
|
|
|
|
2017-10-03 18:38:31 +02:00
|
|
|
|
private void entries_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
2017-09-15 18:15:48 +02:00
|
|
|
|
{
|
2017-10-03 18:38:31 +02:00
|
|
|
|
switch (GridView.SelectedIndex)
|
2017-10-02 18:40:54 +02:00
|
|
|
|
{
|
2017-10-03 18:38:31 +02:00
|
|
|
|
case -1:
|
|
|
|
|
return;
|
2017-10-13 15:46:41 +02:00
|
|
|
|
default:
|
2018-06-25 17:31:17 +02:00
|
|
|
|
var entry = GridView.SelectedItem as EntryVm;
|
2020-04-27 11:14:29 +02:00
|
|
|
|
Model.GoToEntry(entry?.Id);
|
2017-10-13 15:46:41 +02:00
|
|
|
|
break;
|
2017-10-02 18:40:54 +02:00
|
|
|
|
}
|
2017-09-15 18:15:48 +02:00
|
|
|
|
}
|
2018-06-21 18:40:44 +02:00
|
|
|
|
|
2017-10-09 18:40:02 +02:00
|
|
|
|
private void SemanticZoom_ViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e)
|
|
|
|
|
{
|
2017-10-13 15:46:41 +02:00
|
|
|
|
// We need to synchronize the two lists (zoomed-in and zoomed-out) because the source is different
|
2018-06-18 14:58:01 +02:00
|
|
|
|
if (!e.IsSourceZoomedInView)
|
2017-10-09 18:40:02 +02:00
|
|
|
|
{
|
|
|
|
|
e.DestinationItem.Item = e.SourceItem.Item;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-29 19:13:38 +01:00
|
|
|
|
|
|
|
|
|
private void GridView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = !Model.IsEditMode;
|
2017-11-30 18:56:56 +01:00
|
|
|
|
e.Data.RequestedOperation = DataPackageOperation.Move;
|
2017-11-29 19:13:38 +01:00
|
|
|
|
}
|
2020-05-04 20:56:19 +02:00
|
|
|
|
|
|
|
|
|
private void GroupDetailPage_OnSizeChanged(object sender, SizeChangedEventArgs e)
|
2017-12-14 17:15:28 +01:00
|
|
|
|
{
|
2020-05-04 20:56:19 +02:00
|
|
|
|
if (e.NewSize.Width <= 640)
|
2017-12-14 17:15:28 +01:00
|
|
|
|
{
|
2020-05-04 20:56:19 +02:00
|
|
|
|
VisualStateManager.GoToState(this, "Small", true);
|
|
|
|
|
VisualStateManager.GoToState(TopMenu, "Collapsed", true);
|
|
|
|
|
VisualStateManager.GoToState(HamburgerMenu, "Hidden", true);
|
|
|
|
|
}
|
|
|
|
|
else if (e.NewSize.Width > 640 && e.NewSize.Width <= 1008)
|
|
|
|
|
{
|
|
|
|
|
VisualStateManager.GoToState(this, "Medium", true);
|
|
|
|
|
VisualStateManager.GoToState(TopMenu, "Overflowed", true);
|
|
|
|
|
VisualStateManager.GoToState(HamburgerMenu, "Collapsed", true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
VisualStateManager.GoToState(this, "Large", true);
|
|
|
|
|
VisualStateManager.GoToState(TopMenu, "Overflowed", true);
|
|
|
|
|
VisualStateManager.GoToState(HamburgerMenu, "Expanded", true);
|
2017-12-14 17:15:28 +01:00
|
|
|
|
}
|
2017-12-11 19:00:14 +01:00
|
|
|
|
}
|
2020-04-22 11:58:06 +02:00
|
|
|
|
|
2017-12-11 19:00:14 +01:00
|
|
|
|
#endregion
|
2017-09-11 18:25:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|