public void ShowImage(ImageAttachmentViewModel image, ImageAttachmentViewModel[] allImages)
        {
            try
            {
                var mainWindow = Windows.OfType <MainAppWindow>().FirstOrDefault();
                if (mainWindow != null)
                {
                    MainWindowViewModel viewModel = mainWindow.GetViewModel();
                    if (viewModel != null)
                    {
                        viewModel.ShowImage(image, allImages);
                    }
                    else
                    {
                        throw new NullReferenceException("Couldn't find MainWindowViewModel");
                    }
                }
                else
                {
                    throw new NullReferenceException("Couldn't find main window");
                }
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
 public MyImageAttachmentViewHelper(ImageView imageView, ImageAttachmentViewModel viewModel)
 {
     _imageView = imageView;
     _imageView.SetBackgroundColor(Color.Black);
     _viewModel = viewModel;
     viewModel.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged).Handler;
     viewModel.StartLoad();
     Update();
 }
        public void Initialize(ImageAttachmentViewModel currentImage, ImageAttachmentViewModel[] allImages)
        {
            AllImages    = allImages;
            CurrentImage = currentImage;

            var adapter = new ImagesPagerAdapter(allImages);

            this.Adapter = adapter;
            this.SetCurrentItem(adapter.GetPosition(currentImage), false);
        }
            public int GetPosition(ImageAttachmentViewModel img)
            {
                for (int i = 0; i < ItemsSource.Length; i++)
                {
                    if (ItemsSource[i] == img)
                    {
                        return(i);
                    }
                }

                return(-1);
            }
Exemple #5
0
        private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ImageAttachmentViewModel image = grid.SelectedItem as ImageAttachmentViewModel;

            if (image == null)
            {
                return;
            }

            grid.SelectedItem = null;

            IEnumerable <ImageAttachmentViewModel> allImages = DataContext as IEnumerable <ImageAttachmentViewModel>;

            if (allImages == null)
            {
                return;
            }

            PowerPlannerApp.Current.ShowImage(image, allImages.ToArray());
        }
 public void ShowImage(ImageAttachmentViewModel image, ImageAttachmentViewModel[] allImages)
 {
     Navigate(new ShowImagesViewModel(this, image, allImages));
 }
 public ImageAttachmentZoomableView(Context context, ImageAttachmentViewModel viewModel) : base(context)
 {
     _helper = new MyImageAttachmentViewHelper(this, viewModel);
 }
 public ImageAttachmentThumbnailView(Context context, ImageAttachmentViewModel viewModel) : base(context)
 {
     ViewModel = viewModel;
     base.SetScaleType(ScaleType.CenterCrop);
     _helper = new MyImageAttachmentViewHelper(this, viewModel);
 }
 public ShowImagesViewModel(BaseViewModel parent, ImageAttachmentViewModel image, ImageAttachmentViewModel[] allImages) : base(parent)
 {
     AllImages    = allImages;
     CurrentImage = image;
 }