private void cbContinent_SelectionChanged(object sender, SelectionChangedEventArgs e) { Continent selectedContinent = (Continent)cbContinent.SelectedItem; cbRegion.Items.Clear(); if (selectedContinent.Uid == "100") { foreach (Region region in Regions.GetAllRegions().OrderBy(r => r.Name)) { cbRegion.Items.Add(region); } } else { if (selectedContinent.Regions.Count > 1) { cbRegion.Items.Add(Regions.GetRegion("100")); } foreach (Region region in selectedContinent.Regions.OrderBy(r => r.Name)) { cbRegion.Items.Add(region); } } cbRegion.SelectedIndex = 0; }
private void cbContinent_SelectionChanged(object sender, SelectionChangedEventArgs e) { Continent continent = (Continent)cbContinent.SelectedItem; if (continent.Regions.Count == 0) { cbRegion.Items.Clear(); 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); } } else { cbRegion.Items.Clear(); if (continent.Regions.Count > 1) { cbRegion.Items.Add(Regions.GetRegion("100")); } foreach (Region region in continent.Regions.FindAll(r => Airlines.GetAirlines(r).Count > 0).OrderBy(r => r.Name)) { cbRegion.Items.Add(region); } } }
public PageRoutePlanner(FleetAirliner airliner) { this.Airliner = airliner; this.Entries = new ObservableCollection <RouteTimeTableEntry>(); this.Entries.CollectionChanged += Entries_CollectionChanged; this.AllRoutes = new List <RoutePlannerItemMVVM>(); this.Intervals = new ObservableCollection <int>() { 1, 2, 3, 4, 5, 6 }; this.Routes = this.Airliner.Airliner.Airline.Routes.Where(r => r.getDistance() <= this.Airliner.Airliner.Type.Range).ToList(); this.AllRegions = new List <Region>(); this.AllRegions.Add(Regions.GetRegion("100")); var routeRegions = this.Routes.Select(r => r.Destination1.Profile.Country.Region).ToList(); routeRegions.AddRange(this.Routes.Select(r => r.Destination2.Profile.Country.Region)); foreach (Region region in routeRegions.Distinct()) { this.AllRegions.Add(region); } foreach (Route route in this.Airliner.Airliner.Airline.Routes.Where(r => r.getDistance() <= this.Airliner.Airliner.Type.Range)) { this.AllRoutes.Add(new RoutePlannerItemMVVM(route, this.Airliner.Airliner.Type)); } this.OutboundAirports = new List <Airport>(); var routeAirports = this.Routes.Select(r => r.Destination1).ToList(); routeAirports.AddRange(this.Routes.Select(r => r.Destination2)); foreach (Airport airport in routeAirports.Distinct()) { this.OutboundAirports.Add(airport); } this.StartTimes = new ObservableCollection <TimeSpan>(); for (int i = 0; i < 20; i++) { this.StartTimes.Add(new TimeSpan(6, i * 15, 0)); } this.StopoverMinutes = new List <int>() { 45, 60, 75, 90, 105, 120 }; this.Loaded += PageRoutePlanner_Loaded; InitializeComponent(); }
//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); }
public PageRoutePlanner(FleetAirliner airliner) { this.ShowSeason = Weather.Season.All_Year; this.Airliner = airliner; this.Entries = new ObservableCollection <RouteTimeTableEntry>(); this.Entries.CollectionChanged += Entries_CollectionChanged; this.ViewEntries = new ObservableCollection <RouteTimeTableEntry>(); this.ViewEntries.CollectionChanged += ViewEntries_CollectionChanged; this.IsLongRoute = false; this.AllRoutes = new List <RoutePlannerItemMVVM>(); this.Intervals = new ObservableCollection <int>() { 1, 2, 3, 4, 5, 6 }; this.Routes = new ObservableCollection <Route>(); Route.RouteType routeType = (Route.RouteType)Enum.Parse(typeof(Route.RouteType), this.Airliner.Airliner.Type.TypeAirliner.ToString(), true);; foreach (Route route in this.Airliner.Airliner.Airline.Routes.Where(r => r.getDistance() <= this.Airliner.Airliner.Type.Range && r.Type == routeType)) { this.Routes.Add(route); } this.AllRegions = new List <Region>(); this.AllRegions.Add(Regions.GetRegion("100")); var routeRegions = this.Routes.Select(r => r.Destination1.Profile.Country.Region).ToList(); routeRegions.AddRange(this.Routes.Select(r => r.Destination2.Profile.Country.Region)); foreach (Region region in routeRegions.Distinct()) { this.AllRegions.Add(region); } foreach (Route route in this.Airliner.Airliner.Airline.Routes.Where(r => r.getDistance() <= this.Airliner.Airliner.Type.Range && r.Type == routeType)) { this.AllRoutes.Add(new RoutePlannerItemMVVM(route, this.Airliner.Airliner.Type)); } this.OutboundAirports = new List <Airport>(); var routeAirports = this.Routes.Select(r => r.Destination1).ToList(); routeAirports.AddRange(this.Routes.Select(r => r.Destination2)); foreach (Airport airport in routeAirports.Distinct()) { this.OutboundAirports.Add(airport); } this.StartTimes = new ObservableCollection <TimeSpan>(); for (int i = 0; i < 20; i++) { this.StartTimes.Add(new TimeSpan(6, i * 15, 0)); } this.StopoverMinutes = new List <int>() { 45, 60, 75, 90, 105, 120 }; setCanTransferSchedule(); this.Loaded += PageRoutePlanner_Loaded; InitializeComponent(); }
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 PageSearchAirports(PageAirports parent) { InitializeComponent(); this.ParentPage = parent; StackPanel panelSearch = new StackPanel(); panelSearch.Margin = new Thickness(0, 10, 50, 0); 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("PageSearchAirports", txtHeader.Uid); panelSearch.Children.Add(txtHeader); ListBox lbSearch = new ListBox(); lbSearch.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbSearch.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelSearch.Children.Add(lbSearch); WrapPanel panelCheckBoxes = new WrapPanel(); lbSearch.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageSearchAirports", "1004"), panelCheckBoxes)); cbHumanAirports = new CheckBox(); cbHumanAirports.Uid = "1002"; cbHumanAirports.Content = Translator.GetInstance().GetString("PageSearchAirports", cbHumanAirports.Uid); cbHumanAirports.IsChecked = false; cbHumanAirports.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; cbHumanAirports.FlowDirection = System.Windows.FlowDirection.RightToLeft; panelCheckBoxes.Children.Add(cbHumanAirports); cbHubs = new CheckBox(); cbHubs.Uid = "1003"; cbHubs.Content = Translator.GetInstance().GetString("PageSearchAirports", cbHubs.Uid); cbHubs.IsChecked = false; cbHubs.FlowDirection = System.Windows.FlowDirection.RightToLeft; cbHubs.Margin = new Thickness(5, 0, 0, 0); panelCheckBoxes.Children.Add(cbHubs); cbRegion = new ComboBox(); cbRegion.DisplayMemberPath = "Name"; cbRegion.SelectedValuePath = "Name"; cbRegion.Width = 250; cbRegion.Background = Brushes.Transparent; cbRegion.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle"); cbRegion.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; cbRegion.SelectionChanged += new SelectionChangedEventHandler(cbRegions_SelectionChanged); List <Region> regions = Regions.GetRegions(); regions.Sort(delegate(Region r1, Region r2){ return(r1.Name.CompareTo(r2.Name)); }); // 100 is the predefined Uid for "All Regions" Region regionAll = Regions.GetRegion("100"); cbRegion.Items.Add(regionAll); foreach (Region region in regions) { cbRegion.Items.Add(region); } lbSearch.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageSearchAirports", "1005"), cbRegion)); cbCountry = new ComboBox(); cbCountry.SetResourceReference(ComboBox.ItemTemplateProperty, "CountryFlagLongItem"); cbCountry.Width = 250; //cbCountries.Style = this.Resources["ComboBoxStyle"] as Style; cbCountry.Background = Brushes.Transparent; cbCountry.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle"); cbCountry.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; List <Country> countries = Countries.GetCountries(); countries.Sort(delegate(Country c1, Country c2) { return(c1.Name.CompareTo(c2.Name)); }); // 100 is the predefined Uid for "All Countries" Country countryAll = Countries.GetCountry("100"); cbCountry.Items.Add(countryAll); foreach (Country country in countries) { cbCountry.Items.Add(country); } cbCountry.SelectedItem = countryAll; cbRegion.SelectedItem = regionAll; lbSearch.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageSearchAirports", "1006"), cbCountry)); WrapPanel panelSizes = new WrapPanel(); cbCompareSize = new ComboBox(); createCompareComboBox(cbCompareSize); panelSizes.Children.Add(cbCompareSize); cbSize = new ComboBox(); cbSize.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle"); cbSize.Background = Brushes.Transparent; cbSize.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; cbSize.SetResourceReference(ComboBox.ItemTemplateProperty, "TextUnderscoreTextBlock"); cbSize.Width = 100; foreach (GeneralHelpers.Size type in Enum.GetValues(typeof(GeneralHelpers.Size))) { cbSize.Items.Add(type); } cbSize.SelectedIndex = 0; panelSizes.Children.Add(cbSize); lbSearch.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageSearchAirports", "1007"), panelSizes)); txtTextSearch = new TextBox(); txtTextSearch.Width = 300; txtTextSearch.Background = Brushes.Transparent; txtTextSearch.Foreground = Brushes.White; txtTextSearch.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; lbSearch.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageSearchAirports", "1008"), txtTextSearch)); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); panelButtons.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; panelSearch.Children.Add(panelButtons); Button btnSearch = new Button(); btnSearch.Uid = "109"; btnSearch.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnSearch.Height = Double.NaN; btnSearch.Width = Double.NaN; btnSearch.IsDefault = true; btnSearch.Content = Translator.GetInstance().GetString("General", btnSearch.Uid); btnSearch.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnSearch.Click += new RoutedEventHandler(btnSearch_Click); panelButtons.Children.Add(btnSearch); Button btnClear = new Button(); btnClear.Uid = "110"; btnClear.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnClear.Width = Double.NaN; btnClear.Height = Double.NaN; btnClear.Margin = new Thickness(10, 0, 0, 0); btnClear.Content = Translator.GetInstance().GetString("General", btnClear.Uid); btnClear.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnClear.Click += new RoutedEventHandler(btnClear_Click); panelButtons.Children.Add(btnClear); this.Content = panelSearch; }
//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); 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); } entryPanel.Children.Add(cbRegion); cbRoute = new ComboBox(); cbRoute.ItemTemplate = this.Resources["RouteItem"] as DataTemplate; cbRoute.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle"); cbRoute.SelectionChanged += new SelectionChangedEventHandler(cbRoute_SelectionChanged); long requiredRunway = this.Airliner.Airliner.Type.MinRunwaylength; foreach (Route route in this.Airliner.Airliner.Airline.Routes.FindAll(r => this.Airliner.Airliner.Type.Range > r.getDistance() && !r.Banned && r.Destination1.getMaxRunwayLength() >= requiredRunway && r.Destination2.getMaxRunwayLength() >= requiredRunway).OrderBy(r => new AirportCodeConverter().Convert(r.Destination1)).ThenBy(r => new AirportCodeConverter().Convert(r.Destination2))) { string outboundRoute; if (route.HasStopovers) { string stopovers = string.Join("-", from s in route.Stopovers select new AirportCodeConverter().Convert(s.Stopover)); outboundRoute = string.Format("{0}-{1}-{2}", new AirportCodeConverter().Convert(route.Destination1), stopovers, new AirportCodeConverter().Convert(route.Destination2)); } else { outboundRoute = string.Format("{0}-{1}", new AirportCodeConverter().Convert(route.Destination1), new AirportCodeConverter().Convert(route.Destination2)); } ComboBoxItem item1 = new ComboBoxItem(); item1.Tag = new KeyValuePair <Route, Airport>(route, route.Destination2); item1.Content = outboundRoute; cbRoute.Items.Add(item1); string inboundRoute; if (route.HasStopovers) { var lStopovers = route.Stopovers; lStopovers.Reverse(); string stopovers = string.Join("-", from s in lStopovers select new AirportCodeConverter().Convert(s.Stopover)); inboundRoute = string.Format("{2}-{1}-{0}", new AirportCodeConverter().Convert(route.Destination1), stopovers, new AirportCodeConverter().Convert(route.Destination2)); } else { inboundRoute = string.Format("{0}-{1}", new AirportCodeConverter().Convert(route.Destination2), new AirportCodeConverter().Convert(route.Destination1)); } ComboBoxItem item2 = new ComboBoxItem(); item2.Tag = new KeyValuePair <Route, Airport>(route, route.Destination1); item2.Content = inboundRoute; cbRoute.Items.Add(item2); } entryPanel.Children.Add(cbRoute); 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 = cbRoute.Items.Count > 0; btnAdd.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; btnAdd.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); entryPanel.Children.Add(btnAdd); txtFlightTime = new TextBlock(); txtFlightTime.Text = "Flight time: "; newEntryPanel.Children.Add(txtFlightTime); //cbRoute.SelectedIndex = 0; cbRegion.SelectedIndex = 0; return(newEntryPanel); }
// Todo: Initialize via reflection & injection from configuration static DarkestDungeonGame() { Regions = GameBot.Plugins.Get <RegionPlugin>(); CampaignButton = Regions.GetRegion("CampaignButton"); }
//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); }