113 lines
3.2 KiB
C#
113 lines
3.2 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Windows.Media;
|
|
using ChatController.LoginKlassen;
|
|
using static System.String;
|
|
|
|
namespace ChatController.ChatKlassen
|
|
{
|
|
public class Contact
|
|
{
|
|
public string Name { get; }
|
|
|
|
private GroupLatestMessage _ReceivedMessage;
|
|
public GroupLatestMessage ReceivedMessage
|
|
{
|
|
get => _ReceivedMessage;
|
|
|
|
set
|
|
{
|
|
_ReceivedMessage = value;
|
|
OnPropertyChanged(nameof(ReceivedMessage));
|
|
}
|
|
}
|
|
|
|
public bool IsNewMessage { get; set; }
|
|
|
|
private Brush _color;
|
|
public Brush Color
|
|
{
|
|
get => _color;
|
|
|
|
set
|
|
{
|
|
_color = value;
|
|
OnPropertyChanged(nameof(Color));
|
|
}
|
|
}
|
|
|
|
private bool _HasUnreadMessages;
|
|
public bool HasUnreadMessages
|
|
{
|
|
get => _HasUnreadMessages;
|
|
|
|
set
|
|
{
|
|
_HasUnreadMessages = value;
|
|
|
|
if (_HasUnreadMessages)
|
|
{
|
|
_color = new BrushConverter().ConvertFromString("#ff5e00") as SolidColorBrush;
|
|
}
|
|
else
|
|
{
|
|
_color = new SolidColorBrush(Colors.Gray);
|
|
}
|
|
|
|
OnPropertyChanged(nameof(HasUnreadMessages));
|
|
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 int GroupId { get; set; }
|
|
public int UserOid { get; set; }
|
|
public string UserIdManage { get; set; }
|
|
|
|
public Contact(string pName, ImageSource pImage, GroupLatestMessage pLatestMessage, DateTime pTimeStamp, int pGroupId, string pUserIdManage, bool pOnlyEmployees, int pUserCount)
|
|
{
|
|
Name = pName;
|
|
ReceivedMessage = pLatestMessage;
|
|
Image = pImage;
|
|
TimeStamp = pTimeStamp;
|
|
GroupId = pGroupId;
|
|
UserIdManage = pUserIdManage;
|
|
HasUnreadMessages = false;
|
|
|
|
if (UserIdManage != 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));
|
|
}
|
|
}
|
|
}
|