public ScheduleViewModel(BaseViewModel parent, Params modelParams = null) : base(parent)
        {
            SemesterItemsViewGroup semesterGroup = SemesterItemsViewGroup.Load(MainScreenViewModel.CurrentLocalAccountId, MainScreenViewModel.CurrentSemester, trackChanges: true);

            if (semesterGroup == null)
            {
                throw new NullReferenceException("semesterGroup was null");
            }
            if (semesterGroup.Semester == null)
            {
                throw new NullReferenceException("semesterGroup.Semester was null");
            }

            if (modelParams == null)
            {
                modelParams = new Params();
            }
            _modelParams = modelParams;

            _arrangerItemsChangedHandler = new WeakEventHandler <EventArgs>(Arranger_OnItemsChanged);

            SemesterViewItemsGroup = semesterGroup;

            var acct = MainScreenViewModel.CurrentAccount;

            Account        = acct ?? throw new NullReferenceException("MainScreenViewModel.CurrentAccount was null");
            FirstDayOfWeek = acct.WeekChangesOn;

            DateTime today = DateTime.Today;

            if (semesterGroup.Semester.IsDateDuringThisSemester(today))
            {
                StartDate = DateTools.Last(FirstDayOfWeek);
            }
            else if (!PowerPlannerSending.DateValues.IsUnassigned(semesterGroup.Semester.Start) && today < semesterGroup.Semester.Start)
            {
                // Semester hasn't started yet, jump to first week of semester
                StartDate = DateTools.Last(FirstDayOfWeek, semesterGroup.Semester.Start);
            }
            else
            {
                // Semester already ended, jump to last week of semester
                StartDate = DateTools.Last(FirstDayOfWeek, semesterGroup.Semester.End);
            }

            if (!HasSchedules() || modelParams.IsEditing)
            {
                EnterEditMode();
            }

            AccountDataStore.AddDataChangedEventHandler(this);

            UpdateHasTwoWeekSchedule();
        }
Ejemplo n.º 2
0
        private void Initialize(Guid localAccountId, ViewItemSemester semester)
        {
            var acct = MainScreenViewModel.CurrentAccount;

            if (acct == null)
            {
                throw new NullReferenceException("MainScreenViewModel.CurrentAccount was null");
            }
            _showPastCompleteItemsOnFullCalendar = acct.ShowPastCompleteItemsOnFullCalendar;
            FirstDayOfWeek = acct.WeekChangesOn;

            SemesterItemsViewGroup = SemesterItemsViewGroup.Load(localAccountId, semester);
        }
 private void Initialize(Guid localAccountId, ViewItemSemester semester)
 {
     SemesterItemsViewGroup = SemesterItemsViewGroup.Load(localAccountId, semester);
 }