Пример #1
0
 public void EditHomeworkOrExam(BaseViewItemHomeworkExam item)
 {
     ShowPopup(AddHomeworkViewModel.CreateForEdit(this, new AddHomeworkViewModel.EditParameter()
     {
         Item = item
     }));
 }
Пример #2
0
        public override void OnViewModelLoadedOverride()
        {
            if (_prevItem != null && _itemPropertyChangedHandler != null)
            {
                _prevItem.PropertyChanged -= _itemPropertyChangedHandler;
                _prevItem = null;
            }

            switch (ViewModel.Type)
            {
            case ViewHomeworkViewModel.ItemType.Exam:
                Title = PowerPlannerResources.GetString("ViewHomeworkPage_String_TitleExam");
                _homeworkProgressBarControl.Visibility = ViewStates.Gone;
                break;

            case ViewHomeworkViewModel.ItemType.Homework:
                Title = PowerPlannerResources.GetString("ViewHomeworkPage_String_TitleHomework");

                if (ViewModel.IsUnassigedMode)
                {
                    _homeworkProgressBarControl.Visibility = ViewStates.Gone;
                    _buttonConvertToGrade.Visibility       = ViewStates.Visible;
                }
                else
                {
                    _homeworkProgressBarControl.Visibility = ViewStates.Visible;
                    _itemPropertyChangedHandler            = new WeakEventHandler <PropertyChangedEventArgs>(Item_PropertyChanged).Handler;
                    ViewModel.Item.PropertyChanged        += _itemPropertyChangedHandler;
                    _prevItem = ViewModel.Item;
                    UpdatePercentCompleteFromItem();
                }
                break;
            }
        }
Пример #3
0
        private void HandleWeightCategoryForHomeworkExam(BaseViewItemHomeworkExam item)
        {
            if (item.WeightCategoryIdentifier == PowerPlannerSending.BaseHomeworkExam.WEIGHT_CATEGORY_UNASSIGNED)
            {
                item.WeightCategory = ViewItemWeightCategory.UNASSIGNED;
            }
            else if (item.WeightCategoryIdentifier == PowerPlannerSending.BaseHomeworkExam.WEIGHT_CATEGORY_EXCLUDED)
            {
                item.WeightCategory = ViewItemWeightCategory.EXCLUDED;
            }
            else
            {
                if (WeightCategories == null)
                {
                    // WeightCategories should only be null in the scenario where the view group was loaded disregarding
                    // the weight categories (like from the live tile task)
                    item.WeightCategory = null;
                    return;
                }

                var weight = WeightCategories.FirstOrDefault(i => i.Identifier == item.WeightCategoryIdentifier);
                if (weight != null)
                {
                    item.WeightCategory = weight;
                }
                else
                {
                    item.WeightCategory = ViewItemWeightCategory.UNASSIGNED;
                }
            }
        }
Пример #4
0
        public static BaseArguments CreateArgumentsForView(BaseViewItemHomeworkExam item, Guid localAccountId)
        {
            BaseArgumentsWithAccountAndItem args;

            if (item is ViewItemHomework)
            {
                args = new ViewHomeworkArguments();
            }

            else if (item is ViewItemExam)
            {
                args = new ViewExamArguments();
            }

            else
            {
                return new OpenAccountArguments()
                       {
                           LocalAccountId = localAccountId
                       }
            };

            args.LocalAccountId = localAccountId;
            args.ItemId         = item.Identifier;

            return(args);
        }
    }
        /// <summary>
        /// Returns something like "Due 11:00 AM" or "Due today" or just "11:00 AM" if event
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static string GetDueTimeAsString(BaseViewItemHomeworkExam item)
        {
            string answer = "";

            if (item is ViewItemHomework)
            {
                answer += "Due ";
            }

            switch (item.GetActualTimeOption())
            {
            case DataLayer.DataItems.DataItemMegaItem.TimeOptions.BeforeClass:
            case DataLayer.DataItems.DataItemMegaItem.TimeOptions.Custom:
            case DataLayer.DataItems.DataItemMegaItem.TimeOptions.StartOfClass:
            case DataLayer.DataItems.DataItemMegaItem.TimeOptions.EndOfClass:
                answer += item.GetDueDateWithTime().ToString("t");
                break;

            case DataLayer.DataItems.DataItemMegaItem.TimeOptions.DuringClass:
                answer += "during class";
                break;

            case DataLayer.DataItems.DataItemMegaItem.TimeOptions.AllDay:
            default:
                answer += "today";
                break;
            }

            if (item.TryGetEndDateWithTime(out DateTime endTime))
            {
                answer += " to " + endTime.ToString("t");
            }

            return(answer.Substring(0, 1).ToUpper() + answer.Substring(1));
        }
