TextObjectBase.DesignExt.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Windows.Forms;
  3. using FastReport.Format;
  4. using FastReport.Controls;
  5. using FastReport.Dialog;
  6. using System.Reflection;
  7. using FastReport.Utils;
  8. namespace FastReport
  9. {
  10. partial class TextObjectBase : ICustomDataTreeItemsProvider
  11. {
  12. #region Private Methods
  13. private bool ShouldSerializeBrackets()
  14. {
  15. return Brackets != "[,]";
  16. }
  17. private bool ShouldSerializePadding()
  18. {
  19. return Padding != new Padding(2, 0, 2, 0);
  20. }
  21. private bool ShouldSerializeFormat()
  22. {
  23. return (formats.Count == 1 && !(formats[0] is GeneralFormat)) || formats.Count > 1;
  24. }
  25. #endregion
  26. #region Public Methods
  27. /// <inheritdoc/>
  28. public override void AssignFormat(ReportComponentBase source)
  29. {
  30. base.AssignFormat(source);
  31. TextObjectBase src = source as TextObjectBase;
  32. if (src == null)
  33. return;
  34. Formats.Assign(src.Formats);
  35. }
  36. /// <inheritdoc/>
  37. public virtual void ProvideCustomItems(DataTreeView tree)
  38. {
  39. TreeNode dialogNode = null;
  40. foreach (Base c in Report.AllObjects)
  41. {
  42. if (c is DialogControl)
  43. {
  44. PropertyInfo bindableProp = (c as DialogControl).BindableProperty;
  45. if (bindableProp != null)
  46. {
  47. if (dialogNode == null)
  48. {
  49. dialogNode = tree.Nodes.Add(Res.Get("Designer,ToolWindow,Dictionary,DialogControls"));
  50. dialogNode.ImageIndex = 136;
  51. dialogNode.SelectedImageIndex = dialogNode.ImageIndex;
  52. }
  53. TreeNode node = dialogNode.Nodes.Add(c.Name + "." + bindableProp.Name);
  54. node.ImageIndex = DataTreeHelper.GetTypeImageIndex(bindableProp.PropertyType);
  55. node.SelectedImageIndex = node.ImageIndex;
  56. }
  57. }
  58. }
  59. }
  60. #endregion
  61. }
  62. }