Files
linphone-tutorials/uwp/cs/07_AdvancedChat/Shared/ChatRoomToStringConverter.cs
Thibault Lemaire aca479888a Give the UWP Tutorial a little refresher
In order to write an equivalent tutorial for Xamarin, I am first
following the UWP tutorial.

Fixed many little spelling mistakes and rephrased some sentences.

Fixed a crash when video is requested but the device has no camera.

Fixed a crash when opening an audio recording. (Linphone.Content.FilePath
returns a path with mixed '/' and '\'. I don't know why and I'm not sure
I understand why the file was auto-downloaded either)
2022-02-17 16:10:10 +01:00

47 lines
1.3 KiB
C#

using Linphone;
using System;
using System.Linq;
using Windows.UI.Xaml.Data;
namespace _07_AdvancedChat.Shared
{
public class ChatRoomToStringConverter : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
{
ChatRoom chatRoom = (ChatRoom)value;
string nameInList = null;
if (chatRoom.HasCapability((int)ChatRoomCapabilities.Basic))
{
nameInList = chatRoom.PeerAddress.Username;
}
else if (chatRoom.HasCapability((int)ChatRoomCapabilities.OneToOne))
{
nameInList = chatRoom.Participants.FirstOrDefault() == null ? "" : chatRoom.Participants.First().Address.Username;
}
else if (chatRoom.HasCapability((int)ChatRoomCapabilities.Conference))
{
nameInList = chatRoom.Subject;
}
// You can check the Encrypted ChatRoomCapabilities to know if a ChatRoom uses
// encryption or not.
if (chatRoom.HasCapability((int)ChatRoomCapabilities.Encrypted))
{
nameInList += " #SECURE#";
}
if (string.IsNullOrEmpty(nameInList))
{
nameInList = "Incoherent ChatRoom values";
}
return nameInList;
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}