Пример #1
0
        /// <inheritDoc/>
        public virtual ImageViewModel GetViewModel()
        {
            var viewModel = new ImageViewModel()
            {
                AlternativeText = this.AlternativeText,
                Title           = this.Title,
                DisplayMode     = this.DisplayMode,
                ThumbnailName   = this.ThumbnailName,
                ThumbnailUrl    = this.ThumbnailUrl,
                ThumbnailHeight = null,
                ThumbnailWidth  = null,
                CustomSize      = this.CustomSize != null ? new JavaScriptSerializer().Deserialize <CustomSizeModel>(this.CustomSize) : null,
                Responsive      = this.Responsive,
                UseAsLink       = this.UseAsLink,
                CssClass        = this.CssClass
            };

            SfImage image;

            if (this.Id != Guid.Empty)
            {
                image = this.GetImage();
                if (image != null)
                {
                    viewModel.SelectedSizeUrl  = this.GetSelectedSizeUrl(image);
                    viewModel.LinkedContentUrl = GetLinkedUrl(image);
                }
            }
            else
            {
                image = new SfImage();
            }

            int width;
            int height;

            this.GetThumbnailSizes(out width, out height, image);

            viewModel.ThumbnailHeight = height;
            viewModel.ThumbnailWidth  = width;

            viewModel.Item = new ItemViewModel(image);

            return(viewModel);
        }
Пример #2
0
        /// <inheritDoc/>
        public virtual ImageViewModel GetViewModel()
        {
            var viewModel = new ImageViewModel()
            {
                AlternativeText = this.AlternativeText,
                Title = this.Title,
                DisplayMode = this.DisplayMode,
                ThumbnailName = this.ThumbnailName,
                ThumbnailUrl = this.ThumbnailUrl,
                CustomSize = this.CustomSize != null ? new JavaScriptSerializer().Deserialize<CustomSizeModel>(this.CustomSize) : null,
                UseAsLink = this.UseAsLink,
                CssClass = this.CssClass
            };

            SfImage image;
            if (this.Id != Guid.Empty)
            {
                image = this.GetImage();
                if (image != null)
                {
                    viewModel.SelectedSizeUrl = this.GetSelectedSizeUrl(image);
                    viewModel.LinkedContentUrl = GetLinkedUrl(image);
                }
            }
            else
            {
                image = new SfImage();
            }

            viewModel.Item = new ItemViewModel(image);

            return viewModel;
        }