Пример #1
0
        public ViewViewModel()
        {
            chatService = ServiceLocator.Current.GetInstance<IChatService>();
            parentViewModel = ServiceLocator.Current.GetInstance<PhotosViewModel>();
            timer = new Timer(new TimerCallback((c) => {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    App.RootFrame.Navigate(new Uri("/View/PhotosPage.xaml", UriKind.RelativeOrAbsolute));
                });
            }),
            null,
            Timeout.Infinite,
            Timeout.Infinite);

            HideCommand = new RelayCommand(async () =>

            {
                timer.Change(TimeSpan.FromSeconds(6), TimeSpan.FromMilliseconds(-1));
                var contentList = await chatService.ReadPhotoContentAsync(
                    parentViewModel.SelectedPhoto.PhotoContentSecretId);
                var content = contentList.FirstOrDefault();
                if (content != null)
                {
                    Uri = chatService.ReadPhotoAsUri(content.Uri);
                    Stream = chatService.ReadPhotoAsStream(content.Uri);
                }
                else
                {
                    Uri = null;
                    Stream = null;
                }

            });
        }
Пример #2
0
        public ViewViewModel()
        {
            chatService     = ServiceLocator.Current.GetInstance <IChatService>();
            parentViewModel = ServiceLocator.Current.GetInstance <PhotosViewModel>();
            timer           = new Timer(new TimerCallback((c) => {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    App.RootFrame.Navigate(new Uri("/View/PhotosPage.xaml", UriKind.RelativeOrAbsolute));
                });
            }),
                                        null,
                                        Timeout.Infinite,
                                        Timeout.Infinite);

            HideCommand = new RelayCommand(async() =>

            {
                timer.Change(TimeSpan.FromSeconds(6), TimeSpan.FromMilliseconds(-1));
                var contentList = await chatService.ReadPhotoContentAsync(
                    parentViewModel.SelectedPhoto.PhotoContentSecretId);
                var content = contentList.FirstOrDefault();
                if (content != null)
                {
                    Uri    = chatService.ReadPhotoAsUri(content.Uri);
                    Stream = chatService.ReadPhotoAsStream(content.Uri);
                }
                else
                {
                    Uri    = null;
                    Stream = null;
                }
            });
        }