public PageInformation()
    {
        this.Background = Brushes.Transparent;

        WrapPanel panelContent = new WrapPanel();

        panelContent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
        panelContent.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
        panelContent.Margin = new Thickness(0, 0, 5, 0);


        Image imgLogo = new Image();

        imgLogo.Source = new BitmapImage(new Uri(@"/Data/images/gas-white.png", UriKind.RelativeOrAbsolute));
        imgLogo.Height = 16;
        RenderOptions.SetBitmapScalingMode(imgLogo, BitmapScalingMode.HighQuality);

        panelContent.Children.Add(imgLogo);

        txtGasPrice = UICreator.CreateTextBlock(string.Format("{0}/{1}.", new ValueCurrencyConverter().Convert(new FuelUnitConverter().Convert(GameObject.GetInstance().FuelPrice)), new StringToLanguageConverter().Convert("ltr")));
        txtGasPrice.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
        txtGasPrice.FontWeight        = FontWeights.Bold;
        txtGasPrice.Margin            = new Thickness(5, 0, 0, 0);

        panelContent.Children.Add(txtGasPrice);

        this.Content = panelContent;
    }
        //creates the panel for airline value
        private WrapPanel createAirlineValuePanel()
        {
            WrapPanel panelValue = new WrapPanel();

            panelValue.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            for (int i = 0; i <= (int)this.Airline.getAirlineValue(); i++)
            {
                Image imgValue = new Image();
                imgValue.Source = new BitmapImage(new Uri(@"/Data/images/coins.png", UriKind.RelativeOrAbsolute));
                imgValue.Height = 20;
                RenderOptions.SetBitmapScalingMode(imgValue, BitmapScalingMode.HighQuality);

                panelValue.Children.Add(imgValue);
            }
            for (int i = (int)this.Airline.getAirlineValue(); i < (int)Airline.AirlineValue.Very_high; i++)
            {
                Image imgValue = new Image();
                imgValue.Source = new BitmapImage(new Uri(@"/Data/images/coins_gray.png", UriKind.RelativeOrAbsolute));
                imgValue.Height = 20;
                RenderOptions.SetBitmapScalingMode(imgValue, BitmapScalingMode.HighQuality);

                panelValue.Children.Add(imgValue);
            }
            // chs, 2011-13-10 added value in $ of an airline to the value text
            //   TextBlock txtValue = UICreator.CreateTextBlock(string.Format(" ({0})", string.Format("{0:c}", this.Airline.getValue())));
            TextBlock txtValue = UICreator.CreateTextBlock(string.Format(" ({0})", new ValueCurrencyConverter().Convert(this.Airline.getValue() * 1000000).ToString()));

            txtValue.FontStyle = FontStyles.Italic;
            panelValue.Children.Add(txtValue);

            return(panelValue);
        }
Exemple #3
0
        //creates the tool tip for an entry
        private Border createToolTip(KeyValuePair <TimeSpan, KeyValuePair <int, int> > value)
        {
            double maxFlightsPerSlot = 10 * this.Airport.Runways.Count;

            double slotValue = Convert.ToDouble(value.Value.Value + value.Value.Key) / maxFlightsPerSlot;

            Border brdToolTip = new Border();

            brdToolTip.Margin  = new Thickness(-4, 0, -4, -3);
            brdToolTip.Padding = new Thickness(5);
            brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2");

            StackPanel panelToolTip = new StackPanel();

            TextBlock txtTime = UICreator.CreateTextBlock(new TimeSpanConverter().Convert(value.Key).ToString());

            txtTime.FontWeight      = FontWeights.Bold;
            txtTime.TextDecorations = TextDecorations.Underline;

            panelToolTip.Children.Add(txtTime);
            panelToolTip.Children.Add(UICreator.CreateTextBlock(string.Format("Departures: {0}", value.Value.Key)));
            panelToolTip.Children.Add(UICreator.CreateTextBlock(string.Format("Arrivals: {0}", value.Value.Value)));
            panelToolTip.Children.Add(UICreator.CreateTextBlock(string.Format("Percent of capacity: {0:P}", slotValue)));

            brdToolTip.Child = panelToolTip;

            return(brdToolTip);
        }
Exemple #4
0
        //creates the slider for the money
        private WrapPanel createMoneySlider()
        {
            double    minValue    = 100000;
            double    maxValue    = GameObject.GetInstance().MainAirline.Money / 2;
            WrapPanel sliderPanel = new WrapPanel();

            TextBlock txtValue = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(minValue).ToString());//UICreator.CreateTextBlock(string.Format("{0:C}", minValue));

            txtValue.VerticalAlignment = VerticalAlignment.Bottom;
            txtValue.Margin            = new Thickness(5, 0, 0, 0);

            slMoney                      = new Slider();
            slMoney.Width                = 200;
            slMoney.Value                = minValue;
            slMoney.Tag                  = txtValue;
            slMoney.Maximum              = maxValue;
            slMoney.Minimum              = minValue;
            slMoney.ValueChanged        += new RoutedPropertyChangedEventHandler <double>(slider_ValueChanged);
            slMoney.TickFrequency        = (maxValue - minValue) / slMoney.Width;
            slMoney.IsSnapToTickEnabled  = true;
            slMoney.IsMoveToPointEnabled = true;
            sliderPanel.Children.Add(slMoney);

            sliderPanel.Children.Add(txtValue);

            return(sliderPanel);
        }
        private void btnHub_Click(object sender, RoutedEventArgs e)
        {
            StackPanel panelHubs = new StackPanel();

            foreach (HubType type in HubTypes.GetHubTypes())
            {
                if (AirlineHelpers.CanCreateHub(GameObject.GetInstance().HumanAirline, this.Airport, type))
                {
                    panelHubs.Children.Add(createHubType(type, panelHubs));
                }
            }

            if (panelHubs.Children.Count == 0)
            {
                panelHubs.Children.Add(UICreator.CreateTextBlock("You can't etablish any hubs at this airport"));
            }

            if (PopUpSingleElement.ShowPopUp("Select hub type", panelHubs) == PopUpSingleElement.ButtonSelected.OK && panelHubs.Tag != null)
            {
                HubType type = (HubType)panelHubs.Tag;

                if (AirportHelpers.GetHubPrice(this.Airport, type) > GameObject.GetInstance().HumanAirline.Money)
                {
                    WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2212"), Translator.GetInstance().GetString("MessageBox", "2212", "message"), WPFMessageBoxButtons.Ok);
                }
                else
                {
                    this.Airport.addHub(new Hub(GameObject.GetInstance().HumanAirline, type));

                    showHubs();

                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -AirportHelpers.GetHubPrice(this.Airport, type));
                }
            }
        }
Exemple #6
0
        //creates the slider for a wage type
        private WrapPanel createWageSlider(FeeType type)
        {
            WrapPanel sliderPanel = new WrapPanel();

            TextBlock txtValue = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.FeeValues[type]).ToString());//UICreator.CreateTextBlock(string.Format("{0:C}", this.FeeValues[type]));

            txtValue.VerticalAlignment = VerticalAlignment.Bottom;
            txtValue.Margin            = new Thickness(5, 0, 0, 0);
            txtValue.Tag = type;

            Slider slider = new Slider();

            slider.Width                = 200;
            slider.Value                = this.FeeValues[type];
            slider.Tag                  = txtValue;
            slider.Maximum              = type.MaxValue;
            slider.Minimum              = type.MinValue;
            slider.ValueChanged        += new RoutedPropertyChangedEventHandler <double>(slider_ValueChanged);
            slider.TickFrequency        = (type.MaxValue - type.MinValue) / slider.Width;
            slider.IsSnapToTickEnabled  = true;
            slider.IsMoveToPointEnabled = true;
            sliderPanel.Children.Add(slider);

            sliderPanel.Children.Add(txtValue);

            return(sliderPanel);
        }
        public PageAirlinerAdvancedRoute(FleetAirliner airliner, PopUpAirlinerAutoRoutes parent, OnRouteChanged routeChanged)
        {
            this.ParentPage    = parent;
            this.Airliner      = airliner;
            this.RouteChanged += routeChanged;

            InitializeComponent();

            StackPanel panelMain = new StackPanel();

            panelMain.Children.Add(createNewEntryPanel());

            WrapPanel panelFlightTime = new WrapPanel();

            txtStopovers            = UICreator.CreateTextBlock("");
            txtStopovers.Visibility = System.Windows.Visibility.Collapsed;
            txtStopovers.Margin     = new Thickness(0, 0, 10, 0);
            panelFlightTime.Children.Add(txtStopovers);

            txtFlightTime = UICreator.CreateTextBlock("Flight time:");
            panelFlightTime.Children.Add(txtFlightTime);

            panelMain.Children.Add(panelFlightTime);

            this.Content = panelMain;

            cbOrigin.SelectedIndex = 0;
        }
