|
|
@@ -2,6 +2,7 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.ComponentModel;
|
|
|
+using System.Diagnostics.CodeAnalysis;
|
|
|
using System.Globalization;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
@@ -71,11 +72,10 @@ namespace PRSDesktop
|
|
|
Settings // Dont allow settings to be updated
|
|
|
}
|
|
|
|
|
|
- private EventSuppressor suppressor = null;
|
|
|
+ private EventSuppressor? suppressor = null;
|
|
|
public void DisableUpdate()
|
|
|
{
|
|
|
- if (suppressor == null)
|
|
|
- suppressor = new EventSuppressor(Suppress.Refresh, Suppress.Settings);
|
|
|
+ suppressor ??= new EventSuppressor(Suppress.Refresh, Suppress.Settings);
|
|
|
}
|
|
|
|
|
|
public void EnableUpdate()
|
|
|
@@ -87,10 +87,12 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void DoSetValue<T>(DependencyProperty property, T value, Action? updateselector, Action? updateinterface)
|
|
|
+ private void DoSetValue<T>(DependencyProperty? property, T value, Action? updateselector, Action? updateinterface)
|
|
|
{
|
|
|
-
|
|
|
- SetValue(property, value);
|
|
|
+ if(property is not null)
|
|
|
+ {
|
|
|
+ SetValue(property, value);
|
|
|
+ }
|
|
|
|
|
|
if (!EventSuppressor.IsSet(Suppress.Selector) && (updateselector != null))
|
|
|
using (new EventSuppressor(Suppress.Events))
|
|
|
@@ -106,8 +108,8 @@ namespace PRSDesktop
|
|
|
{
|
|
|
Properties.SettingsVisible = SettingsVisible;
|
|
|
Properties.Date = SelectedDate;
|
|
|
- Properties.StartHour = (int)Bookings.DaysViewSettings.StartHour;
|
|
|
- Properties.EndHour = (int)Bookings.DaysViewSettings.EndHour;
|
|
|
+ // Properties.StartHour = (int)Bookings.DaysViewSettings.StartHour;
|
|
|
+ // Properties.EndHour = (int)Bookings.DaysViewSettings.EndHour;
|
|
|
Properties.CalendarView = CalendarView;
|
|
|
Properties.EmployeeSelector = EmployeeSettings;
|
|
|
Properties.EmployeeSelection = EmployeeSelection;
|
|
|
@@ -132,11 +134,7 @@ namespace PRSDesktop
|
|
|
public Visibility HeaderVisibility
|
|
|
{
|
|
|
get => (Visibility)GetValue(HeaderVisibilityProperty);
|
|
|
- set
|
|
|
- {
|
|
|
- SetValue(HeaderVisibilityProperty,value);
|
|
|
- Bookings.HeaderVisibility = value;
|
|
|
- }
|
|
|
+ set => SetValue(HeaderVisibilityProperty,value);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
@@ -171,7 +169,7 @@ namespace PRSDesktop
|
|
|
_splitPanel.AllowableViews = value == CalendarSettingsVisibility.Disabled
|
|
|
? DynamicSplitPanelView.Master
|
|
|
: DynamicSplitPanelView.Master | DynamicSplitPanelView.Combined;
|
|
|
- ResizeColumns(this.ActualWidth);
|
|
|
+ // ResizeColumns(this.ActualWidth);
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
@@ -185,33 +183,39 @@ namespace PRSDesktop
|
|
|
nameof(CalendarView),
|
|
|
typeof(CalendarViewType),
|
|
|
typeof(Calendar),
|
|
|
- new UIPropertyMetadata(CalendarViewType.Day)
|
|
|
+ new UIPropertyMetadata(CalendarViewType.Day, CalendarView_Changed)
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
public CalendarViewType CalendarView
|
|
|
{
|
|
|
get => (CalendarViewType)GetValue(CalendarViewProperty);
|
|
|
- set => SetCalendarView(value);
|
|
|
+ set => SetValue(CalendarViewProperty, value);
|
|
|
}
|
|
|
|
|
|
private void SetCalendarView(CalendarViewType value)
|
|
|
{
|
|
|
- DoSetValue(
|
|
|
- CalendarViewProperty,
|
|
|
- value,
|
|
|
- () => CalendarViewSelector.SelectedIndex = (int)value,
|
|
|
- () =>
|
|
|
- {
|
|
|
- Bookings.ViewType = value switch
|
|
|
- {
|
|
|
- CalendarViewType.Day => SchedulerViewType.Day,
|
|
|
- CalendarViewType.WorkWeek => SchedulerViewType.WorkWeek,
|
|
|
- CalendarViewType.Week => SchedulerViewType.Week,
|
|
|
- _ => SchedulerViewType.Day
|
|
|
- };
|
|
|
- ResizeColumns(this.ActualWidth);
|
|
|
- }
|
|
|
- );
|
|
|
+ // DoSetValue(
|
|
|
+ // CalendarViewProperty,
|
|
|
+ // value,
|
|
|
+ // () =>
|
|
|
+ // {
|
|
|
+ // Bookings.ViewType = value switch
|
|
|
+ // {
|
|
|
+ // CalendarViewType.Day => SchedulerViewType.Day,
|
|
|
+ // CalendarViewType.WorkWeek => SchedulerViewType.WorkWeek,
|
|
|
+ // CalendarViewType.Week => SchedulerViewType.Week,
|
|
|
+ // _ => SchedulerViewType.Day
|
|
|
+ // };
|
|
|
+ // ResizeColumns(this.ActualWidth);
|
|
|
+ // }
|
|
|
+ // );
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void CalendarView_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (d is not Calendar calendar) return;
|
|
|
+ calendar.CalendarViewSelector.SelectedIndex = (int)calendar.CalendarView;
|
|
|
+ calendar.Properties.CalendarView = calendar.CalendarView;
|
|
|
}
|
|
|
|
|
|
private void CalendarViewSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
@@ -658,21 +662,21 @@ namespace PRSDesktop
|
|
|
|
|
|
#region Event Handlers
|
|
|
|
|
|
- public event LoadSettings<CalendarSettings> LoadSettings;
|
|
|
+ public event LoadSettings<CalendarSettings>? LoadSettings;
|
|
|
|
|
|
- public event SaveSettings<CalendarSettings> SaveSettings;
|
|
|
+ public event SaveSettings<CalendarSettings>? SaveSettings;
|
|
|
|
|
|
- public CalendarConfigurationEvent ConfigurationChanged;
|
|
|
+ public CalendarConfigurationEvent? ConfigurationChanged;
|
|
|
|
|
|
- public event CalendarDataEvent CustomiseContextMenu;
|
|
|
+ public event CalendarDataEvent? CustomiseContextMenu;
|
|
|
|
|
|
- public event CalendarDataEvent SelectionChanged;
|
|
|
+ public event CalendarDataEvent? SelectionChanged;
|
|
|
|
|
|
- public event CalendarDataEvent ItemCreated;
|
|
|
+ public event CalendarDataEvent? ItemCreated;
|
|
|
|
|
|
- public event CalendarDataEvent ItemChanged;
|
|
|
+ public event CalendarDataEvent? ItemChanged;
|
|
|
|
|
|
- public event CalendarHandledEvent ItemEditing;
|
|
|
+ public event CalendarHandledEvent? ItemEditing;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
@@ -693,8 +697,8 @@ namespace PRSDesktop
|
|
|
|
|
|
private bool bColumnsLoaded;
|
|
|
|
|
|
- private AssignmentGrid ag;
|
|
|
- private DynamicDataGrid<Meeting> mg;
|
|
|
+ private AssignmentGrid? ag;
|
|
|
+ private DynamicDataGrid<Meeting>? mg;
|
|
|
|
|
|
public bool IsReady { get; set; }
|
|
|
|
|
|
@@ -709,7 +713,7 @@ namespace PRSDesktop
|
|
|
InitializeComponent();
|
|
|
SetValue(StartHourProperty, 0);
|
|
|
SetValue(EndHourProperty, 24);
|
|
|
- SfSkinManager.SetTheme(Bookings, new Theme() { ThemeName = "Office2019White", ScrollBarMode = ScrollBarMode.Compact });
|
|
|
+ // SfSkinManager.SetTheme(Bookings, new Theme() { ThemeName = "Office2019White", ScrollBarMode = ScrollBarMode.Compact });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -753,16 +757,17 @@ namespace PRSDesktop
|
|
|
_standardleaves = query.Get<StandardLeave>().Rows.Select(row => new StandardLeaveModel(row)).ToArray();
|
|
|
_leaverequests = query.Get<LeaveRequest>().Rows.Select(row => new LeaveRequestModel(row)).ToArray();
|
|
|
|
|
|
- var widthtimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(100) };
|
|
|
- widthtimer.Tick += (o, e) =>
|
|
|
- {
|
|
|
- if (Bookings.ActualWidth > 0.0F)
|
|
|
- {
|
|
|
- widthtimer.IsEnabled = false;
|
|
|
- ReloadColumns();
|
|
|
- }
|
|
|
- };
|
|
|
- widthtimer.IsEnabled = true;
|
|
|
+ ReloadColumns();
|
|
|
+ // var widthtimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(100) };
|
|
|
+ // widthtimer.Tick += (o, e) =>
|
|
|
+ // {
|
|
|
+ // if (Bookings.ActualWidth > 0.0F)
|
|
|
+ // {
|
|
|
+ // widthtimer.IsEnabled = false;
|
|
|
+ // ReloadColumns();
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+ // widthtimer.IsEnabled = true;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -829,8 +834,8 @@ namespace PRSDesktop
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- Bookings.DisplayDate = Bookings.SelectedDate.HasValue ? Bookings.SelectedDate.Value : StartDate;
|
|
|
- Bookings.ItemsSource = appointments;
|
|
|
+ // Bookings.DisplayDate = Bookings.SelectedDate.HasValue ? Bookings.SelectedDate.Value : StartDate;
|
|
|
+ Calendar.ItemsSource = appointments;
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
@@ -930,7 +935,7 @@ namespace PRSDesktop
|
|
|
) where TEntity : Entity where TModel : class, IModel
|
|
|
{
|
|
|
|
|
|
- if (Bookings.ItemsSource is CalendarAppointments appointments)
|
|
|
+ if (Calendar.ItemsSource is CalendarAppointments appointments)
|
|
|
{
|
|
|
var appointment = appointments.FirstOrDefault(x => (Guid)x.Id == entity.ID) as ScheduleAppointment;
|
|
|
if (appointment != null)
|
|
|
@@ -953,7 +958,7 @@ namespace PRSDesktop
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (Bookings.ItemsSource is CalendarAppointments appointments)
|
|
|
+ if (Calendar.ItemsSource is CalendarAppointments appointments)
|
|
|
UpdateCalendar(assignment, _assignments, (model) => LoadAssignment(model,appointments));
|
|
|
|
|
|
}
|
|
|
@@ -1144,38 +1149,38 @@ namespace PRSDesktop
|
|
|
ResizeColumns(e.NewSize.Width);
|
|
|
}
|
|
|
|
|
|
- private void ResizeColumns(double width)
|
|
|
- {
|
|
|
- if (double.IsNaN(width) || !Bookings.FindVisualChildren<ScrollPanel>().Any())
|
|
|
- return;
|
|
|
+ // private void ResizeColumns(double width)
|
|
|
+ // {
|
|
|
+ // if (double.IsNaN(width) || !Bookings.FindVisualChildren<ScrollPanel>().Any())
|
|
|
+ // return;
|
|
|
|
|
|
- var maxcount = (int)width / 75;
|
|
|
- Bookings.DaysViewSettings.VisibleResourceCount = Math.Min(maxcount,
|
|
|
- _employees.Length * (Bookings.ViewType == SchedulerViewType.Day ? 1 : Bookings.ViewType == SchedulerViewType.WorkWeek ? 5 : 7));
|
|
|
-
|
|
|
- if (Bookings.ResourceCollection is ObservableCollection<SchedulerResource> resources)
|
|
|
- {
|
|
|
- var colwidth = GetResourceColumnWidth();
|
|
|
- foreach (var emp in _employees)
|
|
|
- {
|
|
|
- var resource = resources.FirstOrDefault(x => String.Equals(x.Id?.ToString(), emp.ID.ToString()));
|
|
|
- if (resource != null)
|
|
|
- {
|
|
|
- var comps = emp.Name.Split(' ');
|
|
|
- var display = emp.Name;
|
|
|
- if (colwidth < 75)
|
|
|
- display = string.Format("{0}{1}", comps[0].Length > 0 ? comps[0][..1] : "",
|
|
|
- comps.Length > 1 ? comps.Skip(1).First()[..1].ToUpper() : "");
|
|
|
- else if (colwidth < 150)
|
|
|
- display = string.Format("{0} {1}", comps.First(),
|
|
|
- comps.Length > 1 ? comps.Skip(1).First()[..1].ToUpper() : "");
|
|
|
- resource.Name = display;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // var maxcount = (int)width / 75;
|
|
|
+ // Bookings.DaysViewSettings.VisibleResourceCount = Math.Min(maxcount,
|
|
|
+ // _employees.Length * (Bookings.ViewType == SchedulerViewType.Day ? 1 : Bookings.ViewType == SchedulerViewType.WorkWeek ? 5 : 7));
|
|
|
+ //
|
|
|
+ // if (Bookings.ResourceCollection is ObservableCollection<SchedulerResource> resources)
|
|
|
+ // {
|
|
|
+ // var colwidth = GetResourceColumnWidth();
|
|
|
+ // foreach (var emp in _employees)
|
|
|
+ // {
|
|
|
+ // var resource = resources.FirstOrDefault(x => String.Equals(x.Id?.ToString(), emp.ID.ToString()));
|
|
|
+ // if (resource != null)
|
|
|
+ // {
|
|
|
+ // var comps = emp.Name.Split(' ');
|
|
|
+ // var display = emp.Name;
|
|
|
+ // if (colwidth < 75)
|
|
|
+ // display = string.Format("{0}{1}", comps[0].Length > 0 ? comps[0][..1] : "",
|
|
|
+ // comps.Length > 1 ? comps.Skip(1).First()[..1].ToUpper() : "");
|
|
|
+ // else if (colwidth < 150)
|
|
|
+ // display = string.Format("{0} {1}", comps.First(),
|
|
|
+ // comps.Length > 1 ? comps.Skip(1).First()[..1].ToUpper() : "");
|
|
|
+ // resource.Name = display;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- private T CheckGrid<T>(ref T grid) where T : new()
|
|
|
+ private T CheckGrid<T>([NotNull] ref T? grid) where T : new()
|
|
|
{
|
|
|
if (grid == null)
|
|
|
grid = new T();
|