Ejemplo n.º 1
0
        private void ShowImages(ChildWindowEventArg args)
        {
            var childWindow = new ChildWindow
            {
                Content     = args.View,
                DataContext = args.ViewModel
            };

            PhotoViewModel photoViewModel = args.ViewModel as PhotoViewModel;
            Action         hideWindows    = () => childWindow.Hide();

            if (photoViewModel != null)
            {
                photoViewModel.HideWindow = () => hideWindows();
            }

            Action <object, KeyEventArgs> childWindowKeyUp =
                (sender, e) =>
            {
                if (e.Key == Key.Escape)
                {
                    hideWindows();
                }
            };

            childWindow.KeyUp += (sender, e) => childWindowKeyUp(sender, e);
            Action <ChildWindowScaleEventArgs> scaleCildWindow =
                x => childWindow.WindowState = x.FullScale ? WindowState.Maximized : WindowState.Normal;
            Func <ChildWindowScaleEventArgs, bool> canScaleCildWindow = x => x != null;

            Messenger?.Register(CommandName.SetPhotoWindowState, scaleCildWindow, canScaleCildWindow);
            childWindow.ShowDialog();
            Messenger?.Unregister(CommandName.SetPhotoWindowState);
            childWindow.Close();
        }
Ejemplo n.º 2
0
 public void ShowPhotos(List <byte[]> photos)
 {
     if (photos != null && photos.Any())
     {
         ObservableCollection <BitmapSource> photoCollection = ImageService.Assemble(photos);
         var photoModel     = new PhotoModel(photoCollection);
         var photoViewModel = new PhotoViewModel(Messenger, ImageService, photoModel);
         var photoView      = new PhotoControl();
         var args           = new ChildWindowEventArg(photoView, photoViewModel);
         Messenger.Send(CommandName.ShowImages, args);
     }
 }
Ejemplo n.º 3
0
 private bool CanShowImages(ChildWindowEventArg args)
 {
     return(args != null && args.ViewModel != null && args.View != null);
 }