ESCPOS icon indicating copy to clipboard operation
ESCPOS copied to clipboard

Split Commands class and Add Simple commands alias for possible full commands combinations

Open igorocampos opened this issue 2 years ago • 0 comments

Simple ESC/POS Commands are actually just static properties of Commands class. And they are easy on the eye when used. On the other hand, full commands require parameters, which is good for flexibility but can create a little bit of wordy command concatenation.

The proposal here is to have the class split into 2 files (as a partial Command class), one for the Simple commands and another that will hold all the Commands that are not static properties.

In addition, to be easier on the eye we should create a number of simple commands (static properties) that can be used for the most used combination of parameters used in the full commands. For Example:

  • SelectPrintMode(PrintMode printMode) will have the following static properties as aliases

  • PrintModeReset

  • PrintModeFontB

  • PrintModeEmphasis

  • SelectUnderlineMode(UnderlineMode underlineMode) will have the following static properties as aliases

  • UnderlineModeOff

  • UnderlineModeOn

Please beware that not all possible combinations should have an alias, only the most used ones. The existing full command methods are not to be depreciated and can still be used for a full usage of the combinations. Aliases properties should just call the existing full commands as shown below

public static byte[] UnderlineModeOff => SelectUnderlineMode(UnderlineMode.Off);

public static byte[] UnderlineModeOn => SelectUnderlineMode(UnderlineMode.OneDotThick);

Now a list with the name of all simple methods that should be created

  • PrintModeReset
  • PrintModeFontB
  • PrintModeEmphasis
  • UnderlineModeOff
  • UnderlineModeOn
  • DoubleStrikeOn
  • DoubleStrikeOff
  • UseFontA
  • UseFontB
  • AlignToLeft
  • AlignToRight
  • AlignToCenter
  • CharSizeDoubleHeight
  • CharSizeDoubleWidth
  • CharSizeDoubleHeightAndWidth
  • CharSizeReset
  • HRIAboveBarcode
  • HRIBelowBarcode
  • HRINotPrinted

igorocampos avatar Nov 25 '22 12:11 igorocampos