Exemple #1
0
 private void Download_Click(object sender, TransferCompletedEventArgs e)
 {
     if (DataContext is TLMessage message)
     {
         Playback.Enqueue(message);
     }
 }
        public static async void Download(object sender, TransferCompletedEventArgs e)
        {
            var element = sender as FrameworkElement;
            var message = element.DataContext as TLMessage;

            if (message != null)
            {
                if (message.IsVideo() || message.IsRoundVideo() || message.IsGif() || message.IsPhoto())
                {
                    var media = element.Ancestors().FirstOrDefault(x => x is FrameworkElement && ((FrameworkElement)x).Name.Equals("MediaControl")) as FrameworkElement;

                    ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("FullScreenPicture", media);

                    GalleryViewModelBase viewModel;
                    if (message.Parent != null)
                    {
                        viewModel = new DialogGalleryViewModel(message.Parent.ToInputPeer(), message, MTProtoService.Current);
                    }
                    else
                    {
                        viewModel = new SingleGalleryViewModel(new GalleryMessageItem(message));
                    }

                    await GalleryView.Current.ShowAsync(viewModel, () => media);
                }
                else if (e != null)
                {
                    var file = await StorageFile.GetFileFromApplicationUriAsync(FileUtils.GetTempFileUri(e.FileName));

                    await Launcher.LaunchFileAsync(file);
                }
            }
        }
        private void Download_Click(object sender, TransferCompletedEventArgs e)
        {
            var border = sender as TransferButton;
            var item   = border.DataContext as GalleryItem;

            if (item.IsVideo)
            {
                Play(item);
            }
        }
        private void Download_Click(object sender, TransferCompletedEventArgs e)
        {
            var border = sender as FrameworkElement;
            var item   = border.DataContext as GalleryItem;

            if (item == null)
            {
                return;
            }

            if (item.IsVideo)
            {
                Play(item);
            }
        }
Exemple #5
0
        public static async void SecretDownload_Click(FrameworkElement sender, TransferCompletedEventArgs e)
        {
            var element = sender as FrameworkElement;
            var message = element.DataContext as TLMessage;

            if (message == null)
            {
                return;
            }

            var bubble = element.Ancestors <MessageBubbleBase>().FirstOrDefault() as MessageBubbleBase;

            if (bubble == null)
            {
                return;
            }

            if (message.IsMediaUnread && !message.IsOut)
            {
                var vector = new TLVector <int> {
                    message.Id
                };
                if (message.Parent is TLChannel channel)
                {
                    bubble.ContextBase.Aggregator.Publish(new TLUpdateChannelReadMessagesContents {
                        ChannelId = channel.Id, Messages = vector
                    });
                    bubble.ContextBase.ProtoService.ReadMessageContentsAsync(channel.ToInputChannel(), vector, result =>
                    {
                        message.IsMediaUnread = false;
                        message.RaisePropertyChanged(() => message.IsMediaUnread);
                    });
                }
                else
                {
                    bubble.ContextBase.Aggregator.Publish(new TLUpdateReadMessagesContents {
                        Messages = vector
                    });
                    bubble.ContextBase.ProtoService.ReadMessageContentsAsync(vector, result =>
                    {
                        message.IsMediaUnread = false;
                        message.RaisePropertyChanged(() => message.IsMediaUnread);
                    });
                }
            }

            var media = element.Ancestors().FirstOrDefault(x => x is FrameworkElement && ((FrameworkElement)x).Name.Equals("Media")) as FrameworkElement;

            if (media == null)
            {
                media = element;
            }

            if (media is Grid grid)
            {
                // TODO: WARNING!!!
                media = grid.Children[1] as FrameworkElement;
            }

            if (message.Parent != null)
            {
                var viewModel = new GallerySecretViewModel(message.Parent.ToInputPeer(), message, bubble.ContextBase.ProtoService, bubble.ContextBase.CacheService, bubble.ContextBase.Aggregator);
                await GallerySecretView.Current.ShowAsync(viewModel, () => media);
            }
        }
Exemple #6
0
 private void SecretDownload_Click(object sender, TransferCompletedEventArgs e)
 {
     SecretDownload_Click(sender as FrameworkElement, e);
 }
Exemple #7
0
        public static async void Download_Click(FrameworkElement sender, TransferCompletedEventArgs e)
        {
            var element = sender as FrameworkElement;

            var bubble = element.Ancestors <MessageBubbleBase>().FirstOrDefault() as MessageBubbleBase;

            if (bubble == null)
            {
                return;
            }

            if (element.DataContext is TLMessageService serviceMessage && serviceMessage.Action is TLMessageActionChatEditPhoto editPhotoAction)
            {
                var media = element.Parent as FrameworkElement;
                if (media == null)
                {
                    media = element;
                }

                var chat = serviceMessage.Parent as TLChatBase;
                if (chat == null)
                {
                    return;
                }

                var chatFull = InMemoryCacheService.Current.GetFullChat(chat.Id);
                if (chatFull != null && chatFull.ChatPhoto is TLPhoto && chat != null)
                {
                    var viewModel = new ChatPhotosViewModel(bubble.ContextBase.ProtoService, bubble.ContextBase.CacheService, chatFull, chat, serviceMessage);
                    await GalleryView.Current.ShowAsync(viewModel, () => media);
                }

                return;
            }

            var message = element.DataContext as TLMessage;

            if (message == null)
            {
                return;
            }

            var document = message.GetDocument();

            if (TLMessage.IsGif(document) && !ApplicationSettings.Current.IsAutoPlayEnabled)
            {
                var page = bubble.Ancestors <IGifPlayback>().FirstOrDefault() as IGifPlayback;
                if (page == null)
                {
                    return;
                }

                if (bubble.ViewModel is TLMessage inner)
                {
                    page.Play(inner);
                }
            }
            else if (TLMessage.IsVideo(document) || TLMessage.IsRoundVideo(document) || TLMessage.IsGif(document) || message.IsPhoto())
            {
                var media = element.Ancestors().FirstOrDefault(x => x is FrameworkElement && ((FrameworkElement)x).Name.Equals("Media")) as FrameworkElement;
                if (media == null)
                {
                    media = element;
                }

                //ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("FullScreenPicture", media);

                GalleryViewModelBase viewModel;
                if (message.Parent == null || TLMessage.IsRoundVideo(document) || TLMessage.IsGif(document))
                {
                    viewModel = new SingleGalleryViewModel(new GalleryMessageItem(message));
                }
                else
                {
                    viewModel = new DialogGalleryViewModel(bubble.ContextBase.ProtoService, bubble.ContextBase.CacheService, message.Parent.ToInputPeer(), message);
                }

                await GalleryView.Current.ShowAsync(viewModel, () => media);
            }
            else if (e != null)
            {
                var file = await StorageFile.GetFileFromApplicationUriAsync(FileUtils.GetTempFileUri(e.FileName));

                await Launcher.LaunchFileAsync(file);
            }
        }
Exemple #8
0
 private void Download_Click(object sender, TransferCompletedEventArgs e)
 {
     Download(sender, e);
 }
 private void Download_Click(object sender, TransferCompletedEventArgs e)
 {
     Themes.Media.Download_Click(sender as FrameworkElement, e);
 }