added styles

This commit is contained in:
Djeeberjr 2022-02-18 19:30:13 +01:00
parent e127efa0aa
commit 0d18ab2651

View File

@ -11,8 +11,14 @@ public class TextInstruction : BaseInstruction
public Alignment alignment {get; set; } = Alignment.Left; public Alignment alignment {get; set; } = Alignment.Left;
public bool underline {get; set; } = false; public bool underline {get; set; } = false;
public bool bold {get; set; } = false;
public bool doubleHeight {get; set; } = false;
public bool doubleWidth {get; set; } = false;
public bool fontB {get; set; } = false;
public bool newLine { get; set; } = true; public bool newLine { get; set; } = true;
public override List<byte[]> GetInstructions() public override List<byte[]> GetInstructions()
{ {
var e = new EPSON(); var e = new EPSON();
@ -20,9 +26,7 @@ public class TextInstruction : BaseInstruction
commands.Add(alignmentCommand(alignment)); commands.Add(alignmentCommand(alignment));
if (underline){ commands.AddRange(setStyles());
commands.Add(e.SetStyles(PrintStyle.Underline));
}
if (newLine) if (newLine)
{ {
@ -33,10 +37,36 @@ public class TextInstruction : BaseInstruction
commands.Add(e.Print(text)); commands.Add(e.Print(text));
} }
if (underline){ if (underline || bold || doubleHeight || doubleWidth || fontB){
commands.Add(e.SetStyles(PrintStyle.None)); commands.Add(e.SetStyles(PrintStyle.None));
} }
return commands; return commands;
} }
private List<byte[]> setStyles(){
var e = new EPSON();
var commands = new List<byte[]>();
if (underline){
commands.Add(e.SetStyles(PrintStyle.Underline));
}
if (bold){
commands.Add(e.SetStyles(PrintStyle.Bold));
}
if (doubleHeight){
commands.Add(e.SetStyles(PrintStyle.DoubleHeight));
}
if (doubleWidth){
commands.Add(e.SetStyles(PrintStyle.DoubleWidth));
}
if (fontB){
commands.Add(e.SetStyles(PrintStyle.FontB));
}
return commands;
}
} }