private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "1003"), Translator.GetInstance().GetString("MessageBox", "1003", "message"), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { this.Close(); } } if (e.Key == Key.F8) { string text = string.Format("Gameobjectworker paused: {0}\n", GameObjectWorker.GetInstance().isPaused()); text += string.Format("Gameobjectworker finished: {0}\n", GameObjectWorker.GetInstance().IsFinish); text += string.Format("Gameobjectworker errored: {0}\n", GameObjectWorker.GetInstance().IsError); Console.WriteLine(text); WPFMessageBox.Show("Threads states", text, WPFMessageBoxButtons.Ok); } if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.F12) { System.IO.StreamWriter file = new System.IO.StreamWriter(AppSettings.getCommonApplicationDataPath() + "\\theairline.log"); if (Airports.Count() >= 5) { for (int i = 0; i < 5; i++) { Airport airport = Airports.GetAllAirports()[i]; file.WriteLine("Airport demand for {0} of size {1}", airport.Profile.Name, airport.Profile.Size); foreach (Airport demand in airport.getDestinationDemands()) { file.WriteLine(" Demand to {0} ({2}) is {1}", demand.Profile.Name, airport.getDestinationPassengersRate(demand, AirlinerClass.ClassType.Economy_Class), demand.Profile.Size); } } } WPFMessageBox.Show("Demand has been dumped", "The demand has been dumped to the log file", WPFMessageBoxButtons.Ok); file.Close(); } }
private async Task GetAllAirports() { try { Airports = await FlightSearchState.GetAllAirports().ConfigureAwait(false); } catch (Exception ex) { await _pageDialogService.DisplayAlertAsync("Error", ex.Message, "Okay"); } if (Airports != null && Airports.Count() > 1) { // set default airports FromAirportsSelectedIndex = 1; ToAirportsSelectedIndex = 2; } }
/// <summary> /// Returns the HREF string suitable for use in an IMG tag (i.e., for a static map vs. a dynamic map) /// <param name="szMapKey">The key for using the google maps API</param> /// <param name="width">The width for the static map</param> /// <param name="height">The height for the static map</param> /// </summary> public string StaticMapHRef(string szMapKey, int height, int width) { StringBuilder sb = new StringBuilder(String.Format(CultureInfo.InvariantCulture, "https://maps.googleapis.com/maps/api/staticmap?maptype=hybrid&key={0}&size={1}x{2}", HttpUtility.UrlEncode(szMapKey), width, height)); bool fHasRoute = Airports != null && Airports.Count() > 0; bool fHasPath = Path != null && Path.Count() > 0 && ShowRoute; if (!String.IsNullOrEmpty(StaticMapAdditionalParams)) { sb.AppendFormat(CultureInfo.InvariantCulture, "&{0}", StaticMapAdditionalParams); } if (fHasPath || fHasRoute) { List <List <string> > lstSegments = new List <List <string> >(); if (fHasRoute) { List <string> lstMarkers = new List <string>(); foreach (AirportList al in Airports) { List <string> lstSegment = new List <string>(); lstSegments.Add(lstSegment); foreach (airport ap in al.GetAirportList()) { string szSegment = String.Format(CultureInfo.InvariantCulture, "{0:F6},{1:F6}", ap.LatLong.Latitude, ap.LatLong.Longitude); lstMarkers.Add(szSegment); lstSegment.Add(szSegment); } } if (ShowMarkers) { sb.Append("&markers=color:red|" + String.Join("|", lstMarkers)); } } if (ShowRoute) { string szPath = string.Empty; if (fHasPath) { List <string> lstPath = new List <string>(); foreach (LatLong ll in Path) { lstPath.Add(String.Format(CultureInfo.InvariantCulture, "{0:F6},{1:F6}", ll.Latitude, ll.Longitude)); } szPath = String.Join("|", lstPath); } // always connect the segments... foreach (List <string> segment in lstSegments) { sb.Append("&path=color:0x0000FF88|weight:5|geodesic:true|" + String.Join("|", segment)); } // and add the path, if possible if (sb.Length + szPath.Length < 8100) { sb.Append("&path=color:0xFF000088|weight:5|" + szPath); } } } else { sb.AppendFormat(CultureInfo.InvariantCulture, "¢er={0:F8},{1:F8}&zoom={2}", MapCenter.Latitude, MapCenter.Longitude, (int)ZoomFactor); } return(sb.ToString()); }