Skip to content

Commit 00049c7

Browse files
authored
Merge pull request #88 from w-ahmad/comments
added comments on types and members
2 parents 9f1eae4 + f935001 commit 00049c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1760
-39
lines changed

src/WinUI.TableView/Controls/TableViewDatePicker.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@
55

66
namespace WinUI.TableView.Controls;
77

8+
/// <summary>
9+
/// Represents a date editing element for the TableViewDateColumn.
10+
/// </summary>
811
public partial class TableViewDatePicker : CalendarDatePicker
912
{
1013
private bool _deferUpdate;
1114

15+
/// <summary>
16+
/// Initializes a new instance of the TableViewDatePicker class.
17+
/// </summary>
1218
public TableViewDatePicker()
1319
{
1420
DateChanged += OnDateChanged;
1521
}
1622

23+
/// <summary>
24+
/// Handles the DateChanged event.
25+
/// </summary>
1726
private void OnDateChanged(CalendarDatePicker sender, CalendarDatePickerDateChangedEventArgs args)
1827
{
1928
if (_deferUpdate) return;
@@ -46,6 +55,9 @@ private void OnDateChanged(CalendarDatePicker sender, CalendarDatePickerDateChan
4655
_deferUpdate = false;
4756
}
4857

58+
/// <summary>
59+
/// Handles changes to the SelectedDate property.
60+
/// </summary>
4961
private static void OnSelectedDateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
5062
{
5163
if (d is TableViewDatePicker datePicker && !datePicker._deferUpdate)
@@ -63,13 +75,23 @@ private static void OnSelectedDateChanged(DependencyObject d, DependencyProperty
6375
}
6476
}
6577

78+
/// <summary>
79+
/// Gets or sets the source type of the date picker.
80+
/// This value could be DateOnly, DateTime, or DateTimeOffset.
81+
/// </summary>
6682
internal Type? SourceType { get; set; }
6783

84+
/// <summary>
85+
/// Gets or sets the selected date.
86+
/// </summary>
6887
public object? SelectedDate
6988
{
7089
get => GetValue(SelectedDateProperty);
7190
set => SetValue(SelectedDateProperty, value);
7291
}
7392

93+
/// <summary>
94+
/// Identifies the SelectedDate dependency property.
95+
/// </summary>
7496
public static readonly DependencyProperty SelectedDateProperty = DependencyProperty.Register(nameof(SelectedDate), typeof(object), typeof(TableViewDatePicker), new PropertyMetadata(default, OnSelectedDateChanged));
7597
}

src/WinUI.TableView/Controls/TableViewTimePicker.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@
99

1010
namespace WinUI.TableView.Controls;
1111

12+
/// <summary>
13+
/// Represents a time editing element for the TableViewTimeColumn.
14+
/// </summary>
1215
public class TableViewTimePicker : Control
1316
{
1417
private TextBlock? _timeText;
1518
private readonly TimePickerFlyout _flyout;
1619

20+
/// <summary>
21+
/// Initializes a new instance of the TableViewTimePicker class.
22+
/// </summary>
1723
public TableViewTimePicker()
1824
{
1925
DefaultStyleKey = typeof(TableViewTimePicker);
@@ -50,6 +56,9 @@ protected override void OnKeyDown(KeyRoutedEventArgs e)
5056
}
5157
}
5258

59+
/// <summary>
60+
/// Shows the time picker flyout.
61+
/// </summary>
5362
private void ShowFlyout()
5463
{
5564
_flyout.Time = SelectedTime switch
@@ -66,6 +75,9 @@ private void ShowFlyout()
6675
_flyout.ShowAt(this);
6776
}
6877

78+
/// <summary>
79+
/// Handles the TimePicked event of the flyout.
80+
/// </summary>
6981
private void OnTimePicked(TimePickerFlyout sender, TimePickedEventArgs args)
7082
{
7183
var oldTime = SelectedTime is null ? TimeSpan.Zero : args.OldTime;
@@ -91,6 +103,9 @@ private void OnTimePicked(TimePickerFlyout sender, TimePickedEventArgs args)
91103
}
92104
}
93105

106+
/// <summary>
107+
/// Updates the text displayed in the time picker.
108+
/// </summary>
94109
private void UpdateTimeText()
95110
{
96111
if (_timeText is null) return;
@@ -108,6 +123,9 @@ private void UpdateTimeText()
108123
};
109124
}
110125

126+
/// <summary>
127+
/// Handles changes to the SelectedTime property.
128+
/// </summary>
111129
private static void OnSelectedTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
112130
{
113131
if (d is TableViewTimePicker timePicker)
@@ -117,6 +135,9 @@ private static void OnSelectedTimeChanged(DependencyObject d, DependencyProperty
117135
}
118136
}
119137

138+
/// <summary>
139+
/// Handles changes to the PlaceholderText property.
140+
/// </summary>
120141
private static void OnPlaceHolderTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
121142
{
122143
if (d is TableViewTimePicker timePicker)
@@ -125,6 +146,9 @@ private static void OnPlaceHolderTextChanged(DependencyObject d, DependencyPrope
125146
}
126147
}
127148