Пример #6
0
        private void HomeworkListViewItem_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
        {
            _currItem = args.NewValue as BaseViewItemHomeworkExam;

            UpdateDisplayDetails();
            UpdateSubtitlePartTwo();
        }
Пример #7
0
            public EventItem(DayScheduleItemsArranger arranger, BaseViewItemHomeworkExam item) : base(arranger)
            {
                Item = item;

                StartTime = item.GetDueDateWithTime().TimeOfDay;
                DateTime endTime;

                if (item.TryGetEndDateWithTime(out endTime))
                {
                    EndTime = endTime.TimeOfDay;
                }

                if (EndTime - arranger.MinDuration < StartTime)
                {
                    EndTime = StartTime + arranger.MinDuration;

                    // If that pushes it past 24 hours
                    if (EndTime >= new TimeSpan(24, 0, 0))
                    {
                        // Move the start time up to accomodate the min duration
                        EndTime   = new TimeSpan(23, 59, 0);
                        StartTime = EndTime - arranger.MinDuration;
                    }
                }
            }
Пример #8
0
 private static AdaptiveText GenerateTileTextForUpcomingItem(BaseViewItemHomeworkExam item)
 {
     return(new AdaptiveText()
     {
         Text = TrimString(item.Name, 200),
         HintStyle = AdaptiveTextStyle.CaptionSubtle
     });
 }
        /// <summary>
        /// Assumes item has already been filtered (date and class)
        /// </summary>
        /// <param name="h"></param>
        private void Add(DataItemMegaItem i)
        {
            BaseViewItemHomeworkExam viewItem = i.CreateViewItemTaskOrEvent(_semester);

            if (viewItem != null && !viewItem.IsComplete())
            {
                Add(viewItem);
            }
        }
        private void Add(BaseViewItemHomeworkExam viewItem)
        {
            if (viewItem == null || viewItem.IsComplete())
            {
                // Complete items aren't added
                return;
            }

            Items.Add(viewItem);
        }
 public static Android.Content.Res.ColorStateList GetBackgroundColorStateList(BaseViewItemHomeworkExam item)
 {
     return(new Android.Content.Res.ColorStateList(new int[][]
     {
         new int[] { }
     },
                                                   new int[]
     {
         item.IsComplete() ? new Color(180, 180, 180).ToArgb() : ColorTools.GetColor(item.GetClassOrNull().Color).ToArgb()
     }));
 }
Пример #12
0
 public void ScrollToItem(BaseViewItemHomeworkExam item)
 {
     //for (int i = 0; i < _viewModel.ItemsWithHeaders.Count; i++)
     //{
     //    if (_viewModel.ItemsWithHeaders[i] == item)
     //    {
     //        _tableView.ScrollToRow(NSIndexPath.FromRowSection(i, 0), UITableViewScrollPosition.None, true);
     //        return;
     //    }
     //}
 }
        private static DateTime getDayOfReminderTime(BaseViewItemHomeworkExam h, AccountDataItem account, ref bool hasClassTime)
        {
            ViewItemClass c = h.GetClassOrNull();

            if (c == null)
            {
                return(DateTime.MinValue);
            }

            return(h.GetDayOfReminderTime(out hasClassTime));
        }
        internal static CGColor GetBackgroundCGColor(BaseViewItemHomeworkExam item)
        {
            if (item.IsComplete())
            {
                return(new CGColor(180 / 255f, 1));
            }

            else
            {
                return(BareUIHelper.ToCGColor(item.GetClassOrNull()?.Color));
            }
        }
        public static Brush GetBackgroundBrush(BaseViewItemHomeworkExam item)
        {
            if (item.IsComplete())
            {
                return(new SolidColorBrush(Color.FromArgb(255, 180, 180, 180)));
            }

            else
            {
                return(new ColorArrayToBrushConverter().Convert(item.GetClassOrNull()?.Color, null, null, null) as Brush);
            }
        }
