using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Media; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; namespace BeWo.Scheduler.ViewModel { public class CustomFieldStorage { public string ToolTip { get { var result = Subject; if(IsTask) { result = result ?? ""; if(CompletedDate.HasValue) { result += " erledigt am " + CompletedDate.Value.ToShortDateString(); } else if(DueDate.HasValue) { result += " bis " + DueDate.Value.ToString("dd.MM.yyyy HH:mm"); } } if (IsAbsenceTime && _AbsenceTimeStart.HasValue) { result += _AbsenceTimeStart.Value.GetIntervalDescription(_AbsenceTimeEnd); } return result; } } public string Subject { get; set; } public bool IsTask { get; set; } public bool IsAbsenceTime { get; set; } public bool IsPrivate { get; set; } public bool IsAllDay { get; set; } public LinearGradientBrush BackgroundColor => new LinearGradientBrush(new GradientStopCollection { new GradientStop(IsTask ? Color.FromRgb(153, 59, 59) : Color.FromRgb(192, 255, 208), 1) }, new Point(.5, 0), new Point(.5, 1)); public LinearGradientBrush ForegroundColor => new LinearGradientBrush(new GradientStopCollection { new GradientStop(IsTask ? Color.FromRgb(224, 224, 224) : Color.FromRgb(0, 0, 0), 1) }, new Point(.5, 0), new Point(.5, 1)); public ObservableCollection EmployeeList { get; set; } = new ObservableCollection(); public List CustomerList { get; set; } = new List(); public List ResourceList { get; set; } = new List(); public List SupportConceptList { get; set; } = new List(); public DateTime? DueDate { get; set; } public DateTime? CompletedDate { get; set; } public string CompletedNotice { get; set; } public string TaskDescription { get; set; } public long? SchedulerAppointmentOid { get; set; } public string RecurrenceId { get; set; } public int RecurrenceIndex { get; set; } public CompactEmployeeDC Originator { get; set; } private DateTime? _AbsenceTimeStart; private DateTime? _AbsenceTimeEnd; public CustomFieldStorage() { } public CustomFieldStorage(SchedulerAppointmentVM pAppointment) { IsTask = pAppointment.IsTask; IsAbsenceTime = pAppointment.IsAbsenceTime; IsPrivate = pAppointment.IsPrivate; IsAllDay = pAppointment.AllDay; EmployeeList = pAppointment.EmployeeList; CustomerList = pAppointment.CustomerList; ResourceList = pAppointment.ResourceList; SupportConceptList = pAppointment.SupportConceptList; DueDate = pAppointment.DueDate; CompletedDate = pAppointment.CompletedDate; CompletedNotice = pAppointment.CompletedNotice; TaskDescription = pAppointment.TaskDescription; Originator = pAppointment.Originator; Subject = pAppointment.Subject; SchedulerAppointmentOid = pAppointment.DataContract?.SchedulerAppointmentOid; RecurrenceId = pAppointment.DataContract?.RecurrenceId; RecurrenceIndex = pAppointment.DataContract?.RecurrenceIndex ?? 0; _AbsenceTimeStart = pAppointment.AbsenceTimeStart; _AbsenceTimeEnd = pAppointment.AbsenceTimeEnd; HasServiceRecordEntry = pAppointment.HasServiceRecordEntry; } public CustomFieldStorage(SchedulerAppointmentDC pAppointment) { IsTask = pAppointment.IsTask; IsAbsenceTime = false; IsPrivate = pAppointment.IsPrivate; IsAllDay = pAppointment.AllDay; EmployeeList = new ObservableCollection(pAppointment.EmployeeList); CustomerList = pAppointment.CustomerList; ResourceList = pAppointment.ResourceList; SupportConceptList = pAppointment.SupportConceptList; DueDate = pAppointment.DueDate; CompletedDate = pAppointment.CompletedDate; CompletedNotice = pAppointment.CompletedNotice; TaskDescription = pAppointment.TaskDescription; Originator = pAppointment.Originator; Subject = pAppointment.Subject; SchedulerAppointmentOid = pAppointment.SchedulerAppointmentOid; RecurrenceId = pAppointment.RecurrenceId; RecurrenceIndex = pAppointment.RecurrenceIndex; HasServiceRecordEntry = pAppointment.HasServiceRecordEntry; } public CustomFieldStorage(ObservableCollection pEmployees, List pCustomers, List pResources, CompactEmployeeDC pOriginator, bool pIsPrivate, bool pIsTask, string pTaskDescription, DateTime? pDueDate, DateTime? pCompletedDate, string pCompletedNotice, List pSupportConcepts, string pSubject, bool pIsAllDay) { IsTask = pIsTask; IsPrivate = pIsPrivate; IsAllDay = pIsAllDay; EmployeeList = pEmployees; CustomerList = pCustomers; ResourceList = pResources; SupportConceptList = pSupportConcepts; DueDate = pDueDate; CompletedDate = pCompletedDate; CompletedNotice = pCompletedNotice; TaskDescription = pTaskDescription; Originator = pOriginator; Subject = pSubject; } public Visibility ToolTipTimeVisibility => IsTask || IsAbsenceTime || IsAllDay ? Visibility.Collapsed : Visibility.Visible; public Visibility ToolTipResourcesVisibility => ResourceList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed; public Visibility ToolTipEmployeesVisibility => EmployeeList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed; public Visibility ToolTipCustomersVisibility => CustomerList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed; public Visibility ToolTipTrennstrichVisibility => EmployeeList?.Count > 0 || CustomerList?.Count > 0 || ResourceList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed; public Visibility ToolTipZusageVisibility => IsTask ? Visibility.Collapsed : Visibility.Visible; public bool HasServiceRecordEntry { get; set; } } }