Exemple #8
0
        //creates an item for an advertisering type
        private UIElement createAdvertisementTypeItem(AdvertisementType.AirlineAdvertisementType type)
        {
            if (this.Airline.IsHuman)
            {
                ComboBox cbType = new ComboBox();
                cbType.ItemTemplate = this.Resources["AdvertisementItem"] as DataTemplate;
                cbType.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
                cbType.Width = 200;

                cbAdvertisements.Add(type, cbType);

                foreach (AdvertisementType aType in AdvertisementTypes.GetTypes(type))
                {
                    cbType.Items.Add(aType);
                }

                cbType.SelectedItem = this.Airline.getAirlineAdvertisement(type);

                return(cbType);
            }
            // chs, 2011-17-10 changed so it is not possible to change the advertisement type for a CPU airline
            else
            {
                return(UICreator.CreateTextBlock(this.Airline.getAirlineAdvertisement(type).Name));
            }
        }
        // chs 11-04-11: changed for making it possible to extending an existing terminal
        //for extending an existing terminal
        public PopUpTerminal(Terminal terminal)
        {
            this.Terminal = terminal;

            InitializeComponent();

            this.Title = "Extend terminal";

            this.Width = 400;

            this.Height = 175;

            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            StackPanel mainPanel = new StackPanel();

            mainPanel.Margin = new Thickness(10, 10, 10, 10);

            ListBox lbTerminal = new ListBox();

            lbTerminal.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbTerminal.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            mainPanel.Children.Add(lbTerminal);

            txtName             = new TextBox();
            txtName.Background  = Brushes.Transparent;
            txtName.BorderBrush = Brushes.Black;
            txtName.IsEnabled   = this.Terminal == null;
            txtName.Width       = 100;
            txtName.Text        = this.Terminal == null ? "Terminal" : this.Terminal.Name;
            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1007"), txtName));


            lbTerminal.Items.Add(new QuickInfoValue("Current gates", UICreator.CreateTextBlock(string.Format("{0} gates", this.Terminal.Gates.getGates().Count))));

            // chs 11-09-11: added numericupdown for selecting number of gates
            nudGates               = new ucNumericUpDown();
            nudGates.Height        = 30;
            nudGates.MaxValue      = 50;
            nudGates.MinValue      = 1;
            nudGates.ValueChanged += new RoutedPropertyChangedEventHandler <decimal>(nudGates_ValueChanged);

            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1001"), nudGates));

            txtDaysToCreate = UICreator.CreateTextBlock("0 days");
            lbTerminal.Items.Add(new QuickInfoValue("Days to extend terminal", txtDaysToCreate));

            txtTotalPrice = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(0).ToString());//UICreator.CreateTextBlock(string.Format("{0:C}", 0));
            lbTerminal.Items.Add(new QuickInfoValue("Price for extending", txtTotalPrice));


            mainPanel.Children.Add(createButtonsPanel());

            nudGates.Value = 1;


            this.Content = mainPanel;
        }
Exemple #10
0
        //creates the panel for arrivals
        private ScrollViewer createArrivalsPanel()
        {
            ScrollViewer svArrivals = new ScrollViewer();

            svArrivals.Margin = new Thickness(0, 10, 0, 0);
            svArrivals.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            svArrivals.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            svArrivals.MaxHeight = GraphicsHelpers.GetContentHeight() / 3;

            StackPanel panelArrivals = new StackPanel();

            panelArrivals.Margin = new Thickness(0, 10, 0, 0);

            Grid grdType = UICreator.CreateGrid(2);

            grdType.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            panelArrivals.Children.Add(grdType);

            Image imgLogo = new Image();

            imgLogo.Source = new BitmapImage(new Uri(@"/Data/images/Arrivals.png", UriKind.RelativeOrAbsolute));
            imgLogo.Height = 20;
            RenderOptions.SetBitmapScalingMode(imgLogo, BitmapScalingMode.HighQuality);

            Grid.SetColumn(imgLogo, 0);
            grdType.Children.Add(imgLogo);

            TextBlock txtType = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PageAirport", "1002"));

            txtType.FontStyle = FontStyles.Oblique;
            txtType.FontSize  = 16;

            Grid.SetColumn(txtType, 1);
            grdType.Children.Add(txtType);

            ContentControl txtHeader = new ContentControl();

            txtHeader.Uid                 = "1003";
            txtHeader.ContentTemplate     = this.Resources["FlightHeader"] as DataTemplate;
            txtHeader.Content             = Translator.GetInstance().GetString("PageAirport", txtHeader.Uid);
            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            panelArrivals.Children.Add(txtHeader);

            lbArrivals = new ListBox();
            lbArrivals.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbArrivals.ItemTemplate = this.Resources["FlightItem"] as DataTemplate;

            panelArrivals.Children.Add(lbArrivals);

            svArrivals.Content = panelArrivals;

            return(svArrivals);
        }
Exemple #11
0
        public PopUpAirportSlot(Airport airport)
        {
            this.Airport = airport;

            InitializeComponent();

            this.Title = this.Airport.Profile.Name;

            this.Width = 800;

            this.Height = 400;

            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            StackPanel panelMain = new StackPanel();

            WrapPanel panelDay = new WrapPanel();

            TextBlock txtDay = UICreator.CreateTextBlock("Day: ");

            //txtDay.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            txtDay.FontWeight = FontWeights.Bold;

            panelDay.Children.Add(txtDay);

            ComboBox cbDay = new ComboBox();

            cbDay.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDay.Width               = 100;
            cbDay.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
            cbDay.Margin              = new Thickness(0, 0, 0, 10);
            cbDay.SelectionChanged   += new SelectionChangedEventHandler(cbDay_SelectionChanged);
            cbDay.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
            {
                cbDay.Items.Add(day);
            }

            panelDay.Children.Add(cbDay);

            panelMain.Children.Add(panelDay);

            panelSlot = new StackPanel();
            panelMain.Children.Add(panelSlot);

            cbDay.SelectedIndex = 0;

            this.Content = panelMain;
        }
        public PanelFlightSchool(PagePilots parent, FlightSchool flighschool)
        {
            this.ParentPage   = parent;
            this.FlightSchool = flighschool;

            InitializeComponent();

            StackPanel panelFlightSchool = 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("PanelFlightSchool", txtHeader.Uid);

            panelFlightSchool.Children.Add(txtHeader);

            ListBox lbFSInformation = new ListBox();

            lbFSInformation.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
            lbFSInformation.ItemContainerStyleSelector = new ListBoxItemStyleSelector();

            lbFSInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelFlightSchool", "1002"), UICreator.CreateTextBlock(this.FlightSchool.Name)));
            lbFSInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelFlightSchool", "1003"), UICreator.CreateTextBlock(this.FlightSchool.NumberOfInstructors.ToString())));

            txtStudents = UICreator.CreateTextBlock(this.FlightSchool.NumberOfStudents.ToString());
            lbFSInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelFlightSchool", "1006"), txtStudents));

            txtTrainingAircrafts = UICreator.CreateTextBlock(this.FlightSchool.TrainingAircrafts.Count.ToString());
            lbFSInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelFlightSchool", "1009"), txtTrainingAircrafts));

            panelFlightSchool.Children.Add(lbFSInformation);
            panelFlightSchool.Children.Add(createInstructorsPanel());
            panelFlightSchool.Children.Add(createTrainingAircraftsPanel());
            panelFlightSchool.Children.Add(createStudentsPanel());

            panelFlightSchool.Children.Add(createButtonsPanel());

            this.Content = panelFlightSchool;

            showInstructors();
            showStudents();
            showTrainingAircrafts();
        }
