Kein Fehler mehr bei fehlender, serverseitiger AccentColor.

Neuladen der Kontaktliste hat nicht mehr zur Folge, dass die Suche nicht mehr funktioniert.
This commit is contained in:
Lyndon Jetten
2020-06-19 18:34:30 +02:00
parent e8ef515e7a
commit 980ea49767
2 changed files with 49 additions and 41 deletions

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Media;
@@ -65,11 +64,9 @@ namespace ChatController.ChatKlassen
public DateTime TimeStamp { get; set; }
public int GroupId { get; set; }
public int GroupId { get; }
public int UserOid { get; set; }
public string UserIdManage { get; set; }
public string UserIdManage { get; }
public bool IsChatMessageInputGridVisible { get; }
@@ -88,63 +85,67 @@ namespace ChatController.ChatKlassen
IsChatMessageInputGridVisible = isChatMessageInputGridVisible;
AccentColorBrush = new BrushConverter().ConvertFromString($"#{accentColorBrushString}") as SolidColorBrush ?? new SolidColorBrush(Colors.Black);
if(accentColorBrushString == null)
{
if(pUserIdManage != null)
{
accentColorBrushString = "3B7799";
}
else if(pOnlyEmployees && pUserCount > 2)
{
accentColorBrushString = "45993B";
}
else
{
accentColorBrushString = "000000";
}
}
AccentColorBrush = new BrushConverter().ConvertFromString($"#{accentColorBrushString}") as SolidColorBrush;
Image = image;
}
private sealed class ContactEqualityComparer : IEqualityComparer<Contact>
public override bool Equals(object obj)
{
public bool Equals(Contact x, Contact y)
if(obj is Contact y)
{
if(ReferenceEquals(x, y))
if(ReferenceEquals(this, y))
{
return true;
}
if(x is null)
if(GetType() != y.GetType())
{
return false;
}
if(y is null)
{
return Name == y.Name &&
IsNewMessage == y.IsNewMessage &&
Equals(ProfilePicture, y.ProfilePicture) &&
TimeStamp.Equals(y.TimeStamp) &&
GroupId == y.GroupId &&
UserIdManage == y.UserIdManage &&
IsChatMessageInputGridVisible == y.IsChatMessageInputGridVisible;
}
return false;
}
if(x.GetType() != y.GetType())
{
return false;
}
return x.Name == y.Name &&
x.IsNewMessage == y.IsNewMessage &&
Equals(x.ProfilePicture, y.ProfilePicture) &&
x.TimeStamp.Equals(y.TimeStamp) &&
x.GroupId == y.GroupId &&
x.UserOid == y.UserOid &&
x.UserIdManage == y.UserIdManage &&
x.IsChatMessageInputGridVisible == y.IsChatMessageInputGridVisible;
}
public int GetHashCode(Contact obj)
public override int GetHashCode()
{
unchecked
{
var hashCode = obj.Name != null ? obj.Name.GetHashCode() : 0;
var hashCode = Name != null ? Name.GetHashCode() : 0;
hashCode = (hashCode * 397) ^ obj.IsNewMessage.GetHashCode();
hashCode = (hashCode * 397) ^ (obj.ProfilePicture != null ? obj.ProfilePicture.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ obj.TimeStamp.GetHashCode();
hashCode = (hashCode * 397) ^ obj.GroupId;
hashCode = (hashCode * 397) ^ obj.UserOid;
hashCode = (hashCode * 397) ^ (obj.UserIdManage != null ? obj.UserIdManage.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ obj.IsChatMessageInputGridVisible.GetHashCode();
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();
return hashCode;
}
}
}
public SolidColorBrush AccentColorBrush { get; }

View File

@@ -912,6 +912,8 @@ namespace ChatController
ReadNewSyncFile();
AddViewFilterToClientlist();
EndWaiting();
});
});
@@ -1096,6 +1098,11 @@ namespace ChatController
}
private void ChatMainControl_OnLoaded(object sender, RoutedEventArgs e)
{
AddViewFilterToClientlist();
}
private void AddViewFilterToClientlist()
{
var view = (CollectionView)CollectionViewSource.GetDefaultView(Clientlist.ItemsSource);
view.Filter = UserFilter;