我尝试使用PrintDocuments控件制作客户收据,现在我想在客户收据上显示页脚。页脚文本存储在字符串类型变量中:
String Footertex="ABC DEF GHIJK LMNOP QRSTUVWXYZ AAA BBBBBBB ABCD";
但是我使用热敏打印机打印客户收据,并且在页脚中仅打印以下文本:
ABC DEF GHIJK LMNOP
现在,我希望它自动换行并在下一行显示其余文本,如下所示:
ABC DEF GHIJK LMNOP
QRSTUVWXYZ AAA
BBBBBBB ABCD
我只是希望,如果文本中的字符数大于19,则它会中断该行并在下一行中打印其余文本。 预先感谢。
string item = (_List[i].Qty + " x " + _List[i].Name);
int nInterval1 = 18;
string res1 = String.Concat(item.Select((c, j) => i > 0 && (i % nInterval1) == 0 ? c.ToString() + Environment.NewLine : c.ToString()));
我已经尝试了上面的代码,但是它会在18个字符后中断字符串,但是在某些情况下,在18个字符后中断行是没有意义的,因为它会中断任何单词。我想在一个完整的单词后换行。
答案 0 :(得分:0)
您可以使用以下代码(带有我的评论)执行此操作:
private static async Task<DialogTurnResult> PromptForLocation(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
Activity reply = stepContext.Context.Activity.CreateReply();
var heroCard = new HeroCard
{
Title = "Please choose a location.",
Buttons = new List<CardAction> { new CardAction(ActionTypes.PostBack, "Redmond", value: "Redmond"),
new CardAction(ActionTypes.PostBack, "Bellevue", value: "Bellevue"),
new CardAction(ActionTypes.PostBack, "Seattle", value: "Seattle") },
};
reply.Attachments = new List<Attachment>() { heroCard.ToAttachment() };
var options = new PromptOptions()
{
Prompt = reply,
RetryPrompt = MessageFactory.Text("Sorry, please choose a location from the list.")
};
return await stepContext.PromptAsync("name", options, cancellationToken);
}