diff --git a/Wino.Calendar.ViewModels/CalendarSettingsPageViewModel.cs b/Wino.Calendar.ViewModels/CalendarSettingsPageViewModel.cs index 1bd20b2e..b0e4a41a 100644 --- a/Wino.Calendar.ViewModels/CalendarSettingsPageViewModel.cs +++ b/Wino.Calendar.ViewModels/CalendarSettingsPageViewModel.cs @@ -26,6 +26,9 @@ public partial class CalendarSettingsPageViewModel : CalendarBaseViewModel [ObservableProperty] public partial bool Is24HourHeaders { get; set; } + [ObservableProperty] + public partial bool IsWorkingHoursEnabled { get; set; } + [ObservableProperty] public partial TimeSpan WorkingHourStart { get; set; } @@ -103,6 +106,7 @@ public partial class CalendarSettingsPageViewModel : CalendarBaseViewModel var cultureFirstDayName = cultureInfo.DateTimeFormat.GetDayName(preferencesService.FirstDayOfWeek); SelectedFirstDayOfWeekIndex = DayNames.IndexOf(cultureFirstDayName); Is24HourHeaders = preferencesService.Prefer24HourTimeFormat; + IsWorkingHoursEnabled = preferencesService.IsWorkingHoursEnabled; WorkingHourStart = preferencesService.WorkingHourStart; WorkingHourEnd = preferencesService.WorkingHourEnd; CellHourHeight = preferencesService.HourHeight; @@ -193,6 +197,7 @@ public partial class CalendarSettingsPageViewModel : CalendarBaseViewModel SaveSettings(); } partial void OnSelectedFirstDayOfWeekIndexChanged(int value) => SaveSettings(); + partial void OnIsWorkingHoursEnabledChanged(bool value) => SaveSettings(); partial void OnWorkingHourStartChanged(TimeSpan value) => SaveSettings(); partial void OnWorkingHourEndChanged(TimeSpan value) => SaveSettings(); partial void OnWorkingDayStartIndexChanged(int value) => SaveSettings(); @@ -327,6 +332,7 @@ public partial class CalendarSettingsPageViewModel : CalendarBaseViewModel }; PreferencesService.Prefer24HourTimeFormat = Is24HourHeaders; + PreferencesService.IsWorkingHoursEnabled = IsWorkingHoursEnabled; PreferencesService.WorkingHourStart = WorkingHourStart; PreferencesService.WorkingHourEnd = WorkingHourEnd; PreferencesService.HourHeight = CellHourHeight; diff --git a/Wino.Core.Domain/Interfaces/IPreferencesService.cs b/Wino.Core.Domain/Interfaces/IPreferencesService.cs index 6d25429b..9b80f8e2 100644 --- a/Wino.Core.Domain/Interfaces/IPreferencesService.cs +++ b/Wino.Core.Domain/Interfaces/IPreferencesService.cs @@ -231,6 +231,7 @@ public interface IPreferencesService : INotifyPropertyChanged #region Calendar DayOfWeek FirstDayOfWeek { get; set; } + bool IsWorkingHoursEnabled { get; set; } TimeSpan WorkingHourStart { get; set; } TimeSpan WorkingHourEnd { get; set; } DayOfWeek WorkingDayStart { get; set; } diff --git a/Wino.Core.Domain/Models/Calendar/CalendarSettings.cs b/Wino.Core.Domain/Models/Calendar/CalendarSettings.cs index ccced811..bb1359d8 100644 --- a/Wino.Core.Domain/Models/Calendar/CalendarSettings.cs +++ b/Wino.Core.Domain/Models/Calendar/CalendarSettings.cs @@ -7,6 +7,7 @@ namespace Wino.Core.Domain.Models.Calendar; public record CalendarSettings(DayOfWeek FirstDayOfWeek, List WorkingDays, + bool IsWorkingHoursEnabled, DayOfWeek WorkWeekStart, DayOfWeek WorkWeekEnd, TimeSpan WorkingHourStart, diff --git a/Wino.Core.Tests/CalendarPageViewModelTests.cs b/Wino.Core.Tests/CalendarPageViewModelTests.cs index a0c06ca5..ce765593 100644 --- a/Wino.Core.Tests/CalendarPageViewModelTests.cs +++ b/Wino.Core.Tests/CalendarPageViewModelTests.cs @@ -164,10 +164,11 @@ public class CalendarPageViewModelTests return new CalendarSettings( firstDayOfWeek, [DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday], + true, workWeekStart, workWeekEnd, - TimeSpan.FromHours(8), - TimeSpan.FromHours(17), + TimeSpan.FromHours(9), + TimeSpan.FromHours(18), 64, DayHeaderDisplayType.TwentyFourHour, CultureInfo.GetCultureInfo(cultureName)); diff --git a/Wino.Core.Tests/CalendarRangeResolverTests.cs b/Wino.Core.Tests/CalendarRangeResolverTests.cs index c72dcf42..ada2b715 100644 --- a/Wino.Core.Tests/CalendarRangeResolverTests.cs +++ b/Wino.Core.Tests/CalendarRangeResolverTests.cs @@ -171,10 +171,11 @@ public class CalendarRangeResolverTests return new CalendarSettings( firstDayOfWeek, [DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday], + true, workWeekStart, workWeekEnd, - TimeSpan.FromHours(8), - TimeSpan.FromHours(17), + TimeSpan.FromHours(9), + TimeSpan.FromHours(18), 64, DayHeaderDisplayType.TwentyFourHour, CultureInfo.GetCultureInfo(cultureName)); diff --git a/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml.cs b/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml.cs index c83ce397..56253051 100644 --- a/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml.cs +++ b/Wino.Mail.WinUI/Controls/Calendar/CalendarPeriodControl.xaml.cs @@ -402,6 +402,7 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty var scaleX = (float)(e.Info.Width / timedSurfaceWidth); var scaleY = (float)(e.Info.Height / timelineHeight); var dayWidth = (float)(_timedLayout.DayWidth * scaleX); + var isWorkingHoursEnabled = CalendarSettings?.IsWorkingHoursEnabled == true; var workDayStartHour = CalendarSettings?.WorkingHourStart.TotalHours ?? 9d; var workDayEndHour = CalendarSettings?.WorkingHourEnd.TotalHours ?? 17d; var intervalHeight = (float)(GetTimedGridIntervalHeight() * scaleY); @@ -410,7 +411,8 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty for (var dayIndex = 0; dayIndex < _timedLayout.VisibleDates.Count; dayIndex++) { var x = dayIndex * dayWidth; - var isWorkingDay = CalendarSettings?.WorkingDays.Contains(_timedLayout.VisibleDates[dayIndex].DayOfWeek) == true; + var isWorkingDay = isWorkingHoursEnabled && + CalendarSettings?.WorkingDays.Contains(_timedLayout.VisibleDates[dayIndex].DayOfWeek) == true; for (var intervalIndex = 0; intervalIndex < intervalCount; intervalIndex++) { diff --git a/Wino.Mail.WinUI/Services/PreferencesService.cs b/Wino.Mail.WinUI/Services/PreferencesService.cs index a5a1dd63..f239003b 100644 --- a/Wino.Mail.WinUI/Services/PreferencesService.cs +++ b/Wino.Mail.WinUI/Services/PreferencesService.cs @@ -311,6 +311,12 @@ public class PreferencesService(IConfigurationService configurationService) : Ob set => SaveProperty(propertyName: nameof(HourHeight), value); } + public bool IsWorkingHoursEnabled + { + get => _configurationService.Get(nameof(IsWorkingHoursEnabled), true); + set => SaveProperty(propertyName: nameof(IsWorkingHoursEnabled), value); + } + public string CalendarTimedDayHeaderDateFormat { get => _configurationService.Get(nameof(CalendarTimedDayHeaderDateFormat), "ddd dd"); @@ -319,13 +325,13 @@ public class PreferencesService(IConfigurationService configurationService) : Ob public TimeSpan WorkingHourStart { - get => _configurationService.Get(nameof(WorkingHourStart), new TimeSpan(8, 0, 0)); + get => _configurationService.Get(nameof(WorkingHourStart), new TimeSpan(9, 0, 0)); set => SaveProperty(propertyName: nameof(WorkingHourStart), value); } public TimeSpan WorkingHourEnd { - get => _configurationService.Get(nameof(WorkingHourEnd), new TimeSpan(17, 0, 0)); + get => _configurationService.Get(nameof(WorkingHourEnd), new TimeSpan(18, 0, 0)); set => SaveProperty(propertyName: nameof(WorkingHourEnd), value); } @@ -402,6 +408,7 @@ public class PreferencesService(IConfigurationService configurationService) : Ob return new CalendarSettings(FirstDayOfWeek, workingDays, + IsWorkingHoursEnabled, WorkingDayStart, WorkingDayEnd, WorkingHourStart, diff --git a/Wino.Mail.WinUI/Views/Calendar/CalendarSettingsPage.xaml b/Wino.Mail.WinUI/Views/Calendar/CalendarSettingsPage.xaml index 05615617..17b3c7f1 100644 --- a/Wino.Mail.WinUI/Views/Calendar/CalendarSettingsPage.xaml +++ b/Wino.Mail.WinUI/Views/Calendar/CalendarSettingsPage.xaml @@ -38,55 +38,71 @@ HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" ContentAlignment="Vertical"> - - - - - + + + + + + - - - - - - - - - - + + + + + - - - - - - - - + + + + + + + + + + - - - + + + + + + + + + + + + + + @@ -177,6 +193,7 @@ @@ -187,19 +204,13 @@ - + - - + + - + + + +