Exemple #13
0
        //creates the flight details
        private StackPanel createFlightInfo()
        {
            StackPanel panelFlight = new StackPanel();

            panelFlight.Margin = new Thickness(0, 5, 0, 0);

            TextBlock txtHeader = new TextBlock();

            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Text       = Translator.GetInstance().GetString("PageFleetRoute", "1001");
            panelFlight.Children.Add(txtHeader);


            ListBox lbFlightInfo = new ListBox();

            lbFlightInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbFlightInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            string status = "Resting";

            if (this.Airliner.Status == FleetAirliner.AirlinerStatus.Stopped)
            {
                status = "Stopped";
            }
            if (this.Airliner.Status == FleetAirliner.AirlinerStatus.On_route || this.Airliner.Status == FleetAirliner.AirlinerStatus.To_route_start)
            {
                status = "Active";
            }

            TextBlock txtStatus        = UICreator.CreateTextBlock(status);
            TextBlock txtFlightsPerDay = UICreator.CreateTextBlock(this.Airliner.Routes.Sum(r => r.TimeTable.Entries.FindAll(e => e.Day == GameObject.GetInstance().GameTime.DayOfWeek).Count).ToString());
            TextBlock txtPassengers    = UICreator.CreateTextBlock(string.Format("{0:0.00}", this.Airliner.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Passengers")) / this.Airliner.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Arrivals"))));

            lbFlightInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetRoute", "1002"), txtStatus));
            lbFlightInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetRoute", "1003"), txtFlightsPerDay));
            lbFlightInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageFleetRoute", "1004"), txtPassengers));

            panelFlight.Children.Add(lbFlightInfo);

            return(panelFlight);
        }
        //creates the panel for the scenario information
        private StackPanel createScenarioPanel()
        {
            StackPanel panelScenario = new StackPanel();

            panelScenario.Margin = new Thickness(10, 0, 0, 0);
            panelScenario.Width  = 400;

            txtName                     = UICreator.CreateTextBlock("");
            txtName.FontWeight          = FontWeights.Bold;
            txtName.FontSize            = 16;
            txtName.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            txtName.TextDecorations     = TextDecorations.Underline;
            panelScenario.Children.Add(txtName);

            txtDescription              = new TextBox();
            txtDescription.Background   = Brushes.Transparent;
            txtDescription.TextWrapping = TextWrapping.Wrap;
            //txtDescription.FontStyle = FontStyles.Italic;
            txtDescription.FontSize                    = 12;
            txtDescription.BorderThickness             = new Thickness(0);
            txtDescription.MaxHeight                   = 250;
            txtDescription.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            txtDescription.IsReadOnly                  = true;
            txtDescription.Text = "";
            panelScenario.Children.Add(txtDescription);


            btnPlay     = new Button();
            btnPlay.Uid = "117";
            btnPlay.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnPlay.Height  = Double.NaN;
            btnPlay.Width   = Double.NaN;
            btnPlay.Content = Translator.GetInstance().GetString("General", btnPlay.Uid);
            btnPlay.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnPlay.Margin = new System.Windows.Thickness(0, 5, 0, 0);
            btnPlay.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            btnPlay.Visibility          = System.Windows.Visibility.Collapsed;
            btnPlay.Click += btnPlay_Click;
            panelScenario.Children.Add(btnPlay);

            return(panelScenario);
        }
        //create the slider indicator
        private Grid createIndicator()
        {
            Grid grdIndicator = UICreator.CreateGrid(3);

            grdIndicator.Width = 200;

            TextBlock txtEasy   = UICreator.CreateTextBlock(DifficultyLevels.GetDifficultyLevel("Easy").Name);
            TextBlock txtNormal = UICreator.CreateTextBlock(DifficultyLevels.GetDifficultyLevel("Normal").Name);
            TextBlock txtHard   = UICreator.CreateTextBlock(DifficultyLevels.GetDifficultyLevel("Hard").Name);

            Grid.SetColumn(txtEasy, 0);
            grdIndicator.Children.Add(txtEasy);

            txtNormal.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            Grid.SetColumn(txtNormal, 1);
            grdIndicator.Children.Add(txtNormal);

            Grid.SetColumn(txtHard, 2);
            txtHard.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            grdIndicator.Children.Add(txtHard);

            return(grdIndicator);
        }
Exemple #16
0
        //creates the panel to transfer funds between airlines
        private StackPanel createTransferFundsPanel()
        {
            panelTransferFunds            = new StackPanel();
            panelTransferFunds.Margin     = new Thickness(0, 5, 0, 0);
            panelTransferFunds.Visibility = this.Airline.Subsidiaries.Count > 0 ? Visibility.Visible : System.Windows.Visibility.Collapsed;

            TextBlock txtHeader = new TextBlock();

            txtHeader.Uid = "1002";
            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Text       = Translator.GetInstance().GetString("PageAirlineSubsidiaries", txtHeader.Uid);

            panelTransferFunds.Children.Add(txtHeader);

            WrapPanel panelTransferAirlines = new WrapPanel();

            panelTransferAirlines.Margin = new Thickness(0, 5, 0, 0);
            panelTransferFunds.Children.Add(panelTransferAirlines);

            cbAirlineFrom = new ComboBox();
            cbAirlineFrom.SelectionChanged += cbAirlineFrom_SelectionChanged;
            cbAirlineFrom.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAirlineFrom.SetResourceReference(ComboBox.ItemTemplateProperty, "AirlineLogoItem");
            cbAirlineFrom.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbAirlineFrom.Width = 200;

            cbAirlineFrom.Items.Add(GameObject.GetInstance().MainAirline);

            foreach (Airline airline in GameObject.GetInstance().MainAirline.Subsidiaries)
            {
                cbAirlineFrom.Items.Add(airline);
            }

            panelTransferAirlines.Children.Add(cbAirlineFrom);

            panelTransferAirlines.Children.Add(UICreator.CreateTextBlock("->"));

            cbAirlineTo = new ComboBox();
            cbAirlineTo.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAirlineTo.SetResourceReference(ComboBox.ItemTemplateProperty, "AirlineLogoItem");
            cbAirlineTo.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbAirlineTo.Width = 200;

            cbAirlineTo.Items.Add(GameObject.GetInstance().MainAirline);

            foreach (Airline airline in GameObject.GetInstance().MainAirline.Subsidiaries)
            {
                cbAirlineTo.Items.Add(airline);
            }

            cbAirlineTo.SelectedItem = GameObject.GetInstance().HumanAirline;

            panelTransferAirlines.Children.Add(cbAirlineTo);

            panelTransferFunds.Children.Add(createMoneySlider());

            Button btnTransferFunds = new Button();

            btnTransferFunds.Uid = "201";
            btnTransferFunds.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnTransferFunds.Height  = Double.NaN;
            btnTransferFunds.Width   = Double.NaN;
            btnTransferFunds.Content = Translator.GetInstance().GetString("PageAirlineSubsidiaries", btnTransferFunds.Uid);
            btnTransferFunds.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnTransferFunds.Margin = new Thickness(0, 5, 0, 0);
            btnTransferFunds.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            btnTransferFunds.Click += btnTransferFunds_Click;

            panelTransferFunds.Children.Add(btnTransferFunds);

            cbAirlineFrom.SelectedItem = GameObject.GetInstance().HumanAirline;

            return(panelTransferFunds);
        }
        //creates the panel for destination flights
        private StackPanel createDestinationFlightsPanel()
        {
            panelDestinationFlights            = new StackPanel();
            panelDestinationFlights.Margin     = new Thickness(0, 10, 0, 0);
            panelDestinationFlights.Visibility = System.Windows.Visibility.Collapsed;

            ScrollViewer svFlights = new ScrollViewer();

            svFlights.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            svFlights.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            svFlights.MaxHeight = GraphicsHelpers.GetContentHeight() / 2;

            panelDestinationFlights.Children.Add(svFlights);

            StackPanel panelFlights = new StackPanel();

            svFlights.Content = panelFlights;

            TextBlock txtDestinationHeader = new TextBlock();

            txtDestinationHeader.Uid = "1004";
            txtDestinationHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtDestinationHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtDestinationHeader.FontWeight = FontWeights.Bold;
            txtDestinationHeader.Text       = Translator.GetInstance().GetString("PageAirportFlights", txtDestinationHeader.Uid);

            panelFlights.Children.Add(txtDestinationHeader);

            Grid grdArrivalsHeader = UICreator.CreateGrid(2);

            grdArrivalsHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            panelFlights.Children.Add(grdArrivalsHeader);

            Image imgArrivalsHeader = new Image();

            imgArrivalsHeader.Source = new BitmapImage(new Uri(@"/Data/images/Arrivals.png", UriKind.RelativeOrAbsolute));
            imgArrivalsHeader.Height = 20;
            RenderOptions.SetBitmapScalingMode(imgArrivalsHeader, BitmapScalingMode.HighQuality);

            Grid.SetColumn(imgArrivalsHeader, 0);
            grdArrivalsHeader.Children.Add(imgArrivalsHeader);

            TextBlock txtArrivalsHeader = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PageAirportFlights", "1002"));

            txtArrivalsHeader.FontStyle = FontStyles.Oblique;
            txtArrivalsHeader.FontSize  = 16;

            Grid.SetColumn(txtArrivalsHeader, 1);
            grdArrivalsHeader.Children.Add(txtArrivalsHeader);

            lbDestinationArrivals = new ListBox();
            lbDestinationArrivals.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbDestinationArrivals.ItemTemplate = this.Resources["AirportDestinationItem"] as DataTemplate;
            panelFlights.Children.Add(lbDestinationArrivals);

            Grid grdDeparturesHeader = UICreator.CreateGrid(2);

            grdDeparturesHeader.Margin = new Thickness(0, 5, 0, 0);
            grdDeparturesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            panelFlights.Children.Add(grdDeparturesHeader);

            Image imgDeparturesHeader = new Image();

            imgDeparturesHeader.Source = new BitmapImage(new Uri(@"/Data/images/Departures.png", UriKind.RelativeOrAbsolute));
            imgDeparturesHeader.Height = 20;
            RenderOptions.SetBitmapScalingMode(imgDeparturesHeader, BitmapScalingMode.HighQuality);

            Grid.SetColumn(imgDeparturesHeader, 0);
            grdDeparturesHeader.Children.Add(imgDeparturesHeader);

            TextBlock txtDeparturesHeader = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PageAirportFlights", "1003"));

            txtDeparturesHeader.FontStyle = FontStyles.Oblique;
            txtDeparturesHeader.FontSize  = 16;

            Grid.SetColumn(txtDeparturesHeader, 1);
            grdDeparturesHeader.Children.Add(txtDeparturesHeader);

            lbDestinationDepartures = new ListBox();
            lbDestinationDepartures.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbDestinationDepartures.ItemTemplate = this.Resources["AirportDestinationItem"] as DataTemplate;
            //lbDestinationDepartures.MaxHeight = GraphicsHelpers.GetContentHeight() / 2 - 100;
            panelFlights.Children.Add(lbDestinationDepartures);

            return(panelDestinationFlights);
        }
