public PanelPilot(PagePilots parent, Pilot pilot) { this.ParentPage = parent; this.Pilot = pilot; InitializeComponent(); StackPanel panelPilot = new StackPanel(); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PanelPilot", txtHeader.Uid); panelPilot.Children.Add(txtHeader); ListBox lbPilotInformation = new ListBox(); lbPilotInformation.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); lbPilotInformation.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot","1002"), UICreator.CreateTextBlock(this.Pilot.Profile.Name))); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1003"), UICreator.CreateTextBlock(this.Pilot.Profile.Birthdate.ToShortDateString()))); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1004"), UICreator.CreateTownPanel(this.Pilot.Profile.Town))); ContentControl lblFlag = new ContentControl(); lblFlag.SetResourceReference(ContentControl.ContentTemplateProperty, "CountryFlagLongItem"); lblFlag.Content = new CountryCurrentCountryConverter().Convert(this.Pilot.Profile.Town.Country); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1005"), lblFlag)); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1006"), UICreator.CreateTextBlock(this.Pilot.EducationTime.ToShortDateString()))); lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1007"), UICreator.CreateTextBlock(this.Pilot.Rating.ToString()))); // lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1008"), UICreator.CreateTextBlock(string.Format("{0:C}", ((int)this.Pilot.Rating) * 1000)))); double pilotBasePrice = GameObject.GetInstance().HumanAirline.Fees.getValue(FeeTypes.GetType("Pilot Base Salary"));//GeneralHelpers.GetInflationPrice(133.53);< lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1008"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(((int)this.Pilot.Rating) * pilotBasePrice).ToString()))); panelPilot.Children.Add(lbPilotInformation); panelPilot.Children.Add(createButtonsPanel()); this.Content = panelPilot; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Route route = (Route)value; WrapPanel panelStopovers = new WrapPanel(); foreach (StopoverRoute sRoute in route.Stopovers) { ContentControl ccStopover = new ContentControl(); ccStopover.SetResourceReference(ContentControl.ContentTemplateProperty, "AirportIATACountryItem"); ccStopover.Content = sRoute.Stopover; ccStopover.Margin = new Thickness(0, 0, 10, 0); panelStopovers.Children.Add(ccStopover); } return panelStopovers; }
//creates the quick info panel for the airline private Panel createQuickInfoPanel() { StackPanel panelInfo = new StackPanel(); panelInfo.Margin = new Thickness(5, 0, 10, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.TextAlignment = TextAlignment.Left; txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirline", txtHeader.Uid); panelInfo.Children.Add(txtHeader); DockPanel grdQuickInfo = new DockPanel(); //grdQuickInfo.Margin = new Thickness(0, 5, 0, 0); panelInfo.Children.Add(grdQuickInfo); Image imgLogo = new Image(); imgLogo.Source = new BitmapImage(new Uri(this.Airline.Profile.Logo, UriKind.RelativeOrAbsolute)); imgLogo.Width = 110; imgLogo.Margin = new Thickness(0, 0, 5, 0); imgLogo.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; RenderOptions.SetBitmapScalingMode(imgLogo, BitmapScalingMode.HighQuality); grdQuickInfo.Children.Add(imgLogo); StackPanel panelQuickInfo = new StackPanel(); grdQuickInfo.Children.Add(panelQuickInfo); ListBox lbQuickInfo = new ListBox(); lbQuickInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbQuickInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelQuickInfo.Children.Add(lbQuickInfo); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1002"), UICreator.CreateTextBlock(this.Airline.Profile.Name))); if (this.Airline.IsSubsidiary) { ContentControl ccParent = new ContentControl(); ccParent.SetResourceReference(ContentControl.ContentTemplateProperty, "AirlineLogoLink"); ccParent.Content = ((SubsidiaryAirline)this.Airline).Airline; lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1021"), ccParent)); } lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1003"), UICreator.CreateTextBlock(this.Airline.Profile.IATACode))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1004"), UICreator.CreateTextBlock(this.Airline.Profile.CEO))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1024"), UICreator.CreateTextBlock(this.Airline.Profile.Founded.ToString()))); ContentControl lblFlag = new ContentControl(); lblFlag.SetResourceReference(ContentControl.ContentTemplateProperty, "CountryFlagLongItem"); lblFlag.Content = new CountryCurrentCountryConverter().Convert(this.Airline.Profile.Country); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1005"), lblFlag)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1006"), UICreator.CreateColorRect(this.Airline.Profile.Color))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline","1027"),UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airline.AirlineRouteFocus).ToString()))); // chs, 2011-10-10 added fleet size to the airline profile TextBlock txtFleetSize = UICreator.CreateTextBlock(string.Format("{0} (+{1} in order)", this.Airline.DeliveredFleet.Count, this.Airline.Fleet.Count - this.Airline.DeliveredFleet.Count)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1007"), txtFleetSize)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1011"), UICreator.CreateTextBlock(string.Format("{0} / {1}", this.Airline.Airports.Count, Airports.GetAllAirports().Sum(a => a.getHubs().Count(h => h.Airline == this.Airline)))))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1008"), createAirlineValuePanel())); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1009"), createAirlineReputationPanel())); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1010"), UICreator.CreateTextBlock(String.Format("{0:0.00} %", PassengerHelpers.GetPassengersHappiness(this.Airline))))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1012"), UICreator.CreateTextBlock(this.Airline.Alliances.Count > 0 ? string.Join(", ", from a in this.Airline.Alliances select a.Name) : Translator.GetInstance().GetString("PageAirline", "1013")))); WrapPanel panelLicens = new WrapPanel(); txtLicense = UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airline.License).ToString()); txtLicense.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelLicens.Children.Add(txtLicense); if (this.Airline.IsHuman && this.Airline.License != Airline.AirlineLicense.Long_Haul) { btnUpgradeLicense = new Button(); btnUpgradeLicense.Margin = new Thickness(5, 0, 0, 0); btnUpgradeLicense.Background = Brushes.Transparent; btnUpgradeLicense.Click += btnUpgradeLicense_Click; btnUpgradeLicense.ToolTip = UICreator.CreateToolTip("1014"); Image imgUpgradeLicens = new Image(); imgUpgradeLicens.Source = new BitmapImage(new Uri(@"/Data/images/add.png", UriKind.RelativeOrAbsolute)); imgUpgradeLicens.Height = 16; RenderOptions.SetBitmapScalingMode(imgUpgradeLicens, BitmapScalingMode.HighQuality); btnUpgradeLicense.Content = imgUpgradeLicens; panelLicens.Children.Add(btnUpgradeLicense); } lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1025"), panelLicens)); return panelInfo; }
//creates the quick info panel for the airport private ScrollViewer createQuickInfoPanel() { ScrollViewer scroller = new ScrollViewer(); scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scroller.MaxHeight = GraphicsHelpers.GetContentHeight() / 2; StackPanel panelInfo = new StackPanel(); scroller.Content = panelInfo; TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1006"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.TextAlignment = TextAlignment.Left; txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirport", txtHeader.Uid); panelInfo.Children.Add(txtHeader); DockPanel grdQuickInfo = new DockPanel(); grdQuickInfo.Margin = new Thickness(0, 5, 0, 0); panelInfo.Children.Add(grdQuickInfo); Image imgAirport = new Image(); imgAirport.Source = this.Airport.Profile.Logo.Length > 0 ? new BitmapImage(new Uri(this.Airport.Profile.Logo, UriKind.RelativeOrAbsolute)) : new BitmapImage(new Uri(@"/Data/images/airport.png", UriKind.Relative)); imgAirport.Width = 110; imgAirport.Margin = new Thickness(0, 0, 5, 0); imgAirport.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; RenderOptions.SetBitmapScalingMode(imgAirport, BitmapScalingMode.HighQuality); grdQuickInfo.Children.Add(imgAirport); StackPanel panelQuickInfo = new StackPanel(); grdQuickInfo.Children.Add(panelQuickInfo); ListBox lbQuickInfo = new ListBox(); lbQuickInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbQuickInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelQuickInfo.Children.Add(lbQuickInfo); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1007"), UICreator.CreateTextBlock(this.Airport.Profile.Name))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1008"), UICreator.CreateTextBlock(new AirportCodeConverter().Convert(this.Airport).ToString()))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1009"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Type).ToString()))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1010"), UICreator.CreateTownPanel(this.Airport.Profile.Town))); ContentControl lblFlag = new ContentControl(); lblFlag.SetResourceReference(ContentControl.ContentTemplateProperty, "CountryFlagLongItem"); lblFlag.Content = new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country);//this.Airport.Profile.Country is TemporaryCountry ? ((TemporaryCountry)this.Airport.Profile.Country).getCurrentCountry(GameObject.GetInstance().GameTime) : this.Airport.Profile.Country; lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1011"), lblFlag)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1022"), UICreator.CreateTextBlock(this.Airport.Profile.Period.From.ToShortDateString()))); if (GameObject.GetInstance().GameTime.AddDays(14) > this.Airport.Profile.Period.To) { TextBlock txtClosingDate = UICreator.CreateTextBlock(this.Airport.Profile.Period.To.ToShortDateString()); txtClosingDate.Foreground = Brushes.DarkRed; lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1024"), txtClosingDate)); } GameTimeZone tz = this.Airport.Profile.TimeZone; TextBlock txtTimeZone = UICreator.CreateTextBlock(tz.DisplayName); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1012"), txtTimeZone)); txtLocalTime = UICreator.CreateTextBlock(string.Format("{0} {1}", MathHelpers.ConvertDateTimeToLoalTime(GameObject.GetInstance().GameTime, tz).ToShortTimeString(), tz.ShortName)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1013"), txtLocalTime)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1019"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Season).ToString()))); WrapPanel panelCoordinates = new WrapPanel(); Image imgMap = new Image(); imgMap.Source = new BitmapImage(new Uri(@"/Data/images/map.png", UriKind.RelativeOrAbsolute)); imgMap.Height = 16; imgMap.MouseDown += new MouseButtonEventHandler(imgMap_MouseDown); RenderOptions.SetBitmapScalingMode(imgMap, BitmapScalingMode.HighQuality); imgMap.Margin = new Thickness(0, 0, 5, 0); panelCoordinates.Children.Add(imgMap); TextBlock txtCoordinates = UICreator.CreateLink(this.Airport.Profile.Coordinates.ToString()); ((Hyperlink)txtCoordinates.Inlines.FirstInline).Click += new RoutedEventHandler(PageAirport_Click); txtCoordinates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelCoordinates.Children.Add(txtCoordinates); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1014"), panelCoordinates)); // lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1015"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Size).ToString()))); // lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1021"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Cargo).ToString()))); WrapPanel panelSize = new WrapPanel(); Image imgPassenger = new Image(); imgPassenger.Source = new BitmapImage(new Uri(@"/Data/images/passenger.png", UriKind.RelativeOrAbsolute)); imgPassenger.Height = 16; RenderOptions.SetBitmapScalingMode(imgPassenger, BitmapScalingMode.HighQuality); panelSize.Children.Add(imgPassenger); TextBlock txtPassengerSize = UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Size).ToString()); txtPassengerSize.Margin = new Thickness(2, 0, 0, 0); txtPassengerSize.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelSize.Children.Add(txtPassengerSize); Image imgCargo = new Image(); imgCargo.Margin = new Thickness(10, 0, 0, 0); imgCargo.Source = new BitmapImage(new Uri(@"/Data/images/cargo.png", UriKind.RelativeOrAbsolute)); imgCargo.Height = 16; RenderOptions.SetBitmapScalingMode(imgCargo, BitmapScalingMode.HighQuality); panelSize.Children.Add(imgCargo); TextBlock txtCargoSize = UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Cargo).ToString()); txtCargoSize.Margin = new Thickness(2, 0, 0, 0); txtCargoSize.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelSize.Children.Add(txtCargoSize); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1015"), panelSize)); TextBlock txtAirportIncome = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airport.Income).ToString()); txtAirportIncome.Foreground = new ValueIsMinusConverter().Convert(this.Airport.Income) as Brush; lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1023"), txtAirportIncome)); WrapPanel panelTerminals = new WrapPanel(); Image imgMapOverview = new Image(); imgMapOverview.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute)); imgMapOverview.Height = 16; imgMapOverview.MouseDown += new MouseButtonEventHandler(imgMapOverview_MouseDown); RenderOptions.SetBitmapScalingMode(imgMapOverview, BitmapScalingMode.HighQuality); imgMapOverview.Margin = new Thickness(5, 0, 0, 0); imgMapOverview.Visibility = this.Airport.Profile.Map != null ? Visibility.Visible : System.Windows.Visibility.Collapsed; panelTerminals.Children.Add(UICreator.CreateTextBlock(string.Format("{0} ({1} {2})", this.Airport.Terminals.getNumberOfGates(), this.Airport.Terminals.getNumberOfAirportTerminals(), Translator.GetInstance().GetString("PageAirport", "1018")))); panelTerminals.Children.Add(imgMapOverview); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1016"), panelTerminals)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1017"), UICreator.CreateTextBlock(this.Airport.Runways.Count.ToString()))); return scroller; }
//creates the info panel for the airliner type private ScrollViewer createAirlinerTypePanel() { ScrollViewer scroller = new ScrollViewer(); scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scroller.MaxHeight = GraphicsHelpers.GetContentHeight() / 2; scroller.Margin = new Thickness(0, 10, 0, 0); AirlinerType airliner = this.Airliner.Airliner.Type; StackPanel panelAirlinerType = new StackPanel(); TextBlock txtHeader = new TextBlock(); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.TextAlignment = TextAlignment.Left; txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageFleetAirliner", "1001"); panelAirlinerType.Children.Add(txtHeader); ListBox lbQuickInfo = new ListBox(); lbQuickInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbQuickInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelAirlinerType.Children.Add(lbQuickInfo); WrapPanel panelAirlinerName = new WrapPanel(); Image imgAirlinerImage = new Image(); imgAirlinerImage.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute)); imgAirlinerImage.Height = 16; imgAirlinerImage.Tag = airliner; imgAirlinerImage.Visibility = airliner.Image == null || airliner.Image.Length<2 ? Visibility.Collapsed : Visibility.Visible; imgAirlinerImage.Margin = new Thickness(5, 0, 0, 0); imgAirlinerImage.MouseDown += new System.Windows.Input.MouseButtonEventHandler(imgAirlinerImage_MouseDown); RenderOptions.SetBitmapScalingMode(imgAirlinerImage, BitmapScalingMode.HighQuality); panelAirlinerName.Children.Add(UICreator.CreateTextBlock(airliner.Name)); panelAirlinerName.Children.Add(imgAirlinerImage); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1002"), panelAirlinerName)); ContentControl ccManufactorer = new ContentControl(); ccManufactorer.SetResourceReference(ContentControl.ContentTemplateProperty, "ManufactorerCountryItem"); ccManufactorer.Content = airliner.Manufacturer; lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1003"), ccManufactorer)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1004"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(airliner.Body, null, null, null).ToString()))); string range = string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(airliner.Range), new StringToLanguageConverter().Convert("km.")); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1005"), UICreator.CreateTextBlock(string.Format("{1} ({0})", new TextUnderscoreConverter().Convert(airliner.RangeType), range)))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1006"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(airliner.Engine, null, null, null).ToString()))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1007"), UICreator.CreateTextBlock(new NumberMeterToUnitConverter().Convert(airliner.Wingspan).ToString()))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1008"), UICreator.CreateTextBlock(new NumberMeterToUnitConverter().Convert(airliner.Length).ToString()))); if (airliner.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger) { lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1009"), UICreator.CreateTextBlock(((AirlinerPassengerType)airliner).MaxSeatingCapacity.ToString())));//SeatingCapacity.ToString()))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1010"), UICreator.CreateTextBlock(((AirlinerPassengerType)airliner).MaxAirlinerClasses.ToString()))); } if (airliner.TypeAirliner == AirlinerType.TypeOfAirliner.Cargo) { lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner","1031"),UICreator.CreateTextBlock(new CargoSizeConverter().Convert(airliner).ToString()))); } lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1011"), UICreator.CreateTextBlock(new NumberMeterToUnitConverter().Convert(airliner.MinRunwaylength).ToString()))); if (airliner.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger) { string crewRequirements = string.Format(Translator.GetInstance().GetString("PageFleetAirliner", "1012"), airliner.CockpitCrew, ((AirlinerPassengerType)airliner).CabinCrew); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1013"), UICreator.CreateTextBlock(crewRequirements))); } lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1014"), UICreator.CreateTextBlock(string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(airliner.CruisingSpeed), new StringToLanguageConverter().Convert("km/t"))))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1015"), UICreator.CreateTextBlock(string.Format("{0:0.###} {1}", new FuelConsumptionToUnitConverter().Convert(airliner.FuelConsumption), new StringToLanguageConverter().Convert("l/seat/km"))))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1027"), UICreator.CreateTextBlock(string.Format("{0:0.#} {1}", new FuelUnitGtLConverter().Convert(airliner.FuelCapacity), new StringToLanguageConverter().Convert("gallons"))))); if (!this.Airliner.HasRoute && this.Airliner.Purchased != FleetAirliner.PurchasedType.Leased && this.Airliner.Airliner.Airline.IsHuman && this.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger) { Button btnConvertToCargo = new Button(); btnConvertToCargo.Uid = "1032"; btnConvertToCargo.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnConvertToCargo.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; btnConvertToCargo.Margin = new Thickness(0, 5, 0, 0); btnConvertToCargo.Height = Double.NaN; btnConvertToCargo.Width = Double.NaN; btnConvertToCargo.Content = Translator.GetInstance().GetString("PageFleetAirliner", btnConvertToCargo.Uid); btnConvertToCargo.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnConvertToCargo.Click+=btnConvertToCargo_Click; panelAirlinerType.Children.Add(btnConvertToCargo); } scroller.Content = panelAirlinerType; return scroller; }
//creates the quick info panel for the fleet airliner private ScrollViewer createQuickInfoPanel() { ScrollViewer scroller = new ScrollViewer(); scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scroller.MaxHeight = GraphicsHelpers.GetContentHeight() / 3; StackPanel panelInfo = new StackPanel(); TextBlock txtHeader = new TextBlock(); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.TextAlignment = TextAlignment.Left; txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageFleetAirliner", "1030"); panelInfo.Children.Add(txtHeader); DockPanel grdQuickInfo = new DockPanel(); grdQuickInfo.Margin = new Thickness(0, 5, 0, 0); panelInfo.Children.Add(grdQuickInfo); Image imgLogo = new Image(); imgLogo.Source = new BitmapImage(new Uri(this.Airliner.Airliner.Airline.Profile.Logo, UriKind.RelativeOrAbsolute)); imgLogo.Width = 110; imgLogo.Margin = new Thickness(0, 0, 5, 0); imgLogo.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; RenderOptions.SetBitmapScalingMode(imgLogo, BitmapScalingMode.HighQuality); grdQuickInfo.Children.Add(imgLogo); StackPanel panelQuickInfo = new StackPanel(); grdQuickInfo.Children.Add(panelQuickInfo); ListBox lbQuickInfo = new ListBox(); lbQuickInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbQuickInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelQuickInfo.Children.Add(lbQuickInfo); DockPanel panelName = new DockPanel(); txtName = UICreator.CreateTextBlock(this.Airliner.Name); txtName.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelName.Children.Add(txtName); Image imgEditName = new Image(); imgEditName.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); imgEditName.Width = 16; RenderOptions.SetBitmapScalingMode(imgEditName, BitmapScalingMode.HighQuality); Button btnEditName = new Button(); btnEditName.Background = Brushes.Transparent; btnEditName.Margin = new Thickness(5, 0, 0, 0); btnEditName.Visibility = Visibility.Collapsed;// this.Airliner.Airliner.Airline.IsHuman ? Visibility.Visible : System.Windows.Visibility.Collapsed; //btnEditName.Click += new RoutedEventHandler(btnEditName_Click); btnEditName.Content = imgEditName; panelName.Children.Add(btnEditName); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1002"), panelName)); DockPanel panelOwner = new DockPanel(); TextBlock lnkOwner = UICreator.CreateLink(this.Airliner.Airliner.Airline.Profile.Name); lnkOwner.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; ((Hyperlink)lnkOwner.Inlines.FirstInline).Click += new RoutedEventHandler(PageFleetAirliner_Click); panelOwner.Children.Add(lnkOwner); Image imgEditOwner = new Image(); imgEditOwner.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); imgEditOwner.Width = 16; RenderOptions.SetBitmapScalingMode(imgEditOwner, BitmapScalingMode.HighQuality); Button btnEditOwner = new Button(); btnEditOwner.Background = Brushes.Transparent; btnEditOwner.Margin = new Thickness(5, 0, 0, 0); btnEditOwner.Visibility = this.Airliner.Airliner.Airline.IsHuman && this.Airliner.Status == FleetAirliner.AirlinerStatus.Stopped && GameObject.GetInstance().MainAirline.Subsidiaries.Count > 0 && !this.Airliner.HasRoute ? Visibility.Visible : System.Windows.Visibility.Collapsed; btnEditOwner.Click += new RoutedEventHandler(btnEditOwner_Click); btnEditOwner.Content = imgEditOwner; panelOwner.Children.Add(btnEditOwner); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1017"), panelOwner)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1025"), UICreator.CreateTextBlock(this.Airliner.PurchasedDate.ToShortDateString()))); DockPanel panelHomeBase = new DockPanel(); Button btnEditHomeBase = new Button(); btnEditHomeBase.Background = Brushes.Transparent; btnEditHomeBase.Click += new RoutedEventHandler(btnEditHomeBase_Click); btnEditHomeBase.Margin = new Thickness(0, 0, 5, 0); Image imgEdit = new Image(); imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); imgEdit.Width = 16; RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEditHomeBase.Visibility = this.Airliner.Airliner.Airline.IsHuman ? Visibility.Visible : System.Windows.Visibility.Collapsed; btnEditHomeBase.Content = imgEdit; panelHomeBase.Children.Add(btnEditHomeBase); lblAirport = new ContentControl(); lblAirport.MouseDown += new MouseButtonEventHandler(lblAirport_MouseDown); lblAirport.SetResourceReference(ContentControl.ContentTemplateProperty, "AirportCountryItem"); lblAirport.Content = this.Airliner.Homebase; panelHomeBase.Children.Add(lblAirport); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1018"), panelHomeBase)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1019"), UICreator.CreateTextBlock(string.Format(Translator.GetInstance().GetString("PageFleetAirliner", "1020"), this.Airliner.Airliner.BuiltDate.ToShortDateString(), this.Airliner.Airliner.Age)))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1021"), UICreator.CreateTextBlock(this.Airliner.Airliner.TailNumber))); TextBlock txtFlown = UICreator.CreateTextBlock(string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(this.Airliner.Airliner.Flown), new StringToLanguageConverter().Convert("km."))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1022"), txtFlown)); TextBlock txtSinceService = UICreator.CreateTextBlock(string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(this.Airliner.Airliner.LastServiceCheck), new StringToLanguageConverter().Convert("km."))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1023"), txtSinceService)); WrapPanel panelCoordinates = new WrapPanel(); Image imgMap = new Image(); imgMap.Source = new BitmapImage(new Uri(@"/Data/images/map.png", UriKind.RelativeOrAbsolute)); imgMap.Height = 16; imgMap.MouseDown += new MouseButtonEventHandler(imgMap_MouseDown); RenderOptions.SetBitmapScalingMode(imgMap, BitmapScalingMode.HighQuality); imgMap.Margin = new Thickness(2, 0, 0, 0); panelCoordinates.Children.Add(imgMap); TextBlock txtCurrentRoute = UICreator.CreateTextBlock(this.Airliner.HasRoute && this.Airliner.CurrentFlight != null ? string.Format("{0} - {1}", this.Airliner.CurrentFlight.Entry.DepartureAirport.Profile.Name, this.Airliner.CurrentFlight.Entry.Destination.Airport.Profile.Name) : "-"); txtCurrentRoute.Margin = new Thickness(5, 0, 0, 0); panelCoordinates.Children.Add(txtCurrentRoute); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1024"), panelCoordinates)); scroller.Content = panelInfo; return scroller; }
//creates the pin at a position with airport private UIElement createPin(Point position, Airport airport) { Ellipse imgPin = new Ellipse(); imgPin.Tag = airport; imgPin.Fill = new SolidColorBrush(getSizeColor(airport.Profile.Size)); imgPin.Height = 8; imgPin.Width = imgPin.Height; imgPin.Stroke = Brushes.Black; imgPin.StrokeThickness = 1; imgPin.MouseDown += new MouseButtonEventHandler(imgPin_MouseDown); Border brdToolTip = new Border(); brdToolTip.Margin = new Thickness(-4, 0, -4, -3); brdToolTip.Padding = new Thickness(5); brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2"); ContentControl lblAirport = new ContentControl(); lblAirport.SetResourceReference(ContentControl.ContentTemplateProperty, "AirportCountryItemNormal"); lblAirport.Content = airport; brdToolTip.Child = lblAirport; imgPin.ToolTip = brdToolTip; Canvas.SetTop(imgPin, position.Y - imgPin.Height + 5); Canvas.SetLeft(imgPin, position.X - imgPin.Height / 2); return imgPin; }
private ComboBox cbAirport; // cbName; #endregion Fields #region Constructors public PanelUsedAirliner(PageAirliners parent, Airliner airliner) : base(parent) { this.Airliner = airliner; StackPanel panelAirliner = new StackPanel(); panelAirliner.Children.Add(PanelAirliner.createQuickInfoPanel(airliner.Type)); this.addObject(panelAirliner); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.Margin = new System.Windows.Thickness(0, 5, 0, 0); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PanelUsedAirliner", txtHeader.Uid); this.addObject(txtHeader); ListBox lbAirlineInfo = new ListBox(); lbAirlineInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbAirlineInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); this.addObject(lbAirlineInfo); lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1002"), UICreator.CreateTextBlock(string.Format("{0} ({1} years old)", this.Airliner.BuiltDate.ToShortDateString(), this.Airliner.Age)))); WrapPanel panelTailNumber = new WrapPanel(); TextBlock txtTailNumber = UICreator.CreateTextBlock(this.Airliner.TailNumber); txtTailNumber.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelTailNumber.Children.Add(txtTailNumber); ContentControl ccFlag = new ContentControl(); ccFlag.SetResourceReference(ContentControl.ContentTemplateProperty, "CountryFlagLongItem"); ccFlag.Content = new CountryCurrentCountryConverter().Convert(Countries.GetCountryFromTailNumber(this.Airliner.TailNumber)); ccFlag.Margin = new Thickness(10, 0, 0, 0); panelTailNumber.Children.Add(ccFlag); lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1003"), panelTailNumber)); lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1004"), UICreator.CreateTextBlock(string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(this.Airliner.Flown), new StringToLanguageConverter().Convert("km."))))); lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1005"), UICreator.CreateTextBlock(string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(this.Airliner.LastServiceCheck),new StringToLanguageConverter().Convert("km."))))); foreach (AirlinerClass aClass in this.Airliner.Classes) { TextBlock txtClass = UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(aClass.Type, null, null, null).ToString()); txtClass.FontWeight = FontWeights.Bold; lbAirlineInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1006"), txtClass)); foreach (AirlinerFacility.FacilityType type in Enum.GetValues(typeof(AirlinerFacility.FacilityType))) { AirlinerFacility facility = aClass.getFacility(type); lbAirlineInfo.Items.Add(new QuickInfoValue(string.Format("{0} facilities", type), UICreator.CreateTextBlock(facility.Name))); } } TextBlock txtPriceHeader = new TextBlock(); txtPriceHeader.Uid = "1101"; txtPriceHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtPriceHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtPriceHeader.Margin = new System.Windows.Thickness(0, 5, 0, 0); txtPriceHeader.FontWeight = FontWeights.Bold; txtPriceHeader.Text = Translator.GetInstance().GetString("PanelUsedAirliner", txtPriceHeader.Uid); this.addObject(txtPriceHeader); ListBox lbPriceInfo = new ListBox(); lbPriceInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbPriceInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); this.addObject(lbPriceInfo); /* lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1102"), UICreator.CreateTextBlock(string.Format("{0:c}", this.Airliner.Price)))); lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1103"), UICreator.CreateTextBlock(string.Format("{0:c}", this.Airliner.LeasingPrice)))); lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1104"), UICreator.CreateTextBlock(string.Format("{0:c}", this.Airliner.Type.getMaintenance())))); */ lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1102"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(Airliner.Price).ToString()))); lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1103"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airliner.LeasingPrice).ToString()))); lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1104"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airliner.Type.getMaintenance()).ToString()))); cbAirport = new ComboBox(); cbAirport.SetResourceReference(ComboBox.ItemTemplateProperty, "AirportCountryItem"); cbAirport.Background = Brushes.Transparent; cbAirport.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle"); cbAirport.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; List<Airport> airports = GameObject.GetInstance().HumanAirline.Airports.FindAll(a=>a.getCurrentAirportFacility(GameObject.GetInstance().HumanAirline, AirportFacility.FacilityType.Service).TypeLevel > 0 && a.getMaxRunwayLength() >= this.Airliner.Type.MinRunwaylength); airports = (from a in airports orderby a.Profile.Name select a).ToList(); foreach (Airport airport in airports) cbAirport.Items.Add(airport); cbAirport.SelectedIndex = 0; lbPriceInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelUsedAirliner", "1105"), cbAirport)); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); this.addObject(panelButtons); Button btnBuy = new Button(); btnBuy.Uid = "200"; btnBuy.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnBuy.Height = Double.NaN; btnBuy.Width = Double.NaN; btnBuy.Content = Translator.GetInstance().GetString("PanelUsedAirliner", btnBuy.Uid); btnBuy.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnBuy.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; btnBuy.Click += new System.Windows.RoutedEventHandler(btnBuy_Click); panelButtons.Children.Add(btnBuy); Button btnLease = new Button(); btnLease.Uid = "201"; btnLease.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnLease.Height = Double.NaN; btnLease.Width = Double.NaN; btnLease.Content = Translator.GetInstance().GetString("PanelUsedAirliner", btnLease.Uid); btnLease.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnLease.Margin = new Thickness(5, 0, 0, 0); btnLease.Click += new RoutedEventHandler(btnLease_Click); panelButtons.Children.Add(btnLease); }
//creates the panel for a new route private void createRoutePanel() { panelRouteInfo.Children.Clear(); ListBox lbRouteInfo = new ListBox(); lbRouteInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbRouteInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelRouteInfo.Children.Add(lbRouteInfo); WrapPanel panelDestination1 = new WrapPanel(); cbDestination1 = createDestinationComboBox(); panelDestination1.Children.Add(cbDestination1); txtDestination1Gates = new TextBlock(); txtDestination1Gates.Margin = new Thickness(5, 0, 0, 0); txtDestination1Gates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelDestination1.Children.Add(txtDestination1Gates); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "202"), panelDestination1)); WrapPanel panelDestination2 = new WrapPanel(); cbDestination2 = createDestinationComboBox(); panelDestination2.Children.Add(cbDestination2); txtDestination2Gates = new TextBlock(); txtDestination2Gates.Margin = new Thickness(5, 0, 0, 0); txtDestination2Gates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelDestination2.Children.Add(txtDestination2Gates); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "203"), panelDestination2)); ucStopover1 = new ucStopover(); ucStopover1.ValueChanged += ucStopover_OnValueChanged; lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1003"), ucStopover1)); ucStopover2 = new ucStopover(); ucStopover2.ValueChanged += ucStopover_OnValueChanged; lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1003"), ucStopover2)); txtRoute = UICreator.CreateTextBlock(""); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1004"), txtRoute)); txtDistance = UICreator.CreateTextBlock("-"); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "204"), txtDistance)); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "205"), UICreator.CreateTextBlock(string.Format("{0:0} {1}", new NumberToUnitConverter().Convert(this.MaxDistance), new StringToLanguageConverter().Convert("km."))))); if (this.RouteType == Route.RouteType.Mixed || this.RouteType == Route.RouteType.Passenger) { this.Classes.Clear(); foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType))) { RouteAirlinerClass rClass = new RouteAirlinerClass(type, RouteAirlinerClass.SeatingType.Reserved_Seating, 1); foreach (RouteFacility.FacilityType ftype in Enum.GetValues(typeof(RouteFacility.FacilityType))) { if (GameObject.GetInstance().GameTime.Year >= (int)ftype) rClass.addFacility(RouteFacilities.GetBasicFacility(ftype)); } this.Classes.Add(type, rClass); WrapPanel panelClassButtons = new WrapPanel(); Button btnEdit = new Button(); btnEdit.Background = Brushes.Transparent; btnEdit.Tag = type; btnEdit.Click += new RoutedEventHandler(btnEdit_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEdit.Content = imgEdit; panelClassButtons.Children.Add(btnEdit); Image imgInfo = new Image(); imgInfo.Width = 16; imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute)); imgInfo.Margin = new Thickness(5, 0, 0, 0); imgInfo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality); Border brdToolTip = new Border(); brdToolTip.Margin = new Thickness(-4, 0, -4, -3); brdToolTip.Padding = new Thickness(5); brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2"); ContentControl lblClass = new ContentControl(); lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem"); lblClass.Content = rClass; brdToolTip.Child = lblClass; imgInfo.ToolTip = brdToolTip; panelClassButtons.Children.Add(imgInfo); lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(type, null, null, null).ToString(), panelClassButtons)); } } if (this.RouteType == Route.RouteType.Mixed || this.RouteType == Route.RouteType.Cargo) { WrapPanel panelCargo = new WrapPanel(); txtCargo = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.CargoPrice).ToString()); txtCargo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelCargo.Children.Add(txtCargo); Button btnEditCargo = new Button(); btnEditCargo.Margin = new Thickness(5, 0, 0, 0); btnEditCargo.Background = Brushes.Transparent; btnEditCargo.Click += new RoutedEventHandler(btnEditCargo_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEditCargo.Content = imgEdit; panelCargo.Children.Add(btnEditCargo); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1007"), panelCargo)); } txtInvalidRoute = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PanelNewRoute", "1001")); txtInvalidRoute.Foreground = Brushes.DarkRed; txtInvalidRoute.Visibility = System.Windows.Visibility.Collapsed; panelRouteInfo.Children.Add(txtInvalidRoute); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); panelRouteInfo.Children.Add(panelButtons); btnSave = new Button(); btnSave.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnSave.Height = Double.NaN; btnSave.Width = Double.NaN; btnSave.Content = Translator.GetInstance().GetString("General", "113"); btnSave.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnSave.Click += new RoutedEventHandler(btnSave_Click); btnSave.IsEnabled = false; panelButtons.Children.Add(btnSave); btnLoad = new Button(); btnLoad.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnLoad.Height = Double.NaN; btnLoad.Width = Double.NaN; btnLoad.Content = Translator.GetInstance().GetString("General", "115"); btnLoad.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnLoad.IsEnabled = false; btnLoad.Click += new RoutedEventHandler(btnLoad_Click); btnLoad.Margin = new Thickness(5, 0, 0, 0); btnLoad.Visibility = this.RouteType == Route.RouteType.Cargo ? Visibility.Collapsed : Visibility.Visible; panelButtons.Children.Add(btnLoad); }
public PanelRoute(PageRoutes parent, Route route) { this.Classes = new Dictionary<Route, Dictionary<AirlinerClass.ClassType, RouteAirlinerClass>>(); this.ParentPage = parent; this.Route = route; this.Margin = new Thickness(0, 0, 50, 0); TextBlock txtHeader = new TextBlock(); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Uid = "1000"; txtHeader.Text = Translator.GetInstance().GetString("PanelRoute", txtHeader.Uid); this.Children.Add(txtHeader); ListBox lbRouteInfo = new ListBox(); lbRouteInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbRouteInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); this.Children.Add(lbRouteInfo); double distance = MathHelpers.GetDistance(this.Route.Destination1.Profile.Coordinates, this.Route.Destination2.Profile.Coordinates); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute","1016"),UICreator.CreateTextBlock(this.Route.Type.ToString()))); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute","1001"), UICreator.CreateTextBlock(this.Route.Destination1.Profile.Name))); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute","1002"), UICreator.CreateTextBlock(this.Route.Destination2.Profile.Name))); if (this.Route.HasStopovers) lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1003"), UICreator.CreateTextBlock(string.Join(", ", from s in this.Route.Stopovers select new AirportCodeConverter().Convert(s.Stopover).ToString())))); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1004"), UICreator.CreateTextBlock(string.Format("{0:0} {1}", new NumberToUnitConverter().Convert(distance), new StringToLanguageConverter().Convert("km."))))); if (this.Route.Type == Route.RouteType.Passenger || this.Route.Type == Route.RouteType.Mixed) { this.Classes.Add(route, new Dictionary<AirlinerClass.ClassType, RouteAirlinerClass>()); foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType))) { RouteAirlinerClass rClass = ((PassengerRoute)this.Route).getRouteAirlinerClass(type); this.Classes[route].Add(type, rClass); WrapPanel panelClassButtons = new WrapPanel(); Button btnEdit = new Button(); btnEdit.Background = Brushes.Transparent; btnEdit.Tag = new KeyValuePair<Route, AirlinerClass.ClassType>(this.Route, type); btnEdit.Click += new RoutedEventHandler(btnEdit_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEdit.Content = imgEdit; Boolean inRoute = route.getAirliners().Exists(a => a.Status != FleetAirliner.AirlinerStatus.Stopped); //btnEdit.Visibility = this.Route.HasAirliner && (this.Route.getCurrentAirliner() != null && this.Route.getCurrentAirliner().Status != FleetAirliner.AirlinerStatus.Stopped) ? Visibility.Collapsed : System.Windows.Visibility.Visible; btnEdit.Visibility = inRoute ? Visibility.Collapsed : System.Windows.Visibility.Visible; panelClassButtons.Children.Add(btnEdit); Image imgInfo = new Image(); imgInfo.Width = 16; imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute)); imgInfo.Margin = new Thickness(5, 0, 0, 0); imgInfo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality); Border brdToolTip = new Border(); brdToolTip.Margin = new Thickness(-4, 0, -4, -3); brdToolTip.Padding = new Thickness(5); brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2"); ContentControl lblClass = new ContentControl(); lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem"); lblClass.Content = rClass; brdToolTip.Child = lblClass; imgInfo.ToolTip = brdToolTip; panelClassButtons.Children.Add(imgInfo); lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(type, null, null, null).ToString(), panelClassButtons)); } } if (this.Route.Type == Model.AirlinerModel.RouteModel.Route.RouteType.Mixed || this.Route.Type == Model.AirlinerModel.RouteModel.Route.RouteType.Cargo) { this.CargoPrice = ((CargoRoute)this.Route).PricePerUnit; WrapPanel panelCargo = new WrapPanel(); txtCargo = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.CargoPrice).ToString()); txtCargo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelCargo.Children.Add(txtCargo); Button btnEditCargo = new Button(); btnEditCargo.Margin = new Thickness(5, 0, 0, 0); btnEditCargo.Background = Brushes.Transparent; btnEditCargo.Click += new RoutedEventHandler(btnEditCargo_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEditCargo.Content = imgEdit; panelCargo.Children.Add(btnEditCargo); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute","1015"),panelCargo)); } foreach (StopoverRoute stopover in this.Route.Stopovers) { foreach (Route leg in stopover.Legs) { lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1005"), UICreator.CreateTextBlock(string.Format("{0}-{1}", new AirportCodeConverter().Convert(leg.Destination1), new AirportCodeConverter().Convert(leg.Destination2))))); if (this.Route.Type == Route.RouteType.Passenger || this.Route.Type == Route.RouteType.Mixed) { this.Classes.Add(leg, new Dictionary<AirlinerClass.ClassType, RouteAirlinerClass>()); foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType))) { RouteAirlinerClass rClass = ((PassengerRoute)leg).getRouteAirlinerClass(type); this.Classes[leg].Add(type, rClass); WrapPanel panelClassButtons = new WrapPanel(); Button btnEdit = new Button(); btnEdit.Background = Brushes.Transparent; btnEdit.Tag = new KeyValuePair<Route, AirlinerClass.ClassType>(leg, type); btnEdit.Click += new RoutedEventHandler(btnEdit_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEdit.Content = imgEdit; btnEdit.Visibility = this.Route.HasAirliner && (this.Route.getCurrentAirliner() != null && this.Route.getCurrentAirliner().Status != FleetAirliner.AirlinerStatus.Stopped) ? Visibility.Collapsed : System.Windows.Visibility.Visible; panelClassButtons.Children.Add(btnEdit); Image imgInfo = new Image(); imgInfo.Width = 16; imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute)); imgInfo.Margin = new Thickness(5, 0, 0, 0); imgInfo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality); Border brdToolTip = new Border(); brdToolTip.Margin = new Thickness(-4, 0, -4, -3); brdToolTip.Padding = new Thickness(5); brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2"); ContentControl lblClass = new ContentControl(); lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem"); lblClass.Content = rClass; brdToolTip.Child = lblClass; imgInfo.ToolTip = brdToolTip; panelClassButtons.Children.Add(imgInfo); lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(type).ToString(), panelClassButtons)); } } } } int numberOfInboundFlights = this.Route.TimeTable.Entries.Count(e => e.DepartureAirport == this.Route.Destination2); int numberOfOutboundFlights = this.Route.TimeTable.Entries.Count(e => e.DepartureAirport == this.Route.Destination1); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1006"), UICreator.CreateTextBlock(string.Format("{0} / {1}", numberOfOutboundFlights, numberOfInboundFlights)))); WrapPanel buttonsPanel = new WrapPanel(); buttonsPanel.Margin = new Thickness(0, 5, 0, 0); this.Children.Add(buttonsPanel); buttonsPanel.Visibility = this.Route.HasAirliner && (this.Route.getCurrentAirliner() != null && this.Route.getCurrentAirliner().Status != FleetAirliner.AirlinerStatus.Stopped) ? Visibility.Collapsed : System.Windows.Visibility.Visible; Button btnOk = new Button(); btnOk.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnOk.Height = Double.NaN; btnOk.Width = Double.NaN; btnOk.Uid = "100"; btnOk.Content = Translator.GetInstance().GetString("General", btnOk.Uid); btnOk.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnOk.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; btnOk.Click += new RoutedEventHandler(btnOk_Click); buttonsPanel.Children.Add(btnOk); Button btnLoad = new Button(); btnLoad.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnLoad.Height = Double.NaN; btnLoad.Width = Double.NaN; btnLoad.Uid = "115"; btnLoad.Content = Translator.GetInstance().GetString("General", btnLoad.Uid); btnLoad.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnLoad.Click += new RoutedEventHandler(btnLoad_Click); btnLoad.Margin = new Thickness(5, 0, 0, 0); btnLoad.Visibility = this.Route.Type == Route.RouteType.Cargo ? Visibility.Collapsed : System.Windows.Visibility.Visible; buttonsPanel.Children.Add(btnLoad); Button btnDelete = new Button(); btnDelete.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnDelete.Height = Double.NaN; btnDelete.Width = Double.NaN; btnDelete.Uid = "200"; btnDelete.Content = Translator.GetInstance().GetString("PanelRoute", btnDelete.Uid); btnDelete.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnDelete.Margin = new System.Windows.Thickness(5, 0, 0, 0); btnDelete.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; btnDelete.Click += new RoutedEventHandler(btnDelete_Click); buttonsPanel.Children.Add(btnDelete); //if (this.Route.HasStopovers) { this.Children.Add(createStopoverStatisticsPanel()); } //else { // this.Children.Add(createRouteFinancesPanel()); } showRouteFinances(); }
//creates the routes details private StackPanel createRoutesInfo() { StackPanel panelRoutesInfo = new StackPanel(); TextBlock txtHeader = new TextBlock(); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = "Routes Information"; panelRoutesInfo.Children.Add(txtHeader); ScrollViewer svRoutes = new ScrollViewer(); svRoutes.MaxHeight = GraphicsHelpers.GetContentHeight()/2; svRoutes.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; svRoutes.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; panelRoutesInfo.Children.Add(svRoutes); StackPanel panelRoutes = new StackPanel(); svRoutes.Content = panelRoutes; foreach (Route route in this.Airliner.Routes) { ListBox lbRouteInfo = new ListBox(); lbRouteInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbRouteInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); lbRouteInfo.Margin = new Thickness(0, 0, 0, 5); panelRoutes.Children.Add(lbRouteInfo); double distance = MathHelpers.GetDistance(route.Destination1.Profile.Coordinates, route.Destination2.Profile.Coordinates); lbRouteInfo.Items.Add(new QuickInfoValue("Route", UICreator.CreateTextBlock(string.Format("{0} <-> {1}",route.Destination1.Profile.Name,route.Destination2.Profile.Name)))); // chs, 2011-10-10 added missing conversion lbRouteInfo.Items.Add(new QuickInfoValue("Distance", UICreator.CreateTextBlock(string.Format("{0:0} {1}", new NumberToUnitConverter().Convert(distance), new StringToLanguageConverter().Convert("km."))))); if (route.Type == Route.RouteType.Passenger || route.Type == Route.RouteType.Mixed) { foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes) { RouteAirlinerClass rClass = ((PassengerRoute)route).getRouteAirlinerClass(aClass.Type); Image imgInfo = new Image(); imgInfo.Width = 16; imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute)); imgInfo.Margin = new Thickness(5, 0, 0, 0); RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality); Border brdToolTip = new Border(); brdToolTip.Margin = new Thickness(-4, 0, -4, -3); brdToolTip.Padding = new Thickness(5); brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2"); ContentControl lblClass = new ContentControl(); lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem"); lblClass.Content = rClass; brdToolTip.Child = lblClass; imgInfo.ToolTip = brdToolTip; lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(aClass.Type, null, null, null).ToString(), imgInfo)); } } } WrapPanel buttonsPanel = new WrapPanel(); buttonsPanel.Margin = new Thickness(0, 5, 0, 0); Button btnTimeTable = new Button(); btnTimeTable.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnTimeTable.Height = Double.NaN; btnTimeTable.Width = Double.NaN; btnTimeTable.Content = "Timetable"; btnTimeTable.Visibility = Visibility.Visible;// Visibility.Collapsed;//this.Airliner.Airliner.Airline.IsHuman ? Visibility.Collapsed : Visibility.Visible; btnTimeTable.Click += new RoutedEventHandler(btnTimeTable_Click); btnTimeTable.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; btnTimeTable.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); buttonsPanel.Children.Add(btnTimeTable); Button btnMap = new Button(); btnMap.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnMap.Width = Double.NaN; btnMap.Height = Double.NaN; btnMap.Content = "Routes map"; btnMap.Margin = new Thickness(2, 0, 0, 0); btnMap.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnMap.Click += new RoutedEventHandler(btnMap_Click); buttonsPanel.Children.Add(btnMap); panelRoutesInfo.Children.Add(buttonsPanel); return panelRoutesInfo; }
//creates the panel for some routes information private StackPanel createRoutesInformationPanel() { StackPanel informationPanel = new StackPanel(); informationPanel.Margin = new Thickness(0, 10, 0, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1003"; txtHeader.Margin = new Thickness(0, 0, 0, 0); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirlineDestinations", txtHeader.Uid); informationPanel.Children.Add(txtHeader); ListBox lbInfo = new ListBox(); lbInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); lbInfo.MaxHeight = (GraphicsHelpers.GetContentHeight()-100)/2; informationPanel.Children.Add(lbInfo); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1004"), UICreator.CreateTextBlock(this.Airline.Routes.Count.ToString()))); Route maxDistanceRoute = this.Airline.Routes.Count>0 ? (from r in this.Airline.Routes orderby MathHelpers.GetDistance(r.Destination1,r.Destination2) descending select r).First() : null; if (maxDistanceRoute != null) lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1005"), UICreator.CreateTextBlock(string.Format("{0:0} {1} ({2}<->{3})", new NumberToUnitConverter().Convert(MathHelpers.GetDistance(maxDistanceRoute.Destination1,maxDistanceRoute.Destination2)), new StringToLanguageConverter().Convert("km."),new AirportCodeConverter().Convert(maxDistanceRoute.Destination1).ToString(),new AirportCodeConverter().Convert(maxDistanceRoute.Destination2).ToString())))); double avgBalance = this.Airline.Routes.Count == 0 ? 0 : this.Airline.Routes.Average(r => r.Balance); //lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1006"), UICreator.CreateTextBlock(string.Format("{0:C}", avgBalance)))); TextBlock txtAvgBalance = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(avgBalance).ToString()); txtAvgBalance.Foreground = new ValueIsMinusConverter().Convert(avgBalance) as SolidColorBrush; lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1006"),txtAvgBalance )); var airlinePassengerRoutes = this.Airline.Routes.Where(r=>r.Type == Route.RouteType.Passenger || r.Type == Route.RouteType.Mixed); double avgFillingPercent = this.Airline.Routes.Count == 0 || airlinePassengerRoutes.Count() == 0 ? 0 : airlinePassengerRoutes.Average(r => ((PassengerRoute)r).FillingDegree); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1007"), UICreator.CreateTextBlock(string.Format("{0:0} %", avgFillingPercent * 100)))); int totalFlights = this.Airline.Routes.Count == 0 ? 0 : this.Airline.Routes.Sum(r => r.TimeTable.Entries.Count); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1008"), UICreator.CreateTextBlock(totalFlights.ToString()))); long totalPassengers = this.Airline.Routes.Count == 0 ? 0 : this.Airline.Routes.Sum(r=>r.Statistics.getTotalValue(StatisticsTypes.GetStatisticsType("Passengers"))); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1009"), UICreator.CreateTextBlock(totalPassengers.ToString()))); Airport largestGateAirport = this.Airline.Airports.OrderByDescending(a => a.Terminals.getNumberOfGates(this.Airline) / Convert.ToDouble(a.Terminals.getInuseGates())).FirstOrDefault(); ContentControl ccLargestAirport = new ContentControl(); ccLargestAirport.SetResourceReference(ContentControl.ContentTemplateProperty, "AirportCountryLink"); ccLargestAirport.Content = largestGateAirport; ccLargestAirport.ToolTip = UICreator.CreateToolTip("The greatest % of owned gates in use"); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1010"), ccLargestAirport)); Airport smallestGateAirport = this.Airline.Airports.OrderBy(a => a.Terminals.getNumberOfGates(this.Airline) / Convert.ToDouble(a.Terminals.getInuseGates())).FirstOrDefault(); ContentControl ccSmallestAirport = new ContentControl(); ccSmallestAirport.SetResourceReference(ContentControl.ContentTemplateProperty, "AirportCountryLink"); ccSmallestAirport.Content = smallestGateAirport; ccSmallestAirport.ToolTip = UICreator.CreateToolTip("The smallest % of owned gates in use"); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineDestinations", "1011"), ccSmallestAirport)); return informationPanel; }
//creates the info panel private StackPanel createInfoPanel() { StackPanel panelInfo = new StackPanel(); panelInfo.Margin = new Thickness(0, 5, 0, 0); TextBlock txtHeader = new TextBlock(); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PanelAlliance", "205"); panelInfo.Children.Add(txtHeader); ListBox lbInfo = new ListBox(); lbInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); lbInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); panelInfo.Children.Add(lbInfo); ContentControl ccHeadquarter = new ContentControl(); ccHeadquarter.SetResourceReference(ContentControl.ContentTemplateProperty, "AirportCountryLink"); ccHeadquarter.Content = this.Alliance.Headquarter; int routes = this.Alliance.Members.Sum(a => a.Airline.Routes.Count); int destinations = this.Alliance.Members.SelectMany(m => m.Airline.Airports).Distinct().Count(); int countries = this.Alliance.Members.SelectMany(m => m.Airline.Airports).Select(a => a.Profile.Country).Distinct().Count(); double annualPassengers = this.Alliance.Members.Sum(m => m.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year - 1, StatisticsTypes.GetStatisticsType("Passengers"))); int hubs = this.Alliance.Members.Sum(m => m.Airline.getHubs().Count); int weeklyDepartures = this.Alliance.Members.Sum(m => m.Airline.Routes.SelectMany(r => r.TimeTable.Entries).Count()); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAlliance", "211"), ccHeadquarter)); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAlliance", "206"), UICreator.CreateTextBlock(this.Alliance.FormationDate.Year.ToString()))); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAlliance", "209"), UICreator.CreateTextBlock(this.Alliance.Type.ToString()))); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAlliance", "207"), UICreator.CreateTextBlock(routes.ToString()))); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAlliance", "208"), UICreator.CreateTextBlock(destinations.ToString()))); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAlliance", "214"), UICreator.CreateTextBlock(countries.ToString()))); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAlliance", "213"), UICreator.CreateTextBlock(weeklyDepartures.ToString()))); lbInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAlliance", "212"), UICreator.CreateTextBlock(hubs.ToString()))); lbInfo.Items.Add(new QuickInfoValue(string.Format(Translator.GetInstance().GetString("PanelAlliance", "210"), GameObject.GetInstance().GameTime.Year - 1), UICreator.CreateTextBlock(annualPassengers.ToString()))); return panelInfo; }
//creates the quick info panel for a airliner type public static StackPanel createQuickInfoPanel(AirlinerType airliner) { StackPanel quickInfoPanel = new StackPanel(); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PanelAirliner", txtHeader.Uid); quickInfoPanel.Children.Add(txtHeader); if (airliner.Image != null) { Image imgAirlinerMap = new Image(); imgAirlinerMap.Width = GraphicsHelpers.GetContentWidth()-100; imgAirlinerMap.Source = new BitmapImage(new Uri(airliner.Image, UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgAirlinerMap, BitmapScalingMode.HighQuality); quickInfoPanel.Children.Add(imgAirlinerMap); } ListBox lbQuickInfo = new ListBox(); lbQuickInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbQuickInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); quickInfoPanel.Children.Add(lbQuickInfo); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1002"), UICreator.CreateTextBlock(airliner.Name))); ContentControl ccManufactorer = new ContentControl(); ccManufactorer.SetResourceReference(ContentControl.ContentTemplateProperty, "ManufactorerCountryItem"); ccManufactorer.Content = airliner.Manufacturer; lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1003"), ccManufactorer)); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1004"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(airliner.Body, null, null, null).ToString()))); string range = string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(airliner.Range), new StringToLanguageConverter().Convert("km.")); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1005"), UICreator.CreateTextBlock(string.Format("{1} ({0})", new TextUnderscoreConverter().Convert(airliner.RangeType), range)))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1006"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(airliner.Engine, null, null, null).ToString()))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1007"), UICreator.CreateTextBlock(new NumberMeterToUnitConverter().Convert(airliner.Wingspan).ToString()))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1008"), UICreator.CreateTextBlock(new NumberMeterToUnitConverter().Convert(airliner.Length).ToString()))); if (airliner.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger) { lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1009"), UICreator.CreateTextBlock(((AirlinerPassengerType)airliner).MaxSeatingCapacity.ToString()))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1010"), UICreator.CreateTextBlock(((AirlinerPassengerType)airliner).MaxAirlinerClasses.ToString()))); } if (airliner.TypeAirliner == AirlinerType.TypeOfAirliner.Cargo) { lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner","1017"),UICreator.CreateTextBlock(new CargoSizeConverter().Convert(airliner).ToString()))); } lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1015"), UICreator.CreateTextBlock(new NumberMeterToUnitConverter().Convert(airliner.MinRunwaylength).ToString()))); if (airliner.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger) { string crewRequirements = string.Format("Cockpit: {0} Cabin: {1}", airliner.CockpitCrew, ((AirlinerPassengerType)airliner).CabinCrew); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1011"), UICreator.CreateTextBlock(crewRequirements))); } lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1012"), UICreator.CreateTextBlock(string.Format("{0:0.##} {1}", new NumberToUnitConverter().Convert(airliner.CruisingSpeed), new StringToLanguageConverter().Convert("km/t"))))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1013"), UICreator.CreateTextBlock(string.Format("{0:0.###} {1}", new FuelConsumptionToUnitConverter().Convert(airliner.FuelConsumption), new StringToLanguageConverter().Convert("l/seat/km"))))); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetAirliner", "1016"), UICreator.CreateTextBlock(string.Format("{0:0.#} {1}", new FuelUnitGtLConverter().Convert(airliner.FuelCapacity), new StringToLanguageConverter().Convert("gallons"))))); string produced = string.Format("{0}-{1}", airliner.Produced.From > GameObject.GetInstance().GameTime ? "?" : airliner.Produced.From.ToShortDateString(), airliner.Produced.To > GameObject.GetInstance().GameTime ? "?" : airliner.Produced.To.ToShortDateString()); lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelAirliner", "1014"), UICreator.CreateTextBlock(produced))); return quickInfoPanel; }
public PageOrderAirliners(PageAirliners parent, Manufacturer manufacturer) { this.ParentPage = parent; this.Manufacturer = manufacturer; this.customConfiguration = false; this.orders = new List<AirlinerOrder>(); this.Classes = new List<AirlinerClass>(); InitializeComponent(); ScrollViewer scroller = new ScrollViewer(); scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; scroller.MaxHeight = GraphicsHelpers.GetContentHeight(); StackPanel mainPanel = new StackPanel(); mainPanel.Margin = new Thickness(0, 0, 5, 0); scroller.Content = mainPanel; TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageOrderAirliners", txtHeader.Uid); mainPanel.Children.Add(txtHeader); ListBox lbManufacturers = new ListBox(); lbManufacturers.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbManufacturers.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); cbAirport = new ComboBox(); cbAirport.SetResourceReference(ComboBox.ItemTemplateProperty, "AirportCountryItem"); cbAirport.Background = Brushes.Transparent; cbAirport.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle"); cbAirport.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; List<Airport> airports = GameObject.GetInstance().HumanAirline.Airports.FindAll(a => a.getCurrentAirportFacility(GameObject.GetInstance().HumanAirline, AirportFacility.FacilityType.Service).TypeLevel > 0); airports = airports.OrderBy(a => a.Profile.Name).ToList(); foreach (Airport airport in airports) cbAirport.Items.Add(airport); cbAirport.SelectedIndex = 0; lbManufacturers.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageOrderAirliners", "1007"), cbAirport)); DateTime firstDate = GameObject.GetInstance().GameTime.AddMonths(3); dpDate = new DatePicker(); dpDate.SetResourceReference(DatePicker.CalendarStyleProperty, "CalendarPickerStyle"); dpDate.DisplayDateStart = new DateTime(firstDate.Year, firstDate.Month, 1); dpDate.DisplayDateEnd = GameObject.GetInstance().GameTime.AddYears(5); dpDate.DisplayDate = firstDate; dpDate.SelectedDate = firstDate; for (int i = 1; i < firstDate.Day; i++) dpDate.BlackoutDates.Add(new CalendarDateRange(new DateTime(firstDate.Year, firstDate.Month, i))); lbManufacturers.Items.Add(new QuickInfoValue("Delivery time", dpDate)); ContentControl ccManufacturer = new ContentControl(); ccManufacturer.SetResourceReference(ContentControl.ContentTemplateProperty, "ManufactorerLogoItem"); ccManufacturer.Content = this.Manufacturer; lbManufacturers.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageOrderAirliners", "1003"), ccManufacturer)); lbManufacturers.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageOrderAirliners", "1004"), createOrderPanel())); mainPanel.Children.Add(lbManufacturers); TextBlock txtOrders = new TextBlock(); txtOrders.FontWeight = FontWeights.Bold; txtOrders.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtOrders.Uid = "1002"; txtOrders.Text = Translator.GetInstance().GetString("PageOrderAirliners", txtOrders.Uid); txtOrders.Margin = new Thickness(0, 5, 0, 0); mainPanel.Children.Add(txtOrders); lbOrders = new ListBox(); lbOrders.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbOrders.ItemTemplate = this.Resources["AirlinerOrderItem"] as DataTemplate; //lbOrders.MaxHeight = GraphicsHelpers.GetContentHeight() / 4; mainPanel.Children.Add(lbOrders); ListBox lbPrice = new ListBox(); lbPrice.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbPrice.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); txtDiscount = new TextBlock(); txtTotalPrice = new TextBlock(); lbPrice.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageOrderAirliners", "1005"), txtDiscount)); lbPrice.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageOrderAirliners", "1006"), txtTotalPrice)); cbDownPayment = new CheckBox(); lbPrice.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageOrderAirliners", "1008"), cbDownPayment)); mainPanel.Children.Add(lbPrice); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); mainPanel.Children.Add(panelButtons); btnOrder = new Button(); btnOrder.Uid = "200"; btnOrder.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnOrder.Height = Double.NaN; btnOrder.Width = Double.NaN; btnOrder.Content = Translator.GetInstance().GetString("PageOrderAirliners", btnOrder.Uid); btnOrder.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnOrder.Click += new RoutedEventHandler(btnOrder_Click); btnOrder.IsEnabled = false; panelButtons.Children.Add(btnOrder); Button btnContract = new Button(); btnContract.Uid = "1009"; btnContract.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnContract.Height = Double.NaN; btnContract.Width = Double.NaN; btnContract.Content = Translator.GetInstance().GetString("PageOrderAirliners", btnContract.Uid); btnContract.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnContract.Margin = new Thickness(5, 0, 0, 0); btnContract.Click += new RoutedEventHandler(btnContract_Click); panelButtons.Children.Add(btnContract); frameAirlinerInfo = new Frame(); frameAirlinerInfo.Margin = new Thickness(0, 10, 0, 0); mainPanel.Children.Add(frameAirlinerInfo); this.Content = scroller; showOrders(); (from t in AirlinerTypes.GetAllTypes() where t.Produced.From <= GameObject.GetInstance().GameTime && t.Produced.To >= GameObject.GetInstance().GameTime && t.Manufacturer == this.Manufacturer orderby t.Name select t).ToList().ForEach(m => cbTypes.Items.Add(m)); cbTypes.SelectedIndex = 0; }