diff --git a/ChatController/ChatController.csproj b/ChatController/ChatController.csproj
index 9df76a0..adde9fb 100644
--- a/ChatController/ChatController.csproj
+++ b/ChatController/ChatController.csproj
@@ -37,16 +37,13 @@
-
- False
-
..\libs\Newtonsoft.Json.dll
-
- ..\libs\RestSharp.dll
+
+ ..\PrototypChat\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll
@@ -54,10 +51,6 @@
-
-
-
-
@@ -109,6 +102,7 @@
+
@@ -150,6 +144,7 @@
+
diff --git a/ChatController/ChatKlassen/ChatMessage.cs b/ChatController/ChatKlassen/ChatMessage.cs
index 87e3472..bbeb2db 100644
--- a/ChatController/ChatKlassen/ChatMessage.cs
+++ b/ChatController/ChatKlassen/ChatMessage.cs
@@ -9,8 +9,10 @@ using static System.Windows.HorizontalAlignment;
namespace ChatController.ChatKlassen
{
- public class ChatMessage
+ public class ChatMessage : INotifyPropertyChanged
{
+ public long MessageId { get; set; }
+
public int TimeStringMaxWidth => IsSeparator ? int.MaxValue : 350;
public int MessageMaxWidth => IsSeparator ? int.MaxValue : 500;
@@ -32,67 +34,127 @@ namespace ChatController.ChatKlassen
}
//Chat-Ansicht
- public ChatMessage(string username, string message, DateTime sendtime, bool isme, long pGroupId, long fileSize)
+ public ChatMessage(string username, string message, DateTime sendtime, bool isme, long groupId, long fileSize, long messageId)
{
+ MessageId = messageId;
+
Id = Guid.NewGuid();
Username = username;
UserMessage = message;
SendTime = sendtime;
IsMyMessage = isme;
- GroupId = pGroupId;
+ GroupId = groupId;
MessageType = IsHyperlink(message) ? ChatMessageType.Hyperlink : ChatMessageType.Message;
}
// Image-Ansicht
- public ChatMessage(string username, string message, DateTime sendtime, bool isme, ImageSource image, string originalImage, string imageName, long pGroupId, long fileSize)
+ public ChatMessage(string username, string message, DateTime sendtime, bool isme, string filePath, string originalImage, string imageName, long groupId, long fileSize, long messageId)
{
+ PicturePlaceholderHeight = Utils.GetHeightFromThumbnailUri(filePath);
+ PictureSource = Utils.GetPicturePlaceholder();
+
+ MessageId = messageId;
+
Id = Guid.NewGuid();
Username = username;
UserMessage = message;
SendTime = sendtime;
- ImageSources = image;
+
IsMyMessage = isme;
OriginalImage = originalImage;
OriginalImageName = imageName;
- GroupId = pGroupId;
+ GroupId = groupId;
MessageType = ChatMessageType.Image;
+
+ Utils.DownloadImageAsync(filePath, $"group-{groupId}", CacheCategory.Thumbnail, imageSource =>
+ {
+ PictureSource = imageSource;
+ });
}
//Dokumenten-Ansicht
- public ChatMessage(string pUsername, string pMessageText, DateTime pSendTime, string pSmallerImagePath, bool pIsLoggedInUsersMessage, string pUrl, long pGroupId, long fileSize)
+ public ChatMessage(string username, string message, DateTime sendtime, string thumbnailPath, bool isme, string filePath, long groupId, long fileSize, long messageId)
{
+ ThumbnailPlaceholderHeight = Utils.GetHeightFromThumbnailUri(thumbnailPath);
+ Thumbnail = Utils.GetPicturePlaceholder();
+
+ MessageId = messageId;
+
Id = Guid.NewGuid();
- Username = pUsername;
- UserMessage = pMessageText;
- SendTime = pSendTime;
- IsMyMessage = pIsLoggedInUsersMessage;
+ Username = username;
+ UserMessage = message;
+ SendTime = sendtime;
+ IsMyMessage = isme;
- FilePath = pUrl;
-
- var cache = OwnChatCache.GetInstance();
-
- var imgSrc = cache.GetImageSourceFromCache($"group-{pGroupId}");
-
- if(imgSrc == null)
- {
- imgSrc = Utils.CreateImageSourceFromPath(pSmallerImagePath);
- }
-
- Thumbnail = imgSrc;
+ FilePath = filePath;
- GroupId = pGroupId;
+ Utils.DownloadImageAsync(thumbnailPath, $"group-{groupId}", CacheCategory.Thumbnail, imageSource =>
+ {
+ Thumbnail = imageSource;
+ });
+
+ GroupId = groupId;
MessageType = ChatMessageType.Document;
}
+ // Mit Logo
+ public ChatMessage(string username, string message, DateTime sendtime, bool isme, ImageSource logo, string originalImage, string imageName, long groupId, long fileSize, long messageId)
+ {
+ MessageId = messageId;
+
+ Id = Guid.NewGuid();
+ Username = username;
+ UserMessage = message;
+ SendTime = sendtime;
+
+ IsMyMessage = isme;
+
+ OriginalImage = originalImage;
+ OriginalImageName = imageName;
+
+ GroupId = groupId;
+
+ MessageType = ChatMessageType.Image;
+
+ PictureSource = logo;
+ }
+
public ChatMessageType MessageType { get; }
- public ImageSource Thumbnail { get; }
+ private ImageSource _Thumbnail;
+ public ImageSource Thumbnail
+ {
+ get => _Thumbnail;
+ set
+ {
+ if(!Equals(_Thumbnail, value))
+ {
+ _Thumbnail = value;
+
+ OnPropertyChanged(nameof(Thumbnail));
+ }
+ }
+ }
+
+ private int _ThumbnailPlaceholderHeight;
+ public int ThumbnailPlaceholderHeight
+ {
+ get => _ThumbnailPlaceholderHeight;
+ set
+ {
+ if(!Equals(_ThumbnailPlaceholderHeight, value))
+ {
+ _ThumbnailPlaceholderHeight = value;
+ OnPropertyChanged(nameof(ThumbnailPlaceholderHeight));
+ }
+ }
+ }
private static readonly Regex _UrlRegex = new Regex(@"(?#Protocol)^(http(?:s?)\:(\/\/|\\\\)|(w){3}(2|3)?\.{1})(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?");
@@ -171,7 +233,33 @@ namespace ChatController.ChatKlassen
public Visibility DokumentVisibility => MessageType == ChatMessageType.Document ? Visibility.Visible : Visibility.Collapsed;
- public ImageSource ImageSources { get; }
+ private ImageSource _PictureSource;
+ public ImageSource PictureSource
+ {
+ get => _PictureSource;
+ set
+ {
+ if(!Equals(_PictureSource, value))
+ {
+ _PictureSource = value;
+ OnPropertyChanged(nameof(PictureSource));
+ }
+ }
+ }
+
+ private int _PicturePlaceholderHeight;
+ public int PicturePlaceholderHeight
+ {
+ get => _PicturePlaceholderHeight;
+ set
+ {
+ if (!Equals(_PicturePlaceholderHeight, value))
+ {
+ _PicturePlaceholderHeight = value;
+ OnPropertyChanged(nameof(PicturePlaceholderHeight));
+ }
+ }
+ }
public object FilePath { get; }
@@ -217,7 +305,7 @@ namespace ChatController.ChatKlassen
return SendTime == message.SendTime;
}
- return message.Id.Equals(Id);
+ return MessageId.Equals(message.MessageId);
}
return false;
diff --git a/ChatController/ChatKlassen/Contact.cs b/ChatController/ChatKlassen/Contact.cs
index 4c384e2..26eb9a2 100644
--- a/ChatController/ChatKlassen/Contact.cs
+++ b/ChatController/ChatKlassen/Contact.cs
@@ -1,8 +1,8 @@
using System;
using System.ComponentModel;
-using System.Drawing;
using System.Windows.Media;
using ChatController.LoginKlassen;
+using ChatController.Utilities;
using Brush = System.Windows.Media.Brush;
namespace ChatController.ChatKlassen
@@ -60,7 +60,19 @@ namespace ChatController.ChatKlassen
}
}
- public ImageSource Image { get; }
+ private ImageSource _Image;
+ public ImageSource Image
+ {
+ get => _Image;
+ set
+ {
+ if(!Equals(_Image, value))
+ {
+ _Image = value;
+ OnPropertyChanged(nameof(Image));
+ }
+ }
+ }
public DateTime TimeStamp { get; set; }
@@ -70,9 +82,7 @@ namespace ChatController.ChatKlassen
public bool IsChatMessageInputGridVisible { get; }
- public Bitmap ProfilePicture { get; }
-
- public Contact(string pName, GroupLatestMessage pLatestMessage, DateTime pTimeStamp, int pGroupId, string pUserIdManage, bool pOnlyEmployees, int pUserCount, bool isChatMessageInputGridVisible, string accentColorBrushString, Bitmap profilePicture, ImageSource image)
+ public Contact(string pName, GroupLatestMessage pLatestMessage, DateTime pTimeStamp, int pGroupId, string pUserIdManage, bool pOnlyEmployees, int pUserCount, bool isChatMessageInputGridVisible, string accentColorBrushString, string profilePicturePath, string key)
{
Name = pName;
ReceivedMessage = pLatestMessage;
@@ -81,8 +91,6 @@ namespace ChatController.ChatKlassen
UserIdManage = pUserIdManage;
HasUnreadMessages = false;
- ProfilePicture = profilePicture;
-
IsChatMessageInputGridVisible = isChatMessageInputGridVisible;
if(accentColorBrushString == null)
@@ -103,7 +111,10 @@ namespace ChatController.ChatKlassen
AccentColorBrush = new BrushConverter().ConvertFromString($"#{accentColorBrushString}") as SolidColorBrush;
- Image = image;
+ Utils.DownloadProfilePictureAsync(profilePicturePath, key, delegate(ImageSource imageSource)
+ {
+ Image = imageSource;
+ });
}
public override bool Equals(object obj)
@@ -122,7 +133,6 @@ namespace ChatController.ChatKlassen
return Name == y.Name &&
IsNewMessage == y.IsNewMessage &&
- Equals(ProfilePicture, y.ProfilePicture) &&
TimeStamp.Equals(y.TimeStamp) &&
GroupId == y.GroupId &&
UserIdManage == y.UserIdManage &&
@@ -138,7 +148,6 @@ namespace ChatController.ChatKlassen
{
var hashCode = Name != null ? Name.GetHashCode() : 0;
- hashCode = (hashCode * 397) ^ (ProfilePicture != null ? ProfilePicture.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ GroupId;
hashCode = (hashCode * 397) ^ (UserIdManage != null ? UserIdManage.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ IsChatMessageInputGridVisible.GetHashCode();
diff --git a/ChatController/ChatMainControl.xaml b/ChatController/ChatMainControl.xaml
index 6077d71..0774e61 100644
--- a/ChatController/ChatMainControl.xaml
+++ b/ChatController/ChatMainControl.xaml
@@ -89,7 +89,7 @@
-
+
@@ -148,10 +148,16 @@
+
+
-
+
@@ -226,11 +232,22 @@
-
+