This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
ContentsPage.xaml.cs
74 lines (64 loc) · 2.05 KB
/
ContentsPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using DropNetRT.Models;
using DropNetRT.Sample.WP8.Extensions;
using DropNetRT.Sample.WP8.ViewModels;
using Microsoft.Phone.Controls;
using System.Windows.Navigation;
namespace DropNetRT.Sample.WP8
{
public partial class ContentsPage : PhoneApplicationPage
{
private ContentsViewModel _model;
public ContentsPage()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
_model = new ContentsViewModel(this.GetProgressIndicator(), Dispatcher);
this.DataContext = _model;
_model.LoadPath("/");
}
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
if (_model.MetaData.Path == "/")
{
base.OnBackKeyPress(e);
}
else
{
var lastslash = _model.MetaData.Path.LastIndexOf("/");
var parentPath = _model.MetaData.Path.Remove(lastslash);
//Check if you can go up a directory
if (string.IsNullOrEmpty(parentPath))
{
//root
_model.LoadPath("/");
e.Cancel = true;
}
else
{
_model.LoadPath(parentPath);
e.Cancel = true;
}
}
}
private void lsbContents_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var selected = (e.AddedItems[0] as Metadata);
if (selected == null) return;
if (selected.IsDirectory)
{
//navigate to the new dir
_model.LoadPath(selected.Path);
}
else
{
//Do something here for files
}
}
}
}
}