Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.Controls;
- using System.IO.IsolatedStorage;
- using System.Xml.Serialization;
- using System.IO;
- using System.Xml.Linq;
- namespace LasnaoloAppsi
- {
- public partial class LasnaoloLista : PhoneApplicationPage
- {
- string id = string.Empty;
- XDocument lista = XDocument.Load("NykyisetKurssit.xml");
- public LasnaoloLista()
- {
- InitializeComponent();
- }
- protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
- {
- const string id1 = "504T11";
- const string id2 = "504T12";
- const string id3 = "504T10";
- const string id4 = "504T09";
- string r504T11 = "People.xml";
- string r504T12 = "People2.xml";
- string r504T10 = "People3.xml";
- string r504T09 = "People4.xml";
- if (NavigationContext.QueryString.TryGetValue("id", out id))
- {
- var ryhma = (from ryhmaInfo in lista.Descendants("Kurssi")
- where ryhmaInfo.Attribute("id").Value == id
- select new Kurssit
- {
- RyhmanNimi = (string)ryhmaInfo.Element("tunnus").Value
- }).FirstOrDefault();
- PageTitle.Text = ryhma.RyhmanNimi;
- switch (id)
- {
- case id1:
- LoadLasnaolot(r504T11);
- break;
- case id2:
- LoadLasnaolot(r504T12);
- break;
- case id3:
- LoadLasnaolot(r504T10);
- break;
- case id4:
- LoadLasnaolot(r504T09);
- break;
- }
- }
- base.OnNavigatedTo(e);
- }
- public void LoadLasnaolot(string filename)
- {
- try
- {
- using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication())
- {
- using (IsolatedStorageFileStream str = ISF.OpenFile(filename, FileMode.Open))
- {
- XmlSerializer serializer = new XmlSerializer(typeof(List<Kurssit>));
- List<Kurssit> l1 = (List<Kurssit>)serializer.Deserialize(str);
- this.LasnaoloListax.ItemsSource = l1;
- }
- }
- }
- catch
- {
- //add some code here
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement