annotate Chronosv2/source/WidgetLibrary/WidgetLibraryViewModel.cs @ 12:6a0449185449

SCC changed from TFS to HG
author stevenh7776 stevenhollidge@hotmail.com
date Tue, 21 Feb 2012 17:47:35 +0700
parents 443821e55f06
children 741981715d94
rev   line source
10
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
1 using System;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
2 using System.Collections.Generic;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
3 using System.Collections.ObjectModel;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
4 using System.ComponentModel;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
5 using System.Linq;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
6 using System.Windows.Input;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
7 using Chronos.Presentation.Core.Configuration;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
8 using Chronos.Presentation.Core.VirtualDesktops;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
9 using Chronos.Presentation.Core.Widgets;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
10 using Chronos.Presentation.Core.Windows;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
11 using Chronos.Presentation.ViewModel;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
12 using NLog;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
13 using nRoute.Components;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
14
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
15 namespace Chronos.WidgetLibrary
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
16 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
17 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
18 /// Widget library ViewModel
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
19 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
20 public sealed class WidgetLibraryViewModel
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
21 : WidgetViewModel
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
22 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
23 #region · Constants ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
24
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
25 private static readonly string AllWidgetsKey = "All";
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
26
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
27 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
28
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
29 #region · PropertyChangedEventArgs Cached Instances ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
30
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
31 private static readonly PropertyChangedEventArgs FilterChangedArgs = CreateArgs<WidgetLibraryViewModel>(x => x.Filter);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
32 private static readonly PropertyChangedEventArgs WidgetsChangedArgs = CreateArgs<WidgetLibraryViewModel>(x => x.Widgets);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
33 private static readonly PropertyChangedEventArgs SelectedWidgetChangedArgs = CreateArgs<WidgetLibraryViewModel>(x => x.SelectedWidget);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
34
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
35 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
36
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
37 #region · Fields ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
38
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
39 private string filter;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
40 private List<string> groups;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
41 private List<WidgetItemViewModel> widgets;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
42 private IWidget selectedWidget;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
43 private ActionCommand createWidgetCommand;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
44
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
45 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
46
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
47 #region · Commands ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
48
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
49 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
50 /// Gets the create widget command.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
51 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
52 /// <value>The create widget command.</value>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
53 public ActionCommand CreateWidgetCommand
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
54 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
55 get
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
56 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
57 if (this.createWidgetCommand == null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
58 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
59 this.createWidgetCommand = new ActionCommand
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
60 (
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
61 () => OnCreateWidget(),
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
62 () => CanCreateWidget()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
63 );
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
64 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
65
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
66 return this.createWidgetCommand;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
67 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
68 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
69
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
70 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
71
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
72 #region · Properties ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
73
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
74 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
75 /// Gets/sets a fragment of the name to filter for.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
76 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
77 public string Filter
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
78 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
79 get { return this.filter; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
80 set
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
81 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
82 if (value != filter)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
83 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
84 this.filter = value;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
85 this.NotifyPropertyChanged(FilterChangedArgs);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
86 this.NotifyPropertyChanged(WidgetsChangedArgs);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
87
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
88 this.SelectedWidget = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
89 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
90 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
91 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
92
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
93 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
94 /// Gets the list of widget groups.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
95 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
96 /// <value>The groups.</value>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
97 public IEnumerable<string> Groups
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
98 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
99 get { return this.groups; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
100 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
101
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
102 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
103 /// Gets the list of widgets
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
104 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
105 public IList<WidgetItemViewModel> Widgets
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
106 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
107 get
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
108 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
109 if (String.IsNullOrEmpty(this.filter)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
110 || this.filter == AllWidgetsKey)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
111 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
112 return this.widgets;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
113 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
114 else
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
115 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
116 return new ReadOnlyCollection<WidgetItemViewModel>(this.widgets.Where(x => x.Group == this.filter).ToList());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
117 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
118 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
119 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
120
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
121 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
122 /// Gets or sets the selected widget.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
123 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
124 /// <value>The selected widget.</value>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
125 public IWidget SelectedWidget
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
126 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
127 get { return this.selectedWidget; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
128 set
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
129 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
130 if (this.selectedWidget != value)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
131 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
132 this.selectedWidget = value;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
133 this.NotifyPropertyChanged(SelectedWidgetChangedArgs);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
134 this.CreateWidgetCommand.RequeryCanExecute();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
135 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
136 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
137 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
138
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
139 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
140
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
141 #region · Constructors ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
142
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
143 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
144 /// Initializes a new instance of the <see cref="WidgetLibrary"/> class.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
145 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
146 public WidgetLibraryViewModel()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
147 : base()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
148 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
149 this.widgets = this.DiscoverWidgets();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
150 this.groups = this.DiscoverWidgetGroups();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
151 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
152
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
153 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
154
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
155 #region · Overriden Methods ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
156
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
157 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
158 /// Called when the related view is being closed.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
159 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
160 public override void Close()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
161 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
162 base.Close();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
163
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
164 this.selectedWidget = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
165 this.createWidgetCommand = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
166
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
167 if (this.groups != null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
168 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
169 this.groups.Clear();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
170 this.groups = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
171 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
172
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
173 if (this.widgets != null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
174 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
175 this.widgets.Clear();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
176 this.widgets = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
177 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
178 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
179
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
180 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
181
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
182 #region · Command Actions ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
183
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
184 private bool CanCreateWidget()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
185 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
186 return (this.selectedWidget != null);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
187 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
188
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
189 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
190 /// Handles the create widget command.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
191 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
192 private void OnCreateWidget()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
193 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
194 this.GetService<IVirtualDesktopManager>()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
195 .Show(this.selectedWidget.CreateView() as IDesktopElement);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
196 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
197
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
198 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
199
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
200 #region · Private Methods ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
201
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
202 private List<string> DiscoverWidgetGroups()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
203 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
204 List<string> groups = new List<string>();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
205 var q = from widgetdef in this.widgets
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
206 select widgetdef.Group;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
207
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
208 groups.Add(AllWidgetsKey);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
209 groups.AddRange(q.Distinct().ToList());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
210
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
211 return groups;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
212 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
213
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
214 private List<WidgetItemViewModel> DiscoverWidgets()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
215 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
216 IEnumerable<IWidget> widgetDefs = this.GetService<IWidgetConfigurationService>()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
217 .GetWidgets();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
218
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
219 if (widgetDefs != null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
220 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
221 var query = from widgetdef in widgetDefs
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
222 select new WidgetItemViewModel(widgetdef);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
223
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
224 return query.ToList();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
225 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
226
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
227 return null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
228 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
229
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
230 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
231 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
232 }