Files
BeWoPlaner/Shared/DataContracts/ClientPartials/SupportConceptGoalDC.cs

241 lines
5.9 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
2016-06-27 01:45:38 +02:00
using System.ComponentModel;
using System.Linq;
using System.Windows.Media;
namespace BS.Shared.DataContracts.ClientPartials
{
public class SupportConceptGoalDC : INotifyPropertyChanged, IFilterableDC
{
private List<SupportConceptGoalDC> _Children;
private ValueListEntryDC _GoalEntryDC;
private bool _IsChecked;
private bool _IsExpanded;
2019-10-10 21:46:41 +02:00
private bool _ShowNotice;
private bool _CheckRecursive = true;
2020-03-03 09:27:02 +01:00
public long? KeyField => GoalEntryDC?.ValueListEntryOid;
public long? ParentField => ParentGoal?.GoalEntryDC?.ValueListEntryOid;
public bool CheckRecursive {
get { return _CheckRecursive; }
set { _CheckRecursive = value; }
}
2016-06-27 01:45:38 +02:00
public List<SupportConceptGoalDC> Children
{
get { return _Children ?? (_Children = new List<SupportConceptGoalDC>()); }
set { _Children = value; }
}
public ValueListEntryDC GoalEntryDC
{
get { return _GoalEntryDC; }
set { _GoalEntryDC = value; }
}
public bool HasParent => ParentGoal != null;
public bool HasNotice => GoalEntryDC != null && !string.IsNullOrEmpty(GoalEntryDC.Notice);
2016-06-27 01:45:38 +02:00
2019-10-10 21:46:41 +02:00
public bool ShowNotice
{
get => _ShowNotice;
set
{
_ShowNotice = value;
RaisePropertyChanged("ShowNotice");
}
}
2016-06-27 01:45:38 +02:00
public bool IsChecked
{
get => _IsChecked;
2016-06-27 01:45:38 +02:00
set
{
_IsChecked = value;
if (CheckRecursive)
2016-06-27 01:45:38 +02:00
{
foreach (var item in Children)
{
item.IsChecked = value;
}
2016-06-27 01:45:38 +02:00
}
RaisePropertyChanged("IsChecked");
}
}
public bool IsExpanded
{
get => _IsExpanded;
2016-06-27 01:45:38 +02:00
set
{
_IsExpanded = value;
RaisePropertyChanged("IsExpanded");
}
}
public string Name => DetailDescription;
2016-06-27 01:45:38 +02:00
public SupportConceptGoalDC ParentGoal { get; set; }
2016-06-27 01:45:38 +02:00
public event PropertyChangedEventHandler PropertyChanged;
public SolidColorBrush FilterableBrush => new SolidColorBrush(Colors.Transparent);
2016-06-27 01:45:38 +02:00
protected void RaisePropertyChanged(string propertyName)
{
var propertyChanged = PropertyChanged;
2016-06-27 01:45:38 +02:00
propertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public override string ToString()
{
return GoalEntryDC == null ? "-" : GoalEntryDC.TypeDescription;
2016-06-27 01:45:38 +02:00
}
#region IFilterableDC Members
public string IconPath
{
get { return string.Empty; }
}
public string DetailDescription
{
get { return GoalEntryDC.DisplayName; }
2016-06-27 01:45:38 +02:00
}
public string FilterRelevants
{
2020-04-08 14:25:01 +02:00
get
{
String filter = this.Name + " " + this.GoalEntryDC?.Abbreviation;
if (this.Children != null)
{
foreach (var child in this.Children)
{
filter += " ";
filter += child.FilterRelevants;
}
}
return filter;
}
2016-06-27 01:45:38 +02:00
}
public bool SupportsActivationType
{
get { return true; }
}
public long Version
{
get { return 0; }
set { }
}
public string SimpleDescription
{
get { return Name; }
}
public ActivationTypeId ActivationType
{
get { return ActivationTypeId.Active; }
set { }
}
#endregion
2019-10-10 21:46:41 +02:00
public void SetRatingType(RatingTypeDC rt)
2019-10-10 21:46:41 +02:00
{
if (GoalEntryDC != null && rt != null)
2019-10-10 21:46:41 +02:00
{
GoalEntryDC.RatingTypeOid = rt.RatingTypeOid.Value;
RatingName = rt.DisplayName;
2019-10-10 21:46:41 +02:00
}
if (rt == null && GoalEntryDC != null)
2019-10-10 21:46:41 +02:00
{
GoalEntryDC.RatingTypeOid = null;
RatingName = "";
//foreach (var item in Children)
//{
// item.SetRatingType(null);
//}
2019-10-10 21:46:41 +02:00
}
2019-10-10 21:46:41 +02:00
RaisePropertyChanged("HasRating");
RaisePropertyChanged("RatingName");
}
public bool HasRating => GoalEntryDC != null && GoalEntryDC.RatingTypeOid.HasValue;
public string RatingName { get; set; }
2019-10-10 21:46:41 +02:00
public bool IsZiel
{
get
{
return IsOfType(ValueListEntryType.SupportConceptGoalCategoryType);
}
}
public bool IsIndZiel
{
get
{
return IsOfType(ValueListEntryType.SupportConceptIndividualGoalCategoryType);
}
}
public bool IsMassnahme
{
get
{
return IsOfType(ValueListEntryType.SupportConceptGoalType);
}
}
public bool IsIndMassnahme
{
get
{
return IsOfType(ValueListEntryType.SupportConceptIndividualGoalType);
}
}
2019-10-10 21:46:41 +02:00
public bool IsOfType(ValueListEntryType t)
{
if (_GoalEntryDC != null)
{
return _GoalEntryDC.Type == t;
}
return false;
}
2016-06-27 01:45:38 +02:00
}
}