ProgressForm.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using FastReport.Utils;
  5. namespace FastReport.Forms
  6. {
  7. /// <summary>
  8. ///
  9. /// </summary>
  10. public partial class ProgressForm : BaseForm
  11. {
  12. private Report report;
  13. private bool aborted;
  14. private long ticks = 0;
  15. /// <summary>
  16. /// Gets Aborted state
  17. /// </summary>
  18. public bool Aborted
  19. {
  20. get { return aborted; }
  21. }
  22. private void btnCancel_Click(object sender, EventArgs e)
  23. {
  24. if (report != null)
  25. report.Abort();
  26. aborted = true;
  27. }
  28. private void ProgressForm_Paint(object sender, PaintEventArgs e)
  29. {
  30. using (Pen p = new Pen(Color.Gray, 2))
  31. {
  32. p.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
  33. e.Graphics.DrawRectangle(p, DisplayRectangle);
  34. }
  35. }
  36. private void ProgressForm_Shown(object sender, EventArgs e)
  37. {
  38. lblProgress.Width = Width - lblProgress.Left * 2;
  39. }
  40. /// <summary>
  41. ///
  42. /// </summary>
  43. public void ShowProgressMessage(string message)
  44. {
  45. lblProgress.Text = message;
  46. lblProgress.Refresh();
  47. if (ticks++ % 500 == 0)
  48. Config.DoEvent();
  49. }
  50. /// <summary>
  51. /// Initialazes a new instance of the <see cref="ProgressForm"/> class.
  52. /// </summary>
  53. /// <param name="report">A reference to the report.</param>
  54. public ProgressForm(Report report)
  55. {
  56. aborted = false;
  57. this.report = report;
  58. InitializeComponent();
  59. btnCancel.Text = Res.Get("Buttons,Cancel");
  60. UIUtils.CheckRTL(this);
  61. UpdateDpiDependencies();
  62. }
  63. /// <summary>
  64. /// Initialazes a new instance of the <see cref="ProgressForm"/> class.
  65. /// </summary>
  66. /// <param name="report">A reference to the report.</param>
  67. /// <param name="withCancelButton">Specifies whether the form should be with Cancel button.</param>
  68. public ProgressForm(Report report, bool withCancelButton)
  69. {
  70. this.report = report;
  71. InitializeComponent();
  72. btnCancel.Text = Res.Get("Buttons,Cancel");
  73. btnCancel.Enabled = withCancelButton;
  74. btnCancel.Visible = withCancelButton;
  75. lblProgress.Location = new Point(12, 50);
  76. UIUtils.CheckRTL(this);
  77. UpdateDpiDependencies();
  78. }
  79. }
  80. }