示例#1
0
        public override void OnViewModelLoadedOverride()
        {
            _navButtonEditDetails = new UIBarButtonItem(UIBarButtonSystemItem.Edit)
            {
                Title = "Edit details"
            };
            _navButtonEditDetails.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.EditClassWithDetails(); }).Handler;

            _navButtonEditTimes = new UIBarButtonItem(UIBarButtonSystemItem.Edit)
            {
                Title = "Edit times"
            };
            _navButtonEditTimes.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.EditTimes(); }).Handler;

            _navButtonAddTask = new UIBarButtonItem(UIBarButtonSystemItem.Add)
            {
                Title = "Add task"
            };
            _navButtonAddTask.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.TasksViewModel.Add(); }).Handler;

            _navButtonAddEvent = new UIBarButtonItem(UIBarButtonSystemItem.Add)
            {
                Title = "Add event"
            };
            _navButtonAddEvent.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.EventsViewModel.Add(); }).Handler;

            _navButtonAddGrade = new UIBarButtonItem(UIBarButtonSystemItem.Add)
            {
                Title = "Add grade"
            };
            _navButtonAddGrade.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.GradesViewModel.Add(); }).Handler;

            _detailsViewController = new ClassDetailsViewController()
            {
                ViewModel = ViewModel.DetailsViewModel
            };
            _timesViewController = new ClassTimesViewController()
            {
                ViewModel = ViewModel.TimesViewModel
            };
            _tasksViewController = new ClassTasksOrEventsViewController()
            {
                Title     = "Tasks",
                ViewModel = ViewModel.TasksViewModel
            };
            _eventsViewController = new ClassTasksOrEventsViewController()
            {
                Title     = "Events",
                ViewModel = ViewModel.EventsViewModel
            };
            _gradesViewController = new ClassGradesViewController()
            {
                ViewModel = ViewModel.GradesViewModel
            };

            int initialPageIndex = ViewModel.InitialPage != null ? (int)ViewModel.InitialPage : 0;

            initialPageIndex--; // Subtract one since don't have the overview view
            if (initialPageIndex < 0)
            {
                initialPageIndex = 0;
            }
            _pageMenuController = new CAPSPageMenuController(new UIViewController[]
            {
                _detailsViewController,
                _timesViewController,
                _tasksViewController,
                _eventsViewController,
                _gradesViewController
            }, new CAPSPageMenuConfiguration()
            {
                SelectedMenuItemLabelColor = ColorResources.PowerPlannerAccentBlue,
                SelectionIndicatorColor    = ColorResources.PowerPlannerAccentBlue
            }, initialPageIndex);
            _pageMenuController.View.TranslatesAutoresizingMaskIntoConstraints = false;
            AddChildViewController(_pageMenuController);
            ContentView.Add(_pageMenuController.View);
            _pageMenuController.View.StretchWidthAndHeight(ContentView);
            switch (ViewModel.InitialPage)
            {
            case ClassViewModel.ClassPages.Times:
                UpdatePage(_timesViewController);
                break;

            case ClassViewModel.ClassPages.Tasks:
                UpdatePage(_tasksViewController);
                break;

            case ClassViewModel.ClassPages.Events:
                UpdatePage(_eventsViewController);
                break;

            case ClassViewModel.ClassPages.Grades:
                UpdatePage(_gradesViewController);
                break;

            default:
                UpdatePage(_detailsViewController);
                break;
            }
            _pageMenuController.SelectionChanged += new WeakEventHandler <CAPSPageMenuSelectionChangedEventArgs>(_pageMenuController_SelectionChanged).Handler;

            _classBindingHost.BindingObject = ViewModel.ViewItemsGroupClass.Class;
            _classBindingHost.SetBinding <string>(nameof(ViewItemClass.Name), (name) =>
            {
                Title = name;
            });

            BackButtonText = "Back";

            base.OnViewModelLoadedOverride();
        }
        public override void OnViewModelLoadedOverride()
        {
            _navButtonEditDetails = new UIBarButtonItem(UIBarButtonSystemItem.Edit)
            {
                Title = "Edit details"
            };
            _navButtonEditDetails.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.EditClassWithDetails(); }).Handler;

            _navButtonEditTimes = new UIBarButtonItem(UIBarButtonSystemItem.Edit)
            {
                Title = "Edit times"
            };
            _navButtonEditTimes.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.EditTimes(); }).Handler;

            _navButtonAddHomework = new UIBarButtonItem(UIBarButtonSystemItem.Add)
            {
                Title = "Add task"
            };
            _navButtonAddHomework.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.HomeworkViewModel.Add(); }).Handler;

            _navButtonAddExam = new UIBarButtonItem(UIBarButtonSystemItem.Add)
            {
                Title = "Add event"
            };
            _navButtonAddExam.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.ExamsViewModel.Add(); }).Handler;

            _navButtonAddGrade = new UIBarButtonItem(UIBarButtonSystemItem.Add)
            {
                Title = "Add grade"
            };
            _navButtonAddGrade.Clicked += new WeakEventHandler <EventArgs>(delegate { ViewModel.GradesViewModel.Add(); }).Handler;

            _detailsViewController = new ClassDetailsViewController()
            {
                ViewModel = ViewModel.DetailsViewModel
            };
            _timesViewController = new ClassTimesViewController()
            {
                ViewModel = ViewModel.TimesViewModel
            };
            _homeworkViewController = new ClassHomeworkOrExamsViewController()
            {
                Title     = "Tasks",
                ViewModel = ViewModel.HomeworkViewModel
            };
            _examsViewController = new ClassHomeworkOrExamsViewController()
            {
                Title     = "Events",
                ViewModel = ViewModel.ExamsViewModel
            };
            _gradesViewController = new ClassGradesViewController()
            {
                ViewModel = ViewModel.GradesViewModel
            };

            _pageMenuController = new CAPSPageMenuController(new UIViewController[]
            {
                _detailsViewController,
                _timesViewController,
                _homeworkViewController,
                _examsViewController,
                _gradesViewController
            }, new CAPSPageMenuConfiguration()
            {
                SelectedMenuItemLabelColor = ColorResources.PowerPlannerAccentBlue,
                SelectionIndicatorColor    = ColorResources.PowerPlannerAccentBlue
            });
            _pageMenuController.SelectionChanged += new WeakEventHandler <CAPSPageMenuSelectionChangedEventArgs>(_pageMenuController_SelectionChanged).Handler;
            _pageMenuController.View.TranslatesAutoresizingMaskIntoConstraints = false;
            AddChildViewController(_pageMenuController);
            ContentView.Add(_pageMenuController.View);
            _pageMenuController.View.StretchWidthAndHeight(ContentView);
            UpdatePage(_detailsViewController);

            _classBindingHost.BindingObject = ViewModel.ViewItemsGroupClass.Class;
            _classBindingHost.SetBinding <string>(nameof(ViewItemClass.Name), (name) =>
            {
                Title = name;
            });

            BackButtonText = "Back";

            base.OnViewModelLoadedOverride();
        }