Exemple #18
0
        //creates the panel for auto generation of time table from a route
        private WrapPanel createAutoGeneratePanel()
        {
            WrapPanel autogeneratePanel = new WrapPanel();

            autogeneratePanel.Margin = new Thickness(0, 5, 0, 0);

            cbRegion = new ComboBox();
            cbRegion.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbRegion.Width             = 150;
            cbRegion.DisplayMemberPath = "Name";
            cbRegion.SelectedValuePath = "Name";
            cbRegion.SelectionChanged += cbRegion_SelectionChanged;
            cbRegion.Items.Add(Regions.GetRegion("100"));
            cbRegion.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            var routes = this.Airliner.Airliner.Airline.Routes.FindAll(r => this.Airliner.Airliner.Type.Range > r.getDistance() && !r.Banned);

            List <Region> regions = routes.Where(r => r.Destination1.Profile.Country.Region == r.Destination2.Profile.Country.Region).Select(r => r.Destination1.Profile.Country.Region).ToList();

            regions.AddRange(routes.Where(r => r.Destination1.Profile.Country == GameObject.GetInstance().HumanAirline.Profile.Country).Select(r => r.Destination2.Profile.Country.Region));
            regions.AddRange(routes.Where(r => r.Destination2.Profile.Country == GameObject.GetInstance().HumanAirline.Profile.Country).Select(r => r.Destination1.Profile.Country.Region));


            foreach (Region region in regions.Distinct())
            {
                cbRegion.Items.Add(region);
            }

            autogeneratePanel.Children.Add(cbRegion);

            cbRoute = new ComboBox();
            cbRoute.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbRoute.SelectionChanged += new SelectionChangedEventHandler(cbAutoRoute_SelectionChanged);
            cbRoute.ItemTemplate      = this.Resources["SelectRouteItem"] as DataTemplate;
            cbRoute.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            foreach (Route route in routes)
            {
                cbRoute.Items.Add(route);
            }

            autogeneratePanel.Children.Add(cbRoute);

            cbFlightCode = new ComboBox();
            cbFlightCode.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbFlightCode.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            foreach (string flightCode in this.Airliner.Airliner.Airline.getFlightCodes())
            {
                cbFlightCode.Items.Add(flightCode);
            }

            cbFlightCode.Items.RemoveAt(cbFlightCode.Items.Count - 1);

            cbFlightCode.SelectedIndex = 0;

            autogeneratePanel.Children.Add(cbFlightCode);

            StackPanel panelFlightInterval = new StackPanel();

            panelFlightInterval.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            panelFlightInterval.Margin            = new Thickness(10, 0, 0, 0);

            RadioButton rbDailyFlights = new RadioButton();

            rbDailyFlights.Content   = Translator.GetInstance().GetString("PopUpAirlinerAutoRoutes", "1002");
            rbDailyFlights.GroupName = "Interval";
            rbDailyFlights.IsChecked = true;
            rbDailyFlights.Checked  += rbDailyFlights_Checked;

            panelFlightInterval.Children.Add(rbDailyFlights);

            RadioButton rbWeeklyFlights = new RadioButton();

            rbWeeklyFlights.Content   = Translator.GetInstance().GetString("PopUpAirlinerAutoRoutes", "1005");
            rbWeeklyFlights.GroupName = "Interval";
            rbWeeklyFlights.Checked  += rbWeeklyFlights_Checked;

            panelFlightInterval.Children.Add(rbWeeklyFlights);

            autogeneratePanel.Children.Add(panelFlightInterval);

            cbFlightsPerDay = new ComboBox();
            cbFlightsPerDay.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbFlightsPerDay.SelectionChanged += cbFlightsPerDay_SelectionChanged;
            cbFlightsPerDay.Margin            = new Thickness(5, 0, 0, 0);
            cbFlightsPerDay.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            autogeneratePanel.Children.Add(cbFlightsPerDay);

            this.Interval = FlightInterval.Daily;

            cbFlightsPerWeek = new ComboBox();
            cbFlightsPerWeek.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbFlightsPerWeek.Visibility        = System.Windows.Visibility.Collapsed;
            cbFlightsPerWeek.Margin            = new Thickness(5, 0, 0, 0);
            cbFlightsPerWeek.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            for (int i = 1; i < 7; i++)
            {
                cbFlightsPerWeek.Items.Add(i);
            }

            cbFlightsPerWeek.SelectedIndex = 0;

            autogeneratePanel.Children.Add(cbFlightsPerWeek);

            TextBlock txtDelayMinutes = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PopUpAirlinerAutoRoutes", "1003"));

            txtDelayMinutes.Margin            = new Thickness(10, 0, 0, 0);
            txtDelayMinutes.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            autogeneratePanel.Children.Add(txtDelayMinutes);

            cbDelayMinutes = new ComboBox();
            cbDelayMinutes.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDelayMinutes.SelectionChanged          += cbDelayMinutes_SelectionChanged;
            cbDelayMinutes.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right;
            cbDelayMinutes.VerticalAlignment          = System.Windows.VerticalAlignment.Bottom;


            autogeneratePanel.Children.Add(cbDelayMinutes);

            TextBlock txtStartTime = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PopUpAirlinerAutoRoutes", "1004"));

            txtStartTime.Margin            = new Thickness(10, 0, 5, 0);
            txtStartTime.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            autogeneratePanel.Children.Add(txtStartTime);

            cbStartTime = new ComboBox();
            cbStartTime.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbStartTime.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            cbStartTime.SetResourceReference(ComboBox.ItemTemplateProperty, "TimeSpanItem");

            autogeneratePanel.Children.Add(cbStartTime);

            StackPanel panelRouteType = new StackPanel();

            panelRouteType.Margin = new Thickness(5, 0, 0, 0);

            //string[] routeTypes = new string[] { "Standard Operations", "Business Operations", "24-Hour Operations" };

            foreach (RouteOperationsType type in Enum.GetValues(typeof(RouteOperationsType)))
            {
                RadioButton rbRouteType = new RadioButton();
                rbRouteType.Tag       = type;
                rbRouteType.GroupName = "RouteType";
                rbRouteType.Content   = type.GetAttributeOfType <DescriptionAttribute>().Description;
                rbRouteType.Checked  += rbRouteType_Checked;

                if (type == RouteOperationsType.Standard)
                {
                    rbRouteType.IsChecked = true;
                }

                panelRouteType.Children.Add(rbRouteType);
            }

            this.RouteOperations = RouteOperationsType.Standard;

            autogeneratePanel.Children.Add(panelRouteType);

            Button btnAdd = new Button();

            btnAdd.Uid = "104";
            btnAdd.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnAdd.Height            = Double.NaN;
            btnAdd.Width             = Double.NaN;
            btnAdd.Click            += new RoutedEventHandler(btnAdd_Click);
            btnAdd.Margin            = new Thickness(5, 0, 0, 0);
            btnAdd.Content           = Translator.GetInstance().GetString("General", btnAdd.Uid);
            btnAdd.IsEnabled         = cbRoute.Items.Count > 0;
            btnAdd.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            btnAdd.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");

            autogeneratePanel.Children.Add(btnAdd);

            cbRegion.SelectedIndex = 0;

            return(autogeneratePanel);
        }
