PreviewSettings.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. using System;
  2. using System.Drawing;
  3. using System.ComponentModel;
  4. using FastReport.Utils;
  5. using FastReport.Preview;
  6. using System.Drawing.Design;
  7. namespace FastReport
  8. {
  9. /// <summary>
  10. /// Specifies the set of buttons available in the preview.
  11. /// </summary>
  12. [Flags]
  13. [EditorAttribute("FastReport.TypeEditors.FlagsEditor, FastReport", typeof(UITypeEditor))]
  14. public enum PreviewButtons
  15. {
  16. /// <summary>
  17. /// No buttons visible.
  18. /// </summary>
  19. None = 0,
  20. /// <summary>
  21. /// The "Print" button is visible.
  22. /// </summary>
  23. Print = 1,
  24. /// <summary>
  25. /// The "Open" button is visible.
  26. /// </summary>
  27. Open = 2,
  28. /// <summary>
  29. /// The "Save" button is visible.
  30. /// </summary>
  31. Save = 4,
  32. /// <summary>
  33. /// The "Email" button is visible.
  34. /// </summary>
  35. Email = 8,
  36. /// <summary>
  37. /// The "Find" button is visible.
  38. /// </summary>
  39. Find = 16,
  40. /// <summary>
  41. /// The zoom buttons are visible.
  42. /// </summary>
  43. Zoom = 32,
  44. /// <summary>
  45. /// The "Outline" button is visible.
  46. /// </summary>
  47. Outline = 64,
  48. /// <summary>
  49. /// The "Page setup" button is visible.
  50. /// </summary>
  51. PageSetup = 128,
  52. /// <summary>
  53. /// The "Edit" button is visible.
  54. /// </summary>
  55. Edit = 256,
  56. /// <summary>
  57. /// The "Watermark" button is visible.
  58. /// </summary>
  59. Watermark = 512,
  60. /// <summary>
  61. /// The page navigator buttons are visible.
  62. /// </summary>
  63. Navigator = 1024,
  64. /// <summary>
  65. /// The "Close" button is visible.
  66. /// </summary>
  67. Close = 2048,
  68. /// <summary>
  69. /// The "Design" button is visible.
  70. /// </summary>
  71. Design = 4096,
  72. /// <summary>
  73. /// The "Copy Page" button is visible.
  74. /// </summary>
  75. CopyPage = 8192,
  76. /// <summary>
  77. /// The "Delete Page" button is visible.
  78. /// </summary>
  79. DeletePage = 16384,
  80. /// <summary>
  81. /// The "About" button is visible.
  82. /// </summary>
  83. About = 32768,
  84. /// <summary>
  85. /// All buttons are visible.
  86. /// </summary>
  87. // if you add something to this enum, don't forget to correct "All" member
  88. All = Print | Open | Save | Email | Find | Zoom | Outline | PageSetup | Edit |
  89. Watermark | Navigator | Close | CopyPage | DeletePage | About
  90. }
  91. /// <summary>
  92. /// Specifies the set of export buttons available in the preview.
  93. /// </summary>
  94. [Flags]
  95. [EditorAttribute("FastReport.TypeEditors.FlagsEditor, FastReport", typeof(UITypeEditor))]
  96. public enum PreviewExports
  97. {
  98. /// <summary>
  99. /// No exports visible.
  100. /// </summary>
  101. None = 0,
  102. /// <summary>
  103. /// The "Prepared" button is visible.
  104. /// </summary>
  105. Prepared = 1,
  106. /// <summary>
  107. /// The "PDFExport" button is visible.
  108. /// </summary>
  109. PDFExport = 2,
  110. /// <summary>
  111. /// The "RTFExport" button is visible.
  112. /// </summary>
  113. RTFExport = 4,
  114. /// <summary>
  115. /// The "HTMLExport" button is visible.
  116. /// </summary>
  117. HTMLExport = 8,
  118. /// <summary>
  119. /// The "MHTExport" button is visible.
  120. /// </summary>
  121. MHTExport = 16,
  122. /// <summary>
  123. /// The "XMLExport" export button is visible.
  124. /// </summary>
  125. XMLExport = 32,
  126. /// <summary>
  127. /// The "Excel2007Export" button is visible.
  128. /// </summary>
  129. Excel2007Export = 64,
  130. /// <summary>
  131. /// The "Excel2003Document" button is visible.
  132. /// </summary>
  133. Excel2003Document = 128,
  134. /// <summary>
  135. /// The "Word2007Export" button is visible.
  136. /// </summary>
  137. Word2007Export = 256,
  138. /// <summary>
  139. /// The "PowerPoint2007Export" button is visible.
  140. /// </summary>
  141. PowerPoint2007Export = 512,
  142. /// <summary>
  143. /// The "ODSExport" button is visible.
  144. /// </summary>
  145. ODSExport = 1024,
  146. /// <summary>
  147. /// The "ODTExport" button is visible.
  148. /// </summary>
  149. ODTExport = 2048,
  150. /// <summary>
  151. /// The "XPSExport" export button is visible.
  152. /// </summary>
  153. XPSExport = 4096,
  154. /// <summary>
  155. /// The "CSVExport" button is visible.
  156. /// </summary>
  157. CSVExport = 8192,
  158. /// <summary>
  159. /// The "DBFExport" button is visible.
  160. /// </summary>
  161. DBFExport = 16384,
  162. /// <summary>
  163. /// The "TextExport" button is visible.
  164. /// </summary>
  165. TextExport = 32768,
  166. /// <summary>
  167. /// The "ZplExport" button is visible.
  168. /// </summary>
  169. ZplExport = 65536,
  170. /// <summary>
  171. /// The "ImageExport" button is visible.
  172. /// </summary>
  173. ImageExport = 131072,
  174. /// <summary>
  175. /// The "XAMLExport" button is visible.
  176. /// </summary>
  177. XAMLExport = 262144,
  178. /// <summary>
  179. /// The "SVGExport" button is visible.
  180. /// </summary>
  181. SVGExport = 524288,
  182. /// <summary>
  183. /// The "PPMLExport" button is visible.
  184. /// </summary>
  185. PPMLExport = 1048576,
  186. /// <summary>
  187. /// The "PSExport" button is visible.
  188. /// </summary>
  189. PSExport = 2097152,
  190. /// <summary>
  191. /// The "JsonExport" button is visible.
  192. /// </summary>
  193. JsonExport = 4194304,
  194. /// <summary>
  195. /// The "LaTeXExport" button is visible.
  196. /// </summary>
  197. LaTeXExport = 8388608,
  198. /// <summary>
  199. /// The "HpglExport" button is visible.
  200. /// </summary>
  201. HpglExport = 16777216,
  202. /// <summary>
  203. /// The "DxfExport" button is visible.
  204. /// </summary>
  205. DxfExport = 33554432,
  206. /// <summary>
  207. /// The All export buttons is visible.
  208. /// </summary>
  209. All = Prepared | PDFExport | RTFExport | HTMLExport | MHTExport | XMLExport | Excel2007Export | Excel2003Document |
  210. Word2007Export | PowerPoint2007Export | ODSExport | ODTExport | XPSExport | CSVExport | DBFExport | TextExport |
  211. ZplExport | ImageExport | XAMLExport | SVGExport | PPMLExport | PSExport | JsonExport | LaTeXExport | DxfExport
  212. }
  213. /// <summary>
  214. /// Specifies the set of export in clouds buttons available in the preview.
  215. /// </summary>
  216. [Flags]
  217. [EditorAttribute("FastReport.TypeEditors.FlagsEditor, FastReport", typeof(UITypeEditor))]
  218. public enum PreviewClouds
  219. {
  220. /// <summary>
  221. /// No exports in clouds visible.
  222. /// </summary>
  223. None = 0,
  224. /// <summary>
  225. /// The "Box" button is visible.
  226. /// </summary>
  227. Box = 1,
  228. /// <summary>
  229. /// The "Dropbox" button is visible.
  230. /// </summary>
  231. Dropbox = 2,
  232. /// <summary>
  233. /// The "Ftp" button is visible.
  234. /// </summary>
  235. Ftp = 4,
  236. /// <summary>
  237. /// The "GoogleDrive" button is visible.
  238. /// </summary>
  239. GoogleDrive = 8,
  240. /// <summary>
  241. /// The "SkyDrive" button is visible.
  242. /// </summary>
  243. SkyDrive = 16,
  244. /// <summary>
  245. /// The All export in clouds buttons is visible.
  246. /// </summary>
  247. All = Box | Dropbox | Ftp | GoogleDrive | SkyDrive
  248. }
  249. /// <summary>
  250. /// Specifies the set of export by messenger buttons available in the preview.
  251. /// </summary>
  252. [Flags]
  253. [EditorAttribute("FastReport.TypeEditors.FlagsEditor, FastReport", typeof(UITypeEditor))]
  254. public enum PreviewMessengers
  255. {
  256. /// <summary>
  257. /// No exports by messengers visible.
  258. /// </summary>
  259. None = 0,
  260. /// <summary>
  261. /// The "Xmpp" button is visible.
  262. /// </summary>
  263. Xmpp = 1,
  264. /// <summary>
  265. /// The All export by messengers buttons is visible.
  266. /// </summary>
  267. All = Xmpp
  268. }
  269. /// <summary>
  270. /// Contains some settings of the preview window.
  271. /// </summary>
  272. [TypeConverter(typeof(FastReport.TypeConverters.FRExpandableObjectConverter))]
  273. public class PreviewSettings
  274. {
  275. #region Fields
  276. private PreviewButtons buttons;
  277. private PreviewExports exports;
  278. private PreviewClouds clouds;
  279. private PreviewMessengers messengers;
  280. private int pagesInCache;
  281. private bool showInTaskbar;
  282. private bool topMost;
  283. private Icon icon;
  284. private string text;
  285. private bool fastScrolling;
  286. private bool allowPrintToFile;
  287. private string saveInitialDirectory;
  288. #endregion
  289. #region Properties
  290. /// <summary>
  291. /// Occurs when the standard preview window opened.
  292. /// </summary>
  293. /// <remarks>
  294. /// You may use this event to change the standard preview window, for example, add an own button to it.
  295. /// The <b>sender</b> parameter in this event is the <b>PreviewControl</b>.
  296. /// </remarks>
  297. public event EventHandler PreviewOpened;
  298. /// <summary>
  299. /// Gets or sets a set of buttons that will be visible in the preview's toolbar.
  300. /// </summary>
  301. /// <example>
  302. /// Here is an example how you can disable the "Print" and "EMail" buttons:
  303. /// <code>
  304. /// Config.PreviewSettings.Buttons = PreviewButtons.Open |
  305. /// PreviewButtons.Save |
  306. /// PreviewButtons.Find |
  307. /// PreviewButtons.Zoom |
  308. /// PreviewButtons.Outline |
  309. /// PreviewButtons.PageSetup |
  310. /// PreviewButtons.Edit |
  311. /// PreviewButtons.Watermark |
  312. /// PreviewButtons.Navigator |
  313. /// PreviewButtons.Close;
  314. /// </code>
  315. /// </example>
  316. [DefaultValue(PreviewButtons.All)]
  317. public PreviewButtons Buttons
  318. {
  319. get { return buttons; }
  320. set { buttons = value; }
  321. }
  322. /// <summary>
  323. /// Specifies the set of exports that will be available in the preview's "save" menu.
  324. /// </summary>
  325. [DefaultValue(PreviewExports.All)]
  326. public PreviewExports Exports
  327. {
  328. get { return exports; }
  329. set { exports = value; }
  330. }
  331. /// <summary>
  332. /// Specifies the set of exports in clouds that will be available in the preview's "save" menu.
  333. /// </summary>
  334. [DefaultValue(PreviewClouds.All)]
  335. public PreviewClouds Clouds
  336. {
  337. get { return clouds; }
  338. set { clouds = value; }
  339. }
  340. /// <summary>
  341. /// Specifies the set of exports by messengers that will be available in the preview's "save" menu.
  342. /// </summary>
  343. //[DefaultValue(PreviewMessengers.All)]
  344. [DefaultValue(PreviewMessengers.None)]
  345. [Browsable(false)]
  346. public PreviewMessengers Messengers
  347. {
  348. get { return messengers; }
  349. set { messengers = value; }
  350. }
  351. /// <summary>
  352. /// Gets or sets the number of prepared pages that can be stored in the memory cache during preview.
  353. /// </summary>
  354. /// <remarks>
  355. /// Decrease this value if your prepared report contains a lot of pictures. This will
  356. /// save the RAM memory.
  357. /// </remarks>
  358. [DefaultValue(50)]
  359. public int PagesInCache
  360. {
  361. get { return pagesInCache; }
  362. set { pagesInCache = value; }
  363. }
  364. /// <summary>
  365. /// Gets or sets a value indicating whether the preview window is displayed in the Windows taskbar.
  366. /// </summary>
  367. [DefaultValue(false)]
  368. public bool ShowInTaskbar
  369. {
  370. get { return showInTaskbar; }
  371. set { showInTaskbar = value; }
  372. }
  373. /// <summary>
  374. /// Gets or sets a value indicating whether the preview window should be displayed as a topmost form.
  375. /// </summary>
  376. [DefaultValue(false)]
  377. public bool TopMost
  378. {
  379. get { return topMost; }
  380. set { topMost = value; }
  381. }
  382. /// <summary>
  383. /// Gets or sets the icon for the preview window.
  384. /// </summary>
  385. public Icon Icon
  386. {
  387. get
  388. {
  389. if (icon == null)
  390. icon = ResourceLoader.GetIcon("icon16.ico");
  391. return icon;
  392. }
  393. set { icon = value; }
  394. }
  395. /// <summary>
  396. /// Gets or sets the text for the preview window.
  397. /// </summary>
  398. /// <remarks>
  399. /// If no text is set, the default text "Preview" will be used.
  400. /// </remarks>
  401. public string Text
  402. {
  403. get { return text; }
  404. set { text = value; }
  405. }
  406. /// <summary>
  407. /// Gets or sets a value indicating whether the fast scrolling method should be used.
  408. /// </summary>
  409. /// <remarks>
  410. /// If you enable this property, the gradient background will be disabled.
  411. /// </remarks>
  412. [DefaultValue(false)]
  413. public bool FastScrolling
  414. {
  415. get { return fastScrolling; }
  416. set { fastScrolling = value; }
  417. }
  418. /// <summary>
  419. /// Enables or disables the "Print to file" feature in the print dialog.
  420. /// </summary>
  421. [DefaultValue(true)]
  422. public bool AllowPrintToFile
  423. {
  424. get { return allowPrintToFile; }
  425. set { allowPrintToFile = value; }
  426. }
  427. /// <summary>
  428. /// Gets or sets the initial directory that is displayed by a save file dialog.
  429. /// </summary>
  430. public string SaveInitialDirectory
  431. {
  432. get { return saveInitialDirectory; }
  433. set { saveInitialDirectory = value; }
  434. }
  435. #endregion
  436. internal void OnPreviewOpened(PreviewControl sender)
  437. {
  438. if (PreviewOpened != null)
  439. PreviewOpened(sender, EventArgs.Empty);
  440. }
  441. /// <summary>
  442. /// Initializes a new instance of the <b>PreviewSettings</b> class with default settings.
  443. /// </summary>
  444. public PreviewSettings()
  445. {
  446. buttons = PreviewButtons.All;
  447. exports = PreviewExports.All;
  448. clouds = PreviewClouds.All;
  449. //messengers = PreviewMessengers.All;
  450. messengers = PreviewMessengers.None;
  451. pagesInCache = 50;
  452. text = "";
  453. allowPrintToFile = true;
  454. }
  455. }
  456. }