149+
/// <summary>
150+
/// Handles changes to the ClockIdentifier property.
151+
/// </summary>
128152
private static void OnClockIdentifierChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
129153
{
130154
if (d is TableViewTimePicker timePicker)
@@ -133,34 +157,65 @@ private static void OnClockIdentifierChanged(DependencyObject d, DependencyPrope
133157
}
134158
}
135159

160+
/// <summary>
161+
/// Gets or sets the source type of the time picker.
162+
/// The value could be TimeSpan, TimeOnly, DateTime, or DateTimeOffset.
163+
/// </summary>
136164
internal Type? SourceType { get; set; }
137165

166+
/// <summary>
167+
/// Gets or sets the selected time.
168+
/// </summary>
138169
public object? SelectedTime
139170
{
140171
get => GetValue(SelectedTimeProperty);
141172
set => SetValue(SelectedTimeProperty, value);
142173
}
143174

175+
/// <summary>
176+
/// Gets or sets the placeholder text for the time picker.
177+
/// </summary>
144178
public string? PlaceholderText
145179
{
146180
get => (string?)GetValue(PlaceholderTextProperty);
147181
set => SetValue(PlaceholderTextProperty, value);
148182
}
149183

184+
/// <summary>
185+
/// Gets or sets the clock identifier for the time picker.
186+
/// </summary>
150187
public string ClockIdentifier
151188
{
152189
get => (string)GetValue(ClockIdentifierProperty);
153190
set => SetValue(ClockIdentifierProperty, value);
154191
}
155192

193+
/// <summary>
194+
/// Gets or sets the minute increment for the time picker.
195+
/// </summary>
156196
public int MinuteIncrement
157197
{
158198
get => (int)GetValue(MinuteIncrementProperty);
159199
set => SetValue(MinuteIncrementProperty, value);
160200
}
161201

202+
/// <summary>
203+
/// Identifies the MinuteIncrement dependency property.
204+
/// </summary>
162205
public static readonly DependencyProperty MinuteIncrementProperty = DependencyProperty.Register(nameof(MinuteIncrement), typeof(int), typeof(TableViewTimePicker), new PropertyMetadata(1));
206+
207+
/// <summary>
208+
/// Identifies the SelectedTime dependency property.
209+
/// </summary>
163210
public static readonly DependencyProperty SelectedTimeProperty = DependencyProperty.Register(nameof(SelectedTime), typeof(object), typeof(TableViewTimePicker), new PropertyMetadata(default, OnSelectedTimeChanged));
211+
212+
/// <summary>
213+
/// Identifies the PlaceholderText dependency property.
214+
/// </summary>
164215
public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register(nameof(PlaceholderText), typeof(string), typeof(TableViewTimePicker), new PropertyMetadata("pick a time", OnPlaceHolderTextChanged));
216+
217+
/// <summary>
218+
/// Identifies the ClockIdentifier dependency property.
219+
/// </summary>
165220
public static readonly DependencyProperty ClockIdentifierProperty = DependencyProperty.Register(nameof(ClockIdentifier), typeof(string), typeof(TableViewTimePicker), new PropertyMetadata(default, OnClockIdentifierChanged));
166221
}

src/WinUI.TableView/Extensions/DateTimeExtensions.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,46 @@
22

33
namespace WinUI.TableView.Extensions;
44