Exemple #19
0
        //creates the panel for the human statistics
        private StackPanel createHumanStatisticsPanel()
        {
            StackPanel panelHumanStatistics = new StackPanel();

            panelHumanStatistics.Margin = new Thickness(0, 10, 0, 0);

            TextBlock txtHeader = new TextBlock();

            txtHeader.Uid    = "1005";
            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("PageAirlineStatistics", txtHeader.Uid);

            panelHumanStatistics.Children.Add(txtHeader);

            ListBox lbHumanStats = new ListBox();

            lbHumanStats.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbHumanStats.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            panelHumanStatistics.Children.Add(lbHumanStats);

            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1006"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", StatisticsHelpers.GetHumanOnTime()))));
            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1007"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", StatisticsHelpers.GetHumanFillAverage() * 100))));
            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1008"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", Ratings.GetCustomerHappiness(GameObject.GetInstance().HumanAirline)))));
            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1009"), UICreator.CreateTextBlock(string.Format("{0:0.00}", StatisticsHelpers.GetHumanAvgTicketPPD()))));
            lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1012"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", Ratings.GetEmployeeHappiness(GameObject.GetInstance().HumanAirline)))));
            return(panelHumanStatistics);
        }
Exemple #20
0
        //shows the ratings
        private void showRatings()
        {
            lbRatings.Items.Clear();

            lbRatings.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1013"), UICreator.CreateTextBlock(this.Airline.Ratings.CustomerHappinessRating.ToString())));
            lbRatings.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1014"), UICreator.CreateTextBlock(this.Airline.Ratings.EmployeeHappinessRating.ToString())));
            lbRatings.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1015"), UICreator.CreateTextBlock(this.Airline.Ratings.MaintenanceRating.ToString())));
            lbRatings.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1016"), UICreator.CreateTextBlock(this.Airline.Ratings.SafetyRating.ToString())));
            lbRatings.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1017"), UICreator.CreateTextBlock(this.Airline.Ratings.SecurityRating.ToString())));
        }
Exemple #21
0
        private ComboBox cbAirport;// cbName;
        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);
        }
