Editors.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using FastReport.Forms;
  6. namespace FastReport.Utils
  7. {
  8. /// <summary>
  9. /// Contains methods to call common editors.
  10. /// </summary>
  11. /// <remarks>
  12. /// Use this class if you are writing a new component for FastReport.
  13. /// </remarks>
  14. public static class Editors
  15. {
  16. /// <summary>
  17. /// Invokes the expression editor.
  18. /// </summary>
  19. /// <param name="report">A reference to the report.</param>
  20. /// <param name="expression">The expression to edit.</param>
  21. /// <returns>The new expression.</returns>
  22. public static string EditExpression(Report report, string expression)
  23. {
  24. using (ExpressionEditorForm form = new ExpressionEditorForm(report))
  25. {
  26. form.ExpressionText = expression;
  27. if (form.ShowDialog() == DialogResult.OK)
  28. return form.ExpressionText;
  29. }
  30. return expression;
  31. }
  32. /// <summary>
  33. /// Invokes the border editor.
  34. /// </summary>
  35. /// <param name="border">The <b>Border</b> to edit.</param>
  36. /// <returns>The new border.</returns>
  37. public static Border EditBorder(Border border)
  38. {
  39. using (BorderEditorForm editor = new BorderEditorForm())
  40. {
  41. editor.Border = border.Clone();
  42. if (editor.ShowDialog() == DialogResult.OK)
  43. return editor.Border;
  44. }
  45. return border;
  46. }
  47. /// <summary>
  48. /// Invokes the data band columns editor.
  49. /// </summary>
  50. /// <param name="columns">The data band columns to edit.</param>
  51. /// <returns></returns>
  52. public static BandColumns EditBandColumns(BandColumns columns)
  53. {
  54. using (DataBandColumnEditorForm editor = new DataBandColumnEditorForm(columns))
  55. {
  56. //editor.Border = border.Clone();
  57. if (editor.ShowDialog() == DialogResult.OK)
  58. return editor.Columns;
  59. }
  60. return columns;
  61. }
  62. /// <summary>
  63. /// Invokes the fill editor.
  64. /// </summary>
  65. /// <param name="fill">The fill to edit.</param>
  66. /// <returns>The new fill.</returns>
  67. public static FillBase EditFill(FillBase fill)
  68. {
  69. using (FillEditorForm editor = new FillEditorForm())
  70. {
  71. editor.Fill = fill.Clone();
  72. if (editor.ShowDialog() == DialogResult.OK)
  73. return editor.Fill;
  74. }
  75. return fill;
  76. }
  77. /// <summary>
  78. /// Invokes the outline editor.
  79. /// </summary>
  80. /// <param name="outline">The outline to edit.</param>
  81. /// <returns>The new outline.</returns>
  82. public static TextOutline EditOutline(TextOutline outline)
  83. {
  84. using (OutlineEditorForm editor = new OutlineEditorForm())
  85. {
  86. editor.Outline = outline.Clone();
  87. if (editor.ShowDialog() == DialogResult.OK)
  88. return editor.Outline;
  89. }
  90. return outline;
  91. }
  92. /// <summary>
  93. /// Invokes the text editor.
  94. /// </summary>
  95. /// <param name="report">A reference to the report. May by null</param>
  96. /// <param name="text">The text to edit.</param>
  97. /// <param name="hideDataBar"></param>
  98. /// <returns>The new text.</returns>
  99. public static string EditText(Report report, string text, bool hideDataBar = true)
  100. {
  101. #if MONO
  102. using (TextEditorForm editor = new TextEditorForm(null, hideDataBar))
  103. #else
  104. using (TextEditorForm editor = new TextEditorForm(null))
  105. #endif
  106. {
  107. editor.ExpressionText = text;
  108. editor.HideDataBar = hideDataBar;
  109. if (editor.ShowDialog() == DialogResult.OK)
  110. return editor.ExpressionText;
  111. }
  112. return text;
  113. }
  114. }
  115. }