Пример #16
0
        /// <summary>
        /// Assumes item has already been filtered
        /// </summary>
        /// <param name="h"></param>
        private void Add(DataItemMegaItem i)
        {
            BaseViewItemHomeworkExam taskOrExam = i.CreateViewItemTaskOrEvent(Semester);

            if (taskOrExam != null)
            {
                Items.Add(taskOrExam);
            }
            else if (i.MegaItemType == PowerPlannerSending.MegaItemType.Holiday)
            {
                var viewItem = CreateHoliday(i);
                Items.Add(viewItem);
            }
        }
            private UIView CreateCircle(BaseViewItemHomeworkExam item)
            {
                var view = new BareUIEllipseView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                };

                view.SetWidth(WIDTH);
                view.SetHeight(WIDTH);

                view.FillColor = GetBackgroundCGColor(item);

                return(view);
            }
        private async Task ScheduleDayOfNotification(Guid localAccountId, BaseViewItemHomeworkExam item, string title, string subtitle, string body, DateTime deliveryTime)
        {
            var content = new UNMutableNotificationContent()
            {
                Title    = title,
                Subtitle = subtitle
            };

            if (!string.IsNullOrWhiteSpace(body))
            {
                content.Body = body;
            }

            await ScheduleNotification(GetIdentifierForDayOfItem(localAccountId, item), content, deliveryTime);
        }
        private void AddSingleFullItemView(UIStackView stackView, BaseViewItemHomeworkExam item)
        {
            var view = new UIMainCalendarItemView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                DataContext = item,

                // After opened, we hide this popup, otherwise when the user presses back, it'll close the popup rather than the homework
                // Ideally we would implement the back handling as part of the view model like we did for UWP, but for simplicity we're going
                // to leave it like this for now
                AfterOpenedHomeworkAction = delegate { HideFull(); }
            };

            stackView.AddArrangedSubview(view);
            view.StretchWidth(stackView);
        }
        private static string getClassName(BaseViewItemHomeworkExam item)
        {
            if (item == null)
            {
                return("");
            }

            var c = item.GetClassOrNull();

            if (c != null)
            {
                return(c.Name);
            }

            return("");
        }
        private static string GetClassName(BaseViewItemHomeworkExam item)
        {
            if (item == null)
            {
                return("");
            }

            var c = item.GetClassOrNull();

            if (c != null)
            {
                return(StringTools.TrimLengthWithEllipses(c.Name, 30));
            }

            return("");
        }
Пример #22
0
            public ItemsGroup GetHeader(BaseViewItemHomeworkExam item)
            {
                DateTime todayAsUtc = DateTime.SpecifyKind(Today, DateTimeKind.Utc);
                DateTime itemDate   = item.Date.Date;

                if (itemDate <= todayAsUtc.AddDays(-1))
                {
                    return(ItemsGroup.Overdue);
                }

                if (itemDate <= todayAsUtc)
                {
                    return(ItemsGroup.Today);
                }

                if (itemDate <= todayAsUtc.AddDays(1))
                {
                    return(ItemsGroup.Tomorrow);
                }

                if (itemDate <= todayAsUtc.AddDays(2))
                {
                    return(ItemsGroup.InTwoDays);
                }

                if (itemDate <= todayAsUtc.AddDays(7))
                {
                    return(ItemsGroup.WithinSevenDays);
                }

                if (itemDate <= todayAsUtc.AddDays(14))
                {
                    return(ItemsGroup.WithinFourteenDays);
                }

                if (itemDate <= todayAsUtc.AddDays(30))
                {
                    return(ItemsGroup.WithinThirtyDays);
                }

                if (itemDate <= todayAsUtc.AddDays(60))
                {
                    return(ItemsGroup.WithinSixtyDays);
                }

                return(ItemsGroup.InTheFuture);
            }