Exemple #22
0
        public PageNewGame()
        {
            OpponentType = OpponentSelect.Random;

            InitializeComponent();

            popUpSplash = new Popup();

            popUpSplash.Child           = UICreator.CreateSplashWindow();
            popUpSplash.Placement       = PlacementMode.Center;
            popUpSplash.PlacementTarget = PageNavigator.MainWindow;
            popUpSplash.IsOpen          = false;

            StackPanel panelContent = new StackPanel();

            panelContent.Margin = new Thickness(10, 0, 10, 0);
            panelContent.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;

            Panel panelLogo = UICreator.CreateGameLogo();

            panelLogo.Margin = new Thickness(0, 0, 0, 20);

            panelContent.Children.Add(panelLogo);

            TextBlock txtHeader = new TextBlock();

            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Uid        = "1001";
            txtHeader.Text       = Translator.GetInstance().GetString("PageNewGame", txtHeader.Uid);
            panelContent.Children.Add(txtHeader);

            lbContentBasics = new ListBox();
            lbContentBasics.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbContentBasics.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
            lbContentBasics.MaxHeight = GraphicsHelpers.GetContentHeight() / 2;

            txtNarrative = new TextBox();
            txtNarrative.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            txtNarrative.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            txtNarrative.Background          = Brushes.Transparent;
            txtNarrative.TextWrapping        = TextWrapping.Wrap;
            txtNarrative.FontStyle           = FontStyles.Italic;
            txtNarrative.Width      = 500;
            txtNarrative.Height     = 100;
            txtNarrative.Uid        = "1015";
            txtNarrative.IsReadOnly = true;
            txtNarrative.Text       = Translator.GetInstance().GetString("PageNewGame", txtNarrative.Uid);
            txtNarrative.Visibility = System.Windows.Visibility.Collapsed;

            panelContent.Children.Add(txtNarrative);

            panelContent.Children.Add(lbContentBasics);

            lbContentHuman            = new ListBox();
            lbContentHuman.Visibility = System.Windows.Visibility.Collapsed;
            lbContentHuman.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
            lbContentHuman.MaxHeight  = GraphicsHelpers.GetContentHeight() / 2;
            lbContentHuman.Visibility = System.Windows.Visibility.Collapsed;

            panelContent.Children.Add(lbContentHuman);

            cbContinent = new ComboBox();
            cbContinent.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbContinent.Width             = 200;
            cbContinent.DisplayMemberPath = "Name";
            cbContinent.SelectedValuePath = "Name";

            cbContinent.Items.Add(new Continent("100", "All continents"));

            foreach (Continent continent in Continents.GetContinents().OrderBy(c => c.Name))
            {
                cbContinent.Items.Add(continent);
            }

            cbContinent.SelectionChanged += cbContinent_SelectionChanged;
            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1022"), cbContinent));

            cbRegion = new ComboBox();
            cbRegion.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbRegion.Width             = 200;
            cbRegion.DisplayMemberPath = "Name";
            cbRegion.SelectedValuePath = "Name";

            cbRegion.Items.Add(Regions.GetRegion("100"));
            foreach (Region region in Regions.GetRegions().FindAll(r => Airlines.GetAirlines(r).Count > 0).OrderBy(r => r.Name))
            {
                cbRegion.Items.Add(region);
            }

            cbRegion.SelectionChanged += new SelectionChangedEventHandler(cbRegion_SelectionChanged);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1012"), cbRegion));
            // chs, 2011-19-10 added for the possibility of creating a new airline
            WrapPanel panelAirline = new WrapPanel();

            cbAirline = new ComboBox();
            cbAirline.SetResourceReference(ComboBox.ItemTemplateProperty, "AirlineLogoItem");
            cbAirline.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAirline.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbAirline.SelectionChanged   += new SelectionChangedEventHandler(cbAirline_SelectionChanged);
            cbAirline.Width = 200;

            List <Airline> airlines = Airlines.GetAllAirlines();

            airlines.Sort((delegate(Airline a1, Airline a2) { return(a1.Profile.Name.CompareTo(a2.Profile.Name)); }));

            cbAirline.ItemsSource = airlines;

            panelAirline.Children.Add(cbAirline);

            Button btnAddAirline = new Button();

            btnAddAirline.Margin     = new Thickness(5, 0, 0, 0);
            btnAddAirline.Background = Brushes.Transparent;
            btnAddAirline.Click     += new RoutedEventHandler(btnAddAirline_Click);

            Image imgAddAirline = new Image();

            imgAddAirline.Source = new BitmapImage(new Uri(@"/Data/images/add.png", UriKind.RelativeOrAbsolute));
            imgAddAirline.Height = 16;
            RenderOptions.SetBitmapScalingMode(imgAddAirline, BitmapScalingMode.HighQuality);

            btnAddAirline.Content = imgAddAirline;

            panelAirline.Children.Add(btnAddAirline);

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1002"), panelAirline));

            txtIATA = UICreator.CreateTextBlock("");
            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1003"), txtIATA));

            txtAirlineType = UICreator.CreateTextBlock("");
            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1021"), txtAirlineType));

            StackPanel panelCountry = new StackPanel();

            cbCountry = new ComboBox();
            cbCountry.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbCountry.SetResourceReference(ComboBox.ItemTemplateProperty, "CountryFlagLongItem");
            cbCountry.Width             = 150;
            cbCountry.SelectionChanged += cbCountry_SelectionChanged;

            panelCountry.Children.Add(cbCountry);

            cbLocalCurrency = new CheckBox();
            cbLocalCurrency.FlowDirection       = System.Windows.FlowDirection.RightToLeft;
            cbLocalCurrency.Content             = Translator.GetInstance().GetString("PageNewGame", "1014");
            cbLocalCurrency.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
            cbLocalCurrency.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

            panelCountry.Children.Add(cbLocalCurrency);

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1004"), panelCountry));


            txtName             = new TextBox();
            txtName.Background  = Brushes.Transparent;
            txtName.BorderBrush = Brushes.Black;
            txtName.Width       = 200;


            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1005"), txtName));

            // chs, 2011-19-10 added to show the airline color
            airlineColorRect                 = new Rectangle();
            airlineColorRect.Width           = 40;
            airlineColorRect.Height          = 20;
            airlineColorRect.StrokeThickness = 1;
            airlineColorRect.Stroke          = Brushes.Black;
            airlineColorRect.Fill            = new AirlineBrushConverter().Convert(Airlines.GetAirline("ZA")) as Brush;
            airlineColorRect.Margin          = new Thickness(0, 2, 0, 2);

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1006"), airlineColorRect));

            cbAirport = new ComboBox();
            cbAirport.SetResourceReference(ComboBox.ItemTemplateProperty, "AirportCountryItem");
            cbAirport.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAirport.IsSynchronizedWithCurrentItem = true;
            cbAirport.HorizontalAlignment           = System.Windows.HorizontalAlignment.Left;
            cbAirport.SelectionChanged += new SelectionChangedEventHandler(cbAirports_SelectionChanged);

            List <Airport> airportsList = Airports.GetAllAirports();

            airportsView = CollectionViewSource.GetDefaultView(airportsList);
            airportsView.SortDescriptions.Add(new SortDescription("Profile.Name", ListSortDirection.Ascending));

            cbAirport.ItemsSource = airportsView;

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1007"), cbAirport));

            cbStartYear = new ComboBox();
            cbStartYear.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbStartYear.Width = 60;
            for (int i = GameObject.StartYear; i < DateTime.Now.Year + 2; i++)
            {
                cbStartYear.Items.Add(i);
            }

            cbStartYear.SelectionChanged += new SelectionChangedEventHandler(cbStartYear_SelectionChanged);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1008"), cbStartYear));

            cbTimeZone = new ComboBox();
            cbTimeZone.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbTimeZone.Width             = 300;
            cbTimeZone.DisplayMemberPath = "DisplayName";
            cbTimeZone.SelectedValuePath = "DisplayName";


            foreach (GameTimeZone gtz in TimeZones.GetTimeZones())
            {
                cbTimeZone.Items.Add(gtz);
            }

            cbTimeZone.SelectedItem = TimeZones.GetTimeZones().Find(delegate(GameTimeZone gtz) { return(gtz.UTCOffset == new TimeSpan(0, 0, 0)); });

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1009"), cbTimeZone));

            cbFocus = new ComboBox();
            cbFocus.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbFocus.Width = 100;

            foreach (Airline.AirlineFocus focus in Enum.GetValues(typeof(Airline.AirlineFocus)))
            {
                cbFocus.Items.Add(focus);
            }

            cbFocus.SelectedIndex = 0;

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1013"), cbFocus));

            WrapPanel panelDifficulty = new WrapPanel();

            cbDifficulty = new ComboBox();
            cbDifficulty.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDifficulty.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbDifficulty.Width             = 100;
            cbDifficulty.DisplayMemberPath = "Name";
            cbDifficulty.SelectedValuePath = "Name";

            foreach (DifficultyLevel difficulty in DifficultyLevels.GetDifficultyLevels())
            {
                cbDifficulty.Items.Add(difficulty);
            }

            cbDifficulty.SelectedIndex = 0;

            panelDifficulty.Children.Add(cbDifficulty);

            Button btnAddDifficulty = new Button();

            btnAddDifficulty.Margin     = new Thickness(5, 0, 0, 0);
            btnAddDifficulty.Background = Brushes.Transparent;
            btnAddDifficulty.Click     += new RoutedEventHandler(btnAddDifficulty_Click);

            Image imgAddDifficulty = new Image();

            imgAddDifficulty.Source = new BitmapImage(new Uri(@"/Data/images/add.png", UriKind.RelativeOrAbsolute));
            imgAddDifficulty.Height = 16;
            RenderOptions.SetBitmapScalingMode(imgAddDifficulty, BitmapScalingMode.HighQuality);

            btnAddDifficulty.Content = imgAddDifficulty;

            panelDifficulty.Children.Add(btnAddDifficulty);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1011"), panelDifficulty));

            WrapPanel panelOpponents = new WrapPanel();

            cbOpponents = new ComboBox();
            cbOpponents.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbOpponents.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbOpponents.Width = 50;
            cbOpponents.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right;
            for (int i = 0; i < Airlines.GetAllAirlines().Count; i++)
            {
                cbOpponents.Items.Add(i);
            }

            cbOpponents.SelectedIndex = 3;

            panelOpponents.Children.Add(cbOpponents);

            cbSameRegion = new CheckBox();
            cbSameRegion.FlowDirection     = System.Windows.FlowDirection.RightToLeft;
            cbSameRegion.Content           = Translator.GetInstance().GetString("PageNewGame", "1017");
            cbSameRegion.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            cbSameRegion.Margin            = new Thickness(5, 0, 0, 0);

            panelOpponents.Children.Add(cbSameRegion);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1010"), panelOpponents));

            WrapPanel panelOpponentSelect = new WrapPanel();

            RadioButton rbRandomOpponents = new RadioButton();

            rbRandomOpponents.IsChecked = true;
            rbRandomOpponents.GroupName = "Opponent";
            rbRandomOpponents.Content   = Translator.GetInstance().GetString("PageNewGame", "1018");
            rbRandomOpponents.Checked  += rbRandomOpponents_Checked;

            panelOpponentSelect.Children.Add(rbRandomOpponents);

            RadioButton rbSelectOpponents = new RadioButton();

            rbSelectOpponents.GroupName = "Opponent";
            rbSelectOpponents.Content   = Translator.GetInstance().GetString("PageNewGame", "1019");
            rbSelectOpponents.Checked  += rbSelectOpponents_Checked;
            rbSelectOpponents.Margin    = new Thickness(5, 0, 0, 0);

            panelOpponentSelect.Children.Add(rbSelectOpponents);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1020"), panelOpponentSelect));

            cbDayTurnEnabled = new CheckBox();
            cbDayTurnEnabled.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            cbDayTurnEnabled.IsChecked         = true;

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1016"), cbDayTurnEnabled));

            WrapPanel panelButtons = new WrapPanel();

            panelButtons.Margin = new Thickness(0, 5, 0, 0);
            panelContent.Children.Add(panelButtons);

            btnCreate = new Button();
            btnCreate.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnCreate.Click  += new RoutedEventHandler(btnCreate_Click);
            btnCreate.Height  = Double.NaN;
            btnCreate.Width   = Double.NaN;
            btnCreate.Uid     = "203";
            btnCreate.Content = Translator.GetInstance().GetString("PageNewGame", btnCreate.Uid);
            btnCreate.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            panelButtons.Children.Add(btnCreate);

            btnBack = new Button();
            btnBack.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnBack.Height  = Double.NaN;
            btnBack.Width   = Double.NaN;
            btnBack.Uid     = "119";
            btnBack.Content = Translator.GetInstance().GetString("General", btnBack.Uid);
            btnBack.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnBack.Margin     = new Thickness(5, 0, 0, 0);
            btnBack.Click     += btnBack_Click;
            btnBack.Visibility = System.Windows.Visibility.Collapsed;
            panelButtons.Children.Add(btnBack);

            Button btnExit = new Button();

            btnExit.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnExit.Height  = double.NaN;
            btnExit.Width   = double.NaN;
            btnExit.Uid     = "202";
            btnExit.Content = Translator.GetInstance().GetString("PageNewGame", btnExit.Uid);
            btnExit.Margin  = new Thickness(5, 0, 0, 0);
            btnExit.Click  += new RoutedEventHandler(btnCancel_Click);
            btnExit.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            panelButtons.Children.Add(btnExit);

            base.setTopMenu(new PageTopMenu());

            base.hideNavigator();

            base.hideBottomMenu();

            base.setContent(panelContent);

            base.setHeaderContent(Translator.GetInstance().GetString("PageNewGame", "200"));

            cbStartYear.SelectedItem = DateTime.Now.Year;



            showPage(this);
        }
        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;
        }
