ImportPlugin.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using FastReport.Forms;
  2. using FastReport.Import;
  3. using System.IO;
  4. namespace FastReport.Design
  5. {
  6. /// <summary>
  7. /// Base class for all import plugins.
  8. /// </summary>
  9. public class ImportPlugin : IDesignerPlugin
  10. {
  11. #region Fields
  12. private string filter;
  13. private Designer designer;
  14. private Report report;
  15. private ImportBase import;
  16. #endregion // Fields
  17. #region Properties
  18. /// <summary>
  19. /// Gets or sets the name of plugin.
  20. /// </summary>
  21. public string Name
  22. {
  23. get { return import.Name; }
  24. }
  25. /// <summary>
  26. /// Gets or sets the filter string used in the "Open File" dialog.
  27. /// </summary>
  28. public string Filter
  29. {
  30. get { return filter; }
  31. protected set { filter = value; }
  32. }
  33. /// <summary>
  34. /// Gets or sets reference to the designer.
  35. /// </summary>
  36. public Designer Designer
  37. {
  38. get { return designer; }
  39. protected set { designer = value; }
  40. }
  41. /// <summary>
  42. /// Gets or sets reference to the report.
  43. /// </summary>
  44. public Report Report
  45. {
  46. get { return report; }
  47. protected set { report = value; }
  48. }
  49. /// <inheritdoc/>
  50. public string PluginName
  51. {
  52. get { return import.Name; }
  53. }
  54. /// <summary>
  55. /// Gets or sets reference to the import.
  56. /// </summary>
  57. protected ImportBase Import
  58. {
  59. get { return import; }
  60. set { import = value; }
  61. }
  62. #endregion // Properties
  63. #region Constructors
  64. /// <summary>
  65. /// Initializes a new instance of the <see cref="ImportPlugin"/> class with default settings.
  66. /// </summary>
  67. public ImportPlugin()
  68. {
  69. filter = GetFilter();
  70. import = new ImportBase();
  71. }
  72. /// <summary>
  73. /// Initializes a new instance of the <see cref="ImportPlugin"/> class with a specified designer.
  74. /// </summary>
  75. /// <param name="designer">The report designer.</param>
  76. public ImportPlugin(Designer designer) : this()
  77. {
  78. this.designer = designer;
  79. }
  80. #endregion // Constructors
  81. #region IDesignerPlugin Members
  82. /// <inheritdoc/>
  83. public void SaveState()
  84. {
  85. }
  86. /// <inheritdoc/>
  87. public void RestoreState()
  88. {
  89. }
  90. /// <inheritdoc/>
  91. public void SelectionChanged()
  92. {
  93. }
  94. /// <inheritdoc/>
  95. public void UpdateContent()
  96. {
  97. }
  98. /// <inheritdoc/>
  99. public void Lock()
  100. {
  101. }
  102. /// <inheritdoc/>
  103. public void Unlock()
  104. {
  105. }
  106. /// <inheritdoc/>
  107. public virtual void Localize()
  108. {
  109. }
  110. /// <inheritdoc/>
  111. public DesignerOptionsPage GetOptionsPage()
  112. {
  113. return null;
  114. }
  115. /// <inheritdoc/>
  116. public virtual void UpdateUIStyle()
  117. {
  118. }
  119. /// <inheritdoc/>
  120. public void UpdateDpiDependencies()
  121. {
  122. }
  123. #endregion // IDesignerPlugin Members
  124. #region Protected Methods
  125. /// <summary>
  126. /// Returns a file filter for a open dialog.
  127. /// </summary>
  128. /// <returns>String that contains a file filter, for example: "Bitmap image (*.bmp)|*.bmp"</returns>
  129. protected virtual string GetFilter()
  130. {
  131. return "";
  132. }
  133. #endregion // Protected Methods
  134. #region Public Methods
  135. /// <summary>
  136. /// Loads the specified file into specified report.
  137. /// </summary>
  138. /// <param name="report">Report object.</param>
  139. /// <param name="filename">File name.</param>
  140. public virtual void LoadReport(Report report, string filename)
  141. {
  142. report.Clear();
  143. }
  144. /// <summary>
  145. /// Loads the specified file into specified report from stream.
  146. /// </summary>
  147. /// <param name="report">Report object.</param>
  148. /// <param name="file">File stream.</param>
  149. public virtual void LoadReport(Report report, Stream file)
  150. {
  151. report.Clear();
  152. }
  153. #endregion // Public Methods
  154. }
  155. }