Esempio n. 1
0
        public ActionResult Index()
        {
            ProfileImage image = new ProfileImage();

            image.Image1 = GenerateImage.GetDefaultBase64Image("Abhimanyu", new Font(FontFamily.GenericSansSerif, 10.0F, FontStyle.Bold), Color.White, Color.Green, 50, 50);
            image.Image2 = GenerateImage.GetDefaultBase64Image("Nisha", new Font(FontFamily.GenericSansSerif, 25.0F, FontStyle.Bold), Color.White, Color.Green, 100, 100);
            image.Image3 = GenerateImage.GetDefaultBase64Image("Ganesh", new Font(FontFamily.GenericSansSerif, 35.0F, FontStyle.Bold), Color.White, Color.Green, 150, 150);
            image.Image4 = GenerateImage.GetDefaultBase64Image("Ramesh", new Font(FontFamily.GenericSansSerif, 50.0F, FontStyle.Bold), Color.White, Color.Green, 200, 200);

            return(View(image));
        }
        private bool BatchBuildCurrent()
        {
            // Switch to Source Files Tab.
            MainTabs.SelectedIndex = MainTabs.TabPages.IndexOfKey("SourceFilesTab");

            // Auto generate images.
            GenerateImage.PerformClick();

            // Switch to Build Tab.
            MainTabs.SelectedIndex = MainTabs.TabPages.IndexOfKey("BuildTab");

            // Check if everything is ready.
            if (TheBigOneTM.Enabled && !IsBuilding)
            {
                // Ready to rumble. :)
                return(BuildAnsync());
            }

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Rendering of a generated image button
        /// </summary>
        /// <param name="writer">The writer to render the html to</param>
        private void RenderGeneratedButton(HtmlTextWriter writer)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "image");
            if (ImageAlign != ImageAlign.NotSet)
                writer.AddAttribute(HtmlTextWriterAttribute.Align, ImageAlign.ToString());

            Size size = new Size();
            bool writeWidth = true;
            bool writeHeight = true;

            if (!this.Width.IsEmpty)
            {
                size.Width = (int)this.Width.Value;
                writeWidth = false;
            }
            else if (Style["width"] != null)
            {
                int width;
                if (int.TryParse(Style["width"].Replace("px", ""), out width))
                    size.Width = width;
                writeWidth = false;
            }

            if (!this.Height.IsEmpty)
            {
                size.Height = (int)this.Height.Value;
                writeHeight = false;
            }
            else if (Style["height"] != null)
            {
                int height;
                if (int.TryParse(Style["height"].Replace("px", ""), out height))
                    size.Height = height;
                writeHeight = false;
            }

            Color fColor = Color.Black;
            if (GenerateStyle == GenerateStyle.Vista)
                fColor = Color.White;

            if (!ForeColor.IsEmpty)
                fColor = ForeColor;
            else if (Style["color"] != null)
            {
                ColorConverter conv = new ColorConverter();
                fColor = (Color)conv.ConvertFrom(Style["color"]);
            }

            string altText = AlternateText;
            string text = Text;
            string imgPath = string.Empty;

            if(Active)
            {
                if(!string.IsNullOrEmpty(ActiveImageUrl))
                    imgPath = Page.Server.MapPath(ActiveImageUrl);

                if(string.IsNullOrEmpty(altText))
                    altText = ActiveText;

                    text = ActiveText;
            }
            else
            {
                if(!string.IsNullOrEmpty(ImageUrl))
                    imgPath = Page.Server.MapPath(ImageUrl);

                if(string.IsNullOrEmpty(altText))
                    altText = Text;
            }

            Font textfont = Util.ConvertFont(Font);
            if (this.IsEnabled)
            {

                GenerateImage normImg = new GenerateImage(GenerateStyle, GenerateImage.ButtonState.Normal, size, text, textfont, fColor, imgPath, CacheName,Page.Server.MapPath(CustomNormalImageUrl), Color.Empty);
                writer.AddAttribute(HtmlTextWriterAttribute.Src, normImg.FullPath);
                writer.AddAttribute("onmouseout", "this.src='" + normImg.FullPath + "';");

                GenerateImage hovImg = new GenerateImage(GenerateStyle, GenerateImage.ButtonState.Hover, size, text, textfont, fColor, imgPath, CacheName, Page.Server.MapPath(CustomHoverImageUrl), Color.Empty);
                writer.AddAttribute("onmouseover", "this.src='" + hovImg.FullPath + "';");

                GenerateImage clickImg = new GenerateImage(GenerateStyle, GenerateImage.ButtonState.Clicked, size, text, textfont, fColor, imgPath, CacheName, Page.Server.MapPath(CustomClickedImageUrl), Color.Empty);
                writer.AddAttribute("onmousedown", "this.src='" + clickImg.FullPath + "';");

                if (!string.IsNullOrEmpty(OnClientClick))
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, OnClientClick);

                size = normImg.Size;
            }
            else
            {
                GenerateImage disImg = new GenerateImage(GenerateStyle, GenerateImage.ButtonState.Disabled, size, text, textfont, fColor, imgPath, CacheName,  Page.Server.MapPath(CustomDisabledImageUrl), CustomDisabledOverlayColor);
                writer.AddAttribute(HtmlTextWriterAttribute.Src, disImg.FullPath);

                size = disImg.Size;
            }

            if (writeWidth)
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, size.Width.ToString() + "px");

            if (writeHeight)
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, size.Height.ToString() + "px");

            if (!string.IsNullOrEmpty(altText))
                writer.AddAttribute(HtmlTextWriterAttribute.Alt, altText);
        }