示例#1
0
        private Control CreatePageContainer(Control control, out bool absoluteSet)
        {
            absoluteSet = false;
            foreach (Control ctrl in control.Controls)
            {
                BillReport r = ctrl as BillReport;
                if (r != null)
                {
                    pagesCount += r.PagesCount;
                    if (pageHeight == WebUnit.Empty)
                    {
                        pageHeight = r.PageHeight;
                    }
                }
            }
            HtmlGenericControl result = new HtmlGenericControl("div");

            result.Style[HtmlTextWriterStyle.Width]       = "100%";
            result.Style[HtmlTextWriterStyle.Padding]     = "0cm";
            result.Style[HtmlTextWriterStyle.BorderWidth] = "0cm";
            result.Style[HtmlTextWriterStyle.Margin]      = "0cm";
            if (!pageHeight.IsEmpty)
            {
                result.Style[HtmlTextWriterStyle.Top]      = new WebUnit((pageHeight.Value * slipPages), pageHeight.Type).ToString();
                result.Style[HtmlTextWriterStyle.Position] = "absolute";
                absoluteSet = true;
            }
            result.Controls.Add(control);
            slipPages = pagesCount;
            return(result);
        }
示例#2
0
 /// <summary>
 /// Ctor
 /// </summary>
 public ClipStyle()
 {
     left     = System.Web.UI.WebControls.Unit.Empty;
     right    = System.Web.UI.WebControls.Unit.Empty;
     top      = System.Web.UI.WebControls.Unit.Empty;
     bottom   = System.Web.UI.WebControls.Unit.Empty;
     clipType = ClipFormat.Auto;
 }
 public FontUnit(System.Web.UI.WebControls.Unit value)
 {
     this.type = FontSize.NotSet;
     if (!value.IsEmpty)
     {
         this.type  = FontSize.AsUnit;
         this.value = value;
     }
     else
     {
         this.value = System.Web.UI.WebControls.Unit.Empty;
     }
 }
 public FontUnit(System.Web.UI.WebControls.Unit value)
 {
     this.type = FontSize.NotSet;
     if (!value.IsEmpty)
     {
         this.type = FontSize.AsUnit;
         this.value = value;
     }
     else
     {
         this.value = System.Web.UI.WebControls.Unit.Empty;
     }
 }
示例#5
0
        /// <summary>
        /// Converts a unit string for example 16px to
        /// a unit
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static System.Web.UI.WebControls.Unit ConvertStringToUnit(string s)
        {
            string number = "";
            string unit   = "";

            for (int i = 0; i < s.Length; i++)
            {
                string c       = s[i].ToString();
                int    current = -1;
                if (Int32.TryParse(c, out current))
                {
                    number += c;
                }
                else
                {
                    unit += c;
                }
            }

            if (number == "")
            {
                return(System.Web.UI.WebControls.Unit.Empty);
            }

            int size = Int32.Parse(number);


            System.Web.UI.WebControls.UnitType unitType = System.Web.UI.WebControls.UnitType.Point;

            if (unit == "px")
            {
                unitType = System.Web.UI.WebControls.UnitType.Pixel;
            }
            if (unit == "pt")
            {
                unitType = System.Web.UI.WebControls.UnitType.Point;
            }
            if (unit == "em")
            {
                unitType = System.Web.UI.WebControls.UnitType.Em;
            }
            if (unit == "%")
            {
                unitType = System.Web.UI.WebControls.UnitType.Percentage;
            }

            System.Web.UI.WebControls.Unit webUnit = new System.Web.UI.WebControls.Unit(size, unitType);
            return(webUnit);
        }
 public FontUnit(FontSize type)
 {
     if ((type < FontSize.NotSet) || (type > FontSize.XXLarge))
     {
         throw new ArgumentOutOfRangeException("type");
     }
     this.type = type;
     if (this.type == FontSize.AsUnit)
     {
         this.value = System.Web.UI.WebControls.Unit.Point(10);
     }
     else
     {
         this.value = System.Web.UI.WebControls.Unit.Empty;
     }
 }
 public FontUnit(FontSize type)
 {
     if ((type < FontSize.NotSet) || (type > FontSize.XXLarge))
     {
         throw new ArgumentOutOfRangeException("type");
     }
     this.type = type;
     if (this.type == FontSize.AsUnit)
     {
         this.value = System.Web.UI.WebControls.Unit.Point(10);
     }
     else
     {
         this.value = System.Web.UI.WebControls.Unit.Empty;
     }
 }
