Esempio n. 1
0
        /// <summary>
        /// Automatically updates display, resets reminders, starts settings sync, and submits changes
        /// </summary>
        /// <param name="startsOn"></param>
        /// <param name="currentWeek"></param>
        public async System.Threading.Tasks.Task SetWeek(DayOfWeek startsOn, Schedule.Week currentWeek)
        {
            if (SetWeekSimple(startsOn, currentWeek))
            {
                // Clear cached schedules on day since they don't subscribe to these changes.
                // Ideally I would have the lists subscribe to the account, but this will do for now.
                ViewLists.SchedulesOnDay.ClearCached();
                ViewLists.DayScheduleItemsArranger.ClearCached();

                NeedsToSyncSettings = true;

                // Save
                await SaveOnThread();

                //make upcoming update
                OnPropertyChanged("ShowSchedule");

                AccountDataStore data = await AccountDataStore.Get(this.LocalAccountId);

                var dontWait = RemindersExtension.Current?.ResetReminders(this, data);

                var dontWaitThread = System.Threading.Tasks.Task.Run(delegate
                {
                    // Update schedule tile
                    var dontWaitScheduleTile = ScheduleTileExtension.Current?.UpdateScheduleTile(this, data);
                });

                dontWait = Sync.SyncSettings(this, Sync.ChangedSetting.WeekOneStartsOn);
            }
        }
Esempio n. 2
0
        public ScheduleWin GrabEarliestScheduleOnDate(DateTime date, Schedule.Week week)
        {
            for (int i = 0; i < Schedules.Count; i++)
            {
                if (Schedules[i].DayOfWeek == date.DayOfWeek && (Schedules[i].ScheduleWeek & week) == week)
                {
                    return(Schedules[i]);
                }
            }

            return(null);
        }
        protected override void PopulateFromDataItemOverride(BaseDataItem dataItem)
        {
            base.PopulateFromDataItemOverride(dataItem);

            DataItemSchedule schedule = (DataItemSchedule)dataItem;

            DayOfWeek    = schedule.DayOfWeek;
            StartTime    = DateTime.SpecifyKind(schedule.StartTime, DateTimeKind.Local);
            EndTime      = DateTime.SpecifyKind(schedule.EndTime, DateTimeKind.Local);
            Room         = schedule.Room;
            ScheduleWeek = schedule.ScheduleWeek;
        }
Esempio n. 4
0
        private void updateWeekDisplay(Schedule.Week week)
        {
            if (week == Schedule.Week.WeekOne)
            {
                tbWeekOne.Style = (Style)Resources["SelectedWeekStyle"];
                tbWeekTwo.Style = (Style)Resources["WeekStyle"];
            }

            else
            {
                tbWeekOne.Style = (Style)Resources["WeekStyle"];
                tbWeekTwo.Style = (Style)Resources["SelectedWeekStyle"];
            }
        }
Esempio n. 5
0
            public static string GetLocalizedWeek(Schedule.Week week)
            {
                switch (week)
                {
                case Schedule.Week.BothWeeks:
                    return(LocalizedResources.GetString("String_BothWeeks"));

                case Schedule.Week.WeekOne:
                    return(LocalizedResources.Common.GetStringWeekA());

                case Schedule.Week.WeekTwo:
                    return(LocalizedResources.Common.GetStringWeekB());

                default:
                    throw new NotImplementedException();
                }
            }
        private SchedulesOnDay(IEnumerable <ViewItemClass> classes, DateTime date, Schedule.Week week, bool trackChanges = false)
        {
            TrackChanges = trackChanges;
            Week         = week;
            Date         = date;
            _classPropertyChangedEventHandler = new WeakEventHandler <PropertyChangedEventArgs>(Class_PropertyChanged).Handler;
            base.Filter = new ScheduleFilter(date, week);

            if (trackChanges && classes is INotifyCollectionChanged)
            {
                (classes as INotifyCollectionChanged).CollectionChanged += new WeakEventHandler <NotifyCollectionChangedEventArgs>(Classes_CollectionChanged).Handler;
                Classes = classes;
            }

            foreach (var c in classes)
            {
                AddClass(c);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Doesn't do any saving or setting of any other dependent properties
        /// </summary>
        /// <param name="startsOn"></param>
        /// <param name="currentWeek"></param>
        public bool SetWeekSimple(DayOfWeek startsOn, Schedule.Week currentWeek)
        {
            DateTime today = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc);

            if (currentWeek == Schedule.Week.WeekTwo)
            {
                today = today.AddDays(-7);
            }

            DateTime answer = DateTools.Last(startsOn, today);

            if (answer != WeekOneStartsOn)
            {
                WeekOneStartsOn = answer;
                return(true);
            }

            return(false);
        }
Esempio n. 8
0
        /// <summary>
        /// Automatically updates display, resets reminders, starts settings sync, and submits changes
        /// </summary>
        /// <param name="startsOn"></param>
        /// <param name="currentWeek"></param>
        public async System.Threading.Tasks.Task SetWeek(DayOfWeek startsOn, Schedule.Week currentWeek)
        {
            // Clear cached schedules on day since they don't subscribe to these changes.
            // Ideally I would have the lists subscribe to the account, but this will do for now.
            ViewLists.SchedulesOnDay.ClearCached();
            ViewLists.DayScheduleItemsArranger.ClearCached();

            DateTime today = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc);

            if (currentWeek == Schedule.Week.WeekTwo)
            {
                today = today.AddDays(-7);
            }

            DateTime answer = DateTools.Last(startsOn, today);

            if (answer != WeekOneStartsOn)
            {
                WeekOneStartsOn     = answer;
                NeedsToSyncSettings = true;

                // Save
                await SaveOnThread();

                //make upcoming update
                OnPropertyChanged("ShowSchedule");

                AccountDataStore data = await AccountDataStore.Get(this.LocalAccountId);

                var dontWait = RemindersExtension.Current?.ResetReminders(this, data);

                var dontWaitThread = System.Threading.Tasks.Task.Run(delegate
                {
                    // Update schedule tile
                    var dontWaitScheduleTile = ScheduleTileExtension.Current?.UpdateScheduleTile(this, data);
                });

                dontWait = Sync.SyncSettings(this, Sync.ChangedSetting.WeekOneStartsOn);
            }
        }
        public static SchedulesOnDay Get(IEnumerable <ViewItemClass> classes, DateTime date, Schedule.Week week, bool trackChanges = false)
        {
            SchedulesOnDay answer;

            for (int i = 0; i < _cached.Count; i++)
            {
                if (_cached[i].TryGetTarget(out answer))
                {
                    if (answer.Date == date.Date && answer.Classes == classes)
                    {
                        if (trackChanges)
                        {
                            return(answer);
                        }
                        else
                        {
                            return(new SchedulesOnDay(answer));
                        }
                    }
                }
                else
                {
                    _cached.RemoveAt(i);
                    i--;
                }
            }

            answer = new SchedulesOnDay(classes, date, week, trackChanges);
            if (trackChanges)
            {
                _cached.Add(new WeakReference <SchedulesOnDay>(answer));
            }
            return(answer);
        }
Esempio n. 10
0
 public ScheduleFilter(DateTime date, Schedule.Week week)
 {
     _date = date.Date;
     _week = week;
 }