Subversion Repository Public Repository

Nextrek

Diff Revisions 44 vs 45 for /WindowsPhone/NotizieTL/NotizieTL/MainPage.xaml.cs

Diff revisions: vs.
  @@ -30,6 +30,27 @@
30 30 {
31 31 public partial class MainPage : PhoneApplicationPage
32 32 {
33 +
34 +
35 + #region CONFIGURA PARAMETRI APPLICAZIONE
36 +
37 + private const string NOME_APPLICAZIONE = "NOTIZIE TUTTO LAVORO";
38 + private const string LINK_FEED_1 = "http://tuttolavoro.indicitalia.it/RSS/app.xml";
39 + private const string LINK_FEED_2 = "http://www.wki.it/marketing/app/tuttolavoroApp_Rel_news.xml";
40 + /* ICONE E IMMAGINE DI APERTURA:
41 + * iconaSMALL.png --> è l'icona che si visualizza nella lista delle applicazioni del telefono
42 + * --> deve avere una risoluzione di (62x62)px
43 + * iconaLARGE.png --> è l'icona che si visualizza quando aggiungiamo l'applicazione al menu start del telefono
44 + * --> è anche l'immagine visualizzata sulla schermata di apertura dell'applicazione (splash screen)
45 + * --> deve avere una risoluzione di (173x173)px
46 + * --> Entrambe le icone devono essere sostituite a quelle presenti mantenedo lo stesso nome ed estensione.
47 + */
48 +
49 + #endregion
50 +
51 +
52 + #region VARIABILI DI CLASSE E COSTRUTTORE
53 +
33 54 PhoneApplicationService phoneAppService = PhoneApplicationService.Current;
34 55
35 56 BackgroundWorker backroungWorker;
  @@ -64,130 +85,25 @@
64 85 this.Loaded += new RoutedEventHandler(MainPage_Loaded);
65 86 }
66 87
67 - // Load data for the ViewModel Items
68 - private void MainPage_Loaded(object sender, RoutedEventArgs e)
69 - {
70 - if (!App.ViewModel.IsDataLoaded)
71 - {
72 - App.ViewModel.LoadData();
73 - }
74 - }
75 88
76 - private void RunBackgroundWorker()
77 - {
78 - backroungWorker.DoWork += ((s, args) =>
79 - {
80 - Thread.Sleep(5000);
81 - });
89 + #endregion
82 90
83 - backroungWorker.RunWorkerCompleted += ((s, args) =>
84 - {
85 - this.Dispatcher.BeginInvoke(() =>
86 - {
87 - this.myPopup.IsOpen = false;
88 - }
89 - );
90 - });
91 - backroungWorker.RunWorkerAsync();
92 - }
93 91
92 + #region METODI
94 93
95 - private void checkConnection()
96 - {
97 - if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None)
98 - {
99 - MessageBox.Show("Nessuna connessione a internet rilevata! Lista notizie non aggiornata!");
100 -
101 - }
102 - }
103 94
104 - private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
105 - {
106 - checkConnection();
107 - SystemTray.IsVisible = false;
95 + #region METODI HELPER
108 96
109 - loadXML();
110 97
111 - // WebClient is used instead of HttpWebRequest in this code sample because
112 - // the implementation is simpler and easier to use, and we do not need to use
113 - // advanced functionality that HttpWebRequest provides, such as the ability to send headers.
114 - WebClient webClient1 = new WebClient();
115 - WebClient webClient3 = new WebClient();
116 -
117 - // Subscribe to the DownloadStringCompleted event prior to downloading the RSS feed.
118 - webClient1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient1_DownloadStringCompleted);
119 - webClient3.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient3_DownloadStringCompleted);
120 -
121 - // Download the RSS feed. DownloadStringAsync was used instead of OpenStreamAsync because we do not need
122 - // to leave a stream open, and we will not need to worry about closing the channel.
123 - webClient1.DownloadStringAsync(new System.Uri("http://tuttolavoro.indicitalia.it/RSS/app.xml"));
124 - webClient3.DownloadStringAsync(new System.Uri("http://www.wki.it/marketing/app/tuttolavoroApp_Rel_news.xml"));
125 -
126 - }
127 -
128 -
129 - // Event handler which runs after the feed is fully downloaded.
130 - private void webClient1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
131 - {
132 - if (e.Error != null)
133 - {
134 - Deployment.Current.Dispatcher.BeginInvoke(() =>
135 - {
136 - // Showing the exact error message is useful for debugging. In a finalized application,
137 - // output a friendly and applicable string to the user instead.
138 - MessageBox.Show(e.Error.Message);
139 - });
140 - }
141 - else
142 - {
143 - // Save the feed into the State property in case the application is tombstoned.
144 - this.State["feed"] = e.Result;
145 -
146 - UpdateFeedList1(e.Result);
147 - }
148 - }
149 -
150 - private void webClient3_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
98 + private void checkConnection()
151 99 {
152 - if (e.Error != null)
153 - {
154 - Deployment.Current.Dispatcher.BeginInvoke(() =>
155 - {
156 - // Showing the exact error message is useful for debugging. In a finalized application,
157 - // output a friendly and applicable string to the user instead.
158 - MessageBox.Show(e.Error.Message);
159 - });
160 - }
161 - else
100 + if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None)
162 101 {
163 - // Save the feed into the State property in case the application is tombstoned.
164 - this.State["feed"] = e.Result;
102 + MessageBox.Show("Nessuna connessione a internet rilevata! Lista notizie non aggiornata!");
165 103
166 - UpdateFeedList3(e.Result);
167 104 }
168 105 }
169 106
170 - // This method determines whether the user has navigated to the application after the application was tombstoned.
171 - protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
172 - {
173 - // First, check whether the feed is already saved in the page state.
174 - if (this.State.ContainsKey("feed"))
175 - {
176 - // Get the feed again only if the application was tombstoned, which means the ListBox will be empty.
177 - // This is because the OnNavigatedTo method is also called when navigating between pages in your application.
178 - // You would want to rebind only if your application was tombstoned and page state has been lost.
179 - if (feedListBoxNews1.Items.Count == 0)
180 - {
181 - UpdateFeedList1(State["feed"] as string);
182 - }
183 -
184 - if (feedListBoxNews3.Items.Count == 0)
185 - {
186 - UpdateFeedList3(State["feed"] as string);
187 - }
188 -
189 - }
190 - }
191 107
192 108 private String convertiData(String data)
193 109 {
  @@ -229,7 +145,7 @@
229 145 {
230 146 data = data.Replace("Jan", "Gen");
231 147 }
232 -
148 +
233 149 if (data.Contains("May"))
234 150 {
235 151 data = data.Replace("May", "Mag");
  @@ -254,13 +170,13 @@
254 170 {
255 171 data = data.Replace("Oct", "Ott");
256 172 }
257 -
173 +
258 174 if (data.Contains("Dec"))
259 175 {
260 176 data = data.Replace("Dec", "Dic");
261 177 }
262 -
263 -
178 +
179 +
264 180 return data;
265 181
266 182 }
  @@ -275,7 +191,7 @@
275 191 {
276 192 int i = feedXML.IndexOf("<item>"); //rappresenta l'indice iniziale del blocco item
277 193 int j = feedXML.IndexOf("</item>"); //rappresenta l'indice finale del blocco item
278 - int k = j-i; //rappresenta la lunghezza della stringa racchiusa dal blocco item
194 + int k = j - i; //rappresenta la lunghezza della stringa racchiusa dal blocco item
279 195 String item = feedXML.Substring(i, k);
280 196
281 197 int it = item.IndexOf("<title>") + 7;
  @@ -284,7 +200,7 @@
284 200
285 201 int il = item.IndexOf("<link>") + 6;
286 202 int fl = item.IndexOf("</link>");
287 - String link = (item.Substring(il, fl - il)).Replace("amp;","");
203 + String link = (item.Substring(il, fl - il)).Replace("amp;", "");
288 204
289 205 int id = item.IndexOf("<description>") + 13;
290 206 int fd = item.IndexOf("</description>");
  @@ -310,7 +226,7 @@
310 226
311 227 feedXML = feedXML.Substring(feedXML.IndexOf("/pubDate") + 16);
312 228
313 -
229 +
314 230 }
315 231
316 232 // Load the feed into a SyndicationFeed instance.
  @@ -344,7 +260,7 @@
344 260 int it = item.IndexOf("<Name>") + 6;
345 261 int ft = item.IndexOf("</Name>");
346 262 String title = item.Substring(it, ft - it);
347 -
263 +
348 264 int id = item.IndexOf("<Descp>") + 7;
349 265 int fd = item.IndexOf("</Descp>");
350 266 String description = item.Substring(id, fd - id);
  @@ -353,38 +269,321 @@
353 269 int fi = item.IndexOf("</Icon>");
354 270 String icona = item.Substring(ii, fi - ii);
355 271
356 - int il = item.IndexOf("<Link>") + 6;
357 - int fl = item.IndexOf("</Link>");
358 - String link = item.Substring(il, fl - il);
272 + int il = item.IndexOf("<Link>") + 6;
273 + int fl = item.IndexOf("</Link>");
274 + String link = item.Substring(il, fl - il);
275 +
276 + //int idp = item.IndexOf("<pubDate>") + 9;
277 + //int fdp = item.IndexOf("</pubDate>");
278 + //String dataPub = item.Substring(idp, fdp - idp);
279 +
280 +
281 + a = new Articolo(title, link, description, description, "", "", icona);
282 + listArticoli3.Add(a);
283 +
284 + feedXML = feedXML.Substring(feedXML.IndexOf("/Link") + 11);
285 +
286 + }
287 +
288 + // Load the feed into a SyndicationFeed instance.
289 + StringReader stringReader = new StringReader(feedXML);
290 + XmlReader xmlReader = XmlReader.Create(stringReader);
291 + //SyndicationFeed feed = SyndicationFeed.Load(xmlReader);
292 +
293 + // In Windows Phone OS 7.1 or later versions, WebClient events are raised on the same type of thread they were called upon.
294 + // For example, if WebClient was run on a background thread, the event would be raised on the background thread.
295 + // While WebClient can raise an event on the UI thread if called from the UI thread, a best practice is to always
296 + // use the Dispatcher to update the UI. This keeps the UI thread free from heavy processing.
297 + Deployment.Current.Dispatcher.BeginInvoke(() =>
298 + {
299 + // Bind the list of SyndicationItems to our ListBox.
300 + feedListBoxNews3.ItemsSource = listArticoli3;
301 + });
302 + }
303 +
304 +
305 +
306 + private static string HtmlToPlainText(string html)
307 + {
308 + const string tagWhiteSpace = @"(>|$)(\W|\n|\r)+<";//matches one or more (white space or line breaks) between '>' and '<'
309 + const string stripFormatting = @"<[^>]*(>|$)";//match any character between '<' and '>', even when end tag is missing
310 + const string lineBreak = @"<(br|BR)\s{0,1}\/{0,1}>";//matches: <br>,<br/>,<br />,<BR>,<BR/>,<BR />
311 + var lineBreakRegex = new Regex(lineBreak, RegexOptions.Multiline);
312 + var stripFormattingRegex = new Regex(stripFormatting, RegexOptions.Multiline);
313 + var tagWhiteSpaceRegex = new Regex(tagWhiteSpace, RegexOptions.Multiline);
314 +
315 + var text = html;
316 + //Decode html specific characters
317 + text = System.Net.HttpUtility.HtmlDecode(text);
318 + //Remove tag whitespace/line breaks
319 + text = tagWhiteSpaceRegex.Replace(text, "><");
320 + //Replace <br /> with line breaks
321 + text = lineBreakRegex.Replace(text, Environment.NewLine);
322 + //Strip formatting
323 + text = stripFormattingRegex.Replace(text, string.Empty);
324 +
325 + return text;
326 + }
327 +
328 +
329 + private void esistePreferito()
330 + {
331 + String titolo = titleCanvas.Text;
332 +
333 + foreach (ArticoloPreferito a in listArticoliP) //controlla se l'articolo preferito che stai per aggiungere esiste, se si ti avvisa
334 + {
335 + if (a.Titolo == titolo)
336 + {
337 + MessageBox.Show("Articolo già presente nella lista dei preferiti!");
338 + esistePref = true;
339 + break;
340 + }
341 + else
342 + {
343 + esistePref = false;
344 + }
345 +
346 + }
347 + }
348 +
349 +
350 +
351 + private void saveXML()
352 + {
353 + // Write to the Isolated Storage
354 + XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
355 + xmlWriterSettings.Indent = true;
356 +
357 + using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
358 + {
359 + using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("favourites.xml", FileMode.Create))
360 + {
361 + XmlSerializer serializer = new XmlSerializer(typeof(List<ArticoloPreferito>));
362 + using (XmlWriter xmlWriter = XmlWriter.Create(stream, xmlWriterSettings))
363 + {
364 + serializer.Serialize(xmlWriter, GenerateFavouritesData());
365 + }
366 + }
367 + }
368 +
369 +
370 + try
371 + {
372 + using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
373 + {
374 + using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("favourites.xml", FileMode.Open))
375 + {
376 + XmlSerializer serializer = new XmlSerializer(typeof(List<ArticoloPreferito>));
377 + List<ArticoloPreferito> data = (List<ArticoloPreferito>)serializer.Deserialize(stream);
378 + this.feedListPreferiti.ItemsSource = data;
379 + listArticoliP = data;
380 + }
381 + }
382 + }
383 + catch
384 + {
385 + //add some code here
386 + }
387 +
388 +
389 + }
390 +
391 + private List<ArticoloPreferito> GenerateFavouritesData()
392 + {
393 + List<ArticoloPreferito> data = new List<ArticoloPreferito>();
394 +
395 + foreach (ArticoloPreferito artPref in listArticoliP)
396 + {
397 + String title = artPref.Titolo;
398 + String link = artPref.Link;
399 + String text = artPref.Testo;
400 + String fullText = artPref.TestoFull;
401 + String date = artPref.DataPub;
402 + String note = artPref.Nota;
403 + String icon = artPref.Icona;
404 + Boolean isChecked = artPref.IsChecked;
405 +
406 + data.Add(new ArticoloPreferito() { Titolo = title, Link = link, Testo = text, TestoFull = fullText, DataPub = date, Nota = note, Icona = icon, IsChecked = isChecked });
407 +
408 + }
409 +
410 + listArticoliP = data;
411 + return data;
412 + }
413 +
414 + private void loadXML()
415 + {
416 + try
417 + {
418 + using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
419 + {
420 + using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("favourites.xml", FileMode.Open))
421 + {
422 + XmlSerializer serializer = new XmlSerializer(typeof(List<ArticoloPreferito>));
423 + List<ArticoloPreferito> data = (List<ArticoloPreferito>)serializer.Deserialize(stream);
424 + this.feedListPreferiti.ItemsSource = data;
425 + listArticoliP = data;
426 + }
427 + }
428 + }
429 + catch
430 + {
431 + //add some code here
432 + }
433 + }
434 +
435 +
436 +
437 + private Storyboard CreateFadeInOutAnimation(double from, double to)
438 + {
439 + Storyboard sb = new Storyboard();
440 + DoubleAnimation fadeInAnimation = new DoubleAnimation();
441 + fadeInAnimation.From = from;
442 + fadeInAnimation.To = to;
443 + fadeInAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.3));
444 +
445 + if (artAddFavCanvas.Visibility == System.Windows.Visibility.Visible)
446 + Storyboard.SetTarget(fadeInAnimation, this.artAddFavCanvas);
447 + if (artDelFavCanvas.Visibility == System.Windows.Visibility.Visible)
448 + Storyboard.SetTarget(fadeInAnimation, this.artDelFavCanvas);
449 + if (savedNoteCanvas.Visibility == System.Windows.Visibility.Visible)
450 + Storyboard.SetTarget(fadeInAnimation, this.savedNoteCanvas);
451 + if (deletedNoteCanvas.Visibility == System.Windows.Visibility.Visible)
452 + Storyboard.SetTarget(fadeInAnimation, this.deletedNoteCanvas);
453 +
454 + Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath("Opacity"));
455 +
456 + sb.Children.Add(fadeInAnimation);
457 +
458 + return sb;
459 + }
460 +
461 +
462 +
463 + #endregion
464 +
465 +
466 + // Load data for the ViewModel Items
467 + private void MainPage_Loaded(object sender, RoutedEventArgs e)
468 + {
469 + if (!App.ViewModel.IsDataLoaded)
470 + {
471 + App.ViewModel.LoadData();
472 + }
473 + }
474 +
475 + private void RunBackgroundWorker()
476 + {
477 + backroungWorker.DoWork += ((s, args) =>
478 + {
479 + Thread.Sleep(5000);
480 + });
481 +
482 + backroungWorker.RunWorkerCompleted += ((s, args) =>
483 + {
484 + this.Dispatcher.BeginInvoke(() =>
485 + {
486 + this.myPopup.IsOpen = false;
487 + }
488 + );
489 + });
490 + backroungWorker.RunWorkerAsync();
491 + }
492 +
493 +
494 +
495 +
496 + private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
497 + {
498 + checkConnection();
499 + SystemTray.IsVisible = false;
500 +
501 + nomeAppTesto.DataContext = NOME_APPLICAZIONE;
502 +
503 + loadXML();
504 +
505 + // WebClient is used instead of HttpWebRequest in this code sample because
506 + // the implementation is simpler and easier to use, and we do not need to use
507 + // advanced functionality that HttpWebRequest provides, such as the ability to send headers.
508 + WebClient webClient1 = new WebClient();
509 + WebClient webClient3 = new WebClient();
510 +
511 + // Subscribe to the DownloadStringCompleted event prior to downloading the RSS feed.
512 + webClient1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient1_DownloadStringCompleted);
513 + webClient3.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient3_DownloadStringCompleted);
514 +
515 + // Download the RSS feed. DownloadStringAsync was used instead of OpenStreamAsync because we do not need
516 + // to leave a stream open, and we will not need to worry about closing the channel.
517 + webClient1.DownloadStringAsync(new System.Uri(LINK_FEED_1));
518 + webClient3.DownloadStringAsync(new System.Uri(LINK_FEED_2));
519 +
520 + }
521 +
522 +
523 + // Event handler which runs after the feed is fully downloaded.
524 + private void webClient1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
525 + {
526 + if (e.Error != null)
527 + {
528 + Deployment.Current.Dispatcher.BeginInvoke(() =>
529 + {
530 + // Showing the exact error message is useful for debugging. In a finalized application,
531 + // output a friendly and applicable string to the user instead.
532 + MessageBox.Show(e.Error.Message);
533 + });
534 + }
535 + else
536 + {
537 + // Save the feed into the State property in case the application is tombstoned.
538 + this.State["feed"] = e.Result;
539 +
540 + UpdateFeedList1(e.Result);
541 + }
542 + }
359 543
360 - //int idp = item.IndexOf("<pubDate>") + 9;
361 - //int fdp = item.IndexOf("</pubDate>");
362 - //String dataPub = item.Substring(idp, fdp - idp);
544 + private void webClient3_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
545 + {
546 + if (e.Error != null)
547 + {
548 + Deployment.Current.Dispatcher.BeginInvoke(() =>
549 + {
550 + // Showing the exact error message is useful for debugging. In a finalized application,
551 + // output a friendly and applicable string to the user instead.
552 + MessageBox.Show(e.Error.Message);
553 + });
554 + }
555 + else
556 + {
557 + // Save the feed into the State property in case the application is tombstoned.
558 + this.State["feed"] = e.Result;
363 559
560 + UpdateFeedList3(e.Result);
561 + }
562 + }
364 563
365 - a = new Articolo(title, link, description, description, "", "", icona);
366 - listArticoli3.Add(a);
564 + // This method determines whether the user has navigated to the application after the application was tombstoned.
565 + protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
566 + {
567 + // First, check whether the feed is already saved in the page state.
568 + if (this.State.ContainsKey("feed"))
569 + {
570 + // Get the feed again only if the application was tombstoned, which means the ListBox will be empty.
571 + // This is because the OnNavigatedTo method is also called when navigating between pages in your application.
572 + // You would want to rebind only if your application was tombstoned and page state has been lost.
573 + if (feedListBoxNews1.Items.Count == 0)
574 + {
575 + UpdateFeedList1(State["feed"] as string);
576 + }
367 577
368 - feedXML = feedXML.Substring(feedXML.IndexOf("/Link") + 11);
578 + if (feedListBoxNews3.Items.Count == 0)
579 + {
580 + UpdateFeedList3(State["feed"] as string);
581 + }
369 582
370 583 }
371 -
372 - // Load the feed into a SyndicationFeed instance.
373 - StringReader stringReader = new StringReader(feedXML);
374 - XmlReader xmlReader = XmlReader.Create(stringReader);
375 - //SyndicationFeed feed = SyndicationFeed.Load(xmlReader);
376 -
377 - // In Windows Phone OS 7.1 or later versions, WebClient events are raised on the same type of thread they were called upon.
378 - // For example, if WebClient was run on a background thread, the event would be raised on the background thread.
379 - // While WebClient can raise an event on the UI thread if called from the UI thread, a best practice is to always
380 - // use the Dispatcher to update the UI. This keeps the UI thread free from heavy processing.
381 - Deployment.Current.Dispatcher.BeginInvoke(() =>
382 - {
383 - // Bind the list of SyndicationItems to our ListBox.
384 - feedListBoxNews3.ItemsSource = listArticoli3;
385 - });
386 584 }
387 585
586 +
388 587 // The SelectionChanged handler for the feed items
389 588 private void feedListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
390 589 {
  @@ -406,7 +605,7 @@
406 605 if (sItem.Nota == "")
407 606 {
408 607 boxNote.Visibility = System.Windows.Visibility.Collapsed;
409 - grigliaTesto.Height = 580.00;
608 + grigliaTesto.Height = 590.00;
410 609 }
411 610 else
412 611 {
  @@ -459,27 +658,7 @@
459 658 }
460 659 }
461 660
462 - private static string HtmlToPlainText(string html)
463 - {
464 - const string tagWhiteSpace = @"(>|$)(\W|\n|\r)+<";//matches one or more (white space or line breaks) between '>' and '<'
465 - const string stripFormatting = @"<[^>]*(>|$)";//match any character between '<' and '>', even when end tag is missing
466 - const string lineBreak = @"<(br|BR)\s{0,1}\/{0,1}>";//matches: <br>,<br/>,<br />,<BR>,<BR/>,<BR />
467 - var lineBreakRegex = new Regex(lineBreak, RegexOptions.Multiline);
468 - var stripFormattingRegex = new Regex(stripFormatting, RegexOptions.Multiline);
469 - var tagWhiteSpaceRegex = new Regex(tagWhiteSpace, RegexOptions.Multiline);
470 -
471 - var text = html;
472 - //Decode html specific characters
473 - text = System.Net.HttpUtility.HtmlDecode(text);
474 - //Remove tag whitespace/line breaks
475 - text = tagWhiteSpaceRegex.Replace(text, "><");
476 - //Replace <br /> with line breaks
477 - text = lineBreakRegex.Replace(text, Environment.NewLine);
478 - //Strip formatting
479 - text = stripFormattingRegex.Replace(text, string.Empty);
480 -
481 - return text;
482 - }
661 +
483 662
484 663
485 664 private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
  @@ -621,7 +800,7 @@
