Пример #1
0
        public EventViewModel(CourseEvent courseEvent, INavigationController controller)
        {
            _event = courseEvent;

            PageTitle = AppResources.ApplicationTitle.ToUpper();

            StartDate = courseEvent.StartDate;
            EndDate = courseEvent.EndDate;

            _showCourseCommand = new DelegateCommand(() => controller.ShowCourse(Course), () => Course != null);
            _addToCalendarCommand = new DelegateCommand(AddToCalendar);

            LoadCourseDataAsync(controller);
        }
Пример #2
0
 public void ShowCourseEvent(CourseEvent courseEvent)
 {
     // Pass the whole event as navigation parameters
     _frame.Navigate(NoppaUtility.MakeUri("/EventPage.xaml",
         "course_id",  courseEvent.CourseId,
         "type", courseEvent.Type,
         "title", courseEvent.Title,
         "weekday", courseEvent.Weekday,
         "location", courseEvent.Location,
         "start_time", courseEvent.StartTime,
         "end_time", courseEvent.EndTime,
         "start_date", courseEvent.StartDate,
         "end_date", courseEvent.EndDate));
 }
Пример #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (_viewModel == null)
            {
                // There's no identifiers for individual events, so the
                // fields of the event is passed as parameters, and
                // a CourseEvent is reassembled here.

                string courseId, type, title, weekday, location;
                string startTime, endTime, startDate, endDate;

                var query = NavigationContext.QueryString;

                query.TryGetValue("course_id", out courseId);
                query.TryGetValue("type", out type);
                query.TryGetValue("title", out title);
                query.TryGetValue("weekday", out weekday);
                query.TryGetValue("location", out location);
                query.TryGetValue("start_time", out startTime);
                query.TryGetValue("end_time", out endTime);
                query.TryGetValue("start_date", out startDate);
                query.TryGetValue("end_date", out endDate);

                var courseEvent = new CourseEvent
                {
                    CourseId = Detail.StripHtml(courseId),
                    Type = Detail.StripHtml(type),
                    Title = Detail.StripHtml(title),
                    Weekday = Detail.StripHtml(weekday),
                    Location = Detail.StripHtml(location),
                    StartTime = DateTime.Parse(startTime),
                    EndTime = DateTime.Parse(endTime),
                    StartDate = DateTime.Parse(startDate),
                    EndDate = DateTime.Parse(endDate)
                };

                _viewModel = new EventViewModel(courseEvent, new PhoneNavigationController());
                DataContext = _viewModel;
            }

            var addToCalendarButton = (ApplicationBarIconButton)ApplicationBar.Buttons[0];
            _unbindAction = AppBar.BindCommand(addToCalendarButton, _viewModel.AddToCalendarCommand);
            addToCalendarButton.Text = AppResources.AddToCalendarTitle;
        }