5+
/// <summary>
6+
/// Provides extension methods for Date&Time types.
7+
/// </summary>
58
internal static class DateTimeExtensions
69
{
10+
/// <summary>
11+
/// Converts a DateTime to a DateTimeOffset using the local time zone.
12+
/// </summary>
13+
/// <param name="dateTime">The DateTime to convert.</param>
14+
/// <returns>A DateTimeOffset representing the same point in time as the DateTime.</returns>
715
public static DateTimeOffset ToDateTimeOffset(this DateTime dateTime)
816
{
917
return new DateTimeOffset(dateTime, TimeZoneInfo.Local.GetUtcOffset(dateTime));
1018
}
1119

20+
/// <summary>
21+
/// Converts a TimeSpan to a DateTimeOffset using the current date.
22+
/// </summary>
23+
/// <param name="timeSpan">The TimeSpan to convert.</param>
24+
/// <returns>A DateTimeOffset representing the same time of day as the TimeSpan on the current date.</returns>
1225
public static DateTimeOffset ToDateTimeOffset(this TimeSpan timeSpan)
1326
{
1427
return DateTime.Today.Add(timeSpan).ToDateTimeOffset();
1528
}
1629

30+
/// <summary>
31+
/// Converts a DateOnly to a DateTimeOffset using the minimum time of day.
32+
/// </summary>
33+
/// <param name="dateOnly">The DateOnly to convert.</param>
34+
/// <returns>A DateTimeOffset representing the same date as the DateOnly with the minimum time of day.</returns>
1735
public static DateTimeOffset ToDateTimeOffset(this DateOnly dateOnly)
1836
{
1937
return dateOnly.ToDateTime(TimeOnly.MinValue).ToDateTimeOffset();
2038
}
2139

40+
/// <summary>
41+
/// Converts a TimeOnly to a DateTimeOffset using the current date.
42+
/// </summary>
43+
/// <param name="timeOnly">The TimeOnly to convert.</param>
44+
/// <returns>A DateTimeOffset representing the same time of day as the TimeOnly on the current date.</returns>
2245
public static DateTimeOffset ToDateTimeOffset(this TimeOnly timeOnly)
2346
{
2447
return timeOnly.ToTimeSpan().ToDateTimeOffset();

src/WinUI.TableView/Extensions/ItemIndexRangeExtensions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22

33
namespace WinUI.TableView.Extensions;
44

5+
/// <summary>
6+
/// Provides extension methods for the ItemIndexRange type.
7+
/// </summary>
58
public static class ItemIndexRangeExtensions
69
{
10+
/// <summary>
11+
/// Determines whether a specified index is within the range.
12+
/// </summary>
13+
/// <param name="range">The ItemIndexRange to check.</param>
14+
/// <param name="index">The index to check.</param>
15+
/// <returns>True if the index is within the range; otherwise, false.</returns>
716
public static bool IsInRange(this ItemIndexRange range, int index)
817
{
918
return index >= range.FirstIndex && index <= range.LastIndex;
1019
}
11-
}
20+
}

src/WinUI.TableView/Extensions/ObjectExtensions.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33

44
namespace WinUI.TableView.Extensions;
55

6+
/// <summary>
7+
/// Provides extension methods for object types.
8+
/// </summary>
69
internal static class ObjectExtensions
710
{
11+
/// <summary>
12+
/// Gets the value of a property from an object using a sequence of property info and index pairs.
13+
/// </summary>
14+
/// <param name="obj">The object from which to get the value.</param>
15+
/// <param name="pis">An array of property info and index pairs.</param>
16+
/// <returns>The value of the property, or null if the object is null.</returns>
817
internal static object? GetValue(this object? obj, (PropertyInfo pi, object? index)[] pis)
918
{
1019
foreach (var pi in pis)
@@ -20,6 +29,14 @@ internal static class ObjectExtensions
2029
return obj;
2130
}
2231

32+
/// <summary>
33+
/// Gets the value of a property from an object using a type and a property path.
34+
/// </summary>
35+
/// <param name="obj">The object from which to get the value.</param>
36+
/// <param name="type">The type of the object.</param>
37+
/// <param name="path">The property path.</param>
38+
/// <param name="pis">An array of property info and index pairs.</param>
39+
/// <returns>The value of the property, or null if the object is null.</returns>
2340
internal static object? GetValue(this object? obj, Type? type, string path, out (PropertyInfo pi, object? index)[] pis)
2441
{
2542
var parts = path.Split('.');

src/WinUI.TableView/Extensions/TableViewCellSlotExtensions.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
namespace WinUI.TableView.Extensions;
22

3+
/// <summary>
4+
/// Provides extension methods for the TableViewCellSlot type.
5+
/// </summary>
36
internal static class TableViewCellSlotExtensions
47
{
8+
/// <summary>
9+
/// Determines whether the row index of the slot is valid within the TableView.
10+
/// </summary>
11+
/// <param name="slot">The TableViewCellSlot to check.</param>
12+
/// <param name="tableView">The TableView to check against.</param>
13+
/// <returns>True if the row index of TableView is valid; otherwise, false.</returns>
514
public static bool IsValidRow(this TableViewCellSlot slot, TableView tableView)
615
{
716
return slot.Row >= 0 && slot.Row < tableView?.Items.Count;
817
}
918

19+
/// <summary>
20+
/// Determines whether the column index of the slot is valid within the TableView.
21+
/// </summary>
22+
/// <param name="slot">The TableViewCellSlot to check.</param>
23+
/// <param name="tableView">The TableView to check against.</param>
24+
/// <returns>True if the column index TableView is valid; otherwise, false.</returns>
1025
public static bool IsValidColumn(this TableViewCellSlot slot, TableView tableView)
1126
{
1227
return slot.Column >= 0 && slot.Column < tableView?.Columns.VisibleColumns.Count;
1328
}
1429

30+
/// <summary>
31+
/// Determines whether both the row and column indices of the slot are valid within the TableView.
32+
/// </summary>
33+
/// <param name="slot">The TableViewCellSlot to check.</param>
34+
/// <param name="tableView">The TableView to check against.</param>
35+
/// <returns>True if both the row and column indices of TableView are valid; otherwise, false.</returns>
1536
public static bool IsValid(this TableViewCellSlot slot, TableView tableView)
1637
{
1738
return slot.IsValidRow(tableView) && slot.IsValidColumn(tableView);

0 commit comments

Comments
 (0)