示例#1
0
        public static bool TryParseDashNumberList(string value, out PDFDash dash)
        {
            bool result = false;

            dash = null;

            var entries            = value.Split(',', ' ');
            int total              = 0;
            List <PDFNumber> items = new List <PDFNumber>(entries.Length);

            foreach (var a in entries)
            {
                if (string.IsNullOrEmpty(a) == false)
                {
                    int i;
                    if (int.TryParse(a.Trim(), out i))
                    {
                        items.Add(new PDFNumber(i));
                        total += i;
                    }
                    else
                    {
                        throw new FormatException("The format of a custom dash phase should be '[n n ...] n' or '[n,n,n] n' or 'n,n,n,n'. Could not understand the format '" + value + "'");
                    }
                }
            }
            result = items.Count > 0;
            dash   = new PDFDash(items.ToArray(), new PDFNumber(total));
            return(result);
        }
示例#2
0
 public bool Equals(PDFDash dash)
 {
     if (this._pattern == null && dash._pattern == null)
     {
         return(this._len == dash._len);
     }
     else if (this._pattern.Length == dash._pattern.Length)
     {
         for (int i = 0; i < this._pattern.Length; i++)
         {
             if (this._pattern[i] != dash._pattern[i])
             {
                 return(false);
             }
         }
         return(this._len == dash._len);
     }
     else
     {
         return(false);
     }
 }
示例#3
0
        public static PDFDash Parse(string dashpattern)
        {
            PDFDash dash = null;

            if (string.IsNullOrEmpty(dashpattern))
            {
                return(dash);
            }
            dashpattern = dashpattern.Trim();

            if (dashpattern.StartsWith("[") && dashpattern.IndexOf("]") > 0)
            {
                dash = ParseExplicit(dashpattern);
            }

            else if (PDFDashes.TryGetNamedDash(dashpattern, out dash) == false)
            {
                if (!TryParseDashNumberList(dashpattern, out dash))
                {
                    throw new ArgumentException("The dash pattern '" + dashpattern + "' could not be parsed. The format of a custom dash phase should be '[n n ...] n' or '[n,n,n] n', or one of hte known named patterns.");
                }
            }
            return(dash);
        }
示例#4
0
 public void RenderLineDash(PDFDash dash)
 {
     this.Writer.WriteArrayNumberEntries(true, dash.Pattern);
     this.Writer.WriteOpCodeS(PDFOpCode.GraphDashPattern, dash.Phase);
 }
示例#5
0
 public PDFDashPen(PDFDash dash, PDFColor color, PDFUnit width)
     : base(color, width)
 {
     this.Dash = dash;
 }
示例#6
0
 public PDFDashPen(PDFDash dash)
 {
     this.Dash = dash;
 }
示例#7
0
 public static bool TryGetNamedDash(string name, out PDFDash found)
 {
     return(_named.TryGetValue(name, out found));
 }