using BeWo.View.Detail.Report; using BS.Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using BS.Shared.Translation; namespace BeWo.View.Controls { public class DPCtrlEmployee : DienstplanerControl { public static readonly DependencyProperty EmployeeInformationProperty = DependencyProperty.Register( "EmployeeInformation", typeof(DPCtrlEmployeeInformation), typeof(DPCtrlEmployee), new UIPropertyMetadata( (s, e) => { var information = (DPCtrlEmployeeInformation)e.NewValue; var ctrl = (DPCtrlEmployee)s; if (ctrl != null) { if (information != null) { if(information.Employee != null) { if (information.IsLastRow) { ctrl.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 1.5); ctrl.BorderLight.BorderThickness = new Thickness(0, 0, 0, 1.5); } else { ctrl.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 0); ctrl.BorderLight.BorderThickness = new Thickness(0, 0, 0, 1); } } else { ctrl.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 2); ctrl.BorderLight.BorderThickness = new Thickness(0, 0, 0, 2); } ctrl.Text = ctrl.DisplayMember; ctrl.ToolTip = new DPCtrlEmployeeTooltip(information.Employee, information.Contracts, information.IsVertretung); //if (information.IsVertretung) // ctrl.Path_Notice.Visibility = Visibility.Visible; } else { ctrl.ToolTip = null; } } })); public DPCtrlEmployee() { InitializeComponent(); FontSize = 12; txt.HorizontalAlignment = HorizontalAlignment.Left; MouseDown += DienstplanerControl_MouseDown; } private void DienstplanerControl_MouseDown(object sender, MouseButtonEventArgs e) { DienstplanerView entryView = null; System.Windows.DependencyObject parent = VisualTreeHelper.GetParent(this); while (parent != null && entryView == null) { entryView = parent as DienstplanerView; var fe = parent as FrameworkElement; parent = fe != null ? VisualTreeHelper.GetParent(fe) : null; } if (entryView != null) { entryView.DienstplanerControl_MouseDown(sender, e); } } public DPCtrlEmployeeInformation EmployeeInformation { get { return (DPCtrlEmployeeInformation)GetValue(EmployeeInformationProperty); } set { SetValue(EmployeeInformationProperty, value); } } public string DisplayMember { get { var sb = new StringBuilder(); if (EmployeeInformation.Employee != null) { switch (EmployeeInformation.Row) { case 0: return EmployeeInformation.Employee.LastNameFirstName; //Auskommentieren für nur eine Zeile //case 1: // foreach (var contract in EmployeeInformation.Contracts) // { // sb.Append(contract.EmploymentType?.Name); // sb.Append('/'); // } // sb.Remove(sb.Length - 1, 1); // return sb.ToString(); //case 2: // foreach (var contract in EmployeeInformation.Contracts) // { // sb.Append('('); // if (contract.EntryDate.HasValue) // sb.Append(contract.EntryDate.Value.ToString("dd.MM.yy")); // else // sb.Append("k.A."); // sb.Append(" - "); // if (contract.ContractEndDate.HasValue) // sb.Append(contract.ContractEndDate.Value.ToString("dd.MM.yy")); // else // sb.Append("unbefr."); // sb.Append(')'); // sb.Append('/'); // } // sb.Remove(sb.Length - 1, 1); // return sb.ToString(); } } else { return Translator.Translate("Status"); } return null; } } } public class DPCtrlEmployeeInformation { public EmployeeDC Employee { get; set; } public List Contracts { get; set; } public int Row { get; set; } public bool IsLastRow { get; set; } public bool IsVertretung { get; set; } } }