621 800 dateCanvas.Visibility = System.Windows.Visibility.Visible;
622 801 ApplicationBar.IsVisible = true;
623 802 grigliaTesto.Margin = new Thickness(-10, 0, 0, 0);
624 - grigliaTesto.Height = 580.00;
803 + grigliaTesto.Height = 590.00;
625 804 e.Cancel = true;
626 805 }
627 806
  @@ -660,7 +839,7 @@
660 839 if (boxNote.Text == "")
661 840 {
662 841 boxNote.Visibility = System.Windows.Visibility.Collapsed;
663 - grigliaTesto.Height = 580.00;
842 + grigliaTesto.Height = 590.00;
664 843 }
665 844 else
666 845 {
  @@ -709,7 +888,7 @@
709 888 if (listArticoli1[i - 1].Nota == "")
710 889 {
711 890 boxNote.Visibility = System.Windows.Visibility.Collapsed;
712 - grigliaTesto.Height = 580.00;
891 + grigliaTesto.Height = 590.00;
713 892 }
714 893 else
715 894 {
  @@ -754,7 +933,7 @@
754 933 if (listArticoliP[i - 1].Nota == "")
755 934 {
756 935 boxNote.Visibility = System.Windows.Visibility.Collapsed;
757 - grigliaTesto.Height = 580.00;
936 + grigliaTesto.Height = 590.00;
758 937 }
759 938 else
760 939 {
  @@ -768,6 +947,8 @@
768 947 }
769 948
770 949 }
950 +
951 + editNotePanel.Visibility = System.Windows.Visibility.Collapsed;
771 952
772 953 }
773 954
  @@ -801,7 +982,7 @@
