private static void TesteImagem() { var printStatus = new StandardSection() { Justification = FontAlignment.Left, HeightScalar = FontHeighScalarEnum.h1, WidthScalar = FontWidthScalarEnum.w1, Font = ThermalFontsEnum.B, AutoNewline = true, }; var document = new StandardDocument() { //Não esquecer de setar essa prop CodePage = CodePagesEnum.CPSPACE, }; document.Sections.Add(new Placeholder()); using (var printer = new GenericPrinter(PortaCom)) { var image = new Imaging.PrinterImage((Bitmap)Image.FromFile(@"XING_B24.BMP")); image.ApplyDithering(Imaging.AlgorithmsEnum.JarvisJudiceNinke, 128); for (int i = 3; i >= 1; i--) { printer.SetImage(image, document, 0, (FontAlignment)i); printer.PrintDocument(document); } printer.FormFeed(5); printer.Cut(CutModeEnum.Parcial); } }
public void AddHotkey(Chord chord, Action <Combo> action, StandardSection section) { if (!_dictionary.TryGetValue(chord, out var set)) { set = new SortedSet <Hotkey>(Hotkey.SectionComparer); _dictionary[chord] = set; } if (set.Any(z => z.Section.CompareTo(section) == 0)) { throw new AmbiguousHotkeyException("Ambiguous hotkey found" + Helper.GetBindingsSuffix(chord, nameof(chord))); } var added = set.Add(new Hotkey(action, section)); Helper.RequireTrue(added); if (chord.Length > Math.Max(Env.Config.MaxChordLength, MaxChordLength)) { Env.Notifier.Error($"Chord with length '{chord.Length}' found, while maximum allowed length is '{Env.Config.MaxChordLength}'. " + $"To change the maximum allowed length, update the config variable '{nameof(Env.Config.MaxChordLength)}'."); } MaxChordLength = Math.Max(MaxChordLength, chord.Length); }
public DynamicHotkey(Action <IInjectorStream <object> > action, StandardSection section) { Action = action; _section = section; }
public DefineSection(StandardSection section) { switch (section) { case StandardSection.Text: name = ".text"; addr_align = 4; isalloc = true; iswrite = false; isexec = true; hasdata = true; break; case StandardSection.Data: name = ".data"; addr_align = 0; isalloc = true; iswrite = true; isexec = false; hasdata = true; break; case StandardSection.Rodata: name = ".rodata"; addr_align = 0; isalloc = true; iswrite = false; isexec = false; hasdata = true; break; case StandardSection.Bss: name = ".bss"; addr_align = 0; isalloc = true; iswrite = true; isexec = false; hasdata = false; break; case StandardSection.ElfDynamic: name = ".dynamic"; addr_align = 0; isalloc = true; iswrite = false; isexec = false; hasdata = true; size = -1; // max size for Elf64 dynamic section break; case StandardSection.ElfHash: name = ".hash"; addr_align = 0; isalloc = true; iswrite = false; isexec = false; hasdata = true; size = -2; // calculated later break; } }
static void Main(string[] args) { const string phoenixPort = "COM1"; const string reliancePort = "COM12"; const int captureRate = 10; // number of seconds between capture Console.WriteLine("Starting Security Camera Sample"); // Setup the header with double width, double height, center justified var header = new StandardSection() { Justification = FontJustification.JustifyCenter, HeightScalar = FontHeighScalar.h2, WidthScalar = FontWidthScalar.w2, Font = ThermalFonts.A, AutoNewline = true, }; // Setup timestamp at normal scalar with bold, underline, and centered var timestamp = new StandardSection() { Justification = FontJustification.JustifyCenter, HeightScalar = FontHeighScalar.h1, WidthScalar = FontWidthScalar.w1, Effects = FontEffects.Italic | FontEffects.Underline, Font = ThermalFonts.B, AutoNewline = true, }; // Print Status is shown as a JSON object var printStatus = new StandardSection() { Justification = FontJustification.JustifyLeft, HeightScalar = FontHeighScalar.h1, WidthScalar = FontWidthScalar.w1, Font = ThermalFonts.C, AutoNewline = true, }; // Document template // Capture #{} // Image.... // Image.... // Image... // Timestamp var document = new StandardDocument() { // Don't forget to set your codepage! CodePage = CodePages.CPSPACE, }; document.Sections.Add(header); document.Sections.Add(new Placeholder()); // Placeholder since we know we'll want an image here document.Sections.Add(timestamp); document.Sections.Add(printStatus); int count = 1; while (true) { // Select one printer or the other. Phoenix does not currently // support dynamic images over ESC/POS. Images will only // be transmitted through the print queue but no examples have // been prepared for this. //using (var printer = new PhoenixPrinter(phoenixPort)) using (var printer = new ReliancePrinter(reliancePort)) using (var image = Webcam.GrabPicture()) { var now = DateTime.Now; Console.WriteLine("Image #{0} taken at {1}", count, now); // Resize image if we want. This will follow ESC/POS justification //logo.Resize(640, 480); image.ApplyDithering(Algorithms.JarvisJudiceNinke, 128); // Print the header document, update with new capture number header.Content = string.Format("Capture #{0} (ЫВФАЫВМОЫВАП)", count); // Printer the timestamp document timestamp.Content = string.Format("{0}: {1}", count++, now); // Get the latest printer status. Note that reliance and phoenix have // slightly different args to this get status command printStatus.Content = printer.GetStatus(StatusTypes.FullStatus).ToJSON(true); // Re-assign this image to the middle part of the document printer.SetImage(image, document, 1); // Send the whole document + image printer.PrintDocument(document); printer.FormFeed(); // Wait for next capture period Thread.Sleep(captureRate * 1000); } } }
public Hotkey(Action <Combo> action, StandardSection section) { Action = action; Section = section; }
private static void TesteCompleto() { var separador = new StandardSection() { Justification = FontAlignment.Center, HeightScalar = FontHeighScalarEnum.h1, WidthScalar = FontWidthScalarEnum.w1, Font = ThermalFontsEnum.A, AutoNewline = true, }; var separadorUmaLinha = new StandardSection() { Justification = FontAlignment.Center, HeightScalar = FontHeighScalarEnum.h1, WidthScalar = FontWidthScalarEnum.w1, Font = ThermalFontsEnum.A, AutoNewline = true, }; var textoHeader = new StandardSection() { Justification = FontAlignment.Center, HeightScalar = FontHeighScalarEnum.h1, WidthScalar = FontWidthScalarEnum.w2, Font = ThermalFontsEnum.A, AutoNewline = true, }; var textoCabecalho = new StandardSection() { Justification = FontAlignment.Center, HeightScalar = FontHeighScalarEnum.h1, WidthScalar = FontWidthScalarEnum.w1, Font = ThermalFontsEnum.A, AutoNewline = true, }; var textoItens = new StandardSection() { Justification = FontAlignment.Left, HeightScalar = FontHeighScalarEnum.h1, WidthScalar = FontWidthScalarEnum.w2, Font = ThermalFontsEnum.A, AutoNewline = true, }; var document = new StandardDocument() { //Não esquecer de setar essa prop CodePage = CodePagesEnum.CPSPACE, }; document.Sections.Add(new Placeholder()); document.Sections.Add(separador); document.Sections.Add(textoHeader); document.Sections.Add(separadorUmaLinha); document.Sections.Add(textoCabecalho); document.Sections.Add(separador); document.Sections.Add(textoItens); document.Sections.Add(separador); using (var printer = new GenericPrinter(PortaCom)) { printer.Reinitialize(); //reader var reader = new StringBuilder(); reader.Append("COZINHA" + Environment.NewLine); reader.Append("MESA: 35"); //Cabeçalho var cabecalho = new StringBuilder(); cabecalho.Append($"Data/Hora: {DateTime.Now}" + Environment.NewLine); cabecalho.Append("Atendente: Caixaa" + Environment.NewLine); cabecalho.Append("Pdv: 099-COMANDA TESTE"); //Itens var itens = new StringBuilder(); itens.Append("QTDE ITEM" + Environment.NewLine); itens.Append("1/2 ALMONDEGA CREAMS" + Environment.NewLine); itens.Append(" * DIGITADA" + Environment.NewLine); itens.Append(" * TESTE SQL"); separador.Content = "".PadRight(40, '='); textoHeader.Content = reader.ToString(); separadorUmaLinha.Content = "".PadRight(40, '-'); textoCabecalho.Content = cabecalho.ToString(); textoItens.Content = itens.ToString(); printer.PrintDocument(document); printer.FormFeed(5); printer.Cut(CutModeEnum.Parcial); } }
public DefineSection(StandardSection section) { switch (section) { case StandardSection.Text: name = ".text"; addr_align = 4; isalloc = true; iswrite = false; isexec = true; hasdata = true; break; case StandardSection.Data: name = ".data"; addr_align = 0; isalloc = true; iswrite = true; isexec = false; hasdata = true; break; case StandardSection.Rodata: name = ".rodata"; addr_align = 0; isalloc = true; iswrite = false; isexec = false; hasdata = true; break; case StandardSection.Bss: name = ".bss"; addr_align = 0; isalloc = true; iswrite = true; isexec = false; hasdata = false; break; } }