Exemple #24
0
        //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);
        }
Exemple #25
0
        //creates the panel for auto generation of time table from a route
        private WrapPanel createAutoGeneratePanel()
        {
            WrapPanel autogeneratePanel = new WrapPanel();

            cbRegion = new ComboBox();
            cbRegion.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbRegion.Width             = 150;
            cbRegion.DisplayMemberPath = "Name";
            cbRegion.SelectedValuePath = "Name";
            cbRegion.SelectionChanged += cbRegion_SelectionChanged;
            cbRegion.Items.Add(Regions.GetRegion("100"));

            List <Region> regions = GameObject.GetInstance().HumanAirline.Routes.Where(r => r.Destination1.Profile.Country.Region == r.Destination2.Profile.Country.Region).Select(r => r.Destination1.Profile.Country.Region).ToList();

            regions.AddRange(GameObject.GetInstance().HumanAirline.Routes.Where(r => r.Destination1.Profile.Country == GameObject.GetInstance().HumanAirline.Profile.Country).Select(r => r.Destination2.Profile.Country.Region));
            regions.AddRange(GameObject.GetInstance().HumanAirline.Routes.Where(r => r.Destination2.Profile.Country == GameObject.GetInstance().HumanAirline.Profile.Country).Select(r => r.Destination1.Profile.Country.Region));


            foreach (Region region in regions.Distinct())
            {
                cbRegion.Items.Add(region);
            }

            autogeneratePanel.Children.Add(cbRegion);

            cbRoute = new ComboBox();
            cbRoute.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbRoute.SelectionChanged += new SelectionChangedEventHandler(cbAutoRoute_SelectionChanged);
            cbRoute.ItemTemplate      = this.Resources["RouteItem"] as DataTemplate;

            foreach (Route route in this.Airliner.Airliner.Airline.Routes.FindAll(r => this.Airliner.Airliner.Type.Range > r.getDistance() && !r.Banned))
            {
                cbRoute.Items.Add(route);
            }

            autogeneratePanel.Children.Add(cbRoute);

            cbFlightCode = new ComboBox();
            cbFlightCode.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");

            foreach (string flightCode in this.Airliner.Airliner.Airline.getFlightCodes())
            {
                cbFlightCode.Items.Add(flightCode);
            }

            cbFlightCode.Items.RemoveAt(cbFlightCode.Items.Count - 1);

            cbFlightCode.SelectedIndex = 0;

            autogeneratePanel.Children.Add(cbFlightCode);

            TextBlock txtFlightsPerDay = UICreator.CreateTextBlock("Flights per day");

            txtFlightsPerDay.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            txtFlightsPerDay.Margin            = new Thickness(10, 0, 5, 0);

            autogeneratePanel.Children.Add(txtFlightsPerDay);

            cbFlightsPerDay = new ComboBox();
            cbFlightsPerDay.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");

            //cbRoute.SelectedIndex = 0;

            autogeneratePanel.Children.Add(cbFlightsPerDay);

            cbBusinessRoute = new CheckBox();
            cbBusinessRoute.FlowDirection     = System.Windows.FlowDirection.RightToLeft;
            cbBusinessRoute.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            cbBusinessRoute.Unchecked        += cbBusinessRoute_Unchecked;
            cbBusinessRoute.Checked          += cbBusinessRoute_Checked;
            cbBusinessRoute.Content           = "Business route";
            cbBusinessRoute.Margin            = new Thickness(5, 0, 0, 0);

            autogeneratePanel.Children.Add(cbBusinessRoute);

            cbRegion.SelectedIndex = 0;

            return(autogeneratePanel);
        }
        //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);
        }
