private void StandardPage_Loaded(object sender, RoutedEventArgs e) { sw.Stop(); long counter = sw.ElapsedMilliseconds; string pageName = this.ToString().Substring(this.ToString().LastIndexOf(".") + 1); PerformanceCounters.AddPerformanceCounter(new PagePerformanceCounter(pageName, GameObject.GetInstance().GameTime, counter)); }
public PanelAirport(Airport airport) { Stopwatch sw = new Stopwatch(); sw.Start(); this.Airport = airport; WrapPanel buttonsPanel = new WrapPanel(); ucSelectButton sbGates = new ucSelectButton(); sbGates.Uid = "201"; sbGates.Content = Translator.GetInstance().GetString("PanelAirport", sbGates.Uid); sbGates.Click += new System.Windows.RoutedEventHandler(sbGates_Click); sbGates.IsSelected = true; buttonsPanel.Children.Add(sbGates); ucSelectButton sbRunways = new ucSelectButton(); sbRunways.Uid = "205"; sbRunways.Content = Translator.GetInstance().GetString("PanelAirport", sbRunways.Uid); sbRunways.Click += new System.Windows.RoutedEventHandler(sbRunways_Click); buttonsPanel.Children.Add(sbRunways); ucSelectButton sbFacilities = new ucSelectButton(); sbFacilities.Uid = "202"; sbFacilities.Content = Translator.GetInstance().GetString("PanelAirport", sbFacilities.Uid); sbFacilities.Click += new System.Windows.RoutedEventHandler(sbFacilities_Click); buttonsPanel.Children.Add(sbFacilities); ucSelectButton sbWeather = new ucSelectButton(); sbWeather.Uid = "208"; sbWeather.Content = Translator.GetInstance().GetString("PanelAirport", sbWeather.Uid); sbWeather.Click += new System.Windows.RoutedEventHandler(sbWeather_Click); buttonsPanel.Children.Add(sbWeather); ucSelectButton sbStatistics = new ucSelectButton(); sbStatistics.Uid = "203"; sbStatistics.Content = Translator.GetInstance().GetString("PanelAirport", sbStatistics.Uid); sbStatistics.Click += new System.Windows.RoutedEventHandler(sbStatistics_Click); buttonsPanel.Children.Add(sbStatistics); ucSelectButton sbTraffic = new ucSelectButton(); sbTraffic.Uid = "207"; sbTraffic.Content = Translator.GetInstance().GetString("PanelAirport", sbTraffic.Uid); sbTraffic.Click += new System.Windows.RoutedEventHandler(sbTraffic_Click); buttonsPanel.Children.Add(sbTraffic); ucSelectButton sbFlights = new ucSelectButton(); sbFlights.Uid = "204"; sbFlights.Content = Translator.GetInstance().GetString("PanelAirport", sbFlights.Uid); sbFlights.Click += new System.Windows.RoutedEventHandler(sbFlights_Click); buttonsPanel.Children.Add(sbFlights); ucSelectButton sbDistances = new ucSelectButton(); sbDistances.Uid = "206"; sbDistances.Content = Translator.GetInstance().GetString("PanelAirport", sbDistances.Uid); sbDistances.Click += new System.Windows.RoutedEventHandler(sbDistances_Click); buttonsPanel.Children.Add(sbDistances); this.Children.Add(buttonsPanel); frameContent = new Frame(); frameContent.NavigationUIVisibility = NavigationUIVisibility.Hidden; frameContent.Navigate(new PageAirportGates(this.Airport)); this.Children.Add(frameContent); sw.Stop(); PerformanceCounters.AddPerformanceCounter(new PagePerformanceCounter("PanelAirport", GameObject.GetInstance().GameTime, sw.ElapsedMilliseconds)); }
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)); }