private void PageCreateRoute_Loaded(object sender, RoutedEventArgs e) { //hide the tab for a route TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Route") .FirstOrDefault(); matchingItem.Visibility = System.Windows.Visibility.Collapsed; var airlinerItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Airliner") .FirstOrDefault(); airlinerItem.Visibility = System.Windows.Visibility.Collapsed; } //sets the selected items for the facilities foreach (MVVMRouteClass rClass in this.Classes) { foreach (MVVMRouteFacility rFacility in rClass.Facilities) { rFacility.SelectedFacility = rFacility.Facilities.OrderBy(f => f.ServiceLevel).First(); } } }
private void btnDeleteRoute_Click(object sender, RoutedEventArgs e) { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2503"), string.Format(Translator.GetInstance().GetString("MessageBox", "2503", "message"), this.Route.Destination1.Profile.Name, this.Route.Destination2.Profile.Name), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { GameObject.GetInstance().HumanAirline.removeRoute(this.Route); if (this.Route.HasAirliner) { this.Route.getAirliners().ForEach(a => a.removeRoute(this.Route)); } TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Routes") .FirstOrDefault(); tab_main.SelectedItem = matchingItem; } } }
private void lnkFlightSchool_Click(object sender, RoutedEventArgs e) { FlightSchool fs = (FlightSchool)((Hyperlink)sender).Tag; TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Flightschool") .FirstOrDefault(); //matchingItem.IsSelected = true; matchingItem.Header = fs.Name; matchingItem.Visibility = System.Windows.Visibility.Visible; tab_main.SelectedItem = matchingItem; } Frame frmContent = UIHelpers.FindChild <Frame>(this.Tag as Page, "frmContent"); if (frmContent != null) { frmContent.Navigate(new PageShowFlightSchool(fs) { Tag = this.Tag }); } }
private void PageAirport_Loaded(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); frmContent.Navigate(new PageAirportInfo(this.Airport) { Tag = this }); TabControl tab_main = UIHelpers.FindChild <TabControl>(this, "tcMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Overview") .FirstOrDefault(); //matchingItem.IsSelected = true; matchingItem.Header = this.Airport.Airport.Profile.Name; matchingItem.Visibility = System.Windows.Visibility.Visible; tab_main.SelectedItem = matchingItem; } }
private void btnCreateGame_Click(object sender, RoutedEventArgs e) { this.StartData.Airline = (Airline)cbAirline.SelectedItem; this.StartData.Airport = (Airport)cbAirport.SelectedItem; this.StartData.CEO = (string)txtCEO.Text; this.StartData.HomeCountry = (Country)cbCountry.SelectedItem; this.StartData.TimeZone = (GameTimeZone)cbTimeZone.SelectedItem; this.StartData.LocalCurrency = cbLocalCurrency.IsChecked.Value && this.StartData.HomeCountry.HasLocalCurrency; if (!this.StartData.RandomOpponents) { PageNavigator.NavigateTo(new PageSelectOpponents(this.StartData)); } else { SplashControl scCreating = UIHelpers.FindChild <SplashControl>(this, "scCreating"); scCreating.Visibility = System.Windows.Visibility.Visible; BackgroundWorker bgWorker = new BackgroundWorker(); bgWorker.DoWork += (y, x) => { GameObjectHelpers.CreateGame(this.StartData); }; bgWorker.RunWorkerCompleted += (y, x) => { scCreating.Visibility = System.Windows.Visibility.Collapsed; PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline)); PageNavigator.ClearNavigator(); }; bgWorker.RunWorkerAsync(); } }
private void PageFleetAirliner_Loaded(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); frmContent.Navigate(new PageFleetAirlinerInformation(this.Airliner) { Tag = this }); TabControl tab_main = UIHelpers.FindChild <TabControl>(this, "tabMenu"); if (tab_main != null) { var infoItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Information") .FirstOrDefault(); //matchingItem.IsSelected = true; infoItem.Header = this.Airliner.Airliner.Name; var maintenanceItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Maintenance") .FirstOrDefault(); if (!this.Airliner.Airliner.Airliner.Airline.IsHuman) { maintenanceItem.Visibility = System.Windows.Visibility.Collapsed; } } }
private void tcMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { TabControl control = (TabControl)sender; string selection = ((TabItem)control.SelectedItem).Tag.ToString(); Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); if (selection == "Information" && frmContent != null) { frmContent.Navigate(new PageFleetAirlinerInformation(this.Airliner) { Tag = this }); } if (selection == "Maintenance" && frmContent != null) { frmContent.Navigate(new PageFleetAirlinerInsurances(this.Airliner) { Tag = this }); } if (selection == "Statistics" && frmContent != null) { frmContent.Navigate(new PageFleetAirlinerStatistics(this.Airliner) { Tag = this }); } }
private void tcMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { TabControl control = (TabControl)sender; string selection = ((TabItem)control.SelectedItem).Tag.ToString(); Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); if (selection == "Search" && frmContent != null) { frmContent.Navigate(new PageSearchAirports() { Tag = this }); } if (selection == "Airports" && frmContent != null) { frmContent.Navigate(new PageShowAirports() { Tag = this }); } if (selection == "Statistics" && frmContent != null) { frmContent.Navigate(new PageAirportsStatistics() { Tag = this }); } }
private void tcMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { TabControl control = (TabControl)sender; string selection = ((TabItem)control.SelectedItem).Tag.ToString(); Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); if (selection == "Routes" && frmContent != null) { frmContent.Navigate(new PageHumanRoutes() { Tag = this }); } if (selection == "Create" && frmContent != null) { frmContent.Navigate(new PageCreateRoute() { Tag = this }); } if (selection == "Airliners" && frmContent != null) { frmContent.Navigate(new PageAssignAirliners() { Tag = this }); } }
private void tcMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { TabControl control = (TabControl)sender; string selection = ((TabItem)control.SelectedItem).Tag.ToString(); Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); if (selection == "Overview" && frmContent != null) { frmContent.Navigate(new PageAirportInfo(this.Airport) { Tag = this }); } if (selection == "Facilities" && frmContent != null) { frmContent.Navigate(new PageAirportFacilities(this.Airport) { Tag = this }); } if (selection == "Traffic" && frmContent != null) { frmContent.Navigate(new PageAirportTraffic(this.Airport) { Tag = this }); } }
private void btnSearch_Click(object sender, RoutedEventArgs e) { ComboBox cbCountry = UIHelpers.FindChild <ComboBox>(this, "cbCountry"); ComboBox cbRegion = UIHelpers.FindChild <ComboBox>(this, "cbRegion"); TextBox txtText = UIHelpers.FindChild <TextBox>(this, "txtText"); string text = txtText.Text.Trim().ToUpper(); Country country = (Country)cbCountry.SelectedItem; Region region = (Region)cbRegion.SelectedItem; if (text == "112") { GameObject.GetInstance().addHumanMoney(10000000); } var airports = Airports.GetAllActiveAirports().Where(a => (a.Profile.IATACode.ToUpper().StartsWith(text) || a.Profile.ICAOCode.ToUpper().StartsWith(text) || a.Profile.Name.ToUpper().StartsWith(text) || a.Profile.Town.Name.ToUpper().StartsWith(text)) && ((country.Uid == "100" && (region.Uid == "100" || a.Profile.Country.Region == region)) || new CountryCurrentCountryConverter().Convert(a.Profile.Country) as Country == country)); Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); if (frmContent != null) { frmContent.Navigate(new PageShowAirports(airports.ToList()) { Tag = this.Tag }); } }
private void PageRoutePlanner_Loaded(object sender, RoutedEventArgs e) { TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Route") .FirstOrDefault(); matchingItem.Visibility = System.Windows.Visibility.Collapsed; } foreach (RouteTimeTableEntry entry in this.Airliner.Routes.SelectMany(r => r.TimeTable.Entries.Where(en => en.Airliner == this.Airliner))) { this.Entries.Add(entry); } setViewEntries(); setFlightNumbers(); cbRoute.SelectedIndex = 0; cbOutbound.SelectedIndex = 0; }
private void btnEdit_Click(object sender, RoutedEventArgs e) { Route route = (Route)((Button)sender).Tag; TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Route") .FirstOrDefault(); //matchingItem.IsSelected = true; matchingItem.Header = string.Format("{0}-{1}", route.Destination1.Profile.Name, route.Destination2.Profile.Name); matchingItem.Visibility = System.Windows.Visibility.Visible; tab_main.SelectedItem = matchingItem; } Frame frmContent = UIHelpers.FindChild <Frame>(this.Tag as Page, "frmContent"); if (frmContent != null) { frmContent.Navigate(new PageShowRoute(route) { Tag = this.Tag }); } }
private void btnCreate_Click(object sender, RoutedEventArgs e) { Slider slMoney = UIHelpers.FindChild <Slider>(this, "money"); Slider slLoan = UIHelpers.FindChild <Slider>(this, "loan"); Slider slPrice = UIHelpers.FindChild <Slider>(this, "price"); Slider slPassengers = UIHelpers.FindChild <Slider>(this, "passengers"); Slider slAI = UIHelpers.FindChild <Slider>(this, "AI"); Slider slStartData = UIHelpers.FindChild <Slider>(this, "startdata"); double money = slMoney.Value; double loan = slLoan.Value; double passengers = slPassengers.Value; double price = slPrice.Value; double AI = slAI.Value; double startData = slStartData.Value; DifficultyLevel level = new DifficultyLevel("Custom", money, loan, passengers, price, AI, startData); WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2406"), Translator.GetInstance().GetString("MessageBox", "2406", "message"), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { DifficultyLevels.AddDifficultyLevel(level); PageNavigator.NavigateTo(new PageNewGame()); } }
private void PageUsedAirliners_Loaded(object sender, RoutedEventArgs e) { TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Manufacturer") .FirstOrDefault(); matchingItem.Visibility = System.Windows.Visibility.Collapsed; matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Airliner") .FirstOrDefault(); matchingItem.Visibility = System.Windows.Visibility.Collapsed; } var filters = ((PageAirliners)this.Tag).AirlinersFilters; if (filters != null) { this.lvAirliners.setCurrentFilters(filters); } }
private void lnkAirliner_Click(object sender, RoutedEventArgs e) { AirlinerMVVM airliner = (AirlinerMVVM)((Hyperlink)sender).Tag; TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Airliner") .FirstOrDefault(); matchingItem.Header = airliner.Airliner.TailNumber; matchingItem.Visibility = System.Windows.Visibility.Visible; tab_main.SelectedItem = matchingItem; } Frame frmContent = UIHelpers.FindChild <Frame>(this.Tag as Page, "frmContent"); if (frmContent != null) { frmContent.Navigate(new PageUsedAirliner(airliner.Airliner) { Tag = this.Tag }); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { RadioButton rbFullScreen = UIHelpers.FindChild <RadioButton>(this, "rbFullScreen"); if (rbFullScreen.IsChecked.Value) { Settings.GetInstance().Mode = Settings.ScreenMode.Fullscreen; PageNavigator.MainWindow.WindowStyle = WindowStyle.None; PageNavigator.MainWindow.WindowState = WindowState.Maximized; PageNavigator.MainWindow.Focus(); } else { Settings.GetInstance().Mode = Settings.ScreenMode.Windowed; } ComboBox cbLanguage = UIHelpers.FindChild <ComboBox>(this, "cbLanguage"); AppSettings.GetInstance().setLanguage((Language)cbLanguage.SelectedItem); System.IO.StreamWriter file = new System.IO.StreamWriter(AppSettings.getCommonApplicationDataPath() + "\\game.settings"); file.WriteLine(AppSettings.GetInstance().getLanguage().Name); file.WriteLine(Settings.GetInstance().Mode); file.Close(); //PageNavigator.NavigateTo(new PageStartMenu()); }
//creates the page private void createPage(List <Airport> airports) { this.AllAirlines = new List <Airline>(); this.SelectedAirports = new ObservableCollection <AirportMVVM>(); this.RoutesRanges = new List <FilterValue>() { new FilterValue("0", 0, 0), new FilterValue("1-9", 1, 9), new FilterValue("10-24", 10, 24), new FilterValue("25+", 25, int.MaxValue) }; this.OperatingRanges = new List <FilterValue>() { new FilterValue("0", 0, 0), new FilterValue("1-5", 1, 5), new FilterValue("6+", 5, int.MaxValue) }; Airline dummyAirline = new Airline(new AirlineProfile("All Airlines", "99", "Blue", "", false, 1900, 1900), Airline.AirlineMentality.Safe, Airline.AirlineFocus.Domestic, Airline.AirlineLicense.Domestic, Route.RouteType.Passenger); dummyAirline.Profile.addLogo(new AirlineLogo(AppSettings.getDataPath() + "\\graphics\\airlinelogos\\default.png")); this.AllAirlines.Add(dummyAirline); foreach (Airline airline in Airlines.GetAllAirlines().Where(a => a != GameObject.GetInstance().HumanAirline).OrderBy(a => a.Profile.Name)) { this.AllAirlines.Add(airline); } this.AllAirports = new List <AirportMVVM>(); foreach (Airport airport in airports.OrderBy(a => a.Profile.Name)) { this.AllAirports.Add(new AirportMVVM(airport)); } AirlinerType dummyAircraft = new AirlinerCargoType(new Manufacturer("Dummy", "", null, false), "All Aircrafts", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, AirlinerType.BodyType.Single_Aisle, AirlinerType.TypeRange.Regional, AirlinerType.EngineType.Jet, new Period <DateTime>(DateTime.Now, DateTime.Now), 0, false); this.HumanAircrafts = new List <AirlinerType>(); this.HumanAircrafts.Add(dummyAircraft); foreach (AirlinerType type in GameObject.GetInstance().HumanAirline.Fleet.Select(f => f.Airliner.Type).Distinct()) { this.HumanAircrafts.Add(type); } InitializeComponent(); TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Airports") .FirstOrDefault(); //matchingItem.IsSelected = true; tab_main.SelectedItem = matchingItem; } }
private void btnBack_Click(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>((Page)this.Tag, "frmContent"); frmContent.Navigate(new PageStartData() { Tag = this.Tag }); }
private void PageNewGame_Loaded(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); frmContent.Navigate(new PageStartData() { Tag = this }); }
private void PageOptions_Loaded(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); frmContent.Navigate(new PageShowOptions() { Tag = this }); }
private void PageAirlines_Loaded(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); frmContent.Navigate(new PageAirlinesStatistics() { Tag = this }); }
private void tcMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { TabControl control = (TabControl)sender; string selection = ((TabItem)control.SelectedItem).Tag.ToString(); Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); if (selection == "Overview" && frmContent != null) { frmContent.Navigate(new PageAirlineInfo(this.Airline) { Tag = this }); } if (selection == "Finances" && frmContent != null) { frmContent.Navigate(new PageAirlineFinances(this.Airline) { Tag = this }); } if (selection == "Employees" && frmContent != null) { frmContent.Navigate(new PageAirlineEmployees(this.Airline) { Tag = this }); } if (selection == "Services" && frmContent != null) { frmContent.Navigate(new PageAirlineServices(this.Airline) { Tag = this }); } if (selection == "Ratings" && frmContent != null) { frmContent.Navigate(new PageAirlineRatings(this.Airline) { Tag = this }); } if (selection == "Insurances" && frmContent != null) { frmContent.Navigate(new PageAirlineInsurance(this.Airline) { Tag = this }); } }
private void btnEditAirliners_Click(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>(this.Tag as Page, "frmContent"); if (frmContent != null) { frmContent.Navigate(new PageAirlineEditAirliners(this.SelectedAirliners.ToList()) { Tag = this.Tag }); } }
public void ClearSearch_Click(object sender, RoutedEventArgs e) { //VM.Instance.Game.SearchText = @"\u200B"; //VM.Instance.Game.SearchText = String.Empty; var searchBoxControl = UIHelpers.FindChild <SearchBox>(this, "SearchBoxControl"); if (null != searchBoxControl) { searchBoxControl.SearchText = String.Empty; } }
private void btnClear_Click(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent"); if (frmContent != null) { frmContent.Navigate(new PageShowAirports() { Tag = this.Tag }); } }
private void btnNext_Click(object sender, RoutedEventArgs e) { Frame frmContent = UIHelpers.FindChild <Frame>((Page)this.Tag, "frmContent"); frmContent.Navigate(new PageAirlineData(new StartDataObject() { MajorAirports = cbMajorAirports.IsChecked.Value, IsPaused = cbPaused.IsChecked.Value, Focus = (Airline.AirlineFocus)cbFocus.SelectedItem, SameRegion = cbSameRegion.IsChecked.Value, RandomOpponents = rbRandomOpponents.IsChecked.Value, UseDayTurns = rbDayTurns.IsChecked.Value, Difficulty = (DifficultyLevel)cbDifficulty.SelectedItem, NumberOfOpponents = (int)cbOpponents.SelectedItem, Year = (int)cbYear.SelectedItem, Continent = (Continent)cbContinent.SelectedItem, Region = (Region)cbRegion.SelectedItem }) { Tag = this.Tag }); }
private void cbRegion_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox cbCountry = UIHelpers.FindChild <ComboBox>(this, "cbCountry"); ComboBox cbRegion = UIHelpers.FindChild <ComboBox>(this, "cbRegion"); Region region = (Region)cbRegion.SelectedItem; var countries = region.Uid == "100" ? Airports.GetAllAirports().Select(a => new CountryCurrentCountryConverter().Convert(a.Profile.Country) as Country).Distinct().ToList() : Countries.GetCountries(region); countries.Add(Countries.GetCountry("100")); cbCountry.ItemsSource = countries.OrderByDescending(c => c.Uid == "100").ThenBy(c => c.Name); }
private void btnCancel_Click(object sender, RoutedEventArgs e) { TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Pilots") .FirstOrDefault(); tab_main.SelectedItem = matchingItem; } }
private void PageCreateAlliance_Loaded(object sender, RoutedEventArgs e) { TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast <TabItem>() .Where(item => item.Tag.ToString() == "Alliance") .FirstOrDefault(); matchingItem.Visibility = System.Windows.Visibility.Collapsed; } }