2020-12-11 00:20:19 +08:00
|
|
|
|
using Linphone;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
|
|
|
|
|
|
|
|
|
namespace _06_GroupChat.Shared
|
|
|
|
|
{
|
|
|
|
|
public class ChatRoomToStringConverter : IValueConverter
|
|
|
|
|
{
|
|
|
|
|
object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
|
|
|
|
|
{
|
|
|
|
|
// We use this converter to choose how to display the ChatRoom in the list.
|
|
|
|
|
ChatRoom chatRoom = (ChatRoom)value;
|
|
|
|
|
string nameInList = null;
|
|
|
|
|
if (chatRoom.HasCapability((int)ChatRoomCapabilities.Basic))
|
|
|
|
|
{
|
|
|
|
|
// For a basic ChatRoom we chose to display the peer Username
|
|
|
|
|
nameInList = chatRoom.PeerAddress.Username;
|
|
|
|
|
}
|
|
|
|
|
else if (chatRoom.HasCapability((int)ChatRoomCapabilities.OneToOne))
|
|
|
|
|
{
|
|
|
|
|
// If the ChatRoom is a OneToOne conference (we will speak more about those in further steps)
|
2021-12-23 23:49:01 +08:00
|
|
|
|
nameInList = chatRoom.Participants.FirstOrDefault()?.Address.Username;
|
2020-12-11 00:20:19 +08:00
|
|
|
|
}
|
|
|
|
|
else if (chatRoom.HasCapability((int)ChatRoomCapabilities.Conference))
|
|
|
|
|
{
|
|
|
|
|
// The subject for a conference
|
|
|
|
|
nameInList = chatRoom.Subject;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-23 23:49:01 +08:00
|
|
|
|
if (string.IsNullOrEmpty(nameInList))
|
2020-12-11 00:20:19 +08:00
|
|
|
|
{
|
|
|
|
|
nameInList = "Incoherent ChatRoom values";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nameInList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|