Jypeli  5
The simple game programming library
ArrayPage.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 ArrayPage : PhoneApplicationPage
18  {
19  public static Uri URI = new Uri( "/ArrayPage.xaml", UriKind.Relative );
20 
21  [Save] string[] array = new string[4];
22  TextBox[] textBoxes = new TextBox[4];
23 
24  public ArrayPage()
25  {
26  InitializeComponent();
27 
28  textBoxes[0] = textBox1;
29  textBoxes[1] = textBox2;
30  textBoxes[2] = textBox3;
31  textBoxes[3] = textBox4;
32 
33  BoxesToArray();
34  }
35 
36  private void ArrayToBoxes()
37  {
38  for ( int i = 0; i < array.Length; i++ )
39  textBoxes[i].Text = array[i];
40  }
41 
42  private void BoxesToArray()
43  {
44  for ( int i = 0; i < array.Length; i++ )
45  array[i] = textBoxes[i].Text;
46  }
47 
48  private void buttonDelete_Click( object sender, RoutedEventArgs e )
49  {
50  for ( int i = 0; i < 4; i++ )
51  textBoxes[i].Text = "";
52 
53  DataStorage.Instance.Delete( "Array.xml" );
54  }
55 
56  private void buttonSave_Click( object sender, RoutedEventArgs e )
57  {
58  BoxesToArray();
59  DataStorage.Instance.Save<string[]>( array, textFileName.Text );
60  }
61 
62  private void buttonLoad_Click( object sender, RoutedEventArgs e )
63  {
64  if ( !DataStorage.Instance.Exists( textFileName.Text ) )
65  {
66  textBox1.Text = "File not found!";
67  return;
68  }
69 
70  array = DataStorage.Instance.Load<string[]>( array, textFileName.Text );
71  ArrayToBoxes();
72  }
73 
74  private void buttonDelete_Click_1( object sender, RoutedEventArgs e )
75  {
76  DataStorage.Instance.Delete( textFileName.Text );
77  }
78 
79  private void buttonClear_Click( object sender, RoutedEventArgs e )
80  {
81  for ( int i = 0; i < textBoxes.Length; i++ )
82  textBoxes[i].Text = "";
83  }
84  }
85 }
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)