Subversion Repository Public Repository

Nextrek

Diff Revisions 36 vs 37 for /WindowsPhone/NotizieTL/NotizieTL/MainPage.xaml.cs

Diff revisions: vs.
  @@ -16,6 +16,7 @@
16 16 using System.Xml;
17 17 using Microsoft.Phone.Tasks;
18 18 using System.Text.RegularExpressions;
19 + using Microsoft.Phone.Shell;
19 20
20 21 namespace NotizieTL
21 22 {
  @@ -30,7 +31,9 @@
30 31 // Constructor
31 32 public MainPage()
32 33 {
34 + //SystemTray.IsVisible = false;
33 35 InitializeComponent();
36 +
34 37
35 38 // Set the data context of the listbox control to the sample data
36 39 DataContext = App.ViewModel;
  @@ -60,6 +63,8 @@
60 63 private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
61 64 {
62 65 checkConnection();
66 + SystemTray.IsVisible = false;
67 + feedListPreferiti.ItemsSource = listArticoliP;
63 68
64 69 // WebClient is used instead of HttpWebRequest in this code sample because
65 70 // the implementation is simpler and easier to use, and we do not need to use
  @@ -316,6 +321,8 @@
316 321 String description1 = item.Substring(id, fd - id);
317 322 String descriptionComplete = HtmlToPlainText(description1);
318 323 descriptionComplete = descriptionComplete.Remove(descriptionComplete.LastIndexOf("\r"));
324 + //if (!descriptionComplete.EndsWith("."))
325 + // descriptionComplete = descriptionComplete.Remove(descriptionComplete.LastIndexOf("\r"));
319 326 if (descriptionComplete.StartsWith("\r\n"))
320 327 descriptionComplete = descriptionComplete.Remove(0, 2);
321 328 //String description = descriptionComplete;
  @@ -349,6 +356,7 @@
349 356 {
350 357 // Bind the list of SyndicationItems to our ListBox.
351 358 feedListBoxNews1.ItemsSource = listArticoli1;
359 + //feedListPreferiti.ItemsSource = listArticoli1;
352 360
353 361 //loadFeedButton.Content = "Refresh Feed";
354 362 });
  @@ -459,8 +467,17 @@
459 467 dateCanvas.Text = sItem.DataPub;
460 468 textCanvas.Text = sItem.TestoFull;
461 469
470 + //Double h = titleCanvas.ActualHeight;
471 +
472 + //grigliaTesto.Height -= (h * 15) / 100;
473 + //Double h = textCanvas.ActualHeight;
474 + scroller.ScrollToVerticalOffset(0.0);
475 +
462 476 notiziaCanvas.Visibility = System.Windows.Visibility.Visible;
463 - scrollTesto.DataContext = sItem.TestoFull;
477 + ApplicationBar.IsVisible = true;
478 +
479 + //scroller.DataContext = sItem.TestoFull;
480 +
464 481 // Get the associated URI of the feed item.
465 482 //Uri uri = new Uri(sItem.Link);
466 483
  @@ -578,13 +595,15 @@
578 595
579 596 private void appBarDelete_Click(object sender, EventArgs e)
580 597 {
581 - if (listArticoliP.Count != 0)
598 +
599 + if (listArticoliP.Count > 0)
582 600 {
583 601 foreach (ArticoloPreferito a in listArticoliP)
584 602 {
585 603 if (a.IsChecked == true)
586 604 {
587 605 listArticoliP.Remove(a);
606 + feedListPreferiti.ItemsSource = listArticoliP;
588 607 }
589 608 }
590 609 }
  @@ -593,24 +612,25 @@
593 612
594 613 private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
595 614 {
596 -
597 615
598 - //if (pivot.SelectedIndex == 0 || pivot.SelectedIndex == 2)
599 - //{
600 - // ApplicationBar.IsVisible = false;
601 -
602 - //}
603 - //else
604 - //{
605 - // ApplicationBar.Mode = Microsoft.Phone.Shell.ApplicationBarMode.Minimized;
606 - // ApplicationBar.IsVisible = true;
607 616
608 - // try
609 - // {
610 - // appBarDelete.IsEnabled = false;
611 - // }
612 - // catch { }
613 - //}
617 + if (pivot.SelectedIndex == 0 || pivot.SelectedIndex == 2)
618 + {
619 + ApplicationBar.IsVisible = false;
620 +
621 + }
622 + else
623 + {
624 + //ApplicationBar.Mode = Microsoft.Phone.Shell.ApplicationBarMode.Minimized;
625 + ApplicationBar.IsVisible = true;
626 + feedListPreferiti.ItemsSource = listArticoliP;
627 +
628 + try
629 + {
630 + //appBarDelete.IsEnabled = false;
631 + }
632 + catch { }
633 + }
614 634
615 635
616 636 }
  @@ -625,7 +645,10 @@
625 645 private void PhoneApplicationPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
626 646 {
627 647 if (notiziaCanvas.Visibility == System.Windows.Visibility.Visible)
648 + {
628 649 notiziaCanvas.Visibility = System.Windows.Visibility.Collapsed;
650 + ApplicationBar.IsVisible = false;
651 + }
629 652
630 653 e.Cancel = true;
631 654 }
  @@ -671,6 +694,154 @@
671 694
672 695 }
673 696
697 + private void boxArticolo_Tap(object sender, System.Windows.Input.GestureEventArgs e)
698 + {
699 + notiziaCanvas.Visibility = System.Windows.Visibility.Visible;
700 + }
701 +
702 + private void appBarZoomIn_Click(object sender, EventArgs e)
703 + {
704 + if (textCanvas.FontSize == 20.0)
705 + {
706 + textCanvas.FontSize = 22.0;
707 + }
708 + else
709 + {
710 + if (textCanvas.FontSize == 22.0)
711 + {
712 + textCanvas.FontSize = 24.0;
713 + }
714 + }
715 + }
716 +
717 + private void appBarZoomOut_Click(object sender, EventArgs e)
718 + {
719 + if (textCanvas.FontSize == 22.0)
720 + {
721 + textCanvas.FontSize = 20.0;
722 + }
723 + else
724 + {
725 + if (textCanvas.FontSize == 24.0)
726 + {
727 + textCanvas.FontSize = 22.0;
728 + }
729 + }
730 + }
731 +
732 + private void appBarPrev_Click(object sender, EventArgs e)
733 + {
734 + String t = titleCanvas.Text;
735 + foreach (Articolo a in listArticoli1)
736 + {
737 + if (a.Titolo == t)
738 + {
739 + int i = listArticoli1.IndexOf(a);
740 +
741 + if (i > 0)
742 + {
743 + scroller.ScrollToVerticalOffset(0.0);
744 + titleCanvas.Text = listArticoli1[i - 1].Titolo;
745 + dateCanvas.Text = listArticoli1[i - 1].DataPub;
746 + textCanvas.Text = listArticoli1[i - 1].TestoFull;
747 + }
748 +
749 + }
750 +
751 + }
752 +
753 + }
754 +
755 + private void appBarNext_Click(object sender, EventArgs e)
756 + {
757 + String t = titleCanvas.Text;
758 + foreach (Articolo a in listArticoli1)
759 + {
760 + if (a.Titolo == t)
761 + {
762 + int i = listArticoli1.IndexOf(a);
763 +
764 + if (!(listArticoli1.Count <= i+1))
765 + {
766 + scroller.ScrollToVerticalOffset(0.0);
767 + titleCanvas.Text = listArticoli1[i + 1].Titolo;
768 + dateCanvas.Text = listArticoli1[i + 1].DataPub;
769 + textCanvas.Text = listArticoli1[i + 1].TestoFull;
770 + }
771 +
772 + }
773 +
774 + }
775 + }
776 +
777 +
778 +
779 + private void appBarCondividi_Click(object sender, EventArgs e)
780 + {
781 + EmailComposeTask email = new EmailComposeTask();
782 + email.To = "";
783 + email.Subject = titleCanvas.Text;
784 + email.Body = titleCanvas.Text + "\r\n" + "\r\n" + dateCanvas.Text + "\r\n" + "\r\n" + textCanvas.Text;
785 + email.Show();
786 + }
787 +
788 + private void boxArticolo_Loaded(object sender, RoutedEventArgs e)
789 + {
790 + SolidColorBrush evenBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff));
791 + SolidColorBrush oddBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xcc, 0xcc, 0xcc));
792 +
793 + StackPanel stackpanel = sender as StackPanel;
794 + int index = feedListBoxNews1.Items.IndexOf(stackpanel.DataContext);
795 + if (index % 2 == 0)
796 + stackpanel.Background = evenBackground;
797 + else
798 + stackpanel.Background = oddBackground;
799 + }
800 +
801 + private void appBarRefresh_Click_1(object sender, EventArgs e)
802 + {
803 +
804 + }
805 +
806 + private void appBarAddFavorites_Click(object sender, EventArgs e)
807 + {
808 + String titolo = titleCanvas.Text;
809 + String data = dateCanvas.Text;
810 + String testo = textCanvas.Text;
811 +
812 + ArticoloPreferito ap = new ArticoloPreferito(titolo, "", testo.Substring(0, 125)+"...", testo, data, false);
813 +
814 + listArticoliP.Add(ap);
815 + //feedListPreferiti.ItemsSource = listArticoliP;
816 +
817 + }
818 +
819 + private void boxArticoloPreferito_Loaded(object sender, RoutedEventArgs e)
820 + {
821 + SolidColorBrush evenBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff));
822 + SolidColorBrush oddBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xcc, 0xcc, 0xcc));
823 +
824 + StackPanel stackpanel = sender as StackPanel;
825 +
826 + int index = feedListPreferiti.Items.IndexOf(stackpanel.DataContext);
827 + if (index % 2 == 0)
828 + stackpanel.Background = evenBackground;
829 + else
830 + stackpanel.Background = oddBackground;
831 + }
832 +
833 +
834 + private void articoloPreferitoPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
835 + {
836 + StackPanel stackpanel = sender as StackPanel;
837 +
838 + titleCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).Titolo;
839 + textCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).TestoFull;
840 + dateCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).DataPub;
841 +
842 + notiziaCanvas.Visibility = System.Windows.Visibility.Visible;
843 +
844 + }
674 845
675 846
676 847