private void rbDailyFlights_Checked(object sender, RoutedEventArgs e) { cbFlightsPerDay.Visibility = System.Windows.Visibility.Visible; cbFlightsPerWeek.Visibility = System.Windows.Visibility.Collapsed; this.Interval = FlightInterval.Daily; }
//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); }
private void rbWeeklyFlights_Checked(object sender, RoutedEventArgs e) { cbFlightsPerWeek.Visibility = System.Windows.Visibility.Visible; cbFlightsPerDay.Visibility = System.Windows.Visibility.Collapsed; cbFlightsPerDay.SelectedIndex = 0; this.Interval = FlightInterval.Weekly; }
//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; }