Skip to content

Commit

Permalink
fix: Switch to OptimizedObservableCollection for performance
Browse files Browse the repository at this point in the history
Updated CalendarBase.cs to use OptimizedObservableCollection for `_columnHeaders`, `_rowHeaders`, and `_displayDates`. Imported `MyNet.Utilities.Collections`.

Changed base class in BlackoutDatesCollection.cs to `OptimizedObservableCollection<DateRange>`. Imported `MyNet.Utilities.Collections`.

Changed base class in SelectedDatesCollection.cs to `OptimizedObservableCollection<DateTime>`. Imported `MyNet.Utilities.Collections`.

Updated MyNet.Wpf.csproj to reference newer versions of `MyNet.Observable`, `MyNet.UI`, and `MyNet.Utilities` packages.
  • Loading branch information
Stéphane ANDRE (E104915) committed Oct 10, 2024
1 parent 5a0a436 commit e1f1f04
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/MyNet.Wpf/Controls/CalendarBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using MyNet.UI.Busy.Models;
using MyNet.UI.Collections;
using MyNet.Utilities;
using MyNet.Utilities.Collections;
using MyNet.Utilities.DateTimes;
using MyNet.Utilities.Helpers;
using MyNet.Utilities.Localization;
Expand Down Expand Up @@ -69,9 +70,9 @@ public abstract class CalendarBase : ListBox
private DateTime? _currentDate;
private ContentControl? _accurateDateControl;
private ContentControl? _accurateDatePreviewControl;
private readonly ObservableCollection<object> _columnHeaders = [];
private readonly ObservableCollection<object> _rowHeaders = [];
private readonly UiObservableCollection<CalendarItem> _displayDates = [];
private readonly OptimizedObservableCollection<object> _columnHeaders = [];
private readonly OptimizedObservableCollection<object> _rowHeaders = [];
private readonly OptimizedObservableCollection<CalendarItem> _displayDates = [];
private readonly UiObservableCollection<CalendarAppointment> _appointments = [];
private readonly SingleTaskDeferrer _refreshAppointments;
private readonly SingleTaskDeferrer _build;
Expand Down
5 changes: 2 additions & 3 deletions src/MyNet.Wpf/Controls/Calendars/BlackoutDatesCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Threading;
using MyNet.Utilities;
using MyNet.Utilities.Collections;
using PropertyChanged;

namespace MyNet.Wpf.Controls.Calendars
Expand All @@ -17,7 +16,7 @@ namespace MyNet.Wpf.Controls.Calendars
/// Initializes a new instance of the SchedulerBlackoutDatesCollection class.
/// </summary>
/// <param name="owner"></param>
public class BlackoutDatesCollection(CalendarBase owner) : ObservableCollection<DateRange>
public class BlackoutDatesCollection(CalendarBase owner) : OptimizedObservableCollection<DateRange>
{
#region Data

Expand Down
3 changes: 2 additions & 1 deletion src/MyNet.Wpf/Controls/Calendars/SelectedDatesCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using System.Threading;
using System.Windows.Controls;
using MyNet.Utilities.Collections;

namespace MyNet.Wpf.Controls.Calendars
{
Expand All @@ -19,7 +20,7 @@ namespace MyNet.Wpf.Controls.Calendars
/// Initializes a new instance of the SchedulerSelectedDatesCollection class.
/// </remarks>
/// <param name="owner"></param>
public sealed class SelectedDatesCollection(CalendarBase owner) : ObservableCollection<DateTime>
public sealed class SelectedDatesCollection(CalendarBase owner) : OptimizedObservableCollection<DateTime>
{
#region Data

Expand Down
6 changes: 3 additions & 3 deletions src/MyNet.Wpf/MyNet.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<PackageReference Include="MahApps.Metro" Version="3.0.0-alpha0492" />
<PackageReference Include="MaterialDesignThemes" Version="5.1.1-ci780" />
<PackageReference Include="MyNet.Humanizer" Version="2.0.0" />
<PackageReference Include="MyNet.Observable" Version="6.0.1-pre.6" />
<PackageReference Include="MyNet.UI" Version="5.0.1-pre.4" />
<PackageReference Include="MyNet.Utilities" Version="5.2.1-pre.4" />
<PackageReference Include="MyNet.Observable" Version="6.0.1-pre.7" />
<PackageReference Include="MyNet.UI" Version="5.0.1-pre.5" />
<PackageReference Include="MyNet.Utilities" Version="5.2.1-pre.6" />
<PackageReference Include="MyNet.Xaml.Html" Version="1.0.0" />
<PackageReference Include="MyNet.Xaml.Merger.MSBuild" Version="2.0.1">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit e1f1f04

Please sign in to comment.