Пример #1
0
        /// <summary>
        /// Print a film box on specified graphics.
        /// </summary>
        /// <param name="filmBox">Film box.</param>
        /// <param name="graphics">Graphics on which to draw the film box.</param>
        /// <param name="marginBounds">Margin bounds.</param>
        /// <param name="imageResolution">Image resolution.</param>
        public static void Print(this FilmBox filmBox, Graphics graphics, Rectangle marginBounds, int imageResolution)
        {
            var parts = filmBox.ImageDisplayFormat.Split('\\', ',');

            if (parts.Length > 0)
            {
                RectF[] boxes = null;
                if (parts[0] == "STANDARD")
                {
                    boxes = FilmBox.PrintStandardFormat(parts, ToRectF(marginBounds));
                }
                else if (parts[0] == "ROW")
                {
                    boxes = FilmBox.PrintRowFormat(parts, ToRectF(marginBounds));
                }
                else if (parts[0] == "COL")
                {
                    boxes = FilmBox.PrintColumnFormat(parts, ToRectF(marginBounds));
                }

                if (boxes == null)
                {
                    throw new InvalidOperationException($"ImageDisplayFormat {filmBox.ImageDisplayFormat} invalid");
                }

                for (var i = 0; i < filmBox.BasicImageBoxes.Count; i++)
                {
                    filmBox.BasicImageBoxes[i].Print(graphics, boxes[i], imageResolution);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Get the film box size in inches.
        /// </summary>
        /// <param name="filmBox">Film box object.</param>
        /// <returns>Size in inches of film box.</returns>
        public static SizeF GetSizeInInch(this FilmBox filmBox)
        {
            // ReSharper disable once InconsistentNaming
            const float CM_PER_INCH = 2.54f;
            var         filmSizeId  = filmBox.FilmSizeID;

            if (filmSizeId.Contains("IN"))
            {
                var parts = filmSizeId.Split(new[] { "IN" }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 2)
                {
                    var width  = parts[0].Replace('_', '.');
                    var height = parts[1].TrimStart('X').Replace('_', '.');

                    return(new SizeF(float.Parse(width), float.Parse(height)));
                }
            }
            else if (filmSizeId.Contains("CM"))
            {
                var parts = filmSizeId.Split(new[] { "CM" }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 2)
                {
                    var width  = parts[0].Replace('_', '.');
                    var height = parts[1].TrimStart('X').Replace('_', '.');

                    return(new SizeF(float.Parse(width) / CM_PER_INCH, float.Parse(height) / CM_PER_INCH));
                }
            }
            else if (filmSizeId == "A3")
            {
                return(new SizeF(29.7f / CM_PER_INCH, 42.0f / CM_PER_INCH));
            }

            return(new SizeF(210 / CM_PER_INCH, 297 / CM_PER_INCH));
        }
Пример #3
0
 /// <summary>
 /// If requested, fill the box with black color.
 /// </summary>
 /// <param name="filmBox">Film box.</param>
 /// <param name="box">Rectangle.</param>
 /// <param name="graphics">Graphics.</param>
 private static void FillBox(FilmBox filmBox, RectF box, Graphics graphics)
 {
     if (filmBox.EmptyImageDensity == "BLACK")
     {
         RectF fillBox = box;
         if (filmBox.BorderDensity == "WHITE" && filmBox.Trim == "YES")
         {
             fillBox.Inflate(-_border, -_border);
         }
         using var brush = new SolidBrush(Color.Black);
         graphics.FillRectangle(brush, fillBox.X, fillBox.Y, fillBox.Width, fillBox.Height);
     }
 }