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.Collections.ObjectModel;
- using System.Xml.Linq;
- namespace LasnaoloAppsi
- {
- public partial class LasnaoloAjat : PhoneApplicationPage
- {
- XDocument lista = XDocument.Load("NykyisetKurssit.xml");
- private ObservableCollection<Kurssit> _Lasnaolot = new ObservableCollection<Kurssit>();
- const string id1 = "504T11";
- const string id2 = "504T12";
- const string id3 = "504T10";
- const string id4 = "504T09";
- string d504T11 = "CurrentDate504T110";
- string d504T12 = "CurrentDate504T120";
- string d504T10 = "CurrentDate504T100";
- string d504T09 = "CurrentDate504T090";
- string id = string.Empty;
- public LasnaoloAjat()
- {
- InitializeComponent();
- }
- protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
- {
- 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;
- if (LasnaoloAikojenLista.ItemsSource != null)
- {
- return;
- }
- switch (id)
- {
- case id1:
- LoadLasnaoloDate(d504T11);
- break;
- case id2:
- LoadLasnaoloDate(d504T12);
- break;
- case id3:
- LoadLasnaoloDate(d504T10);
- break;
- case id4:
- LoadLasnaoloDate(d504T09);
- break;
- }
- }
- base.OnNavigatedTo(e);
- }
- public void LoadLasnaoloDate(string currentDate)
- {
- var settings = IsolatedStorageSettings.ApplicationSettings;
- Kurssit date;
- if (settings.TryGetValue<Kurssit>(currentDate, out date))
- {
- foreach (string s in settings.Keys)
- _Lasnaolot.Add(date);
- LasnaoloAikojenLista.ItemsSource = _Lasnaolot;
- }
- }
- private void LasnaoloAika_HBTN_Click(object sender, RoutedEventArgs e)
- {
- var button2 = (HyperlinkButton)sender;
- var selectedApp2 = (Kurssit)button2.Tag;
- NavigationService.Navigate(new Uri("/LasnaoloLista.xaml?id=" + id, UriKind.Relative));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement