LinePrinterForm.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using ScintillaNET;
  2. using System;
  3. using System.Windows.Forms;
  4. namespace LinePrinterPoC
  5. {
  6. public partial class LinePrinterForm : Form
  7. {
  8. private Scintilla _textBox;
  9. private LinePrinter _printer;
  10. public LinePrinterForm()
  11. {
  12. InitializeComponent();
  13. }
  14. private void LinePrinterForm_Shown(object sender, EventArgs e)
  15. {
  16. _printer = new LinePrinter();
  17. _textBox = new Scintilla { Dock = DockStyle.Fill };
  18. Controls.Add(_textBox);
  19. _textBox.BringToFront();
  20. }
  21. private void ChooseButton_Click(object sender, EventArgs e)
  22. {
  23. if (_printer.ChoosePrinter(this)) PrinterLabel.Text = _printer.PrinterName;
  24. }
  25. private void PrintButton_Click(object sender, EventArgs e)
  26. {
  27. if (false == _printer.Open("print doc"))
  28. {
  29. MessageBox.Show("Open printer fail");
  30. return;
  31. }
  32. MessageBox.Show(
  33. _printer.Print(_textBox.Text)
  34. ? "OK"
  35. : "Fail"
  36. );
  37. _printer.Close();
  38. }
  39. }
  40. }