using EpsonTest.Templates;
using Inspectron.Epson.TemplateEngine;

var engine = new ReceiptTemplateEngine();
var templatesDir = Path.Combine(AppContext.BaseDirectory, "Templates");

// ============================================================================
// FINAL RECEIPT - HTML PRINTER
// ============================================================================
//var json = TestHelpers.BuildFinalReceiptJson(includeTax: true);
//var template = File.ReadAllText(Path.Combine(templatesDir, "FinalReceipt.xml"));
//var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24);

//TestHelpers.PrintCommandsToConsole(printCommands);

//var printer = await TestHelpers.CreateHtmlPrinterAsync();
//await TestHelpers.PrintCommandsToHtmlPrinterAsync(
//    printer,
//    printCommands,
//    logoPath: "ristorante-klinglers.ch-logo_white_bg.png");


// ============================================================================
// FINAL RECEIPT - EPSON PRINTER
// ============================================================================
//var json = TestHelpers.BuildFinalReceiptJson();
//var template = File.ReadAllText(Path.Combine(templatesDir, "FinalReceipt.xml"));
//var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24);

//TestHelpers.PrintCommandsToConsole(printCommands);

//var printer = await TestHelpers.CreateEpsonPrinterAsync();
//await TestHelpers.PrintCommandsToEpsonPrinterAsync(printer, printCommands);


// ============================================================================
// INVOICE RECEIPT - HTML PRINTER
// ============================================================================
//var json = TestHelpers.BuildInvoiceReceiptJson();
//var template = File.ReadAllText(Path.Combine(templatesDir, "InvoiceReceipt.xml"));
//var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24);

//TestHelpers.PrintCommandsToConsole(printCommands);

//var printer = await TestHelpers.CreateHtmlPrinterAsync();
//await TestHelpers.PrintCommandsToHtmlPrinterAsync(
//    printer,
//    printCommands,
//    logoPath: "ristorante-klinglers.ch-logo_white_bg.png");


// ============================================================================
// INVOICE RECEIPT - EPSON PRINTER
// ============================================================================
//var json = TestHelpers.BuildInvoiceReceiptJson();
//var template = File.ReadAllText(Path.Combine(templatesDir, "InvoiceReceipt.xml"));
//var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24);

//TestHelpers.PrintCommandsToConsole(printCommands);

//var printer = await TestHelpers.CreateEpsonPrinterAsync();
//await TestHelpers.PrintCommandsToEpsonPrinterAsync(printer, printCommands);


// ============================================================================
// KITCHEN RECEIPT - HTML PRINTER
// ============================================================================
var json = TestHelpers.BuildKitchenReceiptJson();
var template = File.ReadAllText(Path.Combine(templatesDir, "KitchenReceipt.xml"));
var printCommands = engine.Render(template, json, lineWidth: 33, bigFontLineWidth: 20);

TestHelpers.PrintCommandsToConsole(printCommands);

var printer = await TestHelpers.CreateHtmlPrinterAsync(
    path: @".\kitchen_test.html",
    paperWidth: TestHelpers.KitchenPaperWidth);
await TestHelpers.PrintKitchenCommandsToHtmlPrinterAsync(printer, printCommands);


// ============================================================================
// KITCHEN RECEIPT (NEXT DISH) - HTML PRINTER
// ============================================================================
//var json = TestHelpers.BuildKitchenReceiptNextDishJson();
//var template = File.ReadAllText(Path.Combine(templatesDir, "KitchenReceipt.xml"));
//var printCommands = engine.Render(template, json, lineWidth: 33, bigFontLineWidth: 20);

//TestHelpers.PrintCommandsToConsole(printCommands);

//var printer = await TestHelpers.CreateHtmlPrinterAsync(
//    path: @".\kitchen_next_dish.html",
//    paperWidth: TestHelpers.KitchenPaperWidth);
//await TestHelpers.PrintKitchenCommandsToHtmlPrinterAsync(printer, printCommands);


// ============================================================================
// KITCHEN RECEIPT - EPSON PRINTER
// ============================================================================
//var json = TestHelpers.BuildKitchenReceiptJson();
//var template = File.ReadAllText(Path.Combine(templatesDir, "KitchenReceipt.xml"));
//var printCommands = engine.Render(template, json, lineWidth: 33, bigFontLineWidth: 20);

//TestHelpers.PrintCommandsToConsole(printCommands);

//var printer = await TestHelpers.CreateEpsonPrinterAsync(paperWidth: TestHelpers.KitchenPaperWidth);
//await TestHelpers.PrintCommandsToEpsonPrinterAsync(printer, printCommands, useDelay: true);


// ============================================================================
// ORDER ITEMS RECEIPT - HTML PRINTER
// ============================================================================
//var json = TestHelpers.BuildOrderItemsJson();
//var template = File.ReadAllText(Path.Combine(templatesDir, "OrderItems.xml"));
//var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24);

//TestHelpers.PrintCommandsToConsole(printCommands);

//var printer = await TestHelpers.CreateHtmlPrinterAsync(path: @".\order_items.html");
//await TestHelpers.PrintCommandsToHtmlPrinterAsync(printer, printCommands);
