Example #1
0
        private async void Photo_Click(object sender, RoutedEventArgs e)
        {
            var chat = ViewModel.Chat;

            if (chat == null)
            {
                return;
            }

            if (chat.Type is ChatTypePrivate || chat.Type is ChatTypeSecret)
            {
                var user = ViewModel.ProtoService.GetUser(chat);
                if (user == null || user.ProfilePhoto == null)
                {
                    return;
                }

                var viewModel = new UserPhotosViewModel(ViewModel.ProtoService, ViewModel.Aggregator, user);
                await GalleryView.GetForCurrentView().ShowAsync(viewModel, () => Photo);
            }
            else if (chat.Type is ChatTypeBasicGroup || chat.Type is ChatTypeSupergroup)
            {
                if (chat.Photo == null)
                {
                    return;
                }

                var viewModel = new ChatPhotosViewModel(ViewModel.ProtoService, ViewModel.Aggregator, chat);
                await GalleryView.GetForCurrentView().ShowAsync(viewModel, () => Photo);
            }
        }
Example #2
0
        private async void Photo_Click(object sender, RoutedEventArgs e)
        {
            var chat     = ViewModel.Item as TLChat;
            var chatFull = ViewModel.Full as TLChatFull;

            if (chatFull != null && chatFull.ChatPhoto is TLPhoto && chat != null)
            {
                var viewModel = new ChatPhotosViewModel(ViewModel.ProtoService, ViewModel.CacheService, chatFull, chat);
                await GalleryView.Current.ShowAsync(viewModel, () => Picture);
            }
        }
        private async void Photo_Click(object sender, RoutedEventArgs e)
        {
            ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("FullScreenPicture", Picture);

            var chat     = ViewModel.Item as TLChat;
            var chatFull = ViewModel.Full as TLChatFull;

            if (chat.Photo is TLChatPhoto photo && chatFull != null && chatFull.ChatPhoto is TLPhoto)
            {
                var viewModel = new ChatPhotosViewModel(ViewModel.ProtoService, chatFull, chat);
                await GalleryView.Current.ShowAsync(viewModel, () => Picture);
            }
        }
Example #4
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);
            }
        }