using System; using System.Drawing; using System.ComponentModel; using FastReport.Utils; using FastReport.Preview; using System.Drawing.Design; namespace FastReport { /// /// Specifies the set of buttons available in the preview. /// [Flags] [EditorAttribute("FastReport.TypeEditors.FlagsEditor, FastReport", typeof(UITypeEditor))] public enum PreviewButtons { /// /// No buttons visible. /// None = 0, /// /// The "Print" button is visible. /// Print = 1, /// /// The "Open" button is visible. /// Open = 2, /// /// The "Save" button is visible. /// Save = 4, /// /// The "Email" button is visible. /// Email = 8, /// /// The "Find" button is visible. /// Find = 16, /// /// The zoom buttons are visible. /// Zoom = 32, /// /// The "Outline" button is visible. /// Outline = 64, /// /// The "Page setup" button is visible. /// PageSetup = 128, /// /// The "Edit" button is visible. /// Edit = 256, /// /// The "Watermark" button is visible. /// Watermark = 512, /// /// The page navigator buttons are visible. /// Navigator = 1024, /// /// The "Close" button is visible. /// Close = 2048, /// /// The "Design" button is visible. /// Design = 4096, /// /// The "Copy Page" button is visible. /// CopyPage = 8192, /// /// The "Delete Page" button is visible. /// DeletePage = 16384, /// /// The "About" button is visible. /// About = 32768, /// /// All buttons are visible. /// // if you add something to this enum, don't forget to correct "All" member All = Print | Open | Save | Email | Find | Zoom | Outline | PageSetup | Edit | Watermark | Navigator | Close | CopyPage | DeletePage | About } /// /// Specifies the set of export buttons available in the preview. /// [Flags] [EditorAttribute("FastReport.TypeEditors.FlagsEditor, FastReport", typeof(UITypeEditor))] public enum PreviewExports { /// /// No exports visible. /// None = 0, /// /// The "Prepared" button is visible. /// Prepared = 1, /// /// The "PDFExport" button is visible. /// PDFExport = 2, /// /// The "RTFExport" button is visible. /// RTFExport = 4, /// /// The "HTMLExport" button is visible. /// HTMLExport = 8, /// /// The "MHTExport" button is visible. /// MHTExport = 16, /// /// The "XMLExport" export button is visible. /// XMLExport = 32, /// /// The "Excel2007Export" button is visible. /// Excel2007Export = 64, /// /// The "Excel2003Document" button is visible. /// Excel2003Document = 128, /// /// The "Word2007Export" button is visible. /// Word2007Export = 256, /// /// The "PowerPoint2007Export" button is visible. /// PowerPoint2007Export = 512, /// /// The "ODSExport" button is visible. /// ODSExport = 1024, /// /// The "ODTExport" button is visible. /// ODTExport = 2048, /// /// The "XPSExport" export button is visible. /// XPSExport = 4096, /// /// The "CSVExport" button is visible. /// CSVExport = 8192, /// /// The "DBFExport" button is visible. /// DBFExport = 16384, /// /// The "TextExport" button is visible. /// TextExport = 32768, /// /// The "ZplExport" button is visible. /// ZplExport = 65536, /// /// The "ImageExport" button is visible. /// ImageExport = 131072, /// /// The "XAMLExport" button is visible. /// XAMLExport = 262144, /// /// The "SVGExport" button is visible. /// SVGExport = 524288, /// /// The "PPMLExport" button is visible. /// PPMLExport = 1048576, /// /// The "PSExport" button is visible. /// PSExport = 2097152, /// /// The "JsonExport" button is visible. /// JsonExport = 4194304, /// /// The "LaTeXExport" button is visible. /// LaTeXExport = 8388608, /// /// The "HpglExport" button is visible. /// HpglExport = 16777216, /// /// The "DxfExport" button is visible. /// DxfExport = 33554432, /// /// The All export buttons is visible. /// All = Prepared | PDFExport | RTFExport | HTMLExport | MHTExport | XMLExport | Excel2007Export | Excel2003Document | Word2007Export | PowerPoint2007Export | ODSExport | ODTExport | XPSExport | CSVExport | DBFExport | TextExport | ZplExport | ImageExport | XAMLExport | SVGExport | PPMLExport | PSExport | JsonExport | LaTeXExport | DxfExport } /// /// Specifies the set of cloud exports available in the preview. /// [Flags] [EditorAttribute("FastReport.TypeEditors.FlagsEditor, FastReport", typeof(UITypeEditor))] public enum PreviewClouds { /// /// No items visible. /// None = 0, /// /// The "Box" button is visible. /// Box = 1, /// /// The "Dropbox" button is visible. /// Dropbox = 2, /// /// The "Ftp" button is visible. /// Ftp = 4, /// /// The "GoogleDrive" button is visible. /// GoogleDrive = 8, /// /// The "SkyDrive" button is visible. /// SkyDrive = 16, /// /// The "S3" button is visible. /// S3 = 32, /// /// The All export in clouds buttons is visible. /// All = Box | Dropbox | Ftp | GoogleDrive | SkyDrive | S3 } /// /// Specifies the set of export by messenger buttons available in the preview. /// [Flags] [EditorAttribute("FastReport.TypeEditors.FlagsEditor, FastReport", typeof(UITypeEditor))] public enum PreviewMessengers { /// /// No exports by messengers visible. /// None = 0, /// /// The "Xmpp" button is visible. /// Xmpp = 1, /// /// The All export by messengers buttons is visible. /// All = Xmpp } /// /// Contains some settings of the preview window. /// [TypeConverter(typeof(FastReport.TypeConverters.FRExpandableObjectConverter))] public class PreviewSettings { #region Fields private PreviewButtons buttons; private int pagesInCache; private bool showInTaskbar; private bool topMost; private Icon icon; private string text; private bool fastScrolling; private bool allowPrintToFile; private string saveInitialDirectory; #endregion #region Properties /// /// Occurs when the standard preview window opened. /// /// /// You may use this event to change the standard preview window, for example, add an own button to it. /// The sender parameter in this event is the PreviewControl. /// public event EventHandler PreviewOpened; /// /// Gets or sets a set of buttons that will be visible in the preview's toolbar. /// /// /// Here is an example how you can disable the "Print" and "EMail" buttons: /// /// Config.PreviewSettings.Buttons = PreviewButtons.Open | /// PreviewButtons.Save | /// PreviewButtons.Find | /// PreviewButtons.Zoom | /// PreviewButtons.Outline | /// PreviewButtons.PageSetup | /// PreviewButtons.Edit | /// PreviewButtons.Watermark | /// PreviewButtons.Navigator | /// PreviewButtons.Close; /// /// [DefaultValue(PreviewButtons.All)] public PreviewButtons Buttons { get { return buttons; } set { buttons = value; } } #if !COMMUNITY /// /// Specifies the set of exports that will be available in the preview's "save" menu. /// [DefaultValue(PreviewExports.All)] public PreviewExports Exports { get => ExportsOptions.GetInstance().Exports; set => ExportsOptions.GetInstance().Exports = value; } /// /// Specifies the set of exports in clouds that will be available in the preview's "save" menu. /// [DefaultValue(PreviewClouds.All)] public PreviewClouds Clouds { get => ExportsOptions.GetInstance().Clouds; set => ExportsOptions.GetInstance().Clouds = value; } /// /// Specifies the set of exports by messengers that will be available in the preview's "save" menu. /// //[DefaultValue(PreviewMessengers.All)] [DefaultValue(PreviewMessengers.None)] [Browsable(false)] public PreviewMessengers Messengers { get => ExportsOptions.GetInstance().Messengers; set => ExportsOptions.GetInstance().Messengers = value; } #endif /// /// Gets or sets the number of prepared pages that can be stored in the memory cache during preview. /// /// /// Decrease this value if your prepared report contains a lot of pictures. This will /// save the RAM memory. /// [DefaultValue(50)] public int PagesInCache { get { return pagesInCache; } set { pagesInCache = value; } } /// /// Gets or sets a value indicating whether the preview window is displayed in the Windows taskbar. /// [DefaultValue(false)] public bool ShowInTaskbar { get { return showInTaskbar; } set { showInTaskbar = value; } } /// /// Gets or sets a value indicating whether the preview window should be displayed as a topmost form. /// [DefaultValue(false)] public bool TopMost { get { return topMost; } set { topMost = value; } } /// /// Gets or sets the icon for the preview window. /// public Icon Icon { get { if (icon == null) icon = ResourceLoader.GetIcon("icon16.ico"); return icon; } set { icon = value; } } /// /// Gets or sets the text for the preview window. /// /// /// If no text is set, the default text "Preview" will be used. /// public string Text { get { return text; } set { text = value; } } /// /// Gets or sets a value indicating whether the fast scrolling method should be used. /// /// /// If you enable this property, the gradient background will be disabled. /// [DefaultValue(false)] public bool FastScrolling { get { return fastScrolling; } set { fastScrolling = value; } } /// /// Enables or disables the "Print to file" feature in the print dialog. /// [DefaultValue(true)] public bool AllowPrintToFile { get { return allowPrintToFile; } set { allowPrintToFile = value; } } /// /// Gets or sets the initial directory that is displayed by a save file dialog. /// public string SaveInitialDirectory { get { return saveInitialDirectory; } set { saveInitialDirectory = value; } } #endregion internal void OnPreviewOpened(PreviewControl sender) { if (PreviewOpened != null) PreviewOpened(sender, EventArgs.Empty); } /// /// Initializes a new instance of the PreviewSettings class with default settings. /// public PreviewSettings() { buttons = PreviewButtons.All; pagesInCache = 50; text = ""; allowPrintToFile = true; } } }