Tutorial for LinphoneSDK x UWP - C#
This commit is contained in:
47
uwp/cs/07_AdvancedChat/Shared/ChatRoomToStringConverter.cs
Normal file
47
uwp/cs/07_AdvancedChat/Shared/ChatRoomToStringConverter.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
49
uwp/cs/07_AdvancedChat/Shared/Utils.cs
Normal file
49
uwp/cs/07_AdvancedChat/Shared/Utils.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of Linphone TutorialCS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace _07_AdvancedChat.Shared
|
||||
{
|
||||
public class Utils
|
||||
{
|
||||
public static async Task<string> InputTextDialogAsync(string title)
|
||||
{
|
||||
TextBox inputTextBox = new TextBox
|
||||
{
|
||||
AcceptsReturn = false,
|
||||
Height = 32
|
||||
};
|
||||
ContentDialog dialog = new ContentDialog
|
||||
{
|
||||
Content = inputTextBox,
|
||||
Title = title,
|
||||
IsSecondaryButtonEnabled = true,
|
||||
PrimaryButtonText = "OK",
|
||||
SecondaryButtonText = "Cancel"
|
||||
};
|
||||
if (await dialog.ShowAsync() == ContentDialogResult.Primary)
|
||||
return inputTextBox.Text;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user