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.Navigation;
- using Microsoft.Phone.Controls;
- using System.IO.IsolatedStorage;
- using Microsoft.Phone.Shell;
- namespace Laboratory2
- {
- public partial class Page1 : PhoneApplicationPage
- {
- public Page1()
- {
- InitializeComponent();
- }
- private void Box2_TextChanged(object sender, TextChangedEventArgs e)
- {
- }
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- base.OnNavigatedTo(e);
- String sample = NavigationContext.QueryString["toPass"];
- Box2.Text = sample;
- }
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- IsolatedStorageSettings set = IsolatedStorageSettings.ApplicationSettings;
- this.NavigationService.Navigate(new Uri("/MainPage.xaml?", UriKind.Relative));
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.IO;
- using System.IO.IsolatedStorage;
- using System.Windows.Controls;
- using System.Windows.Navigation;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone.Shell;
- using Laboratory2.Resources;
- namespace Laboratory2
- {
- public partial class MainPage : PhoneApplicationPage
- {
- // Constructor
- public MainPage()
- {
- InitializeComponent();
- // Sample code to localize the ApplicationBar
- //BuildLocalizedApplicationBar();
- }
- private void saveText(string filename, string text)
- {
- using (IsolatedStorageFile isf =
- IsolatedStorageFile.GetUserStoreForApplication())
- {
- using (IsolatedStorageFileStream rawStream =
- isf.CreateFile(filename))
- {
- StreamWriter writer = new StreamWriter(rawStream);
- writer.Write(text);
- writer.Close();
- }
- }
- }
- private bool loadText(string filename, out string result)
- {
- using (IsolatedStorageFile isf =
- IsolatedStorageFile.GetUserStoreForApplication())
- try
- {
- using (IsolatedStorageFileStream rawStream =
- isf.OpenFile(filename, System.IO.FileMode.Open))
- {
- StreamReader reader = new StreamReader(rawStream);
- result = reader.ReadToEnd();
- reader.Close();
- return true;
- }
- }
- catch
- {
- result = "";
- return false;
- }
- }
- String toPass = "";
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- this.NavigationService.Navigate(new Uri("/Page1.xaml?toPass=" + Box1.Text,UriKind.Relative));
- }
- private void Save_Click(object sender, RoutedEventArgs e)
- {
- saveText("test.txt", Box1.Text);
- }
- private void Load_Click(object sender, RoutedEventArgs e)
- {
- string text;
- if (loadText("test.txt", out text))
- {
- Box1.Text = text;
- }
- else
- {
- Box1.Text = "Type anything here";
- }
- }
- private void Button_Click_2(object sender, RoutedEventArgs e)
- {
- string text;
- if (loadText("test.txt", out text))
- {
- Box1.Text = text;
- }
- else
- {
- Box1.Text = "Type anything here";
- }
- }
- private void Box1_TextChanged(object sender, TextChangedEventArgs e)
- {
- }
- // Sample code for building a localized ApplicationBar
- //private void BuildLocalizedApplicationBar()
- //{
- // // Set the page's ApplicationBar to a new instance of ApplicationBar.
- // ApplicationBar = new ApplicationBar();
- // // Create a new button and set the text value to the localized string from AppResources.
- // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
- // appBarButton.Text = AppResources.AppBarButtonText;
- // ApplicationBar.Buttons.Add(appBarButton);
- // // Create a new menu item with the localized string from AppResources.
- // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
- // ApplicationBar.MenuItems.Add(appBarMenuItem);
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement