-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainPage.xaml.cs
170 lines (138 loc) · 6.03 KB
/
MainPage.xaml.cs
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Controls;
namespace LiveSynergyUIDesign
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
LoadDevices();
ListPublicThing.SelectionChanged += OnPublicDeviceSelectedChanged;
}
public static System.Collections.Generic.IEnumerable<PublicGrouping<string, Device>> deviceByLocation;
public static System.Collections.Generic.IEnumerable<PublicGrouping<string, Device>> deviceByName;
private void LoadDevices()
{
List<Device> PublicThings = new List<Device>
{
new Device(){ DeviceName="Television", DeviceLocation="\\msra\\floor\\12\\focus_room" },
new Device(){ DeviceName="Light", DeviceLocation="\\msra\\floor\\12\\focus_room"},
new Device(){ DeviceName="Light2", DeviceLocation="\\msra\\floor\\12\\focus_room"},
new Device(){ DeviceName="Light3", DeviceLocation="\\msra\\floor\\12\\focus_room"},
new Device(){ DeviceName="Computer", DeviceLocation="\\msra\\floor\\12\\fred_cubical"},
new Device(){ DeviceName="Xbox 360", DeviceLocation="\\msra\\floor\\12\\lobby"},
new Device(){ DeviceName="Oscilloscope", DeviceLocation="\\msra\\floor\\12\\fred_cubical"}
};
deviceByLocation = from device in PublicThings
group device by device.DeviceLocation into c
orderby c.Key
select new PublicGrouping<string, Device>(c);
deviceByName = from device in PublicThings
group device by device.DeviceNameFirstLetter into c
orderby c.Key
select new PublicGrouping<string, Device>(c);
ListPublicThing.ItemsSource = deviceByName;
}
void FillItUp(ItemsControl itemsControl, string[] ItemsCollection)
{
foreach (string item in ItemsCollection)
itemsControl.Items.Add(new FontFamily(item));
}
void OnAppbarAddClick(object sender, EventArgs args)
{
this.NavigationService.Navigate(new Uri("/AddNewThing.xaml", UriKind.Relative));
}
void OnAppbarDeleteClick(object sender, EventArgs args)
{
}
void OnAppbarNextClick(object sender, EventArgs args)
{ }
void OnAppbarBackClick(object sender, EventArgs args)
{ }
void OnClickProgramThis(object sender, EventArgs args)
{
}
void OnClickViewProgram(object sender, EventArgs args)
{
}
void OnListBoxSelectionChanged(object sender, EventArgs args)
{
}
void OnClickSignUp(object sender, EventArgs args)
{
this.NavigationService.Navigate(new Uri("/SignUpPage.xaml", UriKind.Relative));
}
void OnMenuClicked(object sender, RoutedEventArgs args)
{
string command = (string)(((MenuItem)sender).Tag);
switch (command)
{
case ("VIEW"): break;
case ("REMOVE"): break;
default: break;
}
}
/*
ListHeaderTemplate="{StaticResource DeviceListHeader}"
GroupHeaderTemplate="{StaticResource DeviceGroupHeader}"
GroupItemTemplate="{StaticResource groupItemHeader}"
ItemTemplate="{StaticResource DeviceItemTemplate}"
*/
void OnClickSortByLocation(object sender, EventArgs args)
{
ListPublicThing.GroupHeaderTemplate = this.Resources["DeviceGroupHeaderLocation"] as DataTemplate;
ListPublicThing.ItemsSource = deviceByLocation;
ListPublicThing.GroupItemTemplate = this.Resources["groupItemHeaderLocation"] as DataTemplate;
}
void OnClickSortByName(object sender, EventArgs args)
{
ListPublicThing.GroupHeaderTemplate = this.Resources["DeviceGroupHeaderNameFirst"] as DataTemplate;
ListPublicThing.ItemsSource = deviceByName;
ListPublicThing.GroupItemTemplate = this.Resources["groupItemHeaderNameFirst"] as DataTemplate;
}
void OnPublicDeviceSelectedChanged(object sender, EventArgs args)
{
Device device = ListPublicThing.SelectedItem as Device;
if (device != null)
{
NavigationService.Navigate(new Uri("/ViewObjectPage.xaml?Name=" + device.DeviceName, UriKind.Relative));
}
}
void OnTapFlowChart(object sender, EventArgs args)
{
this.NavigationService.Navigate(new Uri("/Program.xaml", UriKind.Relative));
}
void OnTapEvent(object sender, EventArgs args)
{
this.NavigationService.Navigate(new Uri("/LongListSelection.xaml", UriKind.Relative));
}
void OnTapCommand1(object sender, EventArgs args)
{
this.NavigationService.Navigate(new Uri("/LongListSelection.xaml", UriKind.Relative));
}
void OnTapCommand2(object sender, EventArgs args)
{
this.NavigationService.Navigate(new Uri("/LongListSelection.xaml", UriKind.Relative));
}
private double PreviousOpacity { get; set; }
void Appbar_StateChanged(object sender, ApplicationBarStateChangedEventArgs args)
{
var opacity = this.ApplicationBar.Opacity;
this.ApplicationBar.Opacity = args.IsMenuVisible ? 1 : PreviousOpacity;
this.PreviousOpacity = opacity;
}
}
}