Jypeli  5
The simple game programming library
ListPage.xaml.cs
Siirry tämän tiedoston dokumentaatioon.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Net;
5 using System.Windows;
6 using System.Windows.Controls;
7 using System.Windows.Documents;
8 using System.Windows.Input;
9 using System.Windows.Media;
10 using System.Windows.Media.Animation;
11 using System.Windows.Shapes;
12 using Microsoft.Phone.Controls;
13 using Jypeli;
14 
15 namespace SilverStorageTest
16 {
17  public partial class ListPage : PhoneApplicationPage
18  {
19  public static Uri URI = new Uri( "/ListPage.xaml", UriKind.Relative );
20 
21  public ListPage()
22  {
23  InitializeComponent();
24  }
25 
26  private void buttonAddText_Click( object sender, RoutedEventArgs e )
27  {
28  listBox.Items.Add( textBox.Text );
29  }
30 
31  private void buttonClear_Click( object sender, RoutedEventArgs e )
32  {
33  listBox.Items.Clear();
34  }
35 
36  private void buttonLoad_Click( object sender, RoutedEventArgs e )
37  {
38  if ( !DataStorage.Instance.Exists( textFileName.Text ) )
39  {
40  textBox.Text = "File not found!";
41  return;
42  }
43 
44  List<string> itemList = DataStorage.Instance.Load<List<string>>( new List<string>(), textFileName.Text );
45  listBox.Items.Clear();
46  foreach ( string item in itemList ) listBox.Items.Add( item );
47  }
48 
49  private void buttonSave_Click( object sender, RoutedEventArgs e )
50  {
51  List<string> itemList = listBox.Items.OfType<string>().ToList<string>();
52  DataStorage.Instance.Save<List<string>>( itemList, textFileName.Text );
53  }
54 
55  private void buttonDelete_Click( object sender, RoutedEventArgs e )
56  {
57  DataStorage.Instance.Delete( textFileName.Text );
58  }
59  }
60 }
static IsolatedStorageManager Instance
Definition: DataStorage.cs:5
override void Delete(string fileName)
Poistaa tiedoston.
override bool Exists(string fileName)
Kertoo onko tiedosto tai hakemisto olemassa.
void Save(object obj, string fileName)