protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
//Dispatcher.Invoke(new Action(() => { }), DispatcherPriority.ContextIdle, null);
string currentBusNumber = (from b in App.activeBus
select b.FirstAttribute.Value).ToList()[0];
string stopName = "";
SolidColorBrush scb = new SolidColorBrush(Colors.Transparent);
TextBlock tbHeader;
ListBox listBox1 = new ListBox();
listBox1.Background = scb;
listBox1.ItemTemplate = Resources["stopsRepresentation"] as DataTemplate;
listBox1.ItemContainerStyle = Resources["styleOfListBoxSO"] as Style;
//listBox1.Tapped += listBox1_Tapped;
//var xd = XDocument.Load("all.xml");
//var bus = from el in xd.Descendants("Bus")
// where el.Attribute("lineNumber").Value == currentBusNumber
// select el;
int stopsCount = App.activeBus.Descendants("Stops").Count();
var listFromStart = App.activeBus.Descendants("Stops").Take(1).Elements("Stop").ToList();
List<Stop> myList1 = new List<Stop>();
for (int i = 0; i < listFromStart.Count; i++)
{
stopName = listFromStart[i].Attribute("stopName").Value;
var aaaaa = listFromStart[i].Elements("C").ToList();
List<string> tempList = new List<string>();
foreach (var innerStop in aaaaa)
{
tempList.Add(innerStop.Value);
}
if (i==0)
myList1.Add(new Stop(stopName, tempList, tempList.Count, -1));
else if (i == listFromStart.Count - 1)
myList1.Add(new Stop(stopName, tempList, tempList.Count, 1));
else
myList1.Add(new Stop(stopName, tempList, tempList.Count, 0));
//myList1.Add(new Stop(stopName, tempList, tempList.Count));
}
listBox1.ItemsSource = myList1;
listBox1.Tapped += listBox1_Tapped;
currentBusNumber = App.ChangeEnglishLettersToGreek(currentBusNumber);
if (stopsCount == 1)
{
tbHeader = new TextBlock { Text = "Κυκλική \"" + currentBusNumber + "\"", FontSize = 28 };
}
else
{
tbHeader = new TextBlock { Text = "Αφετηρία \"" + currentBusNumber + "\"", FontSize = 28 };
}
pivotStops.Items.Add(new PivotItem()
{
Name = "PivotItem1",
Header = tbHeader,
Content = listBox1
});
if (stopsCount == 2)
{
//currentBusNumber = (string)e.Parameter;
ListBox listBox2 = new ListBox();
listBox2.Background = scb;
listBox2.ItemTemplate = Resources["stopsRepresentation"] as DataTemplate;
listBox2.ItemContainerStyle = Resources["styleOfListBoxSO"] as Style;
var listFromFinal = App.activeBus.Descendants("Stops").Reverse().Take(1).Elements("Stop").ToList();
List<Stop> myList2 = new List<Stop>();
for (int i = 0; i < listFromFinal.Count; i++ )
{
stopName = listFromFinal[i].Attribute("stopName").Value;
var aaaaa = listFromFinal[i].Elements("C").ToList();
List<string> tempList = new List<string>();
foreach (var innerStop in aaaaa)
{
tempList.Add(innerStop.Value);
}
//myList2.Add(new Stop(stopName, tempList, tempList.Count, 0));
if (i == 0)
myList2.Add(new Stop(stopName, tempList, tempList.Count, -1));
else if (i == listFromFinal.Count - 1)
myList2.Add(new Stop(stopName, tempList, tempList.Count, 1));
else
myList2.Add(new Stop(stopName, tempList, tempList.Count, 0));
}
listBox2.ItemsSource = myList2;
listBox2.Tapped += listBox1_Tapped;
currentBusNumber = App.ChangeEnglishLettersToGreek(currentBusNumber);
tbHeader = new TextBlock { Text = "Τέρμα \"" + currentBusNumber + "\"", FontSize = 28 };
pivotStops.Items.Add(new PivotItem()
{
Name = "PivotItem2",
Header = tbHeader,
Content = listBox2
});
}
currentBusNumber = "";
}