public PageAirlineFleet(Airline airline) { InitializeComponent(); this.Airline = airline; foreach (FleetAirliner fa in this.Airline.DeliveredFleet) { _FleetDelivered.Add(fa); } StackPanel panelFleet = new StackPanel(); WrapPanel panelMenuButtons = new WrapPanel(); panelFleet.Children.Add(panelMenuButtons); ucSelectButton sbOverview = new ucSelectButton(); sbOverview.Uid = "1001"; sbOverview.Content = Translator.GetInstance().GetString("PageAirlineFleet", sbOverview.Uid); sbOverview.Click += new RoutedEventHandler(sbOverview_Click); sbOverview.IsSelected = true; panelMenuButtons.Children.Add(sbOverview); ucSelectButton sbDetailed = new ucSelectButton(); sbDetailed.Uid = "1002"; sbDetailed.Content = Translator.GetInstance().GetString("PageAirlineFleet", sbDetailed.Uid); sbDetailed.Click += new RoutedEventHandler(sbDetailed_Click); panelMenuButtons.Children.Add(sbDetailed); ucSelectButton sbOrdered = new ucSelectButton(); sbOrdered.Uid = "1009"; sbOrdered.Content = Translator.GetInstance().GetString("PageAirlineFleet", sbOrdered.Uid); sbOrdered.Click += new RoutedEventHandler(sbOrdered_Click); panelMenuButtons.Children.Add(sbOrdered); panelOverview = createOverviewPanel(); panelDetailed = createDetailedPanel(); panelDetailed.Visibility = System.Windows.Visibility.Collapsed; panelDetailed.ToolTip = UICreator.CreateToolTip("View detailed information for this aircraft"); panelOrdered = createOrderedPanel(); panelOrdered.Visibility = System.Windows.Visibility.Collapsed; panelOrdered.ToolTip = UICreator.CreateToolTip("View ordered airliners"); panelFleet.Children.Add(panelOverview); panelFleet.Children.Add(panelDetailed); panelFleet.Children.Add(panelOrdered); this.Content = panelFleet; }
//creates the panel for purchasing an airline private StackPanel createPurchaseAirlinePanel() { double buyingPrice = this.Airline.getValue() * 1000000 * 1.10; StackPanel purchasePanel = new StackPanel(); purchasePanel.Margin = new Thickness(5, 10, 10, 10); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1022"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.TextAlignment = TextAlignment.Left; txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = string.Format("{0} ({1:C})", Translator.GetInstance().GetString("PageAirline", txtHeader.Uid), buyingPrice); purchasePanel.Children.Add(txtHeader); WrapPanel panelButtons = new WrapPanel(); Button btnPurchase = new Button(); btnPurchase.Uid = "1023"; btnPurchase.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnPurchase.Height = Double.NaN; btnPurchase.Width = Double.NaN; btnPurchase.Content = Translator.GetInstance().GetString("PageAirline", btnPurchase.Uid); btnPurchase.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnPurchase.IsEnabled = GameObject.GetInstance().HumanAirline.Money > buyingPrice; btnPurchase.Click += new RoutedEventHandler(btnPurchase_Click); btnPurchase.ToolTip = UICreator.CreateToolTip("1015"); panelButtons.Children.Add(btnPurchase); Button btnPurchaseAsSubsidiary = new Button(); btnPurchaseAsSubsidiary.Uid = "1026"; btnPurchaseAsSubsidiary.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnPurchaseAsSubsidiary.Height = Double.NaN; btnPurchaseAsSubsidiary.Width = Double.NaN; btnPurchaseAsSubsidiary.Content = Translator.GetInstance().GetString("PageAirline", btnPurchaseAsSubsidiary.Uid); btnPurchaseAsSubsidiary.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnPurchaseAsSubsidiary.IsEnabled = GameObject.GetInstance().HumanAirline.Money > buyingPrice; btnPurchaseAsSubsidiary.Margin = new Thickness(5, 0, 0, 0); btnPurchaseAsSubsidiary.Click += btnPurchaseAsSubsidiary_Click; btnPurchaseAsSubsidiary.ToolTip = UICreator.CreateToolTip("1016"); panelButtons.Children.Add(btnPurchaseAsSubsidiary); purchasePanel.Children.Add(panelButtons); return(purchasePanel); }
//private Slider slMarketingBudget; public PageAirlineFinances(Airline airline) { InitializeComponent(); this.Language = XmlLanguage.GetLanguage(new CultureInfo(AppSettings.GetInstance().getLanguage().CultureInfo, true).IetfLanguageTag); this.Airline = airline; StackPanel panelFinances = new StackPanel(); panelFinances.Margin = new Thickness(0, 10, 50, 0); /*REMOVE THIS LINE AFTER 0.3.6 PUBLIC RELEASE ************************ * WrapPanel panelMarketingBudget = new WrapPanel(); * * double minValue = 0; * TextBlock txtSliderValue = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(minValue).ToString()); * txtSliderValue.Margin = new Thickness(5, 0, 5, 0); * txtSliderValue.VerticalAlignment = System.Windows.VerticalAlignment.Top; * txtSliderValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; * * panelFinances.Children.Add(txtSliderValue); * * Slider slMarketingBudget = new Slider(); * slMarketingBudget.Value = 10000; * slMarketingBudget.Minimum = 1; * slMarketingBudget.Maximum = 10000000; * slMarketingBudget.Width = 400; * slMarketingBudget.Tag = txtSliderValue; * slMarketingBudget.IsDirectionReversed = false; * slMarketingBudget.IsSnapToTickEnabled = true; * slMarketingBudget.IsMoveToPointEnabled = true; * slMarketingBudget.TickFrequency = 25000; * slMarketingBudget.ValueChanged += new RoutedPropertyChangedEventHandler<double>(slider_ValueChanged); * slMarketingBudget.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.Both; * * panelFinances.Children.Add(slMarketingBudget); * * Button btnApplyMB = new Button(); * btnApplyMB.Uid = "2001"; * btnApplyMB.SetResourceReference(Button.StyleProperty, "RoundedButton"); * btnApplyMB.Height = Double.NaN; * btnApplyMB.Width = Double.NaN; * btnApplyMB.Content = Translator.GetInstance().GetString("PageFinances", btnApplyMB.Uid); * btnApplyMB.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; * btnApplyMB.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; * btnApplyMB.Margin = new Thickness(0, 10, 0, 10); * btnApplyMB.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); * btnApplyMB.Click += new RoutedEventHandler(btnApplyMB_Click); * panelFinances.Children.Add(btnApplyMB); * * txtMarketingBudget = new TextBlock(); * txtMarketingBudget.Margin = new Thickness(5, 0, 5, 0); * txtMarketingBudget.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; * txtMarketingBudget.Text = Translator.GetInstance().GetString("PageFinances", "1001"); * txtMarketingBudget.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; * * * panelFinances.Children.Add(txtMarketingBudget); * REMOVE THIS LINE AFTER 0.3.6 PUBLIC RELEASE ********************/ TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; 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("PageAirlineFinances", txtHeader.Uid); panelFinances.Children.Add(txtHeader); TextBlock txtSummary = new TextBlock(); txtSummary.Uid = "1002"; txtSummary.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtSummary.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtSummary.FontWeight = FontWeights.Bold; txtSummary.Text = Translator.GetInstance().GetString("PageAirlineFinances", txtSummary.Uid); panelFinances.Children.Add(txtSummary); ListBox lbSummary = new ListBox(); lbSummary.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbSummary.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelFinances.Children.Add(lbSummary); //txtCurrentMoney = UICreator.CreateTextBlock(string.Format("{0:c}", this.Airline.Money)); txtCurrentMoney = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airline.Money).ToString()); txtCurrentMoney.Foreground = new Converters.ValueIsMinusConverter().Convert(this.Airline.Money, null, null, null) as Brush; txtCurrentMoney.ToolTip = UICreator.CreateToolTip("Current expendable cash"); lbSummary.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineFinances", "1003"), txtCurrentMoney)); //txtBalance = UICreator.CreateTextBlock(string.Format("{0:c}", this.Airline.Money - this.Airline.StartMoney)); txtBalance = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airline.Money - this.Airline.StartMoney).ToString()); txtBalance.Foreground = new Converters.ValueIsMinusConverter().Convert(this.Airline.Money - this.Airline.StartMoney, null, null, null) as Brush; lbSummary.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineFinances", "1004"), txtBalance)); txtBalance.ToolTip = UICreator.CreateToolTip("Total balance since start of game"); ContentControl txtSpecifications = new ContentControl(); txtSpecifications.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtSpecifications.ContentTemplate = this.Resources["SpecsHeader"] as DataTemplate; txtSpecifications.Margin = new Thickness(0, 5, 0, 0); panelFinances.Children.Add(txtSpecifications); lbSpecifications = new ListBox(); lbSpecifications.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbSpecifications.ItemTemplate = this.Resources["SpecsItem"] as DataTemplate; panelFinances.Children.Add(lbSpecifications); showSpecifications(); StackPanel panelLoans = new StackPanel(); panelLoans.Visibility = this.Airline.IsHuman ? Visibility.Visible : System.Windows.Visibility.Collapsed; panelLoans.Margin = new Thickness(0, 5, 0, 0); panelFinances.Children.Add(panelLoans); TextBlock txtLoans = new TextBlock(); txtLoans.Uid = "1005"; txtLoans.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtLoans.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtLoans.FontWeight = FontWeights.Bold; txtLoans.Text = Translator.GetInstance().GetString("PageAirlineFinances", txtLoans.Uid); panelLoans.Children.Add(txtLoans); ContentControl ccLoans = new ContentControl(); ccLoans.ContentTemplate = this.Resources["LoansHeader"] as DataTemplate; panelLoans.Children.Add(ccLoans); lbLoans = new ListBox(); lbLoans.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbLoans.MaxHeight = GraphicsHelpers.GetContentHeight() / 2 - 100; lbLoans.ItemTemplate = this.Resources["LoanItem"] as DataTemplate; panelLoans.Children.Add(lbLoans); Button btnLoan = new Button(); btnLoan.Uid = "1006"; btnLoan.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnLoan.Height = Double.NaN; btnLoan.Width = Double.NaN; //btnLoan.Visibility = this.Airline.IsHuman ? Visibility.Visible : System.Windows.Visibility.Collapsed; btnLoan.Content = Translator.GetInstance().GetString("PageAirlineFinances", btnLoan.Uid); btnLoan.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; btnLoan.Margin = new Thickness(0, 10, 0, 0); btnLoan.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnLoan.Click += new RoutedEventHandler(btnLoan_Click); panelLoans.Children.Add(btnLoan); showLoans(false); this.Content = panelFinances; //GameTimer.GetInstance().OnTimeChanged += new GameTimer.TimeChanged(PageAirlineFinances_OnTimeChanged); //this.Unloaded += new RoutedEventHandler(PageAirlineFinances_Unloaded); }
public PageAirlineDestinations(Airline airline) { InitializeComponent(); this.Airline = airline; StackPanel panelDestinations = new StackPanel(); panelDestinations.Margin = new Thickness(0, 10, 50, 0); TextBlock txtDestinationsHeader = new TextBlock(); txtDestinationsHeader.Uid = "1001"; txtDestinationsHeader.Margin = new Thickness(0, 0, 0, 0); txtDestinationsHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtDestinationsHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtDestinationsHeader.FontWeight = FontWeights.Bold; txtDestinationsHeader.Text = Translator.GetInstance().GetString("PageAirlineDestinations", txtDestinationsHeader.Uid); panelDestinations.Children.Add(txtDestinationsHeader); ListBox lbDestinations = new ListBox(); lbDestinations.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbDestinations.ItemTemplate = this.Resources["AirportItem"] as DataTemplate; // chs, 2011-10-11 changed the max height so all elements are visible lbDestinations.MaxHeight = (GraphicsHelpers.GetContentHeight() - 100) / 2; this.Airline.Airports.ForEach(a => lbDestinations.Items.Add(a)); panelDestinations.Children.Add(lbDestinations); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); panelButtons.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; panelDestinations.Children.Add(panelButtons); Button btnDestinations = new Button(); btnDestinations.Uid = "1002"; btnDestinations.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnDestinations.Width = Double.NaN; btnDestinations.Height = Double.NaN; btnDestinations.Content = Translator.GetInstance().GetString("PageAirlineDestinations", btnDestinations.Uid); btnDestinations.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnDestinations.Click += new RoutedEventHandler(btnDestinations_Click); btnDestinations.ToolTip = UICreator.CreateToolTip("Show your airline's destinations"); panelButtons.Children.Add(btnDestinations); Button btnMap = new Button(); btnMap.Uid = "201"; btnMap.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnMap.Width = Double.NaN; btnMap.Height = Double.NaN; btnMap.Content = Translator.GetInstance().GetString("PageAirlineDestinations", btnMap.Uid); btnMap.Margin = new Thickness(5, 0, 0, 0); btnMap.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnMap.Click += new RoutedEventHandler(btnMap_Click); panelButtons.Children.Add(btnMap); panelDestinations.Children.Add(createRoutesInformationPanel()); this.Content = panelDestinations; }
//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); }
public PageAirportGates(Airport airport) { Stopwatch sw = new Stopwatch(); sw.Start(); this.Airport = airport; InitializeComponent(); // chs, 2011-27-10 added for the possibility of purchasing a terminal StackPanel panelGatesTerminals = new StackPanel(); panelGatesTerminals.Margin = new Thickness(0, 10, 50, 0); panelGates = new StackPanel(); panelGatesTerminals.Children.Add(panelGates); ScrollViewer svTerminals = new ScrollViewer(); svTerminals.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; svTerminals.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; svTerminals.MaxHeight = (GraphicsHelpers.GetContentHeight() - 100) / 4; StackPanel panelAirlineGates = new StackPanel(); panelAirlineGates.Margin = new Thickness(0, 0, 10, 0); TextBlock txtGatesHeader = new TextBlock(); txtGatesHeader.Uid = "1007"; txtGatesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtGatesHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtGatesHeader.FontWeight = FontWeights.Bold; txtGatesHeader.Text = Translator.GetInstance().GetString("PageAirportGates", txtGatesHeader.Uid); panelAirlineGates.Children.Add(txtGatesHeader); lbAirlineContracts = new ListBox(); lbAirlineContracts.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbAirlineContracts.ItemTemplate = this.Resources["AirlineContractItem"] as DataTemplate; lbAirlineContracts.MaxHeight = GraphicsHelpers.GetContentHeight() / 4; panelAirlineGates.Children.Add(lbAirlineContracts); //List<Airline> airlines = (from a in Airlines.GetAllAirlines() where this.Airport.Terminals.getNumberOfGates(a) > 0 orderby a.Profile.Name select a).ToList(); //foreach (Airline airline in airlines) //lbAirlineContracts.Items.Add(new AirlineGates(airline, this.Airport.Terminals.getNumberOfGates(airline), this.Airport.Terminals.getNumberOfGates(airline) - this.Airport.Terminals.getNumberOfFreeGates(airline))); var contracts = (from c in this.Airport.AirlineContracts orderby c.Airline.Profile.Name select c); foreach (AirportContract contract in contracts) { lbAirlineContracts.Items.Add(contract); } svTerminals.Content = panelAirlineGates; panelGatesTerminals.Children.Add(svTerminals); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); panelGatesTerminals.Children.Add(panelButtons); Button btnTerminal = new Button(); btnTerminal.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnTerminal.Uid = "201"; btnTerminal.Height = Double.NaN; btnTerminal.Width = Double.NaN; btnTerminal.Content = Translator.GetInstance().GetString("PageAirportGates", btnTerminal.Uid); btnTerminal.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnTerminal.Click += new RoutedEventHandler(btnTerminal_Click); btnTerminal.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; //btnTerminal.Visibility = this.Airport.AirlineContract == null || this.Airport.AirlineContract.Airline.IsHuman ? Visibility.Visible : System.Windows.Visibility.Collapsed; panelButtons.Children.Add(btnTerminal); btnHub = new Button(); btnHub.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnHub.Uid = "204"; btnHub.Width = Double.NaN; btnHub.Height = Double.NaN; btnHub.Content = Translator.GetInstance().GetString("PageAirportGates", btnHub.Uid); btnHub.Click += new RoutedEventHandler(btnHub_Click); btnHub.Margin = new Thickness(5, 0, 0, 0); btnHub.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); panelButtons.Children.Add(btnHub); btnContract = new Button(); btnContract.Margin = new Thickness(5, 0, 0, 0); btnContract.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnContract.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnContract.Width = Double.NaN; btnContract.Height = Double.NaN; btnContract.Uid = "206"; btnContract.Click += btnContract_Click; btnContract.Content = Translator.GetInstance().GetString("PageAirportGates", btnContract.Uid); panelButtons.Children.Add(btnContract); btnContract.ToolTip = UICreator.CreateToolTip("1017"); Airport allocateToAirport = Airports.GetAirports(a => a.Profile.Town == airport.Profile.Town && airport != a && a.Profile.Period.From.AddDays(30) > GameObject.GetInstance().GameTime).FirstOrDefault(); Button btnReallocate = new Button(); btnReallocate.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnReallocate.Uid = "205"; btnReallocate.Width = Double.NaN; btnReallocate.Height = Double.NaN; btnReallocate.Tag = allocateToAirport; btnReallocate.Content = string.Format(Translator.GetInstance().GetString("PageAirportGates", btnReallocate.Uid), allocateToAirport == null ? "" : new AirportCodeConverter().Convert(allocateToAirport).ToString()); btnReallocate.Visibility = allocateToAirport == null || this.Airport.Terminals.getNumberOfGates(GameObject.GetInstance().HumanAirline) == 0 ? Visibility.Collapsed : Visibility.Visible; btnReallocate.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnReallocate.Margin = new Thickness(5, 0, 0, 0); btnReallocate.Click += new RoutedEventHandler(btnReallocate_Click); panelButtons.Children.Add(btnReallocate); this.Content = panelGatesTerminals; showGatesInformation(); showTerminals(); showHubs(); showContracts(); sw.Stop(); PerformanceCounters.AddPerformanceCounter(new PagePerformanceCounter("PageAirportGate", GameObject.GetInstance().GameTime, sw.ElapsedMilliseconds)); }
//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); }