Exemple #28
0
        //creates the side panel for the airport size and zooming
        private StackPanel createAirportSizeSidePanel()
        {
            StackPanel sidePanel = new StackPanel();

            sidePanel.Margin = new Thickness(5, 0, 0, 0);

            foreach (GeneralHelpers.Size size in Enum.GetValues(typeof(GeneralHelpers.Size)))
            {
                WrapPanel panelSize = new WrapPanel();
                panelSize.Margin = new Thickness(0, 5, 0, 5);

                Ellipse eSize = new Ellipse();
                eSize.Width           = 20;
                eSize.Height          = 20;
                eSize.StrokeThickness = 2;
                eSize.Stroke          = Brushes.Black;
                eSize.Fill            = getSizeColor(size);

                panelSize.Children.Add(eSize);

                TextBlock txtSize = new TextBlock();
                txtSize.Text   = new TheAirline.GUIModel.HelpersModel.TextUnderscoreConverter().Convert(size).ToString();
                txtSize.Margin = new Thickness(5, 0, 0, 0);

                panelSize.Children.Add(txtSize);

                sidePanel.Children.Add(panelSize);
            }
            StackPanel panelZoom = new StackPanel();

            panelZoom.Margin = new Thickness(0, 10, 0, 0);

            TextBlock txtMapHeader = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PopUpMap", "1000"));

            txtMapHeader.FontWeight      = FontWeights.Bold;
            txtMapHeader.FontSize        = 14;
            txtMapHeader.TextDecorations = TextDecorations.Underline;

            panelZoom.Children.Add(txtMapHeader);

            panelZoom.Children.Add(UICreator.CreateTextBlock(Translator.GetInstance().GetString("PopUpMap", "1001")));
            panelZoom.Children.Add(UICreator.CreateTextBlock(Translator.GetInstance().GetString("PopUpMap", "1002")));
            panelZoom.Children.Add(UICreator.CreateTextBlock(Translator.GetInstance().GetString("PopUpMap", "1003")));
            panelZoom.Children.Add(UICreator.CreateTextBlock(Translator.GetInstance().GetString("PopUpMap", "1004")));
            panelZoom.Children.Add(UICreator.CreateTextBlock(Translator.GetInstance().GetString("PopUpMap", "1005")));

            sidePanel.Children.Add(panelZoom);

            //var regions = airports.Select(a => a.Profile.Country.Region).Distinct();//from a in airports select a.Profile.Country.Region;

            WrapPanel panelZoomButtons = new WrapPanel();

            Button btnZoomIn = new Button();

            btnZoomIn.SetResourceReference(Button.StyleProperty, "StandardButtonStyle");
            //btnZoomIn.Height = Double.NaN;
            btnZoomIn.Width   = 30;
            btnZoomIn.Content = "+";
            btnZoomIn.Click  += btnZoomIn_Click;
            //  btnZoomIn.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");

            panelZoomButtons.Children.Add(btnZoomIn);

            Button btnZoomOut = new Button();

            btnZoomOut.SetResourceReference(Button.StyleProperty, "StandardButtonStyle");
            //btnZoomOut.Height = Double.NaN;
            btnZoomOut.Width   = 30;
            btnZoomOut.Content = "-";
            btnZoomOut.Margin  = new Thickness(5, 0, 0, 0);
            // btnZoomOut.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnZoomOut.Click += btnZoomOut_Click;

            panelZoomButtons.Children.Add(btnZoomOut);

            sidePanel.Children.Add(panelZoomButtons);

            return(sidePanel);
        }
        //creates the panel for adding a new entry
        private StackPanel createNewEntryPanel()
        {
            StackPanel newEntryPanel = new StackPanel();

            newEntryPanel.Margin = new Thickness(0, 10, 0, 0);

            WrapPanel entryPanel = new WrapPanel();

            newEntryPanel.Children.Add(entryPanel);

            Route.RouteType type = this.Airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Cargo ? Route.RouteType.Cargo : Route.RouteType.Passenger;

            var origins = this.Airliner.Airliner.Airline.Routes.Where(r => r.Type == type).SelectMany(r => r.getDestinations()).Distinct();

            origins.OrderBy(a => a.Profile.Name);

            cbOrigin = new ComboBox();
            cbOrigin.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbOrigin.SetResourceReference(ComboBox.ItemTemplateProperty, "AirportIATACountryItem");
            cbOrigin.Width             = 100;
            cbOrigin.SelectionChanged += cbOrigin_SelectionChanged;

            foreach (Airport origin in origins)
            {
                cbOrigin.Items.Add(origin);
            }

            entryPanel.Children.Add(cbOrigin);


            TextBlock txtTo = UICreator.CreateTextBlock("->");

            txtTo.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            txtTo.Margin            = new Thickness(5, 0, 5, 0);
            entryPanel.Children.Add(txtTo);

            cbDestination = new ComboBox();
            cbDestination.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDestination.SelectionChanged += cbDestination_SelectionChanged;
            cbDestination.Width             = 100;

            entryPanel.Children.Add(cbDestination);

            cbDay = new ComboBox();
            cbDay.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDay.Width  = 100;
            cbDay.Margin = new Thickness(10, 0, 0, 0);
            cbDay.Items.Add("Daily");

            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
            {
                cbDay.Items.Add(day);
            }

            cbDay.SelectedIndex = 0;

            entryPanel.Children.Add(cbDay);

            tpTime = new TimePicker();
            tpTime.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            tpTime.EndTime             = new TimeSpan(22, 0, 0);
            tpTime.StartTime           = new TimeSpan(6, 0, 0);
            tpTime.Value      = new DateTime(2011, 1, 1, 13, 0, 0);
            tpTime.Format     = TimeFormat.ShortTime;
            tpTime.Background = Brushes.Transparent;
            tpTime.SetResourceReference(TimePicker.ForegroundProperty, "TextColor");
            tpTime.BorderBrush = Brushes.Black;

            entryPanel.Children.Add(tpTime);

            cbFlightCode = new ComboBox();
            cbFlightCode.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");

            foreach (string flightCode in this.Airliner.Airliner.Airline.getFlightCodes())
            {
                cbFlightCode.Items.Add(flightCode);
            }

            cbFlightCode.SelectedIndex = 0;

            entryPanel.Children.Add(cbFlightCode);

            Button btnAdd = new Button();

            btnAdd.Uid = "104";
            btnAdd.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnAdd.Height            = Double.NaN;
            btnAdd.Width             = Double.NaN;
            btnAdd.Click            += new RoutedEventHandler(btnAdd_Click);
            btnAdd.Margin            = new Thickness(5, 0, 0, 0);
            btnAdd.Content           = Translator.GetInstance().GetString("General", btnAdd.Uid);
            btnAdd.IsEnabled         = cbOrigin.Items.Count > 0;
            btnAdd.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            btnAdd.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");

            entryPanel.Children.Add(btnAdd);


            return(newEntryPanel);
        }
        //creates the panel
        private void createPanel()
        {
            ScrollViewer scroller = new ScrollViewer();

            scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scroller.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            scroller.MaxHeight = GraphicsHelpers.GetContentHeight() - 50;
            scroller.Margin    = new Thickness(0, 0, 50, 0);

            StackPanel panelAlliance = new StackPanel();

            WrapPanel panelHeader = new WrapPanel();

            panelAlliance.Children.Add(panelHeader);

            if (this.Alliance.Logo != null)
            {
                Image imgLogo = new Image();
                imgLogo.Source = new BitmapImage(new Uri(this.Alliance.Logo, UriKind.RelativeOrAbsolute));
                imgLogo.Width  = 32;
                imgLogo.Margin = new Thickness(0, 0, 10, 0);
                imgLogo.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                RenderOptions.SetBitmapScalingMode(imgLogo, BitmapScalingMode.HighQuality);
                panelHeader.Children.Add(imgLogo);
            }

            TextBlock txtAirlineName = UICreator.CreateTextBlock(this.Alliance.Name);

            txtAirlineName.FontSize          = 20;
            txtAirlineName.FontWeight        = FontWeights.Bold;
            txtAirlineName.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            panelHeader.Children.Add(txtAirlineName);


            ContentControl txtHeader = new ContentControl();

            txtHeader.ContentTemplate     = this.Resources["AirlinesHeader"] as DataTemplate;
            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.Margin = new Thickness(0, 5, 0, 0);
            panelAlliance.Children.Add(txtHeader);


            ListBox lbMembers = new ListBox();

            lbMembers.ItemTemplate = this.Resources["AirlineItem"] as DataTemplate;
            lbMembers.MaxHeight    = GraphicsHelpers.GetContentHeight() / 2;
            lbMembers.ItemContainerStyleSelector = new ListBoxItemStyleSelector();

            List <Airline> airlines = this.Alliance.Members.Select(m => m.Airline).ToList();

            airlines.Sort((delegate(Airline a1, Airline a2) { return(a1.Profile.Name.CompareTo(a2.Profile.Name)); }));

            foreach (Airline airline in airlines)
            {
                lbMembers.Items.Add(airline);
            }

            panelAlliance.Children.Add(lbMembers);

            ContentControl txtPendingHeader = new ContentControl();

            txtPendingHeader.ContentTemplate     = this.Resources["PendingsHeader"] as DataTemplate;
            txtPendingHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtPendingHeader.Margin = new Thickness(0, 5, 0, 0);

            panelAlliance.Children.Add(txtPendingHeader);

            ListBox lbPendings = new ListBox();

            lbPendings.ItemTemplate = this.Resources["PendingMemberItem"] as DataTemplate;
            lbPendings.MaxHeight    = GraphicsHelpers.GetContentHeight() / 2;
            lbPendings.ItemContainerStyleSelector = new ListBoxItemStyleSelector();

            this.Alliance.PendingMembers.ToList().ForEach(p => lbPendings.Items.Add(p));

            panelAlliance.Children.Add(lbPendings);

            panelAlliance.Children.Add(createInfoPanel());

            Button btnMap = new Button();

            btnMap.Uid = "204";
            btnMap.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnMap.Height  = Double.NaN;
            btnMap.Width   = Double.NaN;
            btnMap.Content = Translator.GetInstance().GetString("PanelAlliance", btnMap.Uid);
            btnMap.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnMap.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            btnMap.Click += new RoutedEventHandler(btnMap_Click);
            btnMap.Margin = new Thickness(0, 5, 0, 0);

            panelAlliance.Children.Add(btnMap);

            panelAlliance.Children.Add(createButtonsPanel());

            scroller.Content = panelAlliance;

            this.Content = scroller;
        }