/
MainPage.xaml.cs
executable file
·277 lines (213 loc) · 9.59 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
//using NotificationsExtensions.TileContent;
using Windows.UI.Notifications;
//using NotificationsExtensions.BadgeContent;
using Windows.Networking.Connectivity;
using Windows.Storage;
using Windows.Storage.Streams;
using System.Runtime.Serialization;
using System.Text;
using Windows.UI.Popups;
using Windows.UI.ViewManagement;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace App15
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
webview1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
this.SizeChanged += (a, b) =>
{
ApplicationViewState views = ApplicationView.Value;
VisualStateManager.GoToState(this, views.ToString(), false);
};
/* ITileWideText03 tileContent = TileContentFactory.CreateTileWideText03();
tileContent.TextHeadingWrap.Text = "Hello World! My very own tile notification";
ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();
squareContent.TextBodyWrap.Text = "Hello World! My very own tile notification";
tileContent.SquareContent = squareContent;
// send the notification
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)1);
// send the notification to the app's application tile
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
BadgeGlyphNotificationContent badgeContent2 = new BadgeGlyphNotificationContent((GlyphValue)1);
// send the notification to the app's application tile
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent2.CreateNotification());
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
*/
}
public static bool IsInternet()
{
ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile();
bool internet = connections != null && connections.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;
return internet;
}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
if (IsInternet())
{
Uri ur = new Uri("https://academics.vit.ac.in/parent/captcha.asp");
webview1.Navigate(ur);
try
{
await RestoreAsync();
}
catch (Exception)
{ }
}
else
{
var dlg = new Windows.UI.Popups.MessageDialog("An internet connection is needed. Please check your connection and restart the app.");
dlg.Commands.Add(new UICommand("Exit", (UICommandInvokedHandler) =>
{
Application.Current.Exit();
}));
dlg.Commands.Add(new UICommand("Try Again", (UICommandInvokedHandler) =>
{
}));
await dlg.ShowAsync();
}
}
string getstring(string id, string pass, string captcha)
{
string g = @"<form name='parent_login' id='f1' action='https://academics.vit.ac.in/parent/parent_login_submit.asp' method='post'>
<input type='TEXT' name='message' value='Invalid Register Number....!'/>
<input type='text' name='wdregno' value='" + id + @"' class='textbox2' size='15' maxlength='9' value='' tabindex='1'/>
<input type='password' name='wdpswd' value='" + pass + @"' class='textbox' size='15' maxlength='8' tabindex='2' />
<input type='text' name='vrfcd' value='" + captcha + @"' class='textbox' size='10' maxlength='6' tabindex='3'/>
</form>
<script type='text/javascript' >
var k=document.getElementById(f1);
f1.style.display = false;
f1.submit();
</script>
";
return g;
}
public class UserDetail
{
public string Id { get; set; }
public string Name { get; set; }
}
UserDetail Stats = new UserDetail();
async Task RestoreAsync()
{
StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("UserDetails");
if (file == null) return;
IRandomAccessStream inStream = await file.OpenReadAsync();
// Deserialize the Session State.
DataContractSerializer serializer = new DataContractSerializer(typeof(UserDetail));
var StatsDetails = (UserDetail)serializer.ReadObject(inStream.AsStreamForRead());
inStream.Dispose();
wdregno.Text = StatsDetails.Name;
wdpswd.Password = StatsDetails.Id;
}
async Task SaveAsync()
{
StorageFile userdetailsfile = await ApplicationData.Current.LocalFolder.CreateFileAsync("UserDetails", CreationCollisionOption.ReplaceExisting);
IRandomAccessStream raStream = await userdetailsfile.OpenAsync(FileAccessMode.ReadWrite);
using (IOutputStream outStream = raStream.GetOutputStreamAt(0))
{
// Serialize the Session State.
DataContractSerializer serializer = new DataContractSerializer(typeof(UserDetail));
serializer.WriteObject(outStream.AsStreamForWrite(), Stats);
await outStream.FlushAsync();
}
}
private async void Login_Click_1(object sender, RoutedEventArgs e)
{
if (wdregno.Text.Length < 9)
{
var messageDialog = new Windows.UI.Popups.MessageDialog("Invalid Register number!!!");
var result = messageDialog.ShowAsync();
}
else if (wdpswd.Password.Length < 8)
{
var messageDialog = new Windows.UI.Popups.MessageDialog("Invalid DOB!!!");
var result = messageDialog.ShowAsync();
}
else if (cap.Text.Length < 6)
{
var messageDialog = new Windows.UI.Popups.MessageDialog("Wrong Captcha!!!");
var result = messageDialog.ShowAsync();
}
else
{
string ht = getstring(wdregno.Text, wdpswd.Password, cap.Text);
ww.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
maingrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
bar.Visibility = Windows.UI.Xaml.Visibility.Visible;
bar.IsIndeterminate = true;
Stats.Name = wdregno.Text;
Stats.Id = wdpswd.Password;
await SaveAsync();
ww.NavigateToString(ht);
}
//var messageDialog = new Windows.UI.Popups.MessageDialog("Enter Correct details!!!");
//var result = messageDialog.ShowAsync();
}
private void webview1_LoadCompleted(object sender, NavigationEventArgs e)
{
webview1.Visibility = Windows.UI.Xaml.Visibility.Visible;
ring.IsActive = false;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ring.IsActive = true;
webview1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
Uri ur = new Uri("https://academics.vit.ac.in/parent/captcha.asp");
webview1.Navigate(ur);
}
private void ww_LoadCompleted(object sender, NavigationEventArgs e)
{
// ww.Visibility = Windows.UI.Xaml.Visibility.Visible;
bar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
bar.IsIndeterminate = false;
this.Frame.Navigate(typeof(BasicPage1));
}
private void Button_PointerEntered(object sender, PointerRoutedEventArgs e)
{
cap.Text = cap.Text.ToUpper();
wdregno.Text = wdregno.Text.ToUpper();
}
private void cap_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key.ToString().Equals("Enter"))
{
Login_Click_1(sender, e);
}
}
private void Refresh_Click(object sender, RoutedEventArgs e)
{
wdregno.Text = "";
wdpswd.Password = "";
cap.Text = "";
}
private async void Help_Click(object sender, RoutedEventArgs e)
{
MessageDialog message = new MessageDialog("Help Menu","Help Menu");
await message.ShowAsync();
}
}
}