Nextrek
@ 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
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; namespace The_Colour_Out_of_Space { public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); // Set the data context of the listbox control to the sample data DataContext = App.ViewModel; this.Loaded += new RoutedEventHandler(MainPage_Loaded); } // Load data for the ViewModel Items private void MainPage_Loaded(object sender, RoutedEventArgs e) { if (!App.ViewModel.IsDataLoaded) { App.ViewModel.LoadData(); } } private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { List<string> content = ReadFilesContents(); panorama.ItemsSource = content; TextPage.Text = "1/" + content.Count; bindList(); } private List<string> ReadFilesContents() { int i; int n = NumberOfTextPage(); List<string> testoPagine = new List<string>(); for (i = 1; i <= n; i++) { //this verse is loaded for the first time so fill it from the text file string uri = String.Format("The Colour Out of Space;component/Data/Nuovo documento di testo ({0}).txt", i); var ResrouceStream = Application.GetResourceStream(new Uri(uri, UriKind.Relative)); if (ResrouceStream != null) { Stream myFileStream = ResrouceStream.Stream; if (myFileStream.CanRead) { StreamReader myStreamReader = new StreamReader(myFileStream); //read the content here string testo = myStreamReader.ReadToEnd(); testoPagine.Add(testo); } } } return testoPagine; } private int NumberOfTextPage() { //this verse is loaded for the first time so fill it from the text file var ResrouceStream = Application.GetResourceStream(new Uri("The Colour Out of Space;component/Data/config.txt", UriKind.Relative)); if (ResrouceStream != null) { Stream myFileStream = ResrouceStream.Stream; if (myFileStream.CanRead) { StreamReader myStreamReader = new StreamReader(myFileStream); //read the content here string numero = myStreamReader.ReadToEnd(); return Int16.Parse(numero); } } return 0; } private void panorama_SelectionChanged(object sender, SelectionChangedEventArgs e) { string numPagina = ((panorama.SelectedIndex) + 1).ToString(); string pagTotali = panorama.Items.Count.ToString(); TextPage.Text = numPagina + "/" + pagTotali; } private void bindList() { List<string> links = new List<string>(); string stringLink = ""; int n = NumberOfTextPage(); for (int i = 1; i <= n; i++) { stringLink = String.Format("PAGE..........{0}", i); links.Add(stringLink); } LinkPageListBox.ItemsSource = links; } private void page_Click(object sender, RoutedEventArgs e) { String pageClicked = (String)((Control)sender).DataContext; string page = pageClicked.Substring(14); Int32 numPage = ((Int32.Parse(page)) - 1); panorama.DefaultItem = panorama.Items[numPage]; pageCanvas.Visibility = System.Windows.Visibility.Collapsed; } private void openPageLinkButton_Click(object sender, RoutedEventArgs e) { pageCanvas.Visibility = System.Windows.Visibility.Visible; } } } |
Commits for Nextrek/WindowsPhone/NextrekBook/H. P. Lovecraft/BookonPhone/The Colour Out of Space/The Colour Out of Space/MainPage.xaml.cs
Revision | Author | Commited | Message |
---|---|---|---|
5 | MOliva | Fri 19 Apr, 2013 17:26:06 +0000 | primo caricamento libri win phone 7 |