Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions BarcodeStandard/BarcodeCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,32 @@ internal static bool CheckNumericOnly(string data)
return true;
}

internal static int GetAlignmentShiftAdjustment(Barcode barcode)
internal static int GetQuietZoneAdjustment(Barcode barcode)
{
if (barcode.IncludeLabel && barcode.GuardBarsMode == GuardBarsMode.EnabledFirstCharOnQuietZone)
{
return Utils.GetFontWidth("0", barcode.LabelFont) * 2;
}

return 0;
}

internal static int GetAlignmentShiftAdjustment(Barcode barcode)
{
var quietZoneAdjustment = BarcodeCommon.GetQuietZoneAdjustment(barcode);

switch (barcode.Alignment)
{
case AlignmentPositions.Left:
return 0;
return quietZoneAdjustment;

case AlignmentPositions.Right:
return (barcode.Width % barcode.EncodedValue.Length);
return ((barcode.Width - quietZoneAdjustment * 2) % barcode.EncodedValue.Length) + quietZoneAdjustment;

case AlignmentPositions.Center:
default:
return (barcode.Width % barcode.EncodedValue.Length) / 2;
return ((barcode.Width - quietZoneAdjustment * 2) % barcode.EncodedValue.Length) / 2 + quietZoneAdjustment;
}//switch
}
}//BarcodeVariables abstract class
}//namespace
}//namespace
Loading