Files
BeWoPlaner/BeWo/View/Controls/DPCtrlEmployee.cs

173 lines
6.0 KiB
C#
Raw Normal View History

using BeWo.View.Detail.Report;
using BS.Shared.DataContracts;
2020-09-30 10:00:31 +02:00
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;
2021-04-22 00:56:10 +02:00
using BS.Shared.Translation;
2020-09-30 10:00:31 +02:00
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)
{
2021-02-02 12:26:15 +01:00
if(information.Employee != null)
2020-09-30 10:00:31 +02:00
{
if (information.IsLastRow)
2021-02-02 12:26:15 +01:00
{
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);
2021-02-02 12:26:15 +01:00
}
2020-09-30 10:00:31 +02:00
}
2021-02-02 12:26:15 +01:00
else
{
ctrl.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 2);
ctrl.BorderLight.BorderThickness = new Thickness(0, 0, 0, 2);
2021-02-02 12:26:15 +01:00
}
2020-09-30 10:00:31 +02:00
ctrl.Text = ctrl.DisplayMember;
ctrl.ToolTip = new DPCtrlEmployeeTooltip(information.Employee, information.Contracts, information.IsVertretung);
//if (information.IsVertretung)
// ctrl.Path_Notice.Visibility = Visibility.Visible;
2020-09-30 10:00:31 +02:00
}
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);
}
2020-09-30 10:00:31 +02:00
}
public DPCtrlEmployeeInformation EmployeeInformation
{
get { return (DPCtrlEmployeeInformation)GetValue(EmployeeInformationProperty); }
set { SetValue(EmployeeInformationProperty, value); }
}
public string DisplayMember
{
get
{
var sb = new StringBuilder();
2021-02-02 12:26:15 +01:00
if (EmployeeInformation.Employee != null)
2020-09-30 10:00:31 +02:00
{
2021-02-02 12:26:15 +01:00
switch (EmployeeInformation.Row)
{
case 0: return EmployeeInformation.Employee.LastNameFirstName;
//Auskommentieren für nur eine Zeile
//case 1:
2020-09-30 10:00:31 +02:00
// foreach (var contract in EmployeeInformation.Contracts)
// {
// sb.Append(contract.EmploymentType?.Name);
// sb.Append('/');
// }
2020-09-30 10:00:31 +02:00
// sb.Remove(sb.Length - 1, 1);
2020-09-30 10:00:31 +02:00
// return sb.ToString();
2020-09-30 10:00:31 +02:00
//case 2:
2020-09-30 10:00:31 +02:00
// foreach (var contract in EmployeeInformation.Contracts)
// {
// sb.Append('(');
2020-09-30 10:00:31 +02:00
// if (contract.EntryDate.HasValue)
// sb.Append(contract.EntryDate.Value.ToString("dd.MM.yy"));
// else
// sb.Append("k.A.");
2020-09-30 10:00:31 +02:00
// sb.Append(" - ");
2020-09-30 10:00:31 +02:00
// if (contract.ContractEndDate.HasValue)
// sb.Append(contract.ContractEndDate.Value.ToString("dd.MM.yy"));
// else
// sb.Append("unbefr.");
2020-09-30 10:00:31 +02:00
// sb.Append(')');
2020-09-30 10:00:31 +02:00
// sb.Append('/');
// }
2020-09-30 10:00:31 +02:00
// sb.Remove(sb.Length - 1, 1);
2020-09-30 10:00:31 +02:00
// return sb.ToString();
2021-02-02 12:26:15 +01:00
}
}
else
{
return Translator.Translate("Status");
2020-09-30 10:00:31 +02:00
}
return null;
}
}
}
public class DPCtrlEmployeeInformation
{
public EmployeeDC Employee { get; set; }
public List<ContractDC> Contracts { get; set; }
public int Row { get; set; }
public bool IsLastRow { get; set; }
public bool IsVertretung { get; set; }
2020-09-30 10:00:31 +02:00
}
}