ReportSettings.PreviewExt.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using System.ComponentModel;
  3. using FastReport.Forms;
  4. using FastReport.Data;
  5. using FastReport.Utils;
  6. namespace FastReport
  7. {
  8. partial class ReportSettings
  9. {
  10. private ProgressForm progress;
  11. private bool showProgress = true;
  12. private bool showPerformance;
  13. /// <summary>
  14. /// Occurs before displaying a progress window.
  15. /// </summary>
  16. public event EventHandler StartProgress;
  17. /// <summary>
  18. /// Occurs after closing a progress window.
  19. /// </summary>
  20. public event EventHandler FinishProgress;
  21. /// <summary>
  22. /// Occurs after printing a report.
  23. /// </summary>
  24. public event EventHandler ReportPrinted;
  25. /// <summary>
  26. /// Occurs when progress state is changed.
  27. /// </summary>
  28. public event ProgressEventHandler Progress;
  29. /// <summary>
  30. /// Gets or sets a value that determines whether to show the progress window
  31. /// when perform time-consuming operations such as run, print, export.
  32. /// </summary>
  33. [DefaultValue(true)]
  34. public bool ShowProgress
  35. {
  36. get { return showProgress; }
  37. set { showProgress = value; }
  38. }
  39. /// <summary>
  40. /// Gets or sets a value that determines whether to show the information about
  41. /// the report performance (report generation time, memory consumed) in the
  42. /// lower right corner of the preview window.
  43. /// </summary>
  44. [DefaultValue(false)]
  45. public bool ShowPerformance
  46. {
  47. get { return showPerformance; }
  48. set { showPerformance = value; }
  49. }
  50. internal void OnStartProgress(Report report)
  51. {
  52. progress = null;
  53. report.SetAborted(false);
  54. if (ShowProgress)
  55. {
  56. if (StartProgress != null)
  57. StartProgress(report, EventArgs.Empty);
  58. else
  59. {
  60. progress = new ProgressForm(report);
  61. progress.ShowProgressMessage(Res.Get("Messages,PreparingData"));
  62. progress.Show();
  63. progress.Refresh();
  64. }
  65. }
  66. }
  67. internal void OnFinishProgress(Report report)
  68. {
  69. if (ShowProgress)
  70. {
  71. if (FinishProgress != null)
  72. FinishProgress(report, EventArgs.Empty);
  73. else if (progress != null)
  74. {
  75. progress.Close();
  76. progress.Dispose();
  77. progress = null;
  78. }
  79. }
  80. }
  81. internal void OnProgress(Report report, string message)
  82. {
  83. OnProgress(report, message, 0, 0);
  84. }
  85. internal void OnProgress(Report report, string message, int pageNumber, int totalPages)
  86. {
  87. if (ShowProgress)
  88. {
  89. if (Progress != null)
  90. Progress(report, new ProgressEventArgs(message, pageNumber, totalPages));
  91. else if (progress != null)
  92. progress.ShowProgressMessage(message);
  93. }
  94. }
  95. internal void OnReportPrinted(object sender)
  96. {
  97. if (ReportPrinted != null)
  98. ReportPrinted(sender, EventArgs.Empty);
  99. }
  100. internal void OnDatabaseLogin(DataConnectionBase sender, DatabaseLoginEventArgs e)
  101. {
  102. if (Config.DesignerSettings.ApplicationConnection != null &&
  103. sender.GetType() == Config.DesignerSettings.ApplicationConnectionType)
  104. {
  105. e.ConnectionString = Config.DesignerSettings.ApplicationConnection.ConnectionString;
  106. }
  107. if (DatabaseLogin != null)
  108. DatabaseLogin(sender, e);
  109. }
  110. }
  111. }