示例#8
0
        public static double ConvertUnit(string length)
        {
            if (string.IsNullOrEmpty(length))
            {
                return 0;
            }
            length = length.Trim();
            double result = 0;
            if (length.EndsWith("px", StringComparison.CurrentCultureIgnoreCase))
            {
                length = length.Remove(length.Length - 2, 2);
            }
            var value = double.TryParse(length, out result) ? result : 0;

            var unit = new System.Web.UI.WebControls.Unit(value, System.Web.UI.WebControls.UnitType.Pixel);
            return MeasureTools.UnitToMillimeters(unit);
        }
        private static void SetObjectParameters(Object chartObject, IDictionary ht)
        {
            foreach (string name in ht.Keys)
            {
                string val = ht[name].ToString();

                PropertyInfo pi = chartObject.GetType().GetProperty(name);

                // Evaluate special cases: Enum, Color, etc. Else do basic conversion
                try
                {
                    Object o;

                    if (pi.PropertyType.BaseType.FullName == "System.Enum")
                    {
                        o = Enum.Parse(pi.PropertyType, val);
                    }
                    else if (pi.PropertyType.FullName == "System.Drawing.Color")
                    {
                        o = System.Drawing.Color.FromName(val);
                    }
                    else if (pi.PropertyType.FullName == "System.Web.UI.WebControls.Unit")
                    {
                        o = new System.Web.UI.WebControls.Unit(val);
                    }
                    else
                    {
                        o = Convert.ChangeType(val, pi.PropertyType);
                    }

                    pi.SetValue(chartObject, o, null);
                }
                catch (Exception e)
                // DO NOTHING ... Yet
                {

                }
            }
        }
        public FontUnit(string value, CultureInfo culture)
        {
            this.type  = FontSize.NotSet;
            this.value = System.Web.UI.WebControls.Unit.Empty;
            if (!string.IsNullOrEmpty(value))
            {
                char ch = char.ToLower(value[0], CultureInfo.InvariantCulture);
                switch (ch)
                {
                case 's':
                    if (string.Equals(value, "small", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.Small;
                        return;
                    }
                    if (string.Equals(value, "smaller", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.Smaller;
                        return;
                    }
                    break;

                case 'l':
                    if (string.Equals(value, "large", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.Large;
                        return;
                    }
                    if (string.Equals(value, "larger", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.Larger;
                        return;
                    }
                    break;

                case 'x':
                    if (string.Equals(value, "xx-small", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "xxsmall", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.XXSmall;
                        return;
                    }
                    if (string.Equals(value, "x-small", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "xsmall", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.XSmall;
                        return;
                    }
                    if (string.Equals(value, "x-large", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "xlarge", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.XLarge;
                        return;
                    }
                    if (string.Equals(value, "xx-large", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "xxlarge", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.XXLarge;
                        return;
                    }
                    break;

                default:
                    if ((ch == 'm') && string.Equals(value, "medium", StringComparison.OrdinalIgnoreCase))
                    {
                        this.type = FontSize.Medium;
                        return;
                    }
                    break;
                }
                this.value = new System.Web.UI.WebControls.Unit(value, culture, UnitType.Point);
                this.type  = FontSize.AsUnit;
            }
        }
 public FontUnit(int value)
 {
     this.type  = FontSize.AsUnit;
     this.value = System.Web.UI.WebControls.Unit.Point(value);
 }
        public FontUnit(string value, CultureInfo culture)
        {
            this.type = FontSize.NotSet;
            this.value = System.Web.UI.WebControls.Unit.Empty;
            if (!string.IsNullOrEmpty(value))
            {
                char ch = char.ToLower(value[0], CultureInfo.InvariantCulture);
                switch (ch)
                {
                    case 's':
                        if (string.Equals(value, "small", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.Small;
                            return;
                        }
                        if (string.Equals(value, "smaller", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.Smaller;
                            return;
                        }
                        break;

                    case 'l':
                        if (string.Equals(value, "large", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.Large;
                            return;
                        }
                        if (string.Equals(value, "larger", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.Larger;
                            return;
                        }
                        break;

                    case 'x':
                        if (string.Equals(value, "xx-small", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "xxsmall", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.XXSmall;
                            return;
                        }
                        if (string.Equals(value, "x-small", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "xsmall", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.XSmall;
                            return;
                        }
                        if (string.Equals(value, "x-large", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "xlarge", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.XLarge;
                            return;
                        }
                        if (string.Equals(value, "xx-large", StringComparison.OrdinalIgnoreCase) || string.Equals(value, "xxlarge", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.XXLarge;
                            return;
                        }
                        break;

                    default:
                        if ((ch == 'm') && string.Equals(value, "medium", StringComparison.OrdinalIgnoreCase))
                        {
                            this.type = FontSize.Medium;
                            return;
                        }
                        break;
                }
                this.value = new System.Web.UI.WebControls.Unit(value, culture, UnitType.Point);
                this.type = FontSize.AsUnit;
            }
        }
 public FontUnit(int value)
 {
     this.type = FontSize.AsUnit;
     this.value = System.Web.UI.WebControls.Unit.Point(value);
 }
 /// <summary>
 /// This method sets the URL for the Google Checkout "Donate" button image.
 /// </summary>
 protected override void SetImageUrl()
 {
     this.Width  = 115;
     this.Height = 50;
     base.SetImageUrl();
 }