801 982 if (listArticoli1[i + 1].Nota == "")
802 983 {
803 984 boxNote.Visibility = System.Windows.Visibility.Collapsed;
804 - grigliaTesto.Height = 580.00;
985 + grigliaTesto.Height = 590.00;
805 986 }
806 987 else
807 988 {
  @@ -841,7 +1022,7 @@
841 1022 if (listArticoliP[i + 1].Nota == "")
842 1023 {
843 1024 boxNote.Visibility = System.Windows.Visibility.Collapsed;
844 - grigliaTesto.Height = 580.00;
1025 + grigliaTesto.Height = 590.00;
845 1026 }
846 1027 else
847 1028 {
  @@ -853,8 +1034,11 @@
853 1034 }
854 1035
855 1036 }
1037 +
856 1038 }
857 1039
1040 + editNotePanel.Visibility = System.Windows.Visibility.Collapsed;
1041 +
858 1042 }
859 1043
860 1044
  @@ -894,25 +1078,7 @@
894 1078
895 1079 }
896 1080
897 - private void esistePreferito()
898 - {
899 - String titolo = titleCanvas.Text;
900 -
901 - foreach (ArticoloPreferito a in listArticoliP) //controlla se l'articolo preferito che stai per aggiungere esiste, se si ti avvisa
902 - {
903 - if (a.Titolo == titolo)
904 - {
905 - MessageBox.Show("Articolo già presente nella lista dei preferiti!");
906 - esistePref = true;
907 - break;
908 - }
909 - else
910 - {
911 - esistePref = false;
912 - }
913 -
914 - }
915 - }
1081 +
916 1082
917 1083 private void CheckBox_Checked(object sender, RoutedEventArgs e)
918 1084 {
  @@ -957,91 +1123,7 @@
957 1123 }
958 1124
959 1125
960 - private void saveXML()
961 - {
962 - // Write to the Isolated Storage
963 - XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
964 - xmlWriterSettings.Indent = true;
965 -
966 - using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
967 - {
968 - using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("favourites.xml", FileMode.Create))
969 - {
970 - XmlSerializer serializer = new XmlSerializer(typeof(List<ArticoloPreferito>));
971 - using (XmlWriter xmlWriter = XmlWriter.Create(stream, xmlWriterSettings))
972 - {
973 - serializer.Serialize(xmlWriter, GenerateFavouritesData());
974 - }
975 - }
976 - }
977 -
978 -
979 -
980 - //try
981 - //{
982 - // using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
983 - // {
984 - // using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("favourites.xml", FileMode.Open))
985 - // {
986 - // XmlSerializer serializer = new XmlSerializer(typeof(List<ArticoloPreferito>));
987 - // List<ArticoloPreferito> data = (List<ArticoloPreferito>)serializer.Deserialize(stream);
988 - // this.feedListPreferiti.ItemsSource = data;
989 - // }
990 - // }
991 - //}
992 - //catch
993 - //{
994 - // //add some code here
995 - //}
996 -
997 -
998 -
999 - }
1000 -
1001 - private List<ArticoloPreferito> GenerateFavouritesData()
1002 - {
1003 - List<ArticoloPreferito> data = new List<ArticoloPreferito>();
1004 -
1005 - foreach (ArticoloPreferito artPref in listArticoliP)
1006 - {
1007 - String title = artPref.Titolo;
1008 - String link = artPref.Link;
1009 - String text = artPref.Testo;
1010 - String fullText = artPref.TestoFull;
1011 - String date = artPref.DataPub;
1012 - String note = artPref.Nota;
1013 - String icon = artPref.Icona;
1014 - Boolean isChecked = artPref.IsChecked;
1015 -
1016 - data.Add(new ArticoloPreferito()
1017 - { Titolo = title, Link = link, Testo = text, TestoFull = fullText, DataPub = date, Nota = note, Icona = icon, IsChecked = isChecked });
1018 -
1019 - }
1020 -
1021 - listArticoliP = data;
1022 - return data;
1023 - }
1024 -
1025 - private void loadXML()
1026 - {
1027 - try
1028 - {
1029 - using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
1030 - {
1031 - using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("favourites.xml", FileMode.Open))
1032 - {
1033 - XmlSerializer serializer = new XmlSerializer(typeof(List<ArticoloPreferito>));
1034 - List<ArticoloPreferito> data = (List<ArticoloPreferito>)serializer.Deserialize(stream);
1035 - this.feedListPreferiti.ItemsSource = data;
1036 - listArticoliP = data;
1037 - }
1038 - }
1039 - }
1040 - catch
1041 - {
1042 - //add some code here
1043 - }
1044 - }
1126 +
1045 1127
1046 1128
1047 1129 private void appBarDelete_Click(object sender, EventArgs e)
  @@ -1171,7 +1253,7 @@
