blob: 5b5167393d685dfbbc2c33c3587d514e8b440978 (
plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.Explorer;
using Tango.PPC.Common;
namespace Tango.PPC.UI.ViewModels
{
public class StorageViewVM : PPCViewModel
{
private String _currentPath;
public String CurrentPath
{
get { return _currentPath; }
set { _currentPath = value; RaisePropertyChangedAuto(); }
}
public RelayCommand CloseCommand { get; set; }
public RelayCommand<ExplorerFileItem> FileSelectedCommand { get; set; }
public StorageViewVM()
{
CloseCommand = new RelayCommand(Close);
FileSelectedCommand = new RelayCommand<ExplorerFileItem>(OnFileSelected);
}
public override void OnApplicationStarted()
{
}
public override void OnApplicationReady()
{
base.OnApplicationReady();
StorageProvider.StorageConnected += StorageProvider_StorageConnected;
StorageProvider.StorageDisconnected += StorageProvider_StorageDisconnected;
}
public override void OnNavigatedTo()
{
base.OnNavigatedTo();
if (StorageProvider.Drive != null)
{
CurrentPath = StorageProvider.Drive.RootDirectory.FullName;
}
}
private async void Close()
{
await NavigationManager.NavigateTo(Common.Navigation.NavigationView.LayoutView);
}
/// <summary>
/// Handles the storage connected event.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The drive info.</param>
private void StorageProvider_StorageConnected(object sender, System.IO.DriveInfo e)
{
InvokeUI(async () =>
{
if (await NotificationProvider.ShowQuestion("Disk Inserted. Do you want to browse?"))
{
await NavigationManager.NavigateTo(Common.Navigation.NavigationView.StorageView);
}
});
}
/// <summary>
/// Handles the storage disconnected event.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The drive info.</param>
private void StorageProvider_StorageDisconnected(object sender, System.IO.DriveInfo e)
{
InvokeUI(async () =>
{
if (IsVisible)
{
await NavigationManager.NavigateTo(Common.Navigation.NavigationView.LayoutView);
}
});
}
private async void OnFileSelected(ExplorerFileItem fileItem)
{
await NavigationManager.NavigateTo(Common.Navigation.NavigationView.LayoutView);
await NotificationProvider.ShowInfo($"File Selected: {fileItem.Name}");
}
}
}
|