public FullMediaViewModel(
            MusicViewModel <IInputPeer> music,
            FilesViewModel <IInputPeer> files,
            LinksViewModel <IInputPeer> links,
            MediaViewModel <IInputPeer> media,
            IStateService stateService,
            INavigationService navigationService)
        {
            //tombstoning
            if (stateService.CurrentInputPeer == null)
            {
                ShellViewModel.Navigate(navigationService);
                return;
            }

            CurrentItem = stateService.CurrentInputPeer;
            stateService.CurrentInputPeer = null;

            ImageViewer = new ImageViewerViewModel(stateService, IoC.Get <IVideoFileManager>(), true);

            Media                        = media;
            Media.ImageViewer            = ImageViewer;
            Files                        = files;
            Files.SetSelectedCountAction = SetSelectedCount;
            Files.PropertyChanged       += OnFilesPropertyChanged;
            Links                        = links;
            Links.SetSelectedCountAction = SetSelectedCount;
            Links.PropertyChanged       += OnLinksPropertyChanged;
            Music                        = music;
            Music.SetSelectedCountAction = SetSelectedCount;
            Music.PropertyChanged       += OnMusicPropertyChanged;
            _stateService                = stateService;
        }
示例#2
0
        public FullMediaViewModel(
            MusicViewModel <IInputPeer> music,
            FilesViewModel <IInputPeer> files,
            LinksViewModel <IInputPeer> links,
            MediaViewModel <IInputPeer> media,
            IStateService stateService,
            INavigationService navigationService)
        {
            //tombstoning
            if (stateService.CurrentInputPeer == null)
            {
                stateService.ClearNavigationStack = true;
                navigationService.UriFor <ShellViewModel>().Navigate();
                return;
            }

            CurrentItem = stateService.CurrentInputPeer;
            stateService.CurrentInputPeer = null;

            ImageViewer = new ImageViewerViewModel(stateService, IoC.Get <IVideoFileManager>());

            Media                  = media;
            Media.ImageViewer      = ImageViewer;
            Files                  = files;
            Files.PropertyChanged += OnFilesPropertyChanged;
            Links                  = links;
            Links.PropertyChanged += OnLinksPropertyChanged;
            Music                  = music;
            Music.PropertyChanged += OnMusicPropertyChanged;
            _stateService          = stateService;
        }
示例#3
0
        private void SavePhotoAsync(Action <string> callback = null)
        {
            TLFileLocation location     = null;
            var            profilePhoto = CurrentItem as TLUserProfilePhoto;

            if (profilePhoto != null)
            {
                location = profilePhoto.PhotoBig as TLFileLocation;
            }

            var photo = CurrentItem as TLPhoto;

            if (photo != null)
            {
                TLPhotoSize  size  = null;
                var          sizes = photo.Sizes.OfType <TLPhotoSize>();
                const double width = 640.0;
                foreach (var photoSize in sizes)
                {
                    if (size == null ||
                        Math.Abs(width - size.W.Value) > Math.Abs(width - photoSize.W.Value))
                    {
                        size = photoSize;
                    }
                }
                if (size == null)
                {
                    return;
                }

                location = size.Location as TLFileLocation;
            }

            var chatPhoto = CurrentItem as TLChatPhoto;

            if (chatPhoto != null)
            {
                location = chatPhoto.PhotoBig as TLFileLocation;
            }

            if (location == null)
            {
                return;
            }

            var fileName = String.Format("{0}_{1}_{2}.jpg",
                                         location.VolumeId,
                                         location.LocalId,
                                         location.Secret);

            Execute.BeginOnThreadPool(() => ImageViewerViewModel.SavePhoto(fileName, callback));
        }
        private static void SavePhotoAsync(TLDecryptedMessageMediaPhoto mediaPhoto, Action <string> callback = null)
        {
            var location = mediaPhoto.Photo as TLEncryptedFile;

            if (location == null)
            {
                return;
            }

            var fileName = String.Format("{0}_{1}_{2}.jpg",
                                         location.Id,
                                         location.DCId,
                                         location.AccessHash);

            Execute.BeginOnThreadPool(() => ImageViewerViewModel.SavePhoto(fileName, callback));
        }
        private static void SaveVideoAsync(TLDecryptedMessageMediaBase mediaBase)
        {
            var mediaDocument = mediaBase as TLDecryptedMessageMediaDocument45;

            if (mediaDocument != null && TLDecryptedMessageBase.IsVideo(mediaDocument))
            {
                var fileLocation = mediaDocument.File as TLEncryptedFile;
                if (fileLocation == null)
                {
                    return;
                }

                var fileName = String.Format("{0}_{1}_{2}.mp4",
                                             fileLocation.Id,
                                             fileLocation.DCId,
                                             fileLocation.AccessHash);

                Execute.BeginOnThreadPool(() => ImageViewerViewModel.SaveVideo(fileName));

                return;
            }

            var mediaVideo = mediaBase as TLDecryptedMessageMediaVideo;

            if (mediaVideo != null)
            {
                var fileLocation = mediaVideo.File as TLEncryptedFile;
                if (fileLocation == null)
                {
                    return;
                }

                var fileName = String.Format("{0}_{1}_{2}.mp4",
                                             fileLocation.Id,
                                             fileLocation.DCId,
                                             fileLocation.AccessHash);

                Execute.BeginOnThreadPool(() => ImageViewerViewModel.SaveVideo(fileName));

                return;
            }
        }