1171 1253 if (boxNote.Text == "")
1172 1254 {
1173 1255 boxNote.Visibility = System.Windows.Visibility.Collapsed;
1174 - grigliaTesto.Height = 580.00;
1256 + grigliaTesto.Height = 590.00;
1175 1257 }
1176 1258 else
1177 1259 {
  @@ -1227,7 +1309,7 @@
1227 1309 {
1228 1310 if (a.Titolo == titleCanvas.Text)
1229 1311 {
1230 - grigliaTesto.Height = 580.00;
1312 + grigliaTesto.Height = 590.00;
1231 1313 boxNote.Visibility = System.Windows.Visibility.Collapsed;
1232 1314 boxNote.Text = "";
1233 1315 a.Nota = "";
  @@ -1239,7 +1321,7 @@
1239 1321 {
1240 1322 if (ap.Titolo == titleCanvas.Text)
1241 1323 {
1242 - grigliaTesto.Height = 580.00;
1324 + grigliaTesto.Height = 590.00;
1243 1325 boxNote.Visibility = System.Windows.Visibility.Collapsed;
1244 1326 boxNote.Text = "";
1245 1327 ap.Nota = "";
  @@ -1314,28 +1396,6 @@
1314 1396 canvasOff.Stop();
1315 1397 }
1316 1398
1317 - private void refreshButton_Click(object sender, RoutedEventArgs e)
1318 - {
1319 - if (pivot.SelectedIndex == 0)
1320 - {
1321 - WebClient webClient1 = new WebClient();
1322 - webClient1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient1_DownloadStringCompleted);
1323 - webClient1.DownloadStringAsync(new System.Uri("http://tuttolavoro.indicitalia.it/RSS/app.xml"));
1324 - }
1325 -
1326 - if (pivot.SelectedIndex == 2)
1327 - {
1328 - WebClient webClient3 = new WebClient();
1329 - webClient3.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient3_DownloadStringCompleted);
1330 - webClient3.DownloadStringAsync(new System.Uri("http://www.wki.it/marketing/app/tuttolavoroApp_Rel_news.xml"));
1331 - }
1332 -
1333 - dt.Interval = new TimeSpan(0, 0, 0); // 0seconds
1334 - dt.Tick += new EventHandler(dt_Tick);
1335 - dt.Start();
1336 - dt2.Start();
1337 - }
1338 -
1339 1399 void dt_Tick(object sender, EventArgs e)
1340 1400 {
1341 1401 loadingPanel.Visibility = System.Windows.Visibility.Visible;
  @@ -1357,6 +1417,28 @@
1357 1417 dt2.Stop();
1358 1418 }
1359 1419
1420 + private void refreshButton_Click(object sender, RoutedEventArgs e)
1421 + {
1422 + if (pivot.SelectedIndex == 0)
1423 + {
1424 + WebClient webClient1 = new WebClient();
1425 + webClient1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient1_DownloadStringCompleted);
1426 + webClient1.DownloadStringAsync(new System.Uri(LINK_FEED_1));
1427 + }
1428 +
1429 + if (pivot.SelectedIndex == 2)
1430 + {
1431 + WebClient webClient3 = new WebClient();
1432 + webClient3.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient3_DownloadStringCompleted);
1433 + webClient3.DownloadStringAsync(new System.Uri(LINK_FEED_2));
1434 + }
1435 +
1436 + dt.Interval = new TimeSpan(0, 0, 0); // 0seconds
1437 + dt.Tick += new EventHandler(dt_Tick);
1438 + dt.Start();
1439 + dt2.Start();
1440 + }
1441 +
1360 1442 private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
1361 1443 {
1362 1444 if ((e.Orientation & PageOrientation.Portrait) == (PageOrientation.Portrait))
  @@ -1367,7 +1449,7 @@
1367 1449 titleCanvas.Height = 85.00;
1368 1450 dateCanvas.Width = 450.00;
1369 1451 grigliaTesto.Width = 490.00;
1370 - grigliaTesto.Height = 580.00;
1452 + grigliaTesto.Height = 590.00;
1371 1453 grigliaTesto.Margin = new Thickness(-10, 0, 0, 0);
1372 1454 webBrowser1.Margin = new Thickness(0, -23, 0, 0);
1373 1455 if (boxNote.Visibility == System.Windows.Visibility.Visible)
  @@ -1396,40 +1478,17 @@
1396 1478 }
1397 1479 }
1398 1480
1399 -
1400 - private Storyboard CreateFadeInOutAnimation(double from, double to)
1401 - {
1402 - Storyboard sb = new Storyboard();
1403 - DoubleAnimation fadeInAnimation = new DoubleAnimation();
1404 - fadeInAnimation.From = from;
1405 - fadeInAnimation.To = to;
1406 - fadeInAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.3));
1407 -
1408 - if (artAddFavCanvas.Visibility == System.Windows.Visibility.Visible)
1409 - Storyboard.SetTarget(fadeInAnimation, this.artAddFavCanvas);
1410 - if (artDelFavCanvas.Visibility == System.Windows.Visibility.Visible)
1411 - Storyboard.SetTarget(fadeInAnimation, this.artDelFavCanvas);
1412 - if (savedNoteCanvas.Visibility == System.Windows.Visibility.Visible)
1413 - Storyboard.SetTarget(fadeInAnimation, this.savedNoteCanvas);
1414 - if (deletedNoteCanvas.Visibility == System.Windows.Visibility.Visible)
1415 - Storyboard.SetTarget(fadeInAnimation, this.deletedNoteCanvas);
1416 -
1417 - Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath("Opacity"));
1418 -
1419 - sb.Children.Add(fadeInAnimation);
1420 -
1421 - return sb;
1422 - }
1481 +
1423 1482
1424 1483 private void webBrowser1_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
1425 1484 {
1426 1485 loadingPanel2.Visibility = System.Windows.Visibility.Collapsed;
1427 1486 }
1428 -
1429 -
1430 1487
1431 -
1432 1488
1433 -
1489 + #endregion
1490 +
1491 +
1492 +
1434 1493 }
1435 1494 }