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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
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 At_The_Mountains_of_Madness { public partial class PanoramaPage8 : PhoneApplicationPage { public PanoramaPage8() { InitializeComponent(); } private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { List<string> content = bindPages(); panorama.ItemsSource = content; TextPage.Text = "312/" + NumberOfTextPage(); bindList(); } private string ReadCapContents() { //this verse is loaded for the first time so fill it from the text file string uri = "At The Mountains of Madness;component/Data/Cap8.txt"; string testo = ""; 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 testo = myStreamReader.ReadToEnd(); return testo; } } return ""; } private List<string> bindPages() { List<String> pageList = new List<String>(); String testo = ReadCapContents(); string pageText = ""; int i = 0; int j = 741; int x = 0; while (testo.Substring(j + 1).Contains("\r\n")) { int contj = 0; x = 0; int n = testo.IndexOf("\r\n", i); int y = n - (741 + x + i); if (i == 0 && n < 741) { pageText = testo.Substring(i, testo.IndexOf("\r\n")); j = testo.IndexOf("\r\n", i + 1); } else if (n < 741 + i) { pageText = testo.Substring(i, n - i).Replace("\n", ""); j = testo.IndexOf("\r\n", i + 1); } else { if (i == 0) { while (testo.Substring(j + 741, 1) != " ") { j++; x++; } pageText = testo.Substring(i, n - i - y + x + 8).Replace("\n", ""); j = i + 741 + x + 7; } else { while (testo.Substring(j + 741, 1) != " ") { j++; x++; } pageText = testo.Substring(i, n - i - y + x).Replace("\n", ""); j = i + 741 + x - 1; } } pageList.Add(pageText); j = j + contj; i = j + 1; } return pageList; } private int NumberOfTextPage() { //this verse is loaded for the first time so fill it from the text file var ResrouceStream = Application.GetResourceStream(new Uri("At The Mountains of Madness;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 + 42 + 78 + 44 + 33 + 51 + 28 + 35).ToString(); string pagTotali = NumberOfTextPage().ToString(); TextPage.Text = numPagina + "/" + pagTotali; } private void bindList() { List<string> links = new List<string>(); string stringLink = ""; //int n = NumberOfCapPage(); int n = bindPages().Count; for (int i = 1; i <= n; i++) { stringLink = String.Format("PAGE..........{0}", i + 42 + 78 + 44 + 33 + 51 + 28 + 35); 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 - 42 - 78 - 44 - 33 - 51 - 28 - 35]; pageCanvas.Visibility = System.Windows.Visibility.Collapsed; } private void openPageLinkButton_Click(object sender, RoutedEventArgs e) { pageCanvas.Visibility = System.Windows.Visibility.Visible; } private void nextCap_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/At The Mountains of Madness;component/PanoramaPage9.xaml", UriKind.Relative)); } private void prevCap_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/At The Mountains of Madness;component/PanoramaPage7.xaml", UriKind.Relative)); } private void home_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/At The Mountains of Madness;component/MainPage.xaml", UriKind.Relative)); } } } |
Commits for Nextrek/WindowsPhone/NextrekBook/H. P. Lovecraft/At The Mountains of Madness/At The Mountains of Madness/PanoramaPage8.xaml.cs
Revision | Author | Commited | Message |
---|---|---|---|
5 | MOliva | Fri 19 Apr, 2013 17:26:06 +0000 | primo caricamento libri win phone 7 |