-
Notifications
You must be signed in to change notification settings - Fork 0
/
Materials.xaml.cs
239 lines (189 loc) · 8.27 KB
/
Materials.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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Data.Pdf;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.Storage.Streams;
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.Media.Imaging;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace ShegzstuffPC
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Materials : Page
{
string zeUri = " ";
public Materials()
{
this.InitializeComponent();
this.DataContext = this;
EnglishButton.Content = "English \n past \n question \n (jamb)";
MathButton.Content = "Maths \n past \n question \n (jamb)";
physicsButton.Content = "Maths \n past \n question \n (jamb)";
BiologyButton.Content = "Biology \n past \n question \n (jamb)";
ChemistryButton.Content = "Chemistry \n past \n question \n (jamb)";
EconsButton.Content = "Economics \n past \n question \n (jamb)";
GovernmentButton.Content = "Government \n past \n question \n (jamb)";
AccountButton.Content = "Account \n past \n question \n (jamb)";
CommerceButton.Content = "Comercerce \n past \n question \n (jamb)";
CRKButton.Content = "CRK \n past \n question \n (jamb)";
MathButton2.Content = "Maths 2 \n past \n question \n (jamb)";
}
public async void OpenLocal()
{
StorageFile f = await
StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/PDF/Government.pdf"));
PdfDocument doc = await PdfDocument.LoadFromFileAsync(f);
Load(doc);
}
public async void OpenRemote()
{
HttpClient client = new HttpClient();
var stream = await
client.GetStreamAsync(zeUri);
var memStream = new MemoryStream();
await stream.CopyToAsync(memStream);
memStream.Position = 0;
PdfDocument doc = await PdfDocument.LoadFromStreamAsync(memStream.AsRandomAccessStream());
Load(doc);
}
async void Load(PdfDocument pdfDoc)
{
PdfPages.Clear();
for (uint i = 0; i < pdfDoc.PageCount; i++)
{
BitmapImage image = new BitmapImage();
var page = pdfDoc.GetPage(i);
using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream())
{
await page.RenderToStreamAsync(stream);
await image.SetSourceAsync(stream);
}
PdfPages.Add(image);
}
}
public ObservableCollection<BitmapImage> PdfPages
{
get;
set;
} = new ObservableCollection<BitmapImage>();
private void EnglishButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=be50f7b3f79c9e9c24de666a65fdf90e";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void MathButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=f9c4f0330adba579e740c5a8e6ed433f";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void EconsButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=1ee713cd73d7e5ca4676c1f37bfd920d";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void physicsButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://uc8af94216a21e58ae9ff905570e.dl.dropboxusercontent.com/cd/0/get/AcoU8LozyQsPtrx-eFhAGcyXrWhonCM8b9MwVqYBEam96HylEVtXkMAhW43EvXgzMGIJXJUultkkJdIz95jPuj--59iXfZuDQlbxBUzHZ8n9WQ/file?dl=1";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void ChemistryButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=e78bece0f5d6e4b8388c7d08a28daeb5";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void GovernmentButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=fee0dca831ff937752d71ba71b13f55b";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void BiologyButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=5fce41774fd14124d2d3474e9fda82fa";
pdfViewer.Visibility = Visibility.Visible;
OpenRemote();
}
private void CommerceButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://uc8af94216a21e58ae9ff905570e.dl.dropboxusercontent.com/cd/0/get/AcoU8LozyQsPtrx-eFhAGcyXrWhonCM8b9MwVqYBEam96HylEVtXkMAhW43EvXgzMGIJXJUultkkJdIz95jPuj--59iXfZuDQlbxBUzHZ8n9WQ/file?dl=1";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void AccountButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=5faf11f0ee39e88f9a85f2ea1bb8e4ea";
pdfViewer.Visibility = Visibility.Visible;
OpenRemote();
}
private void CRKButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=bce50af81f6d63a4bf0a975fb00ebd9c";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void JambsylabButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=d9e631ae85050db304bb9ef2fb4bc8b8";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void JambbrocureButton_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=4228210eb5f21337d51f1fdd852dcbcd";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
private void Colapseview()
{
EnglishButton.Visibility = Visibility.Collapsed;
MathButton.Visibility = Visibility.Collapsed;
JambbrocureButton.Visibility = Visibility.Collapsed;
JambsylabButton.Visibility = Visibility.Collapsed;
physicsButton.Visibility = Visibility.Collapsed;
BiologyButton.Visibility = Visibility.Collapsed;
ChemistryButton.Visibility = Visibility.Collapsed;
EconsButton.Visibility = Visibility.Collapsed;
GovernmentButton.Visibility = Visibility.Collapsed;
AccountButton.Visibility = Visibility.Collapsed;
CommerceButton.Visibility = Visibility.Collapsed;
CRKButton.Visibility = Visibility.Collapsed;
}
private void MathButton2_Click(object sender, RoutedEventArgs e)
{
zeUri = "https://www.pdfhost.net/index.php?Action=DownloadFile&id=566ed018a69aeee78fa47a158d95f82f";
pdfViewer.Visibility = Visibility.Visible;
Colapseview();
OpenRemote();
}
}
}