Jypeli  5
The simple game programming library
SimplePage.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 SimplePage : PhoneApplicationPage
18  {
19  public static Uri URI = new Uri( "/SimplePage.xaml", UriKind.Relative );
20 
21  // Constructor
22  public SimplePage()
23  {
24  InitializeComponent();
25  }
26 
27  private void buttonSave_Click( object sender, RoutedEventArgs e )
28  {
29  using ( SaveState state = DataStorage.Instance.BeginSave( textFileName.Text ) )
30  {
31  state.Save<bool>( checkBox1.IsChecked.Value, "Check1" );
32  state.Save<bool>( checkBox2.IsChecked.Value, "Check2" );
33  state.Save<bool>( checkBox3.IsChecked.Value, "Check3" );
34  state.Save<string>( textBox1.Text, "TextBox" );
35  }
36  }
37 
38  private void buttonLoad_Click( object sender, RoutedEventArgs e )
39  {
40  if ( !DataStorage.Instance.Exists( textFileName.Text ) )
41  {
42  textBox1.Text = "File not found.";
43  return;
44  }
45 
46  using ( Jypeli.LoadState state = DataStorage.Instance.BeginLoad( textFileName.Text ) )
47  {
48  checkBox1.IsChecked = state.Load<bool>( false, "Check1" );
49  checkBox2.IsChecked = state.Load<bool>( false, "Check2" );
50  checkBox3.IsChecked = state.Load<bool>( false, "Check3" );
51  textBox1.Text = state.Load<string>( textBox1.Text, "TextBox" );
52  }
53  }
54 
55  private void buttonDelete_Click( object sender, RoutedEventArgs e )
56  {
57  DataStorage.Instance.Delete( textFileName.Text );
58  }
59 
60  private void buttonClear_Click( object sender, RoutedEventArgs e )
61  {
62  checkBox1.IsChecked = false;
63  checkBox2.IsChecked = false;
64  checkBox3.IsChecked = false;
65  textBox1.Text = "";
66  }
67 
68  private void simpleTestPage_BackKeyPress( object sender, System.ComponentModel.CancelEventArgs e )
69  {
70  NavigationService.GoBack();
71  }
72  }
73 }
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.
LoadState BeginLoad(string fileName)
void Save(object obj, Type objType, string name)
Definition: SaveState.cs:49
SaveState BeginSave(string tag)