EnvironmentSettings.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.ComponentModel;
  5. using System.Drawing;
  6. using FastReport.Utils;
  7. using FastReport.Design;
  8. using FastReport.Export.Email;
  9. namespace FastReport
  10. {
  11. /// <summary>
  12. /// This class contains some global settings that used in the FastReport.Net.
  13. /// </summary>
  14. /// <remarks>
  15. /// This component is intended for use in the Visual Studio IDE to quickly configure
  16. /// FastReport global settings. To use it, drop the component on your Form and set up
  17. /// its properties and events.
  18. /// <para/>Here are some common actions that can be performed with this object:
  19. /// <list type="bullet">
  20. /// <item>
  21. /// <description>To define own open/save dialogs that will be used in the report designer,
  22. /// use the <see cref="CustomOpenDialog"/>, <see cref="CustomSaveDialog"/>,
  23. /// <see cref="CustomOpenReport"/>, <see cref="CustomSaveReport"/> events;
  24. /// </description>
  25. /// </item>
  26. /// <item>
  27. /// <description>To pass connection string to the connection object defined in a report,
  28. /// or to define own database login dialog, use the <see cref="DatabaseLogin"/> event;
  29. /// </description>
  30. /// </item>
  31. /// <item>
  32. /// <description>To adjust the connection object after it is opened,
  33. /// use the <see cref="AfterDatabaseLogin"/> event;
  34. /// </description>
  35. /// </item>
  36. /// <item>
  37. /// <description>To define own progress window, use the <see cref="StartProgress"/>,
  38. /// <see cref="FinishProgress"/> and <see cref="Progress"/> events;
  39. /// </description>
  40. /// </item>
  41. /// <item>
  42. /// <description>To setup some common properties of the report, designer and preview,
  43. /// use properties defined in this class;
  44. /// </description>
  45. /// </item>
  46. /// <item>
  47. /// <description>To set UI style of the designer and preview window,
  48. /// use <see cref="UIStyle"/> property.
  49. /// </description>
  50. /// </item>
  51. /// </list>
  52. /// <para/>This component actually uses the <see cref="Config"/> static class which
  53. /// contains <see cref="Config.ReportSettings"/>, <see cref="Config.DesignerSettings"/> and
  54. /// <see cref="Config.PreviewSettings"/> properties. You can use <b>Config</b> class as well.
  55. /// </remarks>
  56. [ToolboxItem(true), ToolboxBitmap(typeof(Report), "Resources.EnvironmentSettings.bmp")]
  57. public class EnvironmentSettings : Component
  58. {
  59. /// <summary>
  60. /// Gets or sets the UI style of the designer and preview windows.
  61. /// </summary>
  62. /// <remarks>
  63. /// This property affects both designer and preview windows.
  64. /// </remarks>
  65. [SRCategory("UI")]
  66. [Description("UI style of the designer and preview window.")]
  67. public UIStyle UIStyle
  68. {
  69. get { return Config.UIStyle; }
  70. set { Config.UIStyle = value; }
  71. }
  72. #if !MONO
  73. /// <summary>
  74. /// Indicates whether the Ribbon-style window should be used.
  75. /// </summary>
  76. [SRCategory("UI")]
  77. [DefaultValue(true)]
  78. [Description("Indicates whether the Ribbon-style window should be used.")]
  79. public bool UseRibbonUI
  80. {
  81. get { return Config.UseRibbon; }
  82. set { Config.UseRibbon = value; }
  83. }
  84. #endif
  85. #region Report
  86. /// <summary>
  87. /// Occurs before displaying a progress window.
  88. /// </summary>
  89. [SRCategory("Report")]
  90. [Description("Occurs before displaying a progress window.")]
  91. public event EventHandler StartProgress
  92. {
  93. add { Config.ReportSettings.StartProgress += value; }
  94. remove { Config.ReportSettings.StartProgress -= value; }
  95. }
  96. /// <summary>
  97. /// Occurs after closing a progress window.
  98. /// </summary>
  99. [SRCategory("Report")]
  100. [Description("Occurs after closing a progress window.")]
  101. public event EventHandler FinishProgress
  102. {
  103. add { Config.ReportSettings.FinishProgress += value; }
  104. remove { Config.ReportSettings.FinishProgress -= value; }
  105. }
  106. /// <summary>
  107. /// Occurs when progress state is changed.
  108. /// </summary>
  109. [SRCategory("Report")]
  110. [Description("Occurs when progress state is changed.")]
  111. public event ProgressEventHandler Progress
  112. {
  113. add { Config.ReportSettings.Progress += value; }
  114. remove { Config.ReportSettings.Progress -= value; }
  115. }
  116. /// <include file='Resources/doc.xml' path='//CodeDoc/Topics/EnvironmentSettings/DatabaseLogin/*'/>
  117. [SRCategory("Report")]
  118. [Description("Occurs when database connection is about to open.")]
  119. public event DatabaseLoginEventHandler DatabaseLogin
  120. {
  121. add { Config.ReportSettings.DatabaseLogin += value; }
  122. remove { Config.ReportSettings.DatabaseLogin -= value; }
  123. }
  124. /// <summary>
  125. /// Occurs after the database connection is established.
  126. /// </summary>
  127. [SRCategory("Report")]
  128. [Description("Occurs after the database connection is established.")]
  129. public event AfterDatabaseLoginEventHandler AfterDatabaseLogin
  130. {
  131. add { Config.ReportSettings.AfterDatabaseLogin += value; }
  132. remove { Config.ReportSettings.AfterDatabaseLogin -= value; }
  133. }
  134. /// <summary>
  135. /// Occurs when discovering the business object's structure.
  136. /// </summary>
  137. [SRCategory("Report")]
  138. [Description("Occurs when discovering the business object's structure.")]
  139. public event FilterPropertiesEventHandler FilterBusinessObjectProperties
  140. {
  141. add { Config.ReportSettings.FilterBusinessObjectProperties += value; }
  142. remove { Config.ReportSettings.FilterBusinessObjectProperties -= value; }
  143. }
  144. /// <summary>
  145. /// Occurs when determining the kind of business object's property.
  146. /// </summary>
  147. [SRCategory("Report")]
  148. [Description("Occurs when determining the kind of business object's property.")]
  149. public event GetPropertyKindEventHandler GetBusinessObjectPropertyKind
  150. {
  151. add { Config.ReportSettings.GetBusinessObjectPropertyKind += value; }
  152. remove { Config.ReportSettings.GetBusinessObjectPropertyKind -= value; }
  153. }
  154. /// <summary>
  155. /// Gets or sets the report settings.
  156. /// </summary>
  157. [Description("The report settings.")]
  158. public ReportSettings ReportSettings
  159. {
  160. get { return Config.ReportSettings; }
  161. set { Config.ReportSettings = value; }
  162. }
  163. #endregion
  164. #region Designer
  165. /// <summary>
  166. /// Occurs when the designer is loaded.
  167. /// </summary>
  168. /// <remarks>
  169. /// Use this event if you want to customize some aspects of the designer, for example,
  170. /// to hide some menu items.
  171. /// </remarks>
  172. /// <example>
  173. /// This example demonstrates how to hide the "File|Select Language..." menu item.
  174. /// <code>
  175. /// environmentSettings1.DesignerLoaded += new EventHandler(DesignerSettings_DesignerLoaded);
  176. ///
  177. /// void DesignerSettings_DesignerLoaded(object sender, EventArgs e)
  178. /// {
  179. /// (sender as DesignerControl).MainMenu.miFileSelectLanguage.Visible = false;
  180. /// }
  181. /// </code>
  182. /// </example>
  183. [Description("Occurs when the designer is loaded.")]
  184. public event EventHandler DesignerLoaded
  185. {
  186. add { Config.DesignerSettings.DesignerLoaded += value; }
  187. remove { Config.DesignerSettings.DesignerLoaded -= value; }
  188. }
  189. /// <summary>
  190. /// Occurs when report is loaded in the designer.
  191. /// </summary>
  192. /// <remarks>
  193. /// Use this event handler to register application data in a report.
  194. /// </remarks>
  195. [SRCategory("Designer")]
  196. [Description("Occurs when report is loaded in the designer.")]
  197. public event ReportLoadedEventHandler ReportLoaded
  198. {
  199. add { Config.DesignerSettings.ReportLoaded += value; }
  200. remove { Config.DesignerSettings.ReportLoaded -= value; }
  201. }
  202. /// <summary>
  203. /// Occurs when object is inserted in the designer.
  204. /// </summary>
  205. /// <remarks>
  206. /// Use this event handler to set some object's properties when it is inserted.
  207. /// </remarks>
  208. [SRCategory("Designer")]
  209. [Description("Occurs when object is inserted in the designer.")]
  210. public event ObjectInsertedEventHandler ObjectInserted
  211. {
  212. add { Config.DesignerSettings.ObjectInserted += value; }
  213. remove { Config.DesignerSettings.ObjectInserted -= value; }
  214. }
  215. /// <include file='Resources/doc.xml' path='//CodeDoc/Topics/EnvironmentSettings/CustomOpenDialog/*'/>
  216. /// <include file='Resources/doc.xml' path='//CodeDoc/Examples/EnvironmentSettings/*'/>
  217. [SRCategory("Designer")]
  218. [Description("Occurs when the report designer is about to show the 'Open' dialog.")]
  219. public event OpenSaveDialogEventHandler CustomOpenDialog
  220. {
  221. add { Config.DesignerSettings.CustomOpenDialog += value; }
  222. remove { Config.DesignerSettings.CustomOpenDialog -= value; }
  223. }
  224. /// <include file='Resources/doc.xml' path='//CodeDoc/Topics/EnvironmentSettings/CustomSaveDialog/*'/>
  225. /// <include file='Resources/doc.xml' path='//CodeDoc/Examples/EnvironmentSettings/*'/>
  226. [SRCategory("Designer")]
  227. [Description("Occurs when the report designer is about to show the 'Save' dialog.")]
  228. public event OpenSaveDialogEventHandler CustomSaveDialog
  229. {
  230. add { Config.DesignerSettings.CustomSaveDialog += value; }
  231. remove { Config.DesignerSettings.CustomSaveDialog -= value; }
  232. }
  233. /// <include file='Resources/doc.xml' path='//CodeDoc/Topics/EnvironmentSettings/CustomOpenReport/*'/>
  234. /// <include file='Resources/doc.xml' path='//CodeDoc/Examples/EnvironmentSettings/*'/>
  235. [SRCategory("Designer")]
  236. [Description("Occurs when the report designer is about to load the report.")]
  237. public event OpenSaveReportEventHandler CustomOpenReport
  238. {
  239. add { Config.DesignerSettings.CustomOpenReport += value; }
  240. remove { Config.DesignerSettings.CustomOpenReport -= value; }
  241. }
  242. /// <include file='Resources/doc.xml' path='//CodeDoc/Topics/EnvironmentSettings/CustomSaveReport/*'/>
  243. /// <include file='Resources/doc.xml' path='//CodeDoc/Examples/EnvironmentSettings/*'/>
  244. [SRCategory("Designer")]
  245. [Description("Occurs when the report designer is about to save the report.")]
  246. public event OpenSaveReportEventHandler CustomSaveReport
  247. {
  248. add { Config.DesignerSettings.CustomSaveReport += value; }
  249. remove { Config.DesignerSettings.CustomSaveReport -= value; }
  250. }
  251. /// <summary>
  252. /// Occurs when previewing a report from the designer.
  253. /// </summary>
  254. /// <remarks>
  255. /// Use this event to show own preview window.
  256. /// </remarks>
  257. /// <example>
  258. /// <code>
  259. /// environmentSettings1.CustomPreviewReport += new EventHandler(MyPreviewHandler);
  260. ///
  261. /// private void MyPreviewHandler(object sender, EventArgs e)
  262. /// {
  263. /// Report report = sender as Report;
  264. /// using (MyPreviewForm form = new MyPreviewForm())
  265. /// {
  266. /// report.Preview = form.previewControl1;
  267. /// report.ShowPreparedReport();
  268. /// form.ShowDialog();
  269. /// }
  270. /// }
  271. /// </code>
  272. /// </example>
  273. [SRCategory("Designer")]
  274. [Description("Occurs when previewing a report from the designer.")]
  275. public event EventHandler CustomPreviewReport
  276. {
  277. add { Config.DesignerSettings.CustomPreviewReport += value; }
  278. remove { Config.DesignerSettings.CustomPreviewReport -= value; }
  279. }
  280. /// <summary>
  281. /// Occurs when getting available table names from the connection.
  282. /// </summary>
  283. /// <remarks>
  284. /// Use this handler to filter the list of tables returned by the connection object.
  285. /// </remarks>
  286. /// <example>
  287. /// This example demonstrates how to hide the table with "Table 1" name from the Data Wizard.
  288. /// <code>
  289. /// environmentSettings1.FilterConnectionTables += DesignerSettings_FilterConnectionTables;
  290. ///
  291. /// private void DesignerSettings_FilterConnectionTables(object sender, FilterConnectionTablesEventArgs e)
  292. /// {
  293. /// if (e.TableName == "Table 1")
  294. /// e.Skip = true;
  295. /// }
  296. /// </code>
  297. /// </example>
  298. [SRCategory("Designer")]
  299. [Description("Occurs when getting available table names from the connection.")]
  300. public event FilterConnectionTablesEventHandler FilterConnectionTables
  301. {
  302. add { Config.DesignerSettings.FilterConnectionTables += value; }
  303. remove { Config.DesignerSettings.FilterConnectionTables -= value; }
  304. }
  305. /// <summary>
  306. /// Gets or sets the designer settings.
  307. /// </summary>
  308. [Description("The designer settings.")]
  309. public DesignerSettings DesignerSettings
  310. {
  311. get { return Config.DesignerSettings; }
  312. set { Config.DesignerSettings = value; }
  313. }
  314. #endregion
  315. #region Preview
  316. /// <summary>
  317. /// Gets or sets the preview settings.
  318. /// </summary>
  319. [Description("The preview settings.")]
  320. public PreviewSettings PreviewSettings
  321. {
  322. get { return Config.PreviewSettings; }
  323. set { Config.PreviewSettings = value; }
  324. }
  325. #endregion
  326. #region Email
  327. /// <summary>
  328. /// Gets or sets the email settings.
  329. /// </summary>
  330. [Description("The email settings.")]
  331. public FastReport.Export.Email.EmailSettings EmailSettings
  332. {
  333. get { return Config.EmailSettings; }
  334. set { Config.EmailSettings = value; }
  335. }
  336. #endregion
  337. }
  338. }