Пример #23
0
        internal void Add(BaseViewItemHomeworkExam viewItemHomeworkOrExam)
        {
            if (viewItemHomeworkOrExam is ViewItemHomework)
            {
                (viewItemHomeworkOrExam as ViewItemHomework).Class = this;
            }
            else if (viewItemHomeworkOrExam is ViewItemExam)
            {
                (viewItemHomeworkOrExam as ViewItemExam).Class = this;
            }

            HandleWeightCategoryForHomeworkExam(viewItemHomeworkOrExam);

            if (HomeworkAndExams != null)
            {
                HomeworkAndExams.InsertSorted(viewItemHomeworkOrExam);
            }
        }
        public static ViewHomeworkViewModel Create(BaseViewModel parent, BaseViewItemHomeworkExam item)
        {
            ItemType type;

            if (item is ViewItemHomework)
            {
                type = ItemType.Homework;
            }
            else
            {
                type = ItemType.Exam;
            }

            return(new ViewHomeworkViewModel(parent)
            {
                Item = item,
                Type = type
            });
        }
        public async Task MoveItem(BaseViewItemHomeworkExam item, DateTime toDate)
        {
            try
            {
                if (item.Date.Date == toDate.Date)
                {
                    return;
                }

                DataChanges changes = new DataChanges();

                var editedDataItem = item.CreateBlankDataItem();
                editedDataItem.Date = DateTime.SpecifyKind(toDate.Date.Add(item.Date.TimeOfDay), DateTimeKind.Utc);
                changes.Add(editedDataItem);

                await PowerPlannerApp.Current.SaveChanges(changes);
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
Пример #26
0
 private void SingleDayControl_ItemClick(object sender, BaseViewItemHomeworkExam e)
 {
     ItemClick?.Invoke(sender, e);
 }
Пример #27
0
 private void Adapter_ItemClick(object sender, BaseViewItemHomeworkExam e)
 {
     ItemClick?.Invoke(this, e);
 }
Пример #28
0
 public void ShowUnassignedItem(BaseViewItemHomeworkExam item)
 {
     MainScreenViewModel.ShowPopup(ViewHomeworkViewModel.CreateForUnassigned(MainScreenViewModel, item));
 }
        private static void UpdateDayOfNotification(Guid localAccountId, BaseViewItemHomeworkExam item, DateTime dayOfReminderTime, Context context, NotificationManager notificationManager, List <StatusBarNotification> existingNotifs, bool fromForeground)
        {
            ViewItemClass c = item.GetClassOrNull();

            if (c == null)
            {
                return;
            }

            string tag      = localAccountId.ToString() + ";" + item.Identifier.ToString();
            var    existing = existingNotifs.FirstOrDefault(i => i.Tag == tag);

            // If the reminder has already been sent and the notification doesn't exist,
            // that means the user dismissed it, so don't show it again
            if (item.HasSentReminder && existing == null)
            {
                return;
            }

            // If there's no existing notification, and the updated time is greater than the desired reminder time,
            // then it was edited after the notification should have been sent, so don't notify, since user was already
            // aware of this item (by the fact that they were editing it)
            if (existing == null && item.Updated.ToLocalTime() > dayOfReminderTime)
            {
                return;
            }

            if (existing == null && fromForeground)
            {
                return;
            }

            const string EXTRA_UNIQUE_ID = "UniqueId";
            string       extraUniqueId   = (item.Name + ";" + c.Name).GetHashCode().ToString();

            // If there's an existing, and it hasn't changed, do nothing
            if (existing != null && existing.Notification.Extras.GetString(EXTRA_UNIQUE_ID).Equals(extraUniqueId))
            {
                return;
            }

            BaseArguments launchArgs;

            if (item is ViewItemHomework)
            {
                launchArgs = new ViewHomeworkArguments()
                {
                    LocalAccountId = localAccountId,
                    ItemId         = item.Identifier,
                    LaunchSurface  = LaunchSurface.Toast
                };
            }
            else
            {
                launchArgs = new ViewExamArguments()
                {
                    LocalAccountId = localAccountId,
                    ItemId         = item.Identifier,
                    LaunchSurface  = LaunchSurface.Toast
                };
            }

            var    builder = CreateReminderBuilder(context, localAccountId, launchArgs);
            Bundle b       = new Bundle();

            b.PutString(EXTRA_UNIQUE_ID, extraUniqueId);
            builder.SetExtras(b);
            builder.SetContentTitle(item.Name);
            builder.SetChannelId(GetChannelIdForDayOf(localAccountId));
            string subtitle = item.GetSubtitleOrNull();

            if (subtitle != null)
            {
                builder.SetContentText(subtitle);
            }
            notificationManager.Notify(tag, NotificationIds.DAY_OF_NOTIFICATIONS, BuildReminder(builder));
        }
        private static DateTime GetDayOfReminderTime(PowerPlannerSending.Schedule.Week weekOnItemDate, BaseViewItemHomeworkExam item)
        {
            bool hadSpecificTime;

            return(item.GetDayOfReminderTime(out hadSpecificTime));
        }