ProgressForm.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 panel1_Paint(object sender, PaintEventArgs e)
  29. {
  30. panel1.DrawVisualStyleBorder(e.Graphics, new Rectangle(0, 0, panel1.Width - 1, panel1.Height - 1));
  31. }
  32. private void ProgressForm_Shown(object sender, EventArgs e)
  33. {
  34. lblProgress.Width = Width - lblProgress.Left * 2;
  35. Application.DoEvents();
  36. }
  37. /// <summary>
  38. ///
  39. /// </summary>
  40. public void ShowProgressMessage(string message)
  41. {
  42. lblProgress.Text = message;
  43. lblProgress.Refresh();
  44. if (ticks++ % 10 == 0)
  45. Application.DoEvents();
  46. }
  47. /// <summary>
  48. /// Initialazes a new instance of the <see cref="ProgressForm"/> class.
  49. /// </summary>
  50. /// <param name="report">A reference to the report.</param>
  51. public ProgressForm(Report report)
  52. {
  53. aborted = false;
  54. this.report = report;
  55. InitializeComponent();
  56. btnCancel.Text = Res.Get("Buttons,Cancel");
  57. UIUtils.CheckRTL(this);
  58. UpdateDpiDependencies();
  59. }
  60. /// <summary>
  61. /// Initialazes a new instance of the <see cref="ProgressForm"/> class.
  62. /// </summary>
  63. /// <param name="report">A reference to the report.</param>
  64. /// <param name="withCancelButton">Specifies whether the form should be with Cancel button.</param>
  65. public ProgressForm(Report report, bool withCancelButton)
  66. {
  67. this.report = report;
  68. InitializeComponent();
  69. btnCancel.Text = Res.Get("Buttons,Cancel");
  70. btnCancel.Enabled = withCancelButton;
  71. btnCancel.Visible = withCancelButton;
  72. lblProgress.Location = new Point(12, 50);
  73. UIUtils.CheckRTL(this);
  74. UpdateDpiDependencies();
  75. }
  76. }
  77. }