|
@@ -1,4 +1,6 @@ |
1 |
|
- |
using System; |
|
1 |
+ |
#define DEBUG_AGENT |
|
2 |
+ |
|
|
3 |
+ |
using System; |
2 |
4 |
|
using System.Collections.Generic; |
3 |
5 |
|
using System.Linq; |
4 |
6 |
|
using System.Net; |
|
@@ -24,6 +26,7 @@ |
24 |
26 |
|
|
25 |
27 |
|
using System.Xml.Serialization; |
26 |
28 |
|
using System.IO.IsolatedStorage; |
|
29 |
+ |
using Microsoft.Phone.Scheduler; |
27 |
30 |
|
|
28 |
31 |
|
|
29 |
32 |
|
namespace NotizieTL |
|
@@ -51,6 +54,9 @@ |
51 |
54 |
|
|
52 |
55 |
|
#region VARIABILI DI CLASSE E COSTRUTTORE |
53 |
56 |
|
|
|
57 |
+ |
int indice = 0; |
|
58 |
+ |
String c = ""; |
|
59 |
+ |
|
54 |
60 |
|
PhoneApplicationService phoneAppService = PhoneApplicationService.Current; |
55 |
61 |
|
|
56 |
62 |
|
BackgroundWorker backroungWorker; |
|
@@ -70,6 +76,13 @@ |
70 |
76 |
|
System.Windows.Threading.DispatcherTimer canvasOn = new System.Windows.Threading.DispatcherTimer(); |
71 |
77 |
|
System.Windows.Threading.DispatcherTimer canvasOff = new System.Windows.Threading.DispatcherTimer(); |
72 |
78 |
|
|
|
79 |
+ |
System.Windows.Threading.DispatcherTimer poweredOff = new System.Windows.Threading.DispatcherTimer(); |
|
80 |
+ |
|
|
81 |
+ |
|
|
82 |
+ |
private string periodicTaskName = "LiveTilePeriodicAgent"; |
|
83 |
+ |
private PeriodicTask periodicTask; |
|
84 |
+ |
|
|
85 |
+ |
|
73 |
86 |
|
// Constructor |
74 |
87 |
|
public MainPage() |
75 |
88 |
|
{ |
|
@@ -186,6 +199,7 @@ |
186 |
199 |
|
{ |
187 |
200 |
|
listArticoli1 = new List<Articolo>(); |
188 |
201 |
|
Articolo a; |
|
202 |
+ |
|
189 |
203 |
|
|
190 |
204 |
|
while (feedXML.Contains("<item>")) |
191 |
205 |
|
{ |
|
@@ -223,9 +237,14 @@ |
223 |
237 |
|
String dataPubEng = item.Substring(idp, fdp - idp); |
224 |
238 |
|
String dataPub = convertiData(dataPubEng); |
225 |
239 |
|
|
226 |
|
- |
a = new Articolo(title, link, description, descriptionComplete, dataPub, "", ""); |
227 |
|
- |
listArticoli1.Add(a); |
|
240 |
+ |
if (indice % 2 == 0) |
|
241 |
+ |
c = "White"; |
|
242 |
+ |
else |
|
243 |
+ |
c = "#d3d3d3"; |
228 |
244 |
|
|
|
245 |
+ |
a = new Articolo(title, link, description, descriptionComplete, dataPub, "", "",c); |
|
246 |
+ |
listArticoli1.Add(a); |
|
247 |
+ |
indice++; |
229 |
248 |
|
feedXML = feedXML.Substring(feedXML.IndexOf("/pubDate") + 16); |
230 |
249 |
|
|
231 |
250 |
|
|
|
@@ -244,6 +263,8 @@ |
244 |
263 |
|
{ |
245 |
264 |
|
// Bind the list of SyndicationItems to our ListBox. |
246 |
265 |
|
feedListBoxNews1.ItemsSource = listArticoli1; |
|
266 |
+ |
//updateTile(); |
|
267 |
+ |
StartPeriodicAgent(); |
247 |
268 |
|
}); |
248 |
269 |
|
} |
249 |
270 |
|
|
|
@@ -280,7 +301,7 @@ |
280 |
301 |
|
//String dataPub = item.Substring(idp, fdp - idp); |
281 |
302 |
|
|
282 |
303 |
|
|
283 |
|
- |
a = new Articolo(title, link, description, description, "", "", icona); |
|
304 |
+ |
a = new Articolo(title, link, description, description, "", "", icona,c); |
284 |
305 |
|
listArticoli3.Add(a); |
285 |
306 |
|
|
286 |
307 |
|
feedXML = feedXML.Substring(feedXML.IndexOf("/Link") + 11); |
|
@@ -498,6 +519,7 @@ |
498 |
519 |
|
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) |
499 |
520 |
|
{ |
500 |
521 |
|
checkConnection(); |
|
522 |
+ |
|
501 |
523 |
|
SystemTray.IsVisible = false; |
502 |
524 |
|
|
503 |
525 |
|
nomeAppTesto.DataContext = NOME_APPLICAZIONE; |
|
@@ -519,6 +541,9 @@ |
519 |
541 |
|
webClient1.DownloadStringAsync(new System.Uri(LINK_FEED_1)); |
520 |
542 |
|
webClient3.DownloadStringAsync(new System.Uri(LINK_FEED_2)); |
521 |
543 |
|
|
|
544 |
+ |
poweredOff.Interval = new TimeSpan(0, 0, 25); // 25seconds |
|
545 |
+ |
poweredOff.Tick += new EventHandler(poweredOff_Tick); |
|
546 |
+ |
poweredOff.Start(); |
522 |
547 |
|
} |
523 |
548 |
|
|
524 |
549 |
|
|
|
@@ -588,74 +613,95 @@ |
588 |
613 |
|
|
589 |
614 |
|
// The SelectionChanged handler for the feed items |
590 |
615 |
|
private void feedListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) |
591 |
|
- |
{ |
592 |
|
- |
ListBox listBox = sender as ListBox; |
|
616 |
+ |
{ |
|
617 |
+ |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
|
618 |
+ |
{ |
|
619 |
+ |
//MessageBox.Show("Nessuna connessione a internet rilevata! Notizia non disponibile!"); |
593 |
620 |
|
|
594 |
|
- |
if (listBox != null && listBox.SelectedItem != null) |
|
621 |
+ |
} |
|
622 |
+ |
else |
595 |
623 |
|
{ |
596 |
|
- |
// Get the SyndicationItem that was tapped. |
597 |
|
- |
Articolo sItem = (Articolo)listBox.SelectedItem; |
598 |
624 |
|
|
599 |
|
- |
// Set up the page navigation only if a link actually exists in the feed item. |
600 |
|
- |
if (sItem.Titolo != null && sItem.DataPub != null && sItem.TestoFull != null && sItem.Link != null ) |
|
625 |
+ |
ListBox listBox = sender as ListBox; |
|
626 |
+ |
|
|
627 |
+ |
if (listBox != null && listBox.SelectedItem != null) |
601 |
628 |
|
{ |
602 |
|
- |
titleCanvas.Text = sItem.Titolo; |
603 |
|
- |
dateCanvas.Text = sItem.DataPub; |
604 |
|
- |
textCanvas.Text = sItem.TestoFull; |
605 |
|
- |
boxNote.Text = sItem.Nota; |
|
629 |
+ |
// Get the SyndicationItem that was tapped. |
|
630 |
+ |
Articolo sItem = (Articolo)listBox.SelectedItem; |
606 |
631 |
|
|
607 |
|
- |
if (sItem.Nota == "") |
608 |
|
- |
{ |
609 |
|
- |
boxNote.Visibility = System.Windows.Visibility.Collapsed; |
610 |
|
- |
grigliaTesto.Height = 590.00; |
611 |
|
- |
} |
612 |
|
- |
else |
|
632 |
+ |
// Set up the page navigation only if a link actually exists in the feed item. |
|
633 |
+ |
if (sItem.Titolo != null && sItem.DataPub != null && sItem.TestoFull != null && sItem.Link != null) |
613 |
634 |
|
{ |
614 |
|
- |
boxNote.Visibility = System.Windows.Visibility.Visible; |
615 |
|
- |
grigliaTesto.Height = 420.00; |
616 |
|
- |
} |
|
635 |
+ |
titleCanvas.Text = sItem.Titolo; |
|
636 |
+ |
dateCanvas.Text = sItem.DataPub; |
|
637 |
+ |
textCanvas.Text = sItem.TestoFull; |
|
638 |
+ |
boxNote.Text = sItem.Nota; |
|
639 |
+ |
|
|
640 |
+ |
if (sItem.Nota == "") |
|
641 |
+ |
{ |
|
642 |
+ |
boxNote.Visibility = System.Windows.Visibility.Collapsed; |
|
643 |
+ |
grigliaTesto.Height = 590.00; |
|
644 |
+ |
} |
|
645 |
+ |
else |
|
646 |
+ |
{ |
|
647 |
+ |
boxNote.Visibility = System.Windows.Visibility.Visible; |
|
648 |
+ |
grigliaTesto.Height = 420.00; |
|
649 |
+ |
} |
617 |
650 |
|
|
618 |
|
- |
scroller.ScrollToVerticalOffset(0.0); |
|
651 |
+ |
scroller.ScrollToVerticalOffset(0.0); |
619 |
652 |
|
|
620 |
|
- |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
621 |
|
- |
{ |
622 |
|
- |
loadingPanel2.Visibility = System.Windows.Visibility.Visible; |
623 |
|
- |
} |
|
653 |
+ |
getSizeOfVerticalOrientation(); |
|
654 |
+ |
|
|
655 |
+ |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
|
656 |
+ |
{ |
|
657 |
+ |
loadingPanel2.Visibility = System.Windows.Visibility.Visible; |
|
658 |
+ |
} |
624 |
659 |
|
|
625 |
|
- |
webBrowser1.Navigate(new Uri(sItem.Link, UriKind.Absolute)); |
|
660 |
+ |
webBrowser1.Navigate(new Uri(sItem.Link, UriKind.Absolute)); |
626 |
661 |
|
|
627 |
|
- |
nomeAppTesto.Visibility = System.Windows.Visibility.Collapsed; |
628 |
|
- |
refreshButton.Visibility = System.Windows.Visibility.Collapsed; |
629 |
|
- |
notiziaCanvas.Visibility = System.Windows.Visibility.Visible; |
630 |
|
- |
ApplicationBar.IsVisible = true; |
|
662 |
+ |
nomeAppTesto.Visibility = System.Windows.Visibility.Collapsed; |
|
663 |
+ |
refreshButton.Visibility = System.Windows.Visibility.Collapsed; |
|
664 |
+ |
//notiziaCanvas.Visibility = System.Windows.Visibility.Visible; |
|
665 |
+ |
ApplicationBar.IsVisible = true; |
631 |
666 |
|
|
632 |
|
- |
ApplicationBarMenuItem b = (ApplicationBarMenuItem)ApplicationBar.MenuItems[0]; |
633 |
|
- |
b.IsEnabled = false; |
|
667 |
+ |
ApplicationBarMenuItem b = (ApplicationBarMenuItem)ApplicationBar.MenuItems[0]; |
|
668 |
+ |
b.IsEnabled = false; |
634 |
669 |
|
|
|
670 |
+ |
this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape; |
|
671 |
+ |
} |
635 |
672 |
|
} |
636 |
673 |
|
} |
637 |
674 |
|
} |
638 |
675 |
|
|
639 |
676 |
|
private void feedListBox3_SelectionChanged(object sender, SelectionChangedEventArgs e) |
640 |
677 |
|
{ |
641 |
|
- |
ListBox listBox = sender as ListBox; |
|
678 |
+ |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
|
679 |
+ |
{ |
|
680 |
+ |
//MessageBox.Show("Nessuna connessione a internet rilevata! Notizia non disponibile!"); |
642 |
681 |
|
|
643 |
|
- |
if (listBox != null && listBox.SelectedItem != null) |
|
682 |
+ |
} |
|
683 |
+ |
else |
644 |
684 |
|
{ |
645 |
|
- |
// Get the SyndicationItem that was tapped. |
646 |
|
- |
Articolo sItem = (Articolo)listBox.SelectedItem; |
647 |
685 |
|
|
648 |
|
- |
// Set up the page navigation only if a link actually exists in the feed item. |
649 |
|
- |
if (sItem.Link != null) |
|
686 |
+ |
ListBox listBox = sender as ListBox; |
|
687 |
+ |
|
|
688 |
+ |
if (listBox != null && listBox.SelectedItem != null) |
650 |
689 |
|
{ |
651 |
|
- |
// Get the associated URI of the feed item. |
652 |
|
- |
Uri uri = new Uri(sItem.Link); |
|
690 |
+ |
// Get the SyndicationItem that was tapped. |
|
691 |
+ |
Articolo sItem = (Articolo)listBox.SelectedItem; |
|
692 |
+ |
|
|
693 |
+ |
// Set up the page navigation only if a link actually exists in the feed item. |
|
694 |
+ |
if (sItem.Link != null) |
|
695 |
+ |
{ |
|
696 |
+ |
// Get the associated URI of the feed item. |
|
697 |
+ |
Uri uri = new Uri(sItem.Link); |
653 |
698 |
|
|
654 |
|
- |
// Create a new WebBrowserTask Launcher to navigate to the feed item. |
655 |
|
- |
// An alternative solution would be to use a WebBrowser control, but WebBrowserTask is simpler to use. |
656 |
|
- |
WebBrowserTask webBrowserTask = new WebBrowserTask(); |
657 |
|
- |
webBrowserTask.Uri = uri; |
658 |
|
- |
webBrowserTask.Show(); |
|
699 |
+ |
// Create a new WebBrowserTask Launcher to navigate to the feed item. |
|
700 |
+ |
// An alternative solution would be to use a WebBrowser control, but WebBrowserTask is simpler to use. |
|
701 |
+ |
WebBrowserTask webBrowserTask = new WebBrowserTask(); |
|
702 |
+ |
webBrowserTask.Uri = uri; |
|
703 |
+ |
webBrowserTask.Show(); |
|
704 |
+ |
} |
659 |
705 |
|
} |
660 |
706 |
|
} |
661 |
707 |
|
} |
|
@@ -762,6 +808,10 @@ |
762 |
808 |
|
{ |
763 |
809 |
|
scroller.ScrollToVerticalOffset(0.0); |
764 |
810 |
|
|
|
811 |
+ |
pivot.Visibility = System.Windows.Visibility.Visible; |
|
812 |
+ |
|
|
813 |
+ |
this.SupportedOrientations = SupportedPageOrientation.Portrait; |
|
814 |
+ |
|
765 |
815 |
|
if (notiziaCanvas.Visibility == System.Windows.Visibility.Visible && pivot.SelectedIndex == 0) |
766 |
816 |
|
{ |
767 |
817 |
|
nomeAppTesto.Visibility = System.Windows.Visibility.Visible; |
|
@@ -825,38 +875,51 @@ |
825 |
875 |
|
|
826 |
876 |
|
private void boxArticolo_Tap(object sender, System.Windows.Input.GestureEventArgs e) |
827 |
877 |
|
{ |
828 |
|
- |
StackPanel stackpanel = sender as StackPanel; |
829 |
|
- |
|
830 |
|
- |
titleCanvas.Text = ((Articolo)stackpanel.DataContext).Titolo; |
831 |
|
- |
textCanvas.Text = ((Articolo)stackpanel.DataContext).TestoFull; |
832 |
|
- |
dateCanvas.Text = ((Articolo)stackpanel.DataContext).DataPub; |
833 |
|
- |
boxNote.Text = ((Articolo)stackpanel.DataContext).Nota; |
834 |
|
- |
String link = ((Articolo)stackpanel.DataContext).Link; |
835 |
|
- |
|
836 |
|
- |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
|
878 |
+ |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
837 |
879 |
|
{ |
838 |
|
- |
loadingPanel2.Visibility = System.Windows.Visibility.Visible; |
839 |
|
- |
} |
|
880 |
+ |
MessageBox.Show("Nessuna connessione a internet rilevata! Notizia non disponibile!"); |
840 |
881 |
|
|
841 |
|
- |
if (boxNote.Text == "") |
842 |
|
- |
{ |
843 |
|
- |
boxNote.Visibility = System.Windows.Visibility.Collapsed; |
844 |
|
- |
grigliaTesto.Height = 590.00; |
845 |
882 |
|
} |
846 |
883 |
|
else |
847 |
884 |
|
{ |
848 |
|
- |
boxNote.Visibility = System.Windows.Visibility.Visible; |
849 |
|
- |
grigliaTesto.Height = 420.00; |
850 |
|
- |
} |
|
885 |
+ |
StackPanel stackpanel = sender as StackPanel; |
851 |
886 |
|
|
852 |
|
- |
nomeAppTesto.Visibility = System.Windows.Visibility.Collapsed; |
853 |
|
- |
refreshButton.Visibility = System.Windows.Visibility.Collapsed; |
854 |
|
- |
webBrowser1.Navigate(new Uri(link, UriKind.Absolute)); |
855 |
|
- |
notiziaCanvas.Visibility = System.Windows.Visibility.Visible; |
856 |
|
- |
ApplicationBar.IsVisible = true; |
|
887 |
+ |
titleCanvas.Text = ((Articolo)stackpanel.DataContext).Titolo; |
|
888 |
+ |
textCanvas.Text = ((Articolo)stackpanel.DataContext).TestoFull; |
|
889 |
+ |
dateCanvas.Text = ((Articolo)stackpanel.DataContext).DataPub; |
|
890 |
+ |
boxNote.Text = ((Articolo)stackpanel.DataContext).Nota; |
|
891 |
+ |
String link = ((Articolo)stackpanel.DataContext).Link; |
857 |
892 |
|
|
858 |
|
- |
ApplicationBarMenuItem b = (ApplicationBarMenuItem)ApplicationBar.MenuItems[0]; |
859 |
|
- |
b.IsEnabled = false; |
|
893 |
+ |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
|
894 |
+ |
{ |
|
895 |
+ |
loadingPanel2.Visibility = System.Windows.Visibility.Visible; |
|
896 |
+ |
} |
|
897 |
+ |
|
|
898 |
+ |
if (boxNote.Text == "") |
|
899 |
+ |
{ |
|
900 |
+ |
boxNote.Visibility = System.Windows.Visibility.Collapsed; |
|
901 |
+ |
grigliaTesto.Height = 590.00; |
|
902 |
+ |
} |
|
903 |
+ |
else |
|
904 |
+ |
{ |
|
905 |
+ |
boxNote.Visibility = System.Windows.Visibility.Visible; |
|
906 |
+ |
grigliaTesto.Height = 420.00; |
|
907 |
+ |
} |
|
908 |
+ |
|
|
909 |
+ |
nomeAppTesto.Visibility = System.Windows.Visibility.Collapsed; |
|
910 |
+ |
refreshButton.Visibility = System.Windows.Visibility.Collapsed; |
|
911 |
+ |
|
|
912 |
+ |
getSizeOfVerticalOrientation(); |
|
913 |
+ |
|
|
914 |
+ |
webBrowser1.Navigate(new Uri(link, UriKind.Absolute)); |
|
915 |
+ |
//notiziaCanvas.Visibility = System.Windows.Visibility.Visible; |
|
916 |
+ |
ApplicationBar.IsVisible = true; |
|
917 |
+ |
|
|
918 |
+ |
ApplicationBarMenuItem b = (ApplicationBarMenuItem)ApplicationBar.MenuItems[0]; |
|
919 |
+ |
b.IsEnabled = false; |
|
920 |
+ |
} |
|
921 |
+ |
|
|
922 |
+ |
this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape; |
860 |
923 |
|
} |
861 |
924 |
|
|
862 |
925 |
|
|
|
@@ -1067,17 +1130,48 @@ |
1067 |
1130 |
|
|
1068 |
1131 |
|
private void boxArticolo_Loaded(object sender, RoutedEventArgs e) |
1069 |
1132 |
|
{ |
1070 |
|
- |
SolidColorBrush evenBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff)); |
1071 |
|
- |
SolidColorBrush oddBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xcc, 0xcc, 0xcc)); |
|
1133 |
+ |
//SolidColorBrush evenBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff)); |
|
1134 |
+ |
//SolidColorBrush oddBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xcc, 0xcc, 0xcc)); |
1072 |
1135 |
|
|
1073 |
|
- |
StackPanel stackpanel = sender as StackPanel; |
1074 |
|
- |
int index = feedListBoxNews1.Items.IndexOf(stackpanel.DataContext); |
1075 |
|
- |
if (index % 2 == 0) |
1076 |
|
- |
stackpanel.Background = evenBackground; |
1077 |
|
- |
else |
1078 |
|
- |
stackpanel.Background = oddBackground; |
|
1136 |
+ |
//StackPanel stackpanel = sender as StackPanel; |
|
1137 |
+ |
//int index = feedListBoxNews1.Items.IndexOf(stackpanel.DataContext); |
1079 |
1138 |
|
|
1080 |
|
- |
|
|
1139 |
+ |
|
|
1140 |
+ |
|
|
1141 |
+ |
//if (index % 2 == 0) |
|
1142 |
+ |
// stackpanel.Background = evenBackground; |
|
1143 |
+ |
//else |
|
1144 |
+ |
// stackpanel.Background = oddBackground; |
|
1145 |
+ |
|
|
1146 |
+ |
|
|
1147 |
+ |
} |
|
1148 |
+ |
|
|
1149 |
+ |
private void feedListBoxNews1_Loaded(object sender, RoutedEventArgs e) |
|
1150 |
+ |
{ |
|
1151 |
+ |
//SolidColorBrush evenBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff)); |
|
1152 |
+ |
//SolidColorBrush oddBackground = new SolidColorBrush(Color.FromArgb(0xff, 0xcc, 0xcc, 0xcc)); |
|
1153 |
+ |
|
|
1154 |
+ |
//ListBox listbox = sender as ListBox; |
|
1155 |
+ |
////StackPanel stackpanel = sender as StackPanel |
|
1156 |
+ |
|
|
1157 |
+ |
////int index = feedListBoxNews1.Items.IndexOf(stackpanel.DataContext); |
|
1158 |
+ |
//int size = listbox.Items.Count; |
|
1159 |
+ |
//StackPanel sp; |
|
1160 |
+ |
//for (int i = 0; i <= size; i++) |
|
1161 |
+ |
//{ |
|
1162 |
+ |
// sp = (StackPanel)listbox.Items[i].; |
|
1163 |
+ |
|
|
1164 |
+ |
// if (listbox.Items.IndexOf(i) % 2 == 0) |
|
1165 |
+ |
// { |
|
1166 |
+ |
|
|
1167 |
+ |
// sp.Background = evenBackground; |
|
1168 |
+ |
// } |
|
1169 |
+ |
// else |
|
1170 |
+ |
// { |
|
1171 |
+ |
// sp.Background = oddBackground; |
|
1172 |
+ |
// } |
|
1173 |
+ |
|
|
1174 |
+ |
//} |
1081 |
1175 |
|
} |
1082 |
1176 |
|
|
1083 |
1177 |
|
|
|
@@ -1185,7 +1279,7 @@ |
1185 |
1279 |
|
esistePreferito(); |
1186 |
1280 |
|
if (!esistePref) |
1187 |
1281 |
|
{ |
1188 |
|
- |
ap = new ArticoloPreferito(titolo, link, testo.Substring(0, 125) + "...", testo, data, nota, "", false); |
|
1282 |
+ |
ap = new ArticoloPreferito(titolo, link, testo.Substring(0, 125) + "...", testo, data, nota, "",c, false); |
1189 |
1283 |
|
listArticoliP.Add(ap); |
1190 |
1284 |
|
|
1191 |
1285 |
|
artAddFavCanvas.Visibility = System.Windows.Visibility.Visible; |
|
@@ -1199,7 +1293,7 @@ |
1199 |
1293 |
|
|
1200 |
1294 |
|
if (listArticoliP.Count == 0) //se la lista preferiti è vuota |
1201 |
1295 |
|
{ |
1202 |
|
- |
ap = new ArticoloPreferito(titolo, link, testo.Substring(0, 125) + "...", testo, data, nota, "", false); |
|
1296 |
+ |
ap = new ArticoloPreferito(titolo, link, testo.Substring(0, 125) + "...", testo, data, nota, "",c, false); |
1203 |
1297 |
|
listArticoliP.Add(ap); |
1204 |
1298 |
|
|
1205 |
1299 |
|
artAddFavCanvas.Visibility = System.Windows.Visibility.Visible; |
|
@@ -1239,51 +1333,66 @@ |
1239 |
1333 |
|
|
1240 |
1334 |
|
private void articoloPreferitoPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e) |
1241 |
1335 |
|
{ |
1242 |
|
- |
StackPanel stackpanel = sender as StackPanel; |
1243 |
|
- |
|
1244 |
|
- |
titleCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).Titolo; |
1245 |
|
- |
textCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).TestoFull; |
1246 |
|
- |
dateCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).DataPub; |
1247 |
|
- |
boxNote.Text = ((ArticoloPreferito)stackpanel.DataContext).Nota; |
1248 |
|
- |
String link = ((ArticoloPreferito)stackpanel.DataContext).Link; |
1249 |
|
- |
|
1250 |
|
- |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
|
1336 |
+ |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
1251 |
1337 |
|
{ |
1252 |
|
- |
loadingPanel2.Visibility = System.Windows.Visibility.Visible; |
1253 |
|
- |
} |
|
1338 |
+ |
MessageBox.Show("Nessuna connessione a internet rilevata! Notizia non disponibile!"); |
1254 |
1339 |
|
|
1255 |
|
- |
if (boxNote.Text == "") |
1256 |
|
- |
{ |
1257 |
|
- |
boxNote.Visibility = System.Windows.Visibility.Collapsed; |
1258 |
|
- |
grigliaTesto.Height = 590.00; |
1259 |
1340 |
|
} |
1260 |
1341 |
|
else |
1261 |
1342 |
|
{ |
1262 |
|
- |
boxNote.Visibility = System.Windows.Visibility.Visible; |
1263 |
|
- |
grigliaTesto.Height = 420.00; |
1264 |
|
- |
} |
1265 |
1343 |
|
|
1266 |
|
- |
nomeAppTesto.Visibility = System.Windows.Visibility.Collapsed; |
1267 |
|
- |
refreshButton.Visibility = System.Windows.Visibility.Collapsed; |
1268 |
|
- |
webBrowser1.Navigate(new Uri(link, UriKind.Absolute)); |
1269 |
|
- |
notiziaCanvas.Visibility = System.Windows.Visibility.Visible; |
1270 |
|
- |
ApplicationBar.IsVisible = true; |
|
1344 |
+ |
StackPanel stackpanel = sender as StackPanel; |
1271 |
1345 |
|
|
1272 |
|
- |
ApplicationBarMenuItem b = (ApplicationBarMenuItem)ApplicationBar.MenuItems[0]; |
1273 |
|
- |
b.IsEnabled = false; |
|
1346 |
+ |
titleCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).Titolo; |
|
1347 |
+ |
textCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).TestoFull; |
|
1348 |
+ |
dateCanvas.Text = ((ArticoloPreferito)stackpanel.DataContext).DataPub; |
|
1349 |
+ |
boxNote.Text = ((ArticoloPreferito)stackpanel.DataContext).Nota; |
|
1350 |
+ |
String link = ((ArticoloPreferito)stackpanel.DataContext).Link; |
|
1351 |
+ |
|
|
1352 |
+ |
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) |
|
1353 |
+ |
{ |
|
1354 |
+ |
loadingPanel2.Visibility = System.Windows.Visibility.Visible; |
|
1355 |
+ |
} |
|
1356 |
+ |
|
|
1357 |
+ |
if (boxNote.Text == "") |
|
1358 |
+ |
{ |
|
1359 |
+ |
boxNote.Visibility = System.Windows.Visibility.Collapsed; |
|
1360 |
+ |
grigliaTesto.Height = 590.00; |
|
1361 |
+ |
} |
|
1362 |
+ |
else |
|
1363 |
+ |
{ |
|
1364 |
+ |
boxNote.Visibility = System.Windows.Visibility.Visible; |
|
1365 |
+ |
grigliaTesto.Height = 420.00; |
|
1366 |
+ |
} |
|
1367 |
+ |
|
|
1368 |
+ |
nomeAppTesto.Visibility = System.Windows.Visibility.Collapsed; |
|
1369 |
+ |
refreshButton.Visibility = System.Windows.Visibility.Collapsed; |
|
1370 |
+ |
|
|
1371 |
+ |
getSizeOfVerticalOrientation(); |
|
1372 |
+ |
|
|
1373 |
+ |
webBrowser1.Navigate(new Uri(link, UriKind.Absolute)); |
|
1374 |
+ |
//notiziaCanvas.Visibility = System.Windows.Visibility.Visible; |
|
1375 |
+ |
ApplicationBar.IsVisible = true; |
|
1376 |
+ |
|
|
1377 |
+ |
ApplicationBarMenuItem b = (ApplicationBarMenuItem)ApplicationBar.MenuItems[0]; |
|
1378 |
+ |
b.IsEnabled = false; |
|
1379 |
+ |
|
|
1380 |
+ |
ApplicationBarIconButton b0 = (ApplicationBarIconButton)ApplicationBar.Buttons[0]; |
|
1381 |
+ |
b0.IsEnabled = true; |
|
1382 |
+ |
ApplicationBarIconButton b2 = (ApplicationBarIconButton)ApplicationBar.Buttons[2]; |
|
1383 |
+ |
b2.IsEnabled = true; |
|
1384 |
+ |
ApplicationBarIconButton b3 = (ApplicationBarIconButton)ApplicationBar.Buttons[3]; |
|
1385 |
+ |
b3.IsEnabled = true; |
|
1386 |
+ |
|
|
1387 |
+ |
ApplicationBarIconButton m0 = (ApplicationBarIconButton)ApplicationBar.Buttons[1]; |
|
1388 |
+ |
m0.IsEnabled = true; |
|
1389 |
+ |
ApplicationBarMenuItem m1 = (ApplicationBarMenuItem)ApplicationBar.MenuItems[1]; |
|
1390 |
+ |
m1.IsEnabled = true; |
|
1391 |
+ |
|
|
1392 |
+ |
} |
|
1393 |
+ |
|
|
1394 |
+ |
this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape; |
1274 |
1395 |
|
|
1275 |
|
- |
ApplicationBarIconButton b0 = (ApplicationBarIconButton)ApplicationBar.Buttons[0]; |
1276 |
|
- |
b0.IsEnabled = true; |
1277 |
|
- |
ApplicationBarIconButton b2 = (ApplicationBarIconButton)ApplicationBar.Buttons[2]; |
1278 |
|
- |
b2.IsEnabled = true; |
1279 |
|
- |
ApplicationBarIconButton b3 = (ApplicationBarIconButton)ApplicationBar.Buttons[3]; |
1280 |
|
- |
b3.IsEnabled = true; |
1281 |
|
- |
|
1282 |
|
- |
ApplicationBarIconButton m0 = (ApplicationBarIconButton)ApplicationBar.Buttons[1]; |
1283 |
|
- |
m0.IsEnabled = true; |
1284 |
|
- |
ApplicationBarMenuItem m1 = (ApplicationBarMenuItem)ApplicationBar.MenuItems[1]; |
1285 |
|
- |
m1.IsEnabled = true; |
1286 |
|
- |
|
1287 |
1396 |
|
} |
1288 |
1397 |
|
|
1289 |
1398 |
|
private void appBarAddNote_Click(object sender, EventArgs e) |
|
@@ -1419,6 +1528,13 @@ |
1419 |
1528 |
|
dt2.Stop(); |
1420 |
1529 |
|
} |
1421 |
1530 |
|
|
|
1531 |
+ |
void poweredOff_Tick(object sender, EventArgs e) |
|
1532 |
+ |
{ |
|
1533 |
+ |
pivot.Title = ""; |
|
1534 |
+ |
|
|
1535 |
+ |
poweredOff.Stop(); |
|
1536 |
+ |
} |
|
1537 |
+ |
|
1422 |
1538 |
|
private void refreshButton_Click(object sender, RoutedEventArgs e) |
1423 |
1539 |
|
{ |
1424 |
1540 |
|
if (pivot.SelectedIndex == 0) |
|
@@ -1445,24 +1561,33 @@ |
1445 |
1561 |
|
{ |
1446 |
1562 |
|
if ((e.Orientation & PageOrientation.Portrait) == (PageOrientation.Portrait)) |
1447 |
1563 |
|
{ |
1448 |
|
- |
ApplicationBar.IsVisible = true; |
1449 |
|
- |
pannelloNotizie.Width = 490.00; |
1450 |
|
- |
titleCanvas.Width = 450.00; |
1451 |
|
- |
titleCanvas.Height = 85.00; |
1452 |
|
- |
dateCanvas.Width = 450.00; |
1453 |
|
- |
grigliaTesto.Width = 490.00; |
1454 |
|
- |
grigliaTesto.Height = 590.00; |
1455 |
|
- |
grigliaTesto.Margin = new Thickness(-10, 0, 0, 0); |
1456 |
|
- |
webBrowser1.Margin = new Thickness(0, -23, 0, 0); |
1457 |
|
- |
if (boxNote.Visibility == System.Windows.Visibility.Visible) |
|
1564 |
+ |
if (pivot.SelectedIndex == 0 && notiziaCanvas.Visibility == System.Windows.Visibility.Collapsed) |
1458 |
1565 |
|
{ |
1459 |
|
- |
grigliaTesto.Height = 420.00; |
1460 |
|
- |
boxNote.Margin = new Thickness(0, 0, 10, 0); |
|
1566 |
+ |
ApplicationBar.IsVisible = false; |
|
1567 |
+ |
} |
|
1568 |
+ |
else |
|
1569 |
+ |
{ |
|
1570 |
+ |
|
|
1571 |
+ |
ApplicationBar.IsVisible = true; |
|
1572 |
+ |
pannelloNotizie.Width = 490.00; |
|
1573 |
+ |
titleCanvas.Width = 450.00; |
|
1574 |
+ |
titleCanvas.Height = 85.00; |
|
1575 |
+ |
dateCanvas.Width = 450.00; |
|
1576 |
+ |
grigliaTesto.Width = 490.00; |
|
1577 |
+ |
grigliaTesto.Height = 590.00; |
|
1578 |
+ |
grigliaTesto.Margin = new Thickness(-10, 0, 0, 0); |
|
1579 |
+ |
webBrowser1.Margin = new Thickness(0, -23, 0, 0); |
|
1580 |
+ |
if (boxNote.Visibility == System.Windows.Visibility.Visible) |
|
1581 |
+ |
{ |
|
1582 |
+ |
grigliaTesto.Height = 420.00; |
|
1583 |
+ |
boxNote.Margin = new Thickness(0, 0, 10, 0); |
|
1584 |
+ |
} |
1461 |
1585 |
|
} |
1462 |
1586 |
|
} |
1463 |
1587 |
|
|
1464 |
1588 |
|
if ((e.Orientation & PageOrientation.Landscape) == (PageOrientation.Landscape)) |
1465 |
1589 |
|
{ |
|
1590 |
+ |
pivot.Visibility = System.Windows.Visibility.Collapsed; |
1466 |
1591 |
|
ApplicationBar.IsVisible = false; |
1467 |
1592 |
|
pannelloNotizie.Width = 790.00; |
1468 |
1593 |
|
titleCanvas.Width = 720.00; |
|
@@ -1472,6 +1597,7 @@ |
1472 |
1597 |
|
grigliaTesto.Height = 360.00; |
1473 |
1598 |
|
grigliaTesto.Margin = new Thickness(-15, 0, 0, 0); |
1474 |
1599 |
|
webBrowser1.Margin = new Thickness(0, -30, 0, 0); |
|
1600 |
+ |
loadingPanel.Width = 1000.00; |
1475 |
1601 |
|
if (boxNote.Visibility == System.Windows.Visibility.Visible) |
1476 |
1602 |
|
{ |
1477 |
1603 |
|
grigliaTesto.Height = 220.00; |
|
@@ -1480,17 +1606,120 @@ |
1480 |
1606 |
|
} |
1481 |
1607 |
|
} |
1482 |
1608 |
|
|
|
1609 |
+ |
private void getSizeOfVerticalOrientation() |
|
1610 |
+ |
{ |
|
1611 |
+ |
ApplicationBar.IsVisible = true; |
|
1612 |
+ |
pannelloNotizie.Width = 490.00; |
|
1613 |
+ |
titleCanvas.Width = 450.00; |
|
1614 |
+ |
titleCanvas.Height = 85.00; |
|
1615 |
+ |
dateCanvas.Width = 450.00; |
|
1616 |
+ |
grigliaTesto.Width = 490.00; |
|
1617 |
+ |
grigliaTesto.Height = 590.00; |
|
1618 |
+ |
grigliaTesto.Margin = new Thickness(-10, 0, 0, 0); |
|
1619 |
+ |
webBrowser1.Margin = new Thickness(0, -23, 0, 0); |
|
1620 |
+ |
if (boxNote.Visibility == System.Windows.Visibility.Visible) |
|
1621 |
+ |
{ |
|
1622 |
+ |
grigliaTesto.Height = 420.00; |
|
1623 |
+ |
boxNote.Margin = new Thickness(0, 0, 10, 0); |
|
1624 |
+ |
} |
|
1625 |
+ |
} |
1483 |
1626 |
|
|
1484 |
1627 |
|
|
1485 |
1628 |
|
private void webBrowser1_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) |
1486 |
1629 |
|
{ |
1487 |
1630 |
|
loadingPanel2.Visibility = System.Windows.Visibility.Collapsed; |
|
1631 |
+ |
notiziaCanvas.Visibility = System.Windows.Visibility.Visible; |
1488 |
1632 |
|
} |
1489 |
1633 |
|
|
1490 |
1634 |
|
|
1491 |
1635 |
|
#endregion |
1492 |
1636 |
|
|
1493 |
1637 |
|
|
|
1638 |
+ |
// modify Application Tile data |
|
1639 |
+ |
//private void updateTile() |
|
1640 |
+ |
//{ |
|
1641 |
+ |
// List<Articolo> la = new List<Articolo>(); |
|
1642 |
+ |
|
|
1643 |
+ |
// for (int i = 0; i <= 9; i++) |
|
1644 |
+ |
// { |
|
1645 |
+ |
// la.Add(listArticoli1[i]); |
|
1646 |
+ |
// } |
|
1647 |
+ |
|
|
1648 |
+ |
// // some random number |
|
1649 |
+ |
// Random random = new Random(); |
|
1650 |
+ |
// int r; |
|
1651 |
+ |
// // get application tile |
|
1652 |
+ |
// ShellTile tile = ShellTile.ActiveTiles.First(); |
|
1653 |
+ |
// if (null != tile) |
|
1654 |
+ |
// { |
|
1655 |
+ |
// r = random.Next(9); |
|
1656 |
+ |
// // create a new data for tile |
|
1657 |
+ |
// StandardTileData data = new StandardTileData(); |
|
1658 |
+ |
// // tile foreground data |
|
1659 |
+ |
// data.Title = ""; |
|
1660 |
+ |
// data.BackgroundImage = new Uri("/iconaLARGE.png", UriKind.Relative); //images/iconaLARGE.png |
|
1661 |
+ |
// data.Count = 0;//random.Next(99); |
|
1662 |
+ |
// // to make tile flip add data to background also |
|
1663 |
+ |
// data.BackTitle = la[r].DataPub; |
|
1664 |
+ |
// data.BackBackgroundImage = new Uri("/tileBackBlack.png", UriKind.Relative); |
|
1665 |
+ |
// data.BackContent = la[r].Titolo; |
|
1666 |
+ |
// // update tile |
|
1667 |
+ |
// tile.Update(data); |
|
1668 |
+ |
// } |
|
1669 |
+ |
//} |
|
1670 |
+ |
|
|
1671 |
+ |
private void StartPeriodicAgent() |
|
1672 |
+ |
{ |
|
1673 |
+ |
// is old task running, remove it |
|
1674 |
+ |
periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask; |
|
1675 |
+ |
if (periodicTask != null) |
|
1676 |
+ |
{ |
|
1677 |
+ |
try |
|
1678 |
+ |
{ |
|
1679 |
+ |
ScheduledActionService.Remove(periodicTaskName); |
|
1680 |
+ |
} |
|
1681 |
+ |
catch (Exception) |
|
1682 |
+ |
{ |
|
1683 |
+ |
} |
|
1684 |
+ |
} |
|
1685 |
+ |
// create a new task |
|
1686 |
+ |
periodicTask = new PeriodicTask(periodicTaskName); |
|
1687 |
+ |
// load description from localized strings |
|
1688 |
+ |
periodicTask.Description = "This is LiveTile application update agent."; |
|
1689 |
+ |
// set expiration days |
|
1690 |
+ |
periodicTask.ExpirationTime = DateTime.Now.AddDays(14); |
|
1691 |
+ |
try |
|
1692 |
+ |
{ |
|
1693 |
+ |
// add thas to scheduled action service |
|
1694 |
+ |
ScheduledActionService.Add(periodicTask); |
|
1695 |
+ |
// debug, so run in every 30 secs |
|
1696 |
+ |
#if(DEBUG_AGENT) |
|
1697 |
+ |
ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(5)); |
|
1698 |
+ |
System.Diagnostics.Debug.WriteLine("Periodic task is started: " + periodicTaskName); |
|
1699 |
+ |
#endif |
|
1700 |
+ |
|
|
1701 |
+ |
} |
|
1702 |
+ |
catch (InvalidOperationException exception) |
|
1703 |
+ |
{ |
|
1704 |
+ |
if (exception.Message.Contains("BNS Error: The action is disabled")) |
|
1705 |
+ |
{ |
|
1706 |
+ |
// load error text from localized strings |
|
1707 |
+ |
MessageBox.Show("Background agents for this application have been disabled by the user."); |
|
1708 |
+ |
} |
|
1709 |
+ |
if (exception.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added.")) |
|
1710 |
+ |
{ |
|
1711 |
+ |
// No user action required. The system prompts the user when the hard limit of periodic tasks has been reached. |
|
1712 |
+ |
} |
|
1713 |
+ |
} |
|
1714 |
+ |
catch (SchedulerServiceException) |
|
1715 |
+ |
{ |
|
1716 |
+ |
// No user action required. |
|
1717 |
+ |
} |
|
1718 |
+ |
} |
|
1719 |
+ |
|
|
1720 |
+ |
|
|
1721 |
+ |
|
|
1722 |
+ |
|
1494 |
1723 |
|
|
1495 |
1724 |
|
} |
1496 |
1725 |
|
} |