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; }
//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); }