private void initRdvOpti() { List<Meeting>tmp = new List<Meeting>(); RowDefinition tmpRow; tmp=myRoadM.OptimizedMeetingOrder; for (int i = 0; i < tmp.Count; i++) { if (i == 0) { tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); flbI_InfoRdv = new FlecheBasInfo(); flbI_InfoRdv._EnabledAnimation = false; flbI_InfoRdv.SujetRdv = "Départ"; flbI_InfoRdv.AdrRdv = tmp[i].City; flbI_InfoRdv.InitInfo(); flbI_InfoRdv.Margin = new Thickness(1, 1, 1, 1); flbI_InfoRdv.SetValue(Grid.RowProperty, i); gr_InfoRDOpti.Children.Add(flbI_InfoRdv); continue; } if (tmp[i].Subject != "Départ" && tmp[i].Subject != "Arrivée") { tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); flbI_InfoRdv._EnabledAnimation = false; flbI_InfoRdv = new FlecheBasInfo(); flbI_InfoRdv.SujetRdv = tmp[i].Subject + " (" + tmp[i].DateTime.TimeOfDay + ")"; flbI_InfoRdv.AdrRdv = tmp[i].Address; flbI_InfoRdv.InitInfo(); flbI_InfoRdv.SetValue(Grid.RowProperty, i); flbI_InfoRdv.Margin = new Thickness(1, 5, 1, 5); gr_InfoRDOpti.Children.Add(flbI_InfoRdv); } if (i == tmp.Count - 1) { var monTxt = new TextBlock(); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; monTxt.SetValue(Grid.RowProperty, i+1); monTxt.Text = "Arrivée"; monTxt.FontSize = 35; System.Windows.Shapes.Rectangle monRect = new System.Windows.Shapes.Rectangle(); monRect.Height = 45; monRect.Width =340; monRect.SetValue(Grid.RowProperty, i+1); monRect.SetValue(System.Windows.Shapes.Rectangle.FillProperty, App.Current.Resources["PhoneAccentBrush"]); gr_InfoRDOpti.Children.Add(monRect); gr_InfoRDOpti.Children.Add(monTxt); monTxt = new TextBlock(); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRDOpti.RowDefinitions.Add(tmpRow); monTxt.SetValue(Grid.RowProperty, i+2); monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; monTxt.Text = tmp[i].City; monTxt.FontSize = 20; gr_InfoRDOpti.Children.Add(monTxt); } } }
private void InitGrid() { Trip monTrip; RowDefinition tmpRow; double tpsTot=0; if (m != null) { for (int i = 0; i < m.Count; i++) { monTrip =myRoadM.Trips.Where(o => o.Start.Equals(m[i])).FirstOrDefault(); if (monTrip != null && !m[i].IsLocationFail) { if (i == 0) { tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRD.RowDefinitions.Add(tmpRow); flbI_InfoRdv = new FlecheBasInfo(); flbI_InfoRdv.SujetRdv = "Départ"; flbI_InfoRdv.AdrRdv = m[i].City; flbI_InfoRdv.Distance = monTrip.Distance + " km"; flbI_InfoRdv.TpsTrajet = monTrip.Duration + " min"; tpsTot = tpsTot + monTrip.Duration; flbI_InfoRdv.ConSomation = Math.Round(((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100), 2) + " L"; flbI_InfoRdv.Cout =Math.Round((((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]),2) + " €"; flbI_InfoRdv.IsTripFail1 = monTrip.IsTripFail; flbI_InfoRdv.InitInfo(); //flbI_InfoRdv.Margin = new Thickness(1, 1, 1, 1); flbI_InfoRdv.SetValue(Grid.RowProperty, i); flbI_InfoRdv.Margin = new Thickness(1, 5, 1, 5); gr_InfoRD.Children.Add(flbI_InfoRdv); continue; } tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRD.RowDefinitions.Add(tmpRow); flbI_InfoRdv = new FlecheBasInfo(); flbI_InfoRdv.SujetRdv = m[i].Subject+" ("+m[i].DateTime.ToShortTimeString()+")"; flbI_InfoRdv.AdrRdv = m[i].Address; flbI_InfoRdv.Distance = monTrip.Distance + " km"; flbI_InfoRdv.TpsTrajet = monTrip.Duration + " min"; tpsTot = tpsTot + monTrip.Duration; flbI_InfoRdv.IsTripFail1 = monTrip.IsTripFail; flbI_InfoRdv.ConSomation = Math.Round(((monTrip.Distance * (double)settings["ConsoCarburant"])/100),2) + " L"; flbI_InfoRdv.Cout = Math.Round((((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]), 2) + " €"; flbI_InfoRdv.InitInfo(); flbI_InfoRdv.SetValue(Grid.RowProperty, i); flbI_InfoRdv.Margin = new Thickness(1, 5, 1, 5); gr_InfoRD.Children.Add(flbI_InfoRdv); } if (i == m.Count - 1) { var monTxt = new TextBlock(); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRD.RowDefinitions.Add(tmpRow); monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; monTxt.SetValue(Grid.RowProperty, i); monTxt.Text = "Arrivée"; System.Windows.Shapes.Rectangle monRect = new System.Windows.Shapes.Rectangle(); monRect.Height = 45; monRect.Width = 340; monRect.SetValue(Grid.RowProperty, i); monRect.SetValue(System.Windows.Shapes.Rectangle.FillProperty, App.Current.Resources["PhoneAccentBrush"]); gr_InfoRD.Children.Add(monRect); gr_InfoRD.Children.Add(monTxt); monTxt = new TextBlock(); tmpRow = new RowDefinition(); tmpRow.Height = GridLength.Auto; gr_InfoRD.RowDefinitions.Add(tmpRow); monTxt.SetValue(Grid.RowProperty, i+2); monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; monTxt.Text = m[i].City; monTxt.FontSize = 18.75; monTxt.FontFamily = new System.Windows.Media.FontFamily("Segoe UI Light"); gr_InfoRD.Children.Add(monTxt); } } rt_ConsoTrajet.tb_info2.Text = Math.Round(((myRoadM.Distance * (double)settings["ConsoCarburant"]) / 100), 2) + " L"; ; rt_CoutTot.tb_info2.Text = Math.Round((((myRoadM.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]), 2) + " €"; ; rt_DistRdv.tb_info2.Text = myRoadM.Distance+"km"; rt_nbrRdv.tb_info2.Text = myRoadM.Meetings.Count-2+""; rt_TpsTrajetRdv.tb_info2.Text =tpsTot+" min"; } initRdvOpti(); indicator.IsIndeterminate = false; indicator.IsVisible = false; }