protected static bool IsInlineMedia(TLMessageMediaBase media) { if (media == null) { return(false); } if (media.TypeId == TLType.MessageMediaContact) { return(true); } else if (media.TypeId == TLType.MessageMediaGeoLive) { return(true); } else if (media.TypeId == TLType.MessageMediaVenue) { return(true); } else if (media.TypeId == TLType.MessageMediaPhoto) { var photoMedia = media as TLMessageMediaPhoto; if (string.IsNullOrWhiteSpace(photoMedia.Caption)) { return(false); } return(true); } else if (media.TypeId == TLType.MessageMediaDocument) { var documentMedia = media as TLMessageMediaDocument; if (TLMessage.IsMusic(documentMedia.Document)) { return(true); } else if (TLMessage.IsVoice(documentMedia.Document)) { return(true); } else if (TLMessage.IsVideo(documentMedia.Document)) { if (string.IsNullOrWhiteSpace(documentMedia.Caption)) { return(false); } } else if (TLMessage.IsGif(documentMedia.Document)) { if (string.IsNullOrWhiteSpace(documentMedia.Caption)) { return(false); } } return(true); } return(false); }
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) { var boh = DataTemplate.GetExtensionInstance(container as FrameworkElement); var presenter = container as ContentControl; if (presenter != null && item is TLDocument doc) { presenter.Content = new TLMessage { Media = new TLMessageMediaDocument { Document = doc } }; } if (item is TLMessage message) { item = message.Media; } if (item is TLMessageMediaEmpty) { return(EmptyTemplate); } else if (item is TLMessageMediaContact) { return(ContactTemplate); } else if (item is TLMessageMediaPhoto) { return(PhotoTemplate); } else if (item is TLMessageMediaGame) { return(GameTemplate); } else if (item is TLMessageMediaVenue) { return(VenueTemplate); } else if (item is TLMessageMediaGeo) { return(GeoPointTemplate); } else if (item is TLMessageMediaInvoice invoiceMedia) { if (invoiceMedia.HasPhoto && invoiceMedia.Photo != null) { return(InvoicePhotoTemplate); } return(InvoiceTemplate); } else if (item is TLMessageMediaDocument || item is TLDocument) { if (item is TLMessageMediaDocument documentMedia) { item = documentMedia.Document; } if (item is TLDocument document) { if (TLMessage.IsVoice(document)) { return(AudioTemplate); } else if (TLMessage.IsVideo(document)) { return(VideoTemplate); } else if (TLMessage.IsRoundVideo(document)) { return(RoundVideoTemplate); } else if (TLMessage.IsGif(document)) { return(GifTemplate); } else if (TLMessage.IsSticker(document)) { return(StickerTemplate); } else if (TLMessage.IsMusic(document)) { return(MusicTemplate); } // TODO: ??? //var externalDocument = documentMedia.Document as TLDocumentExternal; //if (externalDocument != null && TLMessage.IsGif(externalDocument)) //{ // return GifTemplate; //} if (document.Thumb != null && !(document.Thumb is TLPhotoSizeEmpty)) { return(DocumentThumbTemplate); } } return(DocumentTemplate); } else if (item is TLMessageMediaWebPage webpageMedia) { if (webpageMedia.WebPage is TLWebPageEmpty) { return(EmptyTemplate); } else if (webpageMedia.WebPage is TLWebPagePending) { return(EmptyTemplate); } else if (webpageMedia.WebPage is TLWebPage webpage) { /*if (TLMessage.IsGif(webpage.Document)) * { * return WebPageGifTemplate; * } * else * if (webpage.Document != null && webpage.Type.Equals("document", StringComparison.OrdinalIgnoreCase)) * { * return WebPageDocumentTemplate; * }*/ if (webpage.Document != null) { return(WebPageDocumentTemplate); } if (webpage.Photo != null && webpage.Type != null) { if (IsWebPagePhotoTemplate(webpage)) { return(WebPagePhotoTemplate); } return(WebPageSmallPhotoTemplate); } } return(WebPageTemplate); } else if (item is TLMessageMediaUnsupported) { return(UnsupportedTemplate); } return(null); }
private string UpdateGlyph(TLDocument document) { Visibility = Visibility.Visible; var fileName = document.GetFileName(); if (File.Exists(FileUtils.GetTempFileName(fileName))) { if (TLMessage.IsVideo(document) || TLMessage.IsRoundVideo(document) || TLMessage.IsGif(document) || TLMessage.IsMusic(document)) { return("\uE102"); } return("\uE160"); } else if (document.IsTransferring) { return("\uE10A"); } else if (document.DownloadingProgress > 0 && document.DownloadingProgress < 1) { return("\uE10A"); } else if (document.UploadingProgress > 0 && document.DownloadingProgress < 1) { return("\uE10A"); } return("\uE118"); }
private string UpdateGlyph(TLDocument document) { ContentVisibility = Visibility.Visible; Visibility = Visibility.Visible; if (document.DownloadingProgress > 0 && document.DownloadingProgress < 1) { ContentVisibility = Visibility.Visible; return("\uE10A"); } else if (document.UploadingProgress > 0 && document.UploadingProgress < 1) { ContentVisibility = Visibility.Collapsed; return("\uE10A"); } else if (File.Exists(FileUtils.GetTempFileName(document.GetFileName()))) { ContentVisibility = Visibility.Collapsed; var message = DataContext as TLMessage; if (message != null && message.Media is TLMessageMediaDocument documentMedia && documentMedia.HasTTLSeconds) { return("\uE60D"); } if (TLMessage.IsVideo(document) || TLMessage.IsRoundVideo(document) || TLMessage.IsMusic(document) || TLMessage.IsVoice(document)) { return("\uE102"); } else if (TLMessage.IsGif(document)) { //Visibility = Visibility.Collapsed; return("\uE906"); } return("\uE160"); } return("\uE118"); }