Mercurial > silverbladetech
comparison Chronosv2/source/WidgetLibrary/WidgetItemViewModel.cs @ 10:443821e55f06
Initial cleaned up add from Codeplex files
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Tue, 21 Feb 2012 17:25:44 +0700 |
parents | |
children | 09d18d6e5f40 |
comparison
equal
deleted
inserted
replaced
9:904a9faadf8b | 10:443821e55f06 |
---|---|
1 using System.Windows.Input; | |
2 using Chronos.Presentation.Core.VirtualDesktops; | |
3 using Chronos.Presentation.Core.Widgets; | |
4 using Chronos.Presentation.Core.Windows; | |
5 using Chronos.Presentation.ViewModel; | |
6 using nRoute.Components; | |
7 | |
8 namespace Chronos.WidgetLibrary | |
9 { | |
10 /// <summary> | |
11 /// Widget Definition ViewModel | |
12 /// </summary> | |
13 public sealed class WidgetItemViewModel | |
14 : ViewModelBase, IWidget | |
15 { | |
16 #region · Fields · | |
17 | |
18 private IWidget widgetDefinition; | |
19 private ICommand createWidgetCommand; | |
20 | |
21 #endregion | |
22 | |
23 #region · Commands · | |
24 | |
25 /// <summary> | |
26 /// Gets the create widget command. | |
27 /// </summary> | |
28 /// <value>The create widget command.</value> | |
29 public ICommand CreateWidgetCommand | |
30 { | |
31 get | |
32 { | |
33 if (this.createWidgetCommand == null) | |
34 { | |
35 this.createWidgetCommand = new ActionCommand(() => OnCreateWidget()); | |
36 } | |
37 | |
38 return this.createWidgetCommand; | |
39 } | |
40 } | |
41 | |
42 #endregion | |
43 | |
44 #region · Properties · | |
45 | |
46 /// <summary> | |
47 /// Gets the widget title | |
48 /// </summary> | |
49 /// <value></value> | |
50 public string Title | |
51 { | |
52 get { return this.widgetDefinition.Title; } | |
53 } | |
54 | |
55 /// <summary> | |
56 /// Gets the widget description | |
57 /// </summary> | |
58 /// <value></value> | |
59 public string Description | |
60 { | |
61 get { return this.widgetDefinition.Description; } | |
62 } | |
63 | |
64 /// <summary> | |
65 /// Gets the widget group | |
66 /// </summary> | |
67 /// <value></value> | |
68 public string Group | |
69 { | |
70 get { return this.widgetDefinition.Group; } | |
71 } | |
72 | |
73 /// <summary> | |
74 /// Gets the widget icon style | |
75 /// </summary> | |
76 /// <value></value> | |
77 public string IconStyle | |
78 { | |
79 get { return this.widgetDefinition.IconStyle; } | |
80 } | |
81 | |
82 #endregion | |
83 | |
84 #region · Constructors · | |
85 | |
86 /// <summary> | |
87 /// Initializes a new instance of the <see cref="WidgetItemViewModel"/> class. | |
88 /// </summary> | |
89 /// <param name="widget">The widget.</param> | |
90 public WidgetItemViewModel(IWidget widgetDefinition) | |
91 : base() | |
92 { | |
93 this.widgetDefinition = widgetDefinition; | |
94 } | |
95 | |
96 #endregion | |
97 | |
98 #region · IWidget Members · | |
99 | |
100 /// <summary> | |
101 /// Creates the widget view | |
102 /// </summary> | |
103 /// <returns></returns> | |
104 System.Windows.FrameworkElement IWidget.CreateView() | |
105 { | |
106 return this.widgetDefinition.CreateView(); | |
107 } | |
108 | |
109 #endregion | |
110 | |
111 #region · Command Actions · | |
112 | |
113 /// <summary> | |
114 /// Handles the create widget command. | |
115 /// </summary> | |
116 private void OnCreateWidget() | |
117 { | |
118 this.GetService<IVirtualDesktopManager>() | |
119 .Show(this.widgetDefinition.CreateView() as IDesktopElement); | |
120 } | |
121 | |
122 #endregion | |
123 } | |
124 } |