Files
BeWoPlaner/BeWo/View/Controls/DPCtrlWeek.cs
2021-10-18 00:43:47 +02:00

93 lines
3.2 KiB
C#

using BS.Shared.DataContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace BeWo.View.Controls
{
public class DPCtrlWeek : DienstplanerControl
{
public static readonly DependencyProperty DPCtrlWeekProperty = DependencyProperty.Register(
"DPCtrlWeekInformation",
typeof(DPCtrlWeekInformation),
typeof(DPCtrlWeek),
new UIPropertyMetadata(
(s, e) =>
{
var dc = (DPCtrlWeekInformation)e.NewValue;
var c = (DPCtrlWeek)s;
if (c != null)
{
c.Text = "";
c.ToolTip = "";
if (dc != null)
{
//dc.RemoveAll(x => x == null);
if (!dc.IsLastRow)
c.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 0);
else
c.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 1);
double res = 0.0;
if(!dc.Statuszeile)
{
if (dc.Hours.Count != 0 || dc.Row == 0)
{
foreach (var dauer in dc.Hours)
{
res += dauer;
}
c.Text = res.ToString("0.##");
}
}
else
{
if(dc.Statuszeile)
c.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 2);
else
c.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 0);
c.Text = "";
}
}
else
{
c.BorderBlack.BorderThickness = new Thickness(0, 0, 1, 1);
c.Text = "";
}
}
}));
public DPCtrlWeek()
{
InitializeComponent();
BorderBlack.BorderThickness = new Thickness(0, 0, 1, 0);
txt.TextAlignment = TextAlignment.Left;
txt.HorizontalAlignment = HorizontalAlignment.Left;
}
public DPCtrlWeekInformation DPCtrlWeekInformation
{
get { return (DPCtrlWeekInformation)GetValue(DPCtrlWeekProperty); }
set { SetValue(DPCtrlWeekProperty, value); }
}
}
public class DPCtrlWeekInformation
{
public List<double> Hours { get; set; }
public bool Statuszeile { get; set; }
public int Row { get; set; }
public bool IsLastRow { get; set; }
}
}