1: public class LauncherChooserViewModel : ViewModelBase
2: {
3: /// <summary>
4: /// The injected launcher manager.
5: /// </summary>
6: private readonly ILauncherManager launcherManager;
7:
8: /// <summary>
9: /// The injected chooser manager.
10: /// </summary>
11: private readonly IChooserManager chooserManager;
12:
13: /// <summary>
14: /// Initializes a new instance of the <see cref="LauncherChooserViewModel"/> class.
15: /// </summary>
16: /// <param name="launcherManager">The launcher manager.</param>
17: /// <param name="chooserManager">The chooser manager.</param>
18: public LauncherChooserViewModel(
19: ILauncherManager launcherManager,
20: IChooserManager chooserManager)
21: {
22: this.launcherManager = launcherManager;
23: this.chooserManager = chooserManager;
24:
25: this.WireEvents();
26: this.WireCommands();
27: }
28:
29: /// <summary>
30: /// Wires the events.
31: /// </summary>
32: private void WireEvents()
33: {
34: this.chooserManager.ChoosePhotoTaskCompleted += ChoosePhotoTaskCompleted;
35: }
36:
37: /// <summary>
38: /// Chooses the photo task completed.
39: /// </summary>
40: /// <param name="sender">The sender.</param>
41: /// <param name="e">The <see cref="PhotoResult"/> instance containing the event data.</param>
42: private void ChoosePhotoTaskCompleted(object sender, EventArgs<PhotoResult> e)
43: {
44: if (e.Value.TaskResult == TaskResult.OK)
45: {
46: MessageBox.Show(e.Value.OriginalFileName);
47: }
48: }
49:
50: /// <summary>
51: /// Wires the commands.
52: /// </summary>
53: private void WireCommands()
54: {
55: this.MakePhoneCallCommand = new RelayCommand(MakePhoneCall);
56: this.SelectPhotoCommand = new RelayCommand(SelectPhoto);
57: }
58:
59: /// <summary>
60: /// Makes the phone call.
61: /// </summary>
62: private void MakePhoneCall()
63: {
64: this.launcherManager.MakeCall(new PhoneNumber("Jon Sharratt", "000000000000"));
65: }
66:
67: /// <summary>
68: /// Selects the photo.
69: /// </summary>
70: private void SelectPhoto()
71: {
72: this.chooserManager.ChoosePhoto();
73: }
74:
75: /// <summary>
76: /// Gets or sets the make phone call command.
77: /// </summary>
78: /// <value>The make phone call command.</value>
79: public ICommand MakePhoneCallCommand { get; private set; }
80:
81: /// <summary>
82: /// Gets or sets the select photo command.
83: /// </summary>
84: /// <value>The select photo command.</value>
85: public ICommand SelectPhotoCommand { get; private set; }
86: }