public GameStart(string aRouteId, ClimbMode aClimbMode) { routeId = aRouteId; climbMode = aClimbMode; InitializeComponent(); // pass cvsBoulderRouteVideos and _routeId to the view model viewModel = gridContainer.DataContext as GameStartViewModel; if (viewModel != null) { CollectionViewSource cvsVideos = gridContainer.Resources["cvsRouteVideos"] as CollectionViewSource; viewModel.SetCvsVideos(cvsVideos); viewModel.SetRouteId(aRouteId); viewModel.SetClimbMode(aClimbMode); viewModel.SetYearListFirstItem("yyyy"); viewModel.SetMonthListFirstItem("mm"); viewModel.SetDayListFirstItem("dd"); viewModel.SetHourListFirstItem(new FilterHourViewModel { Hour = -1, HourString = "time" }); } // pass this Page to the top row user control so it can use this Page's NavigationService navHead.ParentPage = this; // set titles Title = "Just Climb - Game Start"; WindowTitle = Title; string headerRowTitleFormat = "{0} Route {1} - Video Playback"; switch (climbMode) { case ClimbMode.Training: navHead.HeaderRowTitle = string.Format(headerRowTitleFormat, "Training", TrainingRouteDataAccess.TrainingRouteNoById(routeId)); break; case ClimbMode.Boulder: default: navHead.HeaderRowTitle = string.Format(headerRowTitleFormat, "Bouldering", BoulderRouteDataAccess.BoulderRouteNoById(routeId)); break; } }
// can be called by the view during Page.OnLoad public void LoadData() { string wallId = AppGlobal.WallID; /* use * routeDA.ValidBoulderRoutes, <-- only this uses "valid" * difficultyDA.RouteDifficulties * ageGroupDA.AgeGroups */ IEnumerable <RouteViewModel> routeViewModels; switch (_climbMode) { case ClimbMode.Training: routeViewModels = from route in TrainingRouteDataAccess.ValidTrainingRoutesByWall(wallId) join difficulty in RouteDifficultyDataAccess.RouteDifficulties on route.Difficulty equals difficulty.RouteDifficultyID join ageGroup in AgeGroupDataAccess.AgeGroups on route.AgeGroup equals ageGroup.AgeGroupID select new RouteViewModel { RouteID = route.RouteID, RouteNo = route.RouteNo, Difficulty = route.Difficulty, DifficultyDesc = difficulty.DifficultyDesc, AgeGroup = route.AgeGroup, AgeDesc = ageGroup.AgeDesc }; break; case ClimbMode.Boulder: default: routeViewModels = from route in BoulderRouteDataAccess.ValidBoulderRoutesByWall(wallId) join difficulty in RouteDifficultyDataAccess.RouteDifficulties on route.Difficulty equals difficulty.RouteDifficultyID join ageGroup in AgeGroupDataAccess.AgeGroups on route.AgeGroup equals ageGroup.AgeGroupID select new RouteViewModel { RouteID = route.RouteID, RouteNo = route.RouteNo, Difficulty = route.Difficulty, DifficultyDesc = difficulty.DifficultyDesc, AgeGroup = route.AgeGroup, AgeDesc = ageGroup.AgeDesc }; break; } // add null item at the front of the combo boxes /* use "valid" * difficultyDA.ValidRouteDifficulties * ageGroupDA.ValidAgeGroups */ List <AgeGroup> ageGroupList = AgeGroupDataAccess.ValidAgeGroups.ToList(); List <RouteDifficulty> difficultyList = RouteDifficultyDataAccess.ValidRouteDifficulties.ToList(); if (_ageGroupListFirstItem != null) { ageGroupList.Insert(0, _ageGroupListFirstItem); } if (_difficultyListFirstItem != null) { difficultyList.Insert(0, _difficultyListFirstItem); } AgeGroups = new ObservableCollection <AgeGroup>(ageGroupList); RouteDifficulties = new ObservableCollection <RouteDifficulty>(difficultyList); RouteViewModels = new ObservableCollection <RouteViewModel>(routeViewModels); }