private void RadChat_ItemFormattingChildren(object sender, ChatItemElementEventArgs e) { ChatMessageAvatarElement avatar = e.ItemElement.AvatarPictureElement; ChatMessageNameElement name = e.ItemElement.NameLabelElement; ChatMessageStatusElement status = e.ItemElement.StatusLabelElement; LightVisualElement bubble = e.ItemElement.MainMessageElement; if (!e.ItemElement.IsOwnMessage && e.ItemElement is TextMessageItemElement) { avatar.DrawImage = false; name.Font = f; bubble.DrawFill = true; bubble.BackColor = Color.LightGreen; bubble.ShadowDepth = 3; bubble.ShadowColor = Color.Green; } else { avatar.ResetValue(LightVisualElement.ImageProperty, Telerik.WinControls.ValueResetFlags.Local); name.ResetValue(LightVisualElement.FontProperty, Telerik.WinControls.ValueResetFlags.All); status.ResetValue(LightVisualElement.VisibilityProperty, Telerik.WinControls.ValueResetFlags.Local); bubble.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local); bubble.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local); bubble.ResetValue(LightVisualElement.ShadowDepthProperty, Telerik.WinControls.ValueResetFlags.Local); bubble.ResetValue(LightVisualElement.ShadowColorProperty, Telerik.WinControls.ValueResetFlags.Local); } }
/// <summary> /// Format Posted Messages based on message type (normal has one color, media message has another, carousel has another... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RadChat_ItemFormatting(object sender, ChatItemElementEventArgs e) { if (e.ItemElement is TextMessageItemElement) { e.ItemElement.DrawBorder = true; e.ItemElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.FourBorders; e.ItemElement.BorderLeftColor = Color.Transparent; e.ItemElement.BorderTopColor = Color.Transparent; e.ItemElement.BorderRightColor = Color.Transparent; e.ItemElement.BorderBottomColor = Color.LightBlue; } else if (e.ItemElement is MediaMessageItemElement) { e.ItemElement.DrawFill = true; e.ItemElement.BackColor = Color.LightGreen; } else if (e.ItemElement is CardMessageItemElement) { e.ItemElement.DrawFill = true; e.ItemElement.BackColor = Color.LightBlue; } else if (e.ItemElement is CarouselMessageItemElement) { e.ItemElement.DrawFill = true; e.ItemElement.BackColor = Color.LightCoral; } else { e.ItemElement.ResetValue(LightVisualElement.DrawBorderProperty, Telerik.WinControls.ValueResetFlags.Local); e.ItemElement.ResetValue(LightVisualElement.BorderBoxStyleProperty, Telerik.WinControls.ValueResetFlags.Local); e.ItemElement.ResetValue(LightVisualElement.BorderLeftColorProperty, Telerik.WinControls.ValueResetFlags.Local); e.ItemElement.ResetValue(LightVisualElement.BorderRightColorProperty, Telerik.WinControls.ValueResetFlags.Local); e.ItemElement.ResetValue(LightVisualElement.BorderTopColorProperty, Telerik.WinControls.ValueResetFlags.Local); e.ItemElement.ResetValue(LightVisualElement.BorderBottomColorProperty, Telerik.WinControls.ValueResetFlags.Local); e.ItemElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local); e.ItemElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local); } }