diff --git a/XCalendar.Core/Extensions/DateTimeExtensions.cs b/XCalendar.Core/Extensions/DateTimeExtensions.cs
index a664eb3..f32ff9a 100644
--- a/XCalendar.Core/Extensions/DateTimeExtensions.cs
+++ b/XCalendar.Core/Extensions/DateTimeExtensions.cs
@@ -320,13 +320,15 @@ public static int CalendarWeekOfMonth(this DateTime self)
///
/// The at which the week starts.
/// The number corresponding to which week of this instance's month it is in
+ /// The is not present in any of its month's weeks.
public static int CalendarWeekOfMonth(this DateTime self, DayOfWeek startingDayOfWeek)
{
for (int i = self.CalendarWeeksInMonth(startingDayOfWeek); i > 0; i--)
{
if (self.CalendarWeekInMonth(i, startingDayOfWeek).Contains(self.Date)) { return i; }
}
- throw new Exception($"The {nameof(DateTime)} is not present in any of its month's weeks.");
+
+ throw new ArgumentOutOfRangeException($"The {nameof(DateTime)} is not present in any of its month's weeks.");
}
///
/// Gets the specified week in this instance's month.
diff --git a/XCalendar.Core/Models/Calendar.cs b/XCalendar.Core/Models/Calendar.cs
index 1ecb1a7..d794d7b 100644
--- a/XCalendar.Core/Models/Calendar.cs
+++ b/XCalendar.Core/Models/Calendar.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
@@ -6,12 +7,17 @@
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
+using System.Security.Cryptography;
using XCalendar.Core.Enums;
using XCalendar.Core.Extensions;
using XCalendar.Core.Interfaces;
namespace XCalendar.Core.Models
{
+ ///
+ /// A class to represent a calendar.
+ ///
+ /// A model implementing to be used to represent each day in a page.
public class Calendar : ICalendar where T : ICalendarDay, new()
{
#region Fields
@@ -272,6 +278,11 @@ public ObservableRangeCollection SelectedDates
}
}
}
+ ///
+ /// The custom order to display the days of the week in. Replaces the values inside when this value is not null.
+ /// First, the calendar uses the to get the s
+ /// for every day of the week, then it uses those s to construct the dates in the order of the values inside this collection.
+ ///
public ObservableRangeCollection CustomDayNamesOrder
{
get
@@ -358,6 +369,11 @@ public ObservableRangeCollection DayNamesOrder
}
}
}
+ ///
+ /// The start of the range of dates to perform selection on inclusive.
+
+ ///If and are not null, will be called and their values will be set back to null.
+ ///
public DateTime? RangeSelectionStart
{
get
@@ -376,6 +392,10 @@ public DateTime? RangeSelectionStart
}
}
}
+ ///
+ /// The end of the range of dates to perform selection on inclusive.
+ ///If and are not null, will be called and their values will be set back to null.
+ ///
public DateTime? RangeSelectionEnd
{
get
@@ -394,6 +414,9 @@ public DateTime? RangeSelectionEnd
}
}
}
+ ///
+ /// Defines how the user is able to select dates.
+ ///
public SelectionType SelectionType
{
get
@@ -450,9 +473,11 @@ public Calendar()
#endregion
#region Methods
- ///
+ ///
/// Called when changes.
- ///
+ ///
+ /// The previously selected dates.
+ /// The newely selected dates.
protected virtual void OnDateSelectionChanged(IList oldSelection, IList newSelection)
{
DateSelectionChanged?.Invoke(this, new DateSelectionChangedEventArgs(oldSelection, newSelection));
@@ -538,6 +563,7 @@ public virtual void ChangeDateSelection(DateTime dateTime)
///
/// Performs selection on a range of dates as defined by and depending on the current .
///
+ /// and must not be null."
public virtual void CommitRangeSelection()
{
if (RangeSelectionStart == null || RangeSelectionEnd == null) { throw new InvalidOperationException($"{nameof(RangeSelectionStart)} and {nameof(RangeSelectionEnd)} must not be null."); }
@@ -549,21 +575,21 @@ public virtual void CommitRangeSelection()
switch (SelectionAction)
{
case SelectionAction.Add:
- if (datesToAdd.Count() != 0)
+ if (datesToAdd.Any())
{
SelectedDates.AddRange(datesToAdd);
}
break;
case SelectionAction.Remove:
- if (datesToRemove.Count() != 0)
+ if (datesToRemove.Any())
{
SelectedDates.RemoveRange(datesToRemove);
}
break;
case SelectionAction.Modify:
- if (datesToAdd.Count() != 0 || datesToRemove.Count() != 0)
+ if (datesToAdd.Any() || datesToRemove.Any())
{
List newSelectedDates = SelectedDates.Where(x => !datesToRemove.Contains(x.Date)).ToList();
newSelectedDates.AddRange(datesToAdd);
@@ -607,22 +633,47 @@ public int GetMonthRows(DateTime dateTime, bool isConsistent, DayOfWeek startOfW
return dateTime.CalendarWeeksInMonth(startOfWeek);
}
}
+ ///
+ /// Evaluates if the specified is in the 's Calendar month.
+ ///
+ /// The value to evaluate.
+ ///
public virtual bool IsDateTimeCurrentMonth(DateTime dateTime)
{
return dateTime.Month == NavigatedDate.Month && dateTime.Year == NavigatedDate.Year;
}
+ ///
+ /// Evaluates if the specified is considered as 'Today' by the calendar.
+ ///
+ /// The value to evaluate.
+ ///
public virtual bool IsDateTimeToday(DateTime dateTime)
{
return dateTime.Date == TodayDate.Date;
}
+ ///
+ /// Evaluates if the specified is considered as selected by the Calendar.
+ ///
+ /// The value to evaluate.
+ ///
public virtual bool IsDateTimeSelected(DateTime dateTime)
{
return SelectedDates.Any(x => x.Date == dateTime.Date) == true;
}
+ ///
+ /// Evaluates if the specified is not in a valid range for the Calendar.
+ ///
+ /// The value to evaluate.
+ ///
public virtual bool IsDateTimeInvalid(DateTime dateTime)
{
return dateTime.Date < NavigationLowerBound.Date || dateTime.Date > NavigationUpperBound.Date;
}
+ ///
+ /// Updates a day to represent the specified by .
+ ///
+ /// The day to update.
+ /// The new that '' should represent.
public virtual void UpdateDay(T day, DateTime newDateTime)
{
day.DateTime = newDateTime;
@@ -742,7 +793,7 @@ private void OnRowsChanged(int oldValue, int newValue)
{
int coercedRows = CoerceRows(Rows);
- if (coercedRows < 1) { throw new ArgumentException(nameof(newValue)); }
+ if (coercedRows < 1) { throw new ArgumentOutOfRangeException(nameof(newValue)); }
if (Rows != coercedRows)
{
diff --git a/XCalendarFormsSample/XCalendarFormsSample.Android/Resources/Resource.designer.cs b/XCalendarFormsSample/XCalendarFormsSample.Android/Resources/Resource.designer.cs
index 60bc5da..6b4613d 100644
--- a/XCalendarFormsSample/XCalendarFormsSample.Android/Resources/Resource.designer.cs
+++ b/XCalendarFormsSample/XCalendarFormsSample.Android/Resources/Resource.designer.cs
@@ -14,7 +14,7 @@ namespace XCalendarSample.Droid
{
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.2.0.93")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.1.0.5")]
public partial class Resource
{