118 lines
3.4 KiB
C#
118 lines
3.4 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Windows.Media;
|
|
using static System.String;
|
|
|
|
namespace ChatController.ChatKlassen
|
|
{
|
|
public class Contact
|
|
{
|
|
public string Name { get; }
|
|
|
|
private string _ReceivedMessage;
|
|
public string ReceivedMessage
|
|
{
|
|
get
|
|
{
|
|
if (!IsNullOrEmpty(_ReceivedMessage) && _ReceivedMessage.Length > 25)
|
|
{
|
|
return _ReceivedMessage.Substring(0, 25) + "...";
|
|
}
|
|
|
|
return _ReceivedMessage;
|
|
}
|
|
|
|
set
|
|
{
|
|
_ReceivedMessage = value;
|
|
OnPropertyChanged(nameof(ReceivedMessage));
|
|
}
|
|
}
|
|
|
|
private Brush _color;
|
|
public Brush Color
|
|
{
|
|
get => _color;
|
|
|
|
set
|
|
{
|
|
_color = value;
|
|
OnPropertyChanged(nameof(Color));
|
|
}
|
|
}
|
|
|
|
private int _NumberOfReadMessages;
|
|
public int NumberOfReadMessages
|
|
{
|
|
get => _NumberOfReadMessages;
|
|
|
|
set
|
|
{
|
|
_NumberOfReadMessages = value;
|
|
|
|
if (_NumberOfReadMessages == 1)
|
|
{
|
|
_color = new BrushConverter().ConvertFromString("#ff5e00") as SolidColorBrush;
|
|
}
|
|
else
|
|
{
|
|
_color = new SolidColorBrush(Colors.Gray);
|
|
}
|
|
|
|
OnPropertyChanged(nameof(NumberOfReadMessages));
|
|
OnPropertyChanged(nameof(Color));
|
|
}
|
|
}
|
|
|
|
private Brush _ContactChatColor;
|
|
public Brush ContactChatColor
|
|
{
|
|
get => _ContactChatColor;
|
|
set
|
|
{
|
|
|
|
_ContactChatColor = value;
|
|
OnPropertyChanged(nameof(ContactChatColor));
|
|
}
|
|
}
|
|
|
|
public ImageSource Image { get; }
|
|
public DateTime TimeStamp { get; set; }
|
|
public long GroupId { get; set; }
|
|
public long UserId { get; set; }
|
|
public long? CustomerOid { get; set; }
|
|
|
|
public Contact(string pName, ImageSource pImage, string pLastMessageText, DateTime pTimeStamp, long pGroupId,long? pCustomerOid, bool pOnlyEmployees, int pUserCount)
|
|
{
|
|
Name = pName;
|
|
ReceivedMessage = pLastMessageText;
|
|
Image = pImage;
|
|
TimeStamp = pTimeStamp;
|
|
GroupId = pGroupId;
|
|
CustomerOid = pCustomerOid;
|
|
NumberOfReadMessages = 1;
|
|
|
|
if (CustomerOid != null)
|
|
{
|
|
_ContactChatColor = new BrushConverter().ConvertFromString("#3B7799") as SolidColorBrush;
|
|
}
|
|
else if (pOnlyEmployees && pUserCount > 2)
|
|
{
|
|
_ContactChatColor = new BrushConverter().ConvertFromString("#45993B") as SolidColorBrush;
|
|
}
|
|
else
|
|
{
|
|
_ContactChatColor = new BrushConverter().ConvertFromString("#000000") as SolidColorBrush;
|
|
}
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
{
|
|
var handler = PropertyChanged;
|
|
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
}
|