SelectedTextBaseObjects.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Drawing;
  5. using FastReport.Design;
  6. using FastReport.Format;
  7. namespace FastReport
  8. {
  9. internal class SelectedTextBaseObjects
  10. {
  11. private List<TextObjectBase> list;
  12. private Designer designer;
  13. public TextObjectBase First
  14. {
  15. get { return list.Count > 0 ? list[0] : null; }
  16. }
  17. public int Count
  18. {
  19. get { return list.Count; }
  20. }
  21. public bool Enabled
  22. {
  23. get
  24. {
  25. return Count > 1 || (Count == 1 && CanModify(First));
  26. }
  27. }
  28. private List<TextObjectBase> ModifyList
  29. {
  30. get { return list.FindAll(CanModify); }
  31. }
  32. private bool CanModify(TextObjectBase c)
  33. {
  34. return !c.HasRestriction(Restrictions.DontModify);
  35. }
  36. public void SetAllowExpressions(bool value)
  37. {
  38. foreach (TextObjectBase text in ModifyList)
  39. {
  40. text.AllowExpressions = value;
  41. }
  42. }
  43. public void SetFormat(FormatCollection value)
  44. {
  45. foreach (TextObjectBase text in ModifyList)
  46. {
  47. text.Formats.Assign(value);
  48. }
  49. }
  50. public void SetHideZeros(bool value)
  51. {
  52. foreach (TextObjectBase text in ModifyList)
  53. {
  54. text.HideZeros = value;
  55. }
  56. }
  57. public void Update()
  58. {
  59. list.Clear();
  60. if (designer.SelectedObjects != null)
  61. {
  62. foreach (Base c in designer.SelectedObjects)
  63. {
  64. if (c is TextObjectBase)
  65. list.Add(c as TextObjectBase);
  66. }
  67. }
  68. }
  69. public SelectedTextBaseObjects(Designer designer)
  70. {
  71. this.designer = designer;
  72. list = new List<TextObjectBase>();
  73. }
  74. }
  75. }