-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathShellViewModel.cs
More file actions
84 lines (74 loc) · 2.45 KB
/
ShellViewModel.cs
File metadata and controls
84 lines (74 loc) · 2.45 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caliburn.Micro;
using System.ComponentModel.Composition;
using System.IO;
namespace Netduino.Core.ViewModels
{
/// <summary>
/// The implementation of the shell
/// </summary>
[Export(typeof(IShellViewModel))]
public class ShellViewModel :Conductor<Screen>,IShellViewModel
{
private string _emulatorName;
private string _keyBase = @"HKEY_CURRENT_USER\Software\Microsoft\.NETMicroFramework\v4.1\Emulators\{45D406A2-51DD-4662-ABDD-499BD9589AF1}";
private IWindowManager _windowManager;
private IEmulatorViewModel _emulatorViewModel;
private readonly ILog _log = LogManager.GetLog(typeof(ShellViewModel));
[ImportingConstructor]
public ShellViewModel(IWindowManager windowManager,IEmulatorViewModel viewModel)
{
_log.Info("ShellViewModel Constructor");
_windowManager = windowManager;
_emulatorViewModel = viewModel;
this.DisplayName = "Netduino Emulator";
}
public string EmulatorName
{
get { return _emulatorName; }
set
{
if (_emulatorName != value)
{
_emulatorName = value;
NotifyOfPropertyChange(() => EmulatorName);
NotifyOfPropertyChange(() => CanWriteRegistry);
}
}
}
public IEmulatorViewModel EmulatorViewModel
{
get { return _emulatorViewModel; }
set
{
if (_emulatorViewModel != value)
{
_emulatorViewModel = value;
}
}
}
public bool CanWriteRegistry
{
get
{
return !string.IsNullOrEmpty(EmulatorName);
}
set { }
}
public void WriteRegistry()
{
string path = Path.Combine(Directory.GetCurrentDirectory(), "Netduino.Shell.exe"); ;
Microsoft.Win32.Registry.SetValue(_keyBase, "Name", EmulatorName);
Microsoft.Win32.Registry.SetValue(_keyBase, "Path", path);
}
protected override void OnActivate()
{
base.OnActivate();
Screen view = (Screen)IoC.Get<IEmulatorViewModel>();
ChangeActiveItem(view, true);
}
}
}