コード例 #1
0
        /// <summary>
        /// Renders the bar code.
        /// </summary>
        protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
        {
            XGraphicsState state = gfx.Save();

            BarCodeRenderInfo info = new BarCodeRenderInfo(gfx, brush, font, position);

            InitRendering(info);
            info.CurrPosInString = 0;
            //info.CurrPos = info.Center - Size / 2;
            info.CurrPos = position - CodeBase.CalcDistance(AnchorType.TopLeft, Anchor, Size);

            if (TurboBit)
            {
                RenderTurboBit(info, true);
            }
            RenderStart(info);
            while (info.CurrPosInString < Text.Length)
            {
                RenderNextPair(info);
            }
            RenderStop(info);
            if (TurboBit)
            {
                RenderTurboBit(info, false);
            }
            if (TextLocation != TextLocation.None)
            {
                RenderText(info);
            }

            gfx.Restore(state);
        }
コード例 #2
0
 private void RenderStart(BarCodeRenderInfo info)
 {
     RenderBar(info, false);
     RenderGap(info, false);
     RenderBar(info, false);
     RenderGap(info, false);
 }
コード例 #3
0
        /// <summary>
        /// Renders the next digit pair as bar code element.
        /// </summary>
        private void RenderNextPair(BarCodeRenderInfo info)
        {
            int digitForLines = int.Parse(Text[info.CurrPosInString].ToString());
            int digitForGaps  = int.Parse(Text[info.CurrPosInString + 1].ToString());

            bool[] linesArray = Lines[digitForLines];
            bool[] gapsArray  = Lines[digitForGaps];
            for (int idx = 0; idx < 5; ++idx)
            {
                RenderBar(info, linesArray[idx]);
                RenderGap(info, gapsArray[idx]);
            }
            info.CurrPosInString += 2;
        }
コード例 #4
0
        /// <summary>
        /// Calculates the thick and thin line widths,
        /// taking into account the required rendering size.
        /// </summary>
        internal override void CalcThinBarWidth(BarCodeRenderInfo info)
        {
            /*
             * The total width is the sum of the following parts:
             * Starting lines      = 4 * thin
             *  +
             * Code Representation = (2 * thick + 3 * thin) * code.Length
             *  +
             * Stopping lines      =  1 * thick + 2 * thin
             *
             * with r = relation ( = thick / thin), this results in
             *
             * Total width = (6 + r + (2 * r + 3) * text.Length) * thin
             */
            double thinLineAmount = 6 + WideNarrowRatio + (2 * WideNarrowRatio + 3) * Text.Length;

            info.ThinBarWidth = Size.Width / thinLineAmount;
        }
コード例 #5
0
        /// <summary>
        /// Renders the bar code.
        /// </summary>
        protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
        {
            XGraphicsState state = gfx.Save();

            BarCodeRenderInfo info = new BarCodeRenderInfo(gfx, brush, font, position);
            InitRendering(info);
            info.CurrPosInString = 0;
            //info.CurrPos = info.Center - Size / 2;
            info.CurrPos = position - CodeBase.CalcDistance(AnchorType.TopLeft, Anchor, Size);

            if (TurboBit)
                RenderTurboBit(info, true);
            RenderStart(info);
            while (info.CurrPosInString < Text.Length)
                RenderNextPair(info);
            RenderStop(info);
            if (TurboBit)
                RenderTurboBit(info, false);
            if (TextLocation != TextLocation.None)
                RenderText(info);

            gfx.Restore(state);
        }
コード例 #6
0
 /// <summary>
 /// Renders the next digit pair as bar code element.
 /// </summary>
 private void RenderNextPair(BarCodeRenderInfo info)
 {
     int digitForLines = int.Parse(Text[info.CurrPosInString].ToString());
     int digitForGaps = int.Parse(Text[info.CurrPosInString + 1].ToString());
     bool[] linesArray = Lines[digitForLines];
     bool[] gapsArray = Lines[digitForGaps];
     for (int idx = 0; idx < 5; ++idx)
     {
         RenderBar(info, linesArray[idx]);
         RenderGap(info, gapsArray[idx]);
     }
     info.CurrPosInString += 2;
 }
コード例 #7
0
 private void RenderStop(BarCodeRenderInfo info)
 {
     RenderBar(info, true);
     RenderGap(info, false);
     RenderBar(info, false);
 }
コード例 #8
0
 /// <summary>
 /// Calculates the thick and thin line widths,
 /// taking into account the required rendering size.
 /// </summary>
 internal override void CalcThinBarWidth(BarCodeRenderInfo info)
 {
     /*
      * The total width is the sum of the following parts:
      * Starting lines      = 4 * thin
      *  +
      * Code Representation = (2 * thick + 3 * thin) * code.Length
      *  +
      * Stopping lines      =  1 * thick + 2 * thin
      * 
      * with r = relation ( = thick / thin), this results in
      * 
      * Total width = (6 + r + (2 * r + 3) * text.Length) * thin
      */
     double thinLineAmount = 6 + WideNarrowRatio + (2 * WideNarrowRatio + 3) * Text.Length;
     info.ThinBarWidth = Size.Width / thinLineAmount;
 }