Example #1
0
        public static MvcHtmlString SponsorImageTag(this HtmlHelper html, MetroTileImage image, string cssClass = null)
        {
            bool webimage = false;
            var maxWidth = 278;
            var maxHeight = 109;

            if (string.IsNullOrWhiteSpace(image.PathUri))
            {
                webimage = true;
            }

            var url = new UrlHelper(html.ViewContext.RequestContext);

            var imageTagBuilder = new TagBuilder("img");
            if (webimage)
            {
                imageTagBuilder.MergeAttribute("src", "data:image;base64,"+Convert.ToBase64String(image.Logo.GetBytes()));
            }
            else
            {
                imageTagBuilder.MergeAttribute("src", url.Content(image.PathUri));
            }

            imageTagBuilder.MergeAttribute("alt", image.AltText);

            if (image.Height > maxHeight || image.Width > maxWidth)
            {
                double heightRatio = image.Height > maxHeight ? (double)image.Height / maxHeight : 0.0;
                double widthRatio = image.Width > maxWidth ? (double)image.Width / maxWidth : 0.0;

                if (widthRatio > heightRatio)
                {
                    var multiplier = (int)Math.Floor(d: (double)(image.Width / image.Height));
                    var calculatedWidth = (maxHeight * multiplier);
                    imageTagBuilder.MergeAttribute("width",
                                                   calculatedWidth > maxWidth || calculatedWidth == 0
                                                           ? maxWidth.ToString() : calculatedWidth.ToString());
                }
                else
                {
                    if (image.Height > maxHeight)
                        imageTagBuilder.MergeAttribute("height", maxHeight.ToString());
                    else
                    {
                        imageTagBuilder.MergeAttribute("width", maxWidth.ToString());
                    }
                }
            }

            if (!string.IsNullOrEmpty(image.Title))
                imageTagBuilder.MergeAttribute("title", image.Title);
            if (!string.IsNullOrEmpty(cssClass)) imageTagBuilder.MergeAttribute("class", cssClass);
            var imgHtml = imageTagBuilder.ToString(TagRenderMode.SelfClosing);

            return MvcHtmlString.Create(imgHtml);
        }
Example #2
0
 public TweetViewModel()
 {
     ProfilePhoto = new MetroTileImage("../../Content/themes/Metro/Images/twitter_newbird_white.png")
     {
         AltText = "Follow us on Twitter @netda",
         Title   = "Follow us on Twitter @netda"
     };
     TweetContent   = "Test tweet for #SeattleCC with consumption of all 146 characters.  This is for the new Seattle Code Camp site that we are currently working.";/*"Follow us on Twitter @netda or use the hashtag #SeattleCC";*/
     ProfileName    = "Hallmanac";
     ActiveCssClass = "tweetVisible";
 }
Example #3
0
 public TweetViewModel()
 {
     ProfilePhoto = new MetroTileImage("../../Content/themes/Metro/Images/twitter_newbird_white.png")
                    {
                        AltText = "Follow us on Twitter @netda",
                        Title = "Follow us on Twitter @netda"
                    };
     TweetContent = "Test tweet for #SeattleCC with consumption of all 146 characters.  This is for the new Seattle Code Camp site that we are currently working.";/*"Follow us on Twitter @netda or use the hashtag #SeattleCC";*/
     ProfileName = "Hallmanac";
     ActiveCssClass = "tweetVisible";
 }
Example #4
0
        public static MvcHtmlString TileImageTag(this HtmlHelper html, MetroTileImage image, string cssClass = null)
        {
            if (string.IsNullOrWhiteSpace(image.PathUri))
                return null;
            var url = new UrlHelper(html.ViewContext.RequestContext);

            var imageTagBuilder = new TagBuilder("img");
            imageTagBuilder.MergeAttribute("src", url.Content(image.PathUri));
            imageTagBuilder.MergeAttribute("alt", image.AltText);
            // imageTagBuilder.MergeAttribute("height", "80");
            if (!string.IsNullOrEmpty(image.Title))
                imageTagBuilder.MergeAttribute("title", image.Title);
            if (!string.IsNullOrEmpty(cssClass)) imageTagBuilder.MergeAttribute("class", cssClass);
            string imgHtml = imageTagBuilder.ToString(TagRenderMode.SelfClosing);

            return MvcHtmlString.Create(imgHtml);
        }
Example #5
0
 public static MvcHtmlString ImageTag(this HtmlHelper html, MetroTileImage image, string cssClass = null)
 {
     return ImageTag(html, image.PathUri, image.AltText, image.Height, image.Width, image.Title, cssClass);
 }
Example #6
0
        public PartialViewResult SingleMetroTileForAccount()
        {
            MetroTileImage metroTileImage = null;
            MetroTileViewModel metroTileViewModel = null;

            if (CurrentUser != null)
            {
                metroTileViewModel = new MetroTileViewModel
                {
                    TileLinkActionName = "UpdateProfile",
                    TileLinkControllerName = "Account",
                    TileDisplayName = "Update Profile",
                    TileBackgroundCssClass = "singleTileGreenImage"
                };

                Person user = CurrentUser;

                if (!String.IsNullOrEmpty(user.ImageUrl))
                {
                    metroTileImage = new MetroTileImage(user.ImageUrl)
                    {
                        AltText = user.FullName,
                        Title = string.Format("Welcome, {0}", user.FirstName)
                    };
                }
            }
            else
            {
                metroTileViewModel = new MetroTileViewModel
                {
                    TileLinkActionName = "LogOn",
                    TileLinkControllerName = "Account",
                    TileDisplayName = "Login / Register",
                    TileBackgroundCssClass = "singleTileGreenImage"
                };

                metroTileImage = new MetroTileImage("../../Content/themes/Shared/BlankUser.png")
                {
                    AltText = "Login or Register",
                    Title = "Login or Register"
                };
            }

            if (metroTileImage == null)
            {
                metroTileImage = new MetroTileImage("../../Content/themes/Shared/BlankUser.png")
                {
                    AltText = "Login or Register",
                    Title = "Login or Register"
                };
            }

            metroTileViewModel.MetroTileIcons.Add(item: metroTileImage);
            metroTileViewModel.MetroTileIcons.Add(new MetroTileImage("../../Content/themes/Shared/SpaceNeedle.ico")
            {
                AltText = "The only tug",
                Title = "The only tug"
            });

            return PartialView("_SingleMetroTile", metroTileViewModel);
        }