锐腾搅拌上料功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.2 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. namespace ICSSoft.Frame.APP
  11. {
  12. public partial class PDFviewerControl : UserControl
  13. {
  14. public PDFviewerControl()
  15. {
  16. InitializeComponent();
  17. }
  18. private void btnRotateLeft_Click(object sender, EventArgs e)
  19. {
  20. pdfViewer1.Renderer.RotateLeft();
  21. }
  22. private void btnRotateRight_Click(object sender, EventArgs e)
  23. {
  24. pdfViewer1.Renderer.RotateRight();
  25. }
  26. /// <summary>
  27. /// 加载pdf文件
  28. /// </summary>
  29. /// <param name="fullfilename">文件绝对路径</param>
  30. public void LoadFile(string fullfilename)
  31. {
  32. if (pdfViewer1.Document != null)
  33. {
  34. pdfViewer1.Document.Dispose();
  35. }
  36. pdfViewer1.Document = OpenDocument(fullfilename);
  37. }
  38. private PdfiumViewer.PdfDocument OpenDocument(string fileName)
  39. {
  40. try
  41. {
  42. MemoryStream ms = new MemoryStream();
  43. using (FileStream fs = new FileStream(fileName, FileMode.Open))
  44. {
  45. fs.CopyTo(ms);
  46. fs.Close();
  47. }
  48. PdfiumViewer.PdfDocument doc = PdfiumViewer.PdfDocument.Load(ms);
  49. return doc;
  50. }
  51. catch (Exception ex)
  52. {
  53. MessageBox.Show(this, ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  54. return null;
  55. }
  56. }
  57. public void Close()
  58. {
  59. if (pdfViewer1.Document != null)
  60. {
  61. pdfViewer1.Document.Dispose();
  62. }
  63. pdfViewer1.Dispose();
  64. this.Dispose();
  65. }
  66. private void btnPre_Click(object sender, EventArgs e)
  67. {
  68. pdfViewer1.Renderer.Page--;
  69. }
  70. private void btnNext_Click(object sender, EventArgs e)
  71. {
  72. pdfViewer1.Renderer.Page++;
  73. }
  74. }
  75. }