Example #1
0
        /// <summary>
        /// Generate image tag for rating stars
        /// </summary>
        protected override void OnPreRender(EventArgs e)
        {
            if (_radius == 0)
            {
                _radius = _defaultRadius;
            }
            string cacheKey = string.Format("star{0}", _radius);

            if (!this.TagInCache(cacheKey))
            {
                Idaho.Draw.Star draw = new Idaho.Draw.Star(1, 0, _points, _sharpness);

                draw.Width            = _radius * 10;
                draw.Height           = _radius * 2;
                draw.Color.ForeGround = Utility.NoNull <Color>(_foreGroundColor, _defaultColor);
                draw.Color.Border     = Utility.NoNull <Color>(_borderColor, _defaultBorderColor);
                draw.Color.Highlight  = Utility.NoNull <Color>(_burstColor, _defaultBurstColor);
                draw.BorderWidth      = Utility.NoNull <int>(_borderWidth, _defaultBorderWidth);
                this.Src = draw.Url;

                this.Style.Add("width", string.Format("{0}px", _radius * 10));
                this.Style.Add("height", string.Format("{0}px", _radius * 2));
                this.Transparency = true;
            }

            // attributes that aren't cached
            this.AlternateText = "";
            this.Generated     = true;
            base.OnPreRender(e);
        }
        /// <summary>
        /// Generate image tag for rating stars
        /// </summary>
        private void Rating_PreRender(object sender, System.EventArgs e)
        {
            if (_rating > 0)
            {
                if (_radius == 0)
                {
                    _radius = Star.DefaultRadius;
                }
                string cacheKey = string.Format("rating{0}_{1}", _rating, _radius);

                if (!this.TagInCache(cacheKey))
                {
                    Idaho.Draw.Star draw = new Idaho.Draw.Star(5, _rating, _points, _sharpness);

                    draw.Width            = _radius * 10;
                    draw.Height           = _radius * 2;
                    draw.Color.ForeGround = Utility.NoNull <Color>(_foreGroundColor, Star.DefaultColor);
                    draw.Color.Border     = Utility.NoNull <Color>(_borderColor, Star.DefaultBorderColor);
                    draw.Color.Highlight  = Utility.NoNull <Color>(_burstColor, Star.DefaultBurstColor);
                    draw.BorderWidth      = Utility.NoNull <int>(_borderWidth, Star.DefaultBorderWidth);
                    this.Src = draw.Url;

                    this.Style.Add("width", string.Format("{0}px", _radius * 10));
                    this.Style.Add("height", string.Format("{0}px", _radius * 2));
                    //Me.Style.Add("border", "1px solid red")
                    this.Transparency = true;
                }

                // attributes that aren't cached
                this.AlternateText = "";
                this.Generated     = true;
            }
        }