Chat Control

Overview
Custom Controls
Custom Tools
Lazy Messages

How to Use
Live Demo
Last updated
Was this helpful?


Last updated
Was this helpful?
Was this helpful?
// create an instance of the custom control.
var options = new MenuOptions("Pet", "City", "Tree");
// process events from the custom control.
options.MenuItemClicked += Options_MenuItemClicked;
// add the custom control to the ChatBox.
this.chatBox1.DataSource.Add(new Message
{
BubbleVisible = false,
Control = options,
User = _bot
});private void chatBox1_ToolClick(object sender, ToolClickEventArgs e)
{
// triger a programmatic upload of files.
this.upload1.UploadFiles();
}
private void upload1_Uploaded(object sender, UploadedEventArgs e)
{
// once a file is uploaded, show it in a PictureBox control.
this.chatBox1.DataSource.Add(new Message
{
Control = new PictureBox
{
MinimumSize = new Size(200, 200),
SizeMode = PictureBoxSizeMode.Zoom,
Image = Image.FromStream(e.Files[0].InputStream)
},
User = _bot
});
}private void chatBox1_SentMessage(object sender, MessageEventArgs e)
{
// only process user messages.
if (e.IsChatBoxUser)
{
// create a new lazy message.
var message = new LazyMessage(_bot);
// add & show the message.
this.chatBox1.DataSource.Add(message);
// start a background task that completes after three seconds.
Application.StartTask(() =>
{
Thread.Sleep(3000);
message.SetResult("OK!");
Application.Update(this);
});
}
}