Exemple #1
0
        // GET: Slides/AssociatedImages/5
        public async Task <IActionResult> AssociatedImages(int?id, string imageName)
        {
            logger.LogInformation("Getting associated images of slide {ID}...", id);

            if (id == null)
            {
                return(NotFound());
            }

            var slide = await context.Slides.FindAsync(id.Value);

            if (slide == null)
            {
                return(NotFound());
            }
            ViewData[SLIDE_NAME] = slide.Name;
            ViewData[SLIDE_ID]   = id.ToString();
            HttpContext.Session.SetString(SLIDE_ID, slide.Id.ToString());
            ViewData[HAS_ASSOCIATED_IMAGES] = slide.HasAssociatedImages;
            var comments = context.Comments.Where(c => c.SlideId == id);

            ViewData[HAS_COMMENTS] = comments.Any();
            var osr = new OpenSlide(slide.FilePath);

            if (!String.IsNullOrEmpty(imageName))
            {
                logger.LogInformation("Getting associated image {name} of slide {ID}...", imageName, id);
                var associatedSlide = osr.AssociatedImages[imageName].ToImageSlide();
                var imageUrl        = slide.Id + "/" + imageName + ".dzi";

                var displayViewModel = new DisplayViewModel(imageName, imageUrl, 0, associatedSlide);

                return(View("Display", displayViewModel));
            }

            var associated = osr.ReadAssociatedImages();

            GenerateAssociatedImagesThumbnails(id.Value, associated);

            var viewModel = new AssociatedImagesViewModel(slide.Name, associated);

            return(View(viewModel));
        }
Exemple #2
0
        public Slide(OpenSlide osr)
        {
            FilePath            = osr.FilePath;
            Name                = Path.GetFileName(FilePath);
            Url                 = UrlFormatter.UrlFor(Name);
            Vendor              = osr.DetectFormat(FilePath);
            Width               = osr.Dimensions.Width;
            Height              = osr.Dimensions.Height;
            HasAssociatedImages = osr.ReadAssociatedImages().Any();

            try
            {
                double.TryParse(osr.Properties[OpenSlide.PROPERTY_NAME_MPP_X], out double mppX);
                double.TryParse(osr.Properties[OpenSlide.PROPERTY_NAME_MPP_Y], out double mppY);
                Mpp = (mppX + mppY) / 2;
            }
            catch (Exception)
            {
                Mpp = 0;
            }
        }
Exemple #3
0
        public Slide(string pathToSlide)
        {
            FilePath = pathToSlide;
            Name     = Path.GetFileName(pathToSlide);
            Url      = UrlFormatter.UrlFor(Name);
            Vendor   = OpenSlide.DetectVendor(pathToSlide);

            using (var osr = new OpenSlide(pathToSlide))
            {
                try
                {
                    double.TryParse(osr.Properties[OpenSlide.PROPERTY_NAME_MPP_X], out double mppX);
                    double.TryParse(osr.Properties[OpenSlide.PROPERTY_NAME_MPP_Y], out double mppY);
                    Mpp = (mppX + mppY) / 2;
                }
                catch (Exception)
                {
                    Mpp = 0;
                }
                Width  = osr.Dimensions.Width;
                Height = osr.Dimensions.Height;
                HasAssociatedImages = osr.ReadAssociatedImages().Any();
            }
        }