blob: 8e14869865f1f147237ec9bc116477a1cfb51a9b (
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.Core.DI;
using Tango.FSE.Common;
using Tango.FSE.Common.Storage;
namespace Tango.FSE.Procedures.Dialogs
{
public class OpenFileDialogViewVM : FSEDialogViewVM
{
[TangoInject]
protected IStorageProvider StorageProvider { get; set; }
private String _selectedFile;
public String SelectedFile
{
get { return _selectedFile; }
set { _selectedFile = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
public String Extension { get; set; }
public String Message { get; set; }
public RelayCommand BrowseCommand { get; set; }
public OpenFileDialogViewVM(String message, String extension)
{
TangoIOC.Default.Inject(this);
AutoMode = true;
Message = message;
Extension = extension;
BrowseCommand = new RelayCommand(BrowseForFile);
}
private async void BrowseForFile()
{
var result = await StorageProvider.OpenFile("Browse for file", $"Files|{Extension}");
if (result.Confirmed)
{
SelectedFile = result.SelectedItem;
}
}
protected override bool CanOK()
{
return base.CanOK() && SelectedFile != null;
}
protected override void Cancel()
{
SelectedFile = null;
base.Cancel();
}
}
}
|