MatrixButtons.PreviewExt.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Windows.Forms;
  3. using FastReport.Utils;
  4. namespace FastReport.AdvMatrix
  5. {
  6. public partial class MatrixCollapseButton
  7. {
  8. private void CreateMenuItems()
  9. {
  10. ContextMenuStrip menu = new ContextMenuStrip();
  11. ToolStripItem collapseAll = menu.Items.Add(Res.Get("Designer,ToolWindow,CollapseAll"));
  12. collapseAll.Tag = this;
  13. collapseAll.Click += CollapseAll_Click;
  14. ToolStripItem expandAll = menu.Items.Add(Res.Get("Designer,ToolWindow,ExpandAll"));
  15. expandAll.Tag = this;
  16. expandAll.Click += ExpandAll_Click;
  17. menu.Show(Cursor.Position);
  18. }
  19. private void ExpandAll_Click(object sender, EventArgs e)
  20. {
  21. MatrixCollapseButton btn = (sender as ToolStripItem).Tag as MatrixCollapseButton;
  22. if (Matrix != null)
  23. {
  24. if (IsColumn)
  25. Matrix.ToggleColumnVisible(btn.Index, false, true);
  26. else
  27. Matrix.ToggleRowVisible(btn.Index, false, true);
  28. }
  29. Report.Preview.RefreshReport();
  30. }
  31. private void CollapseAll_Click(object sender, EventArgs e)
  32. {
  33. MatrixCollapseButton btn = (sender as ToolStripItem).Tag as MatrixCollapseButton;
  34. if (Matrix != null)
  35. {
  36. if (IsColumn)
  37. Matrix.ToggleColumnVisible(btn.Index, true, false);
  38. else
  39. Matrix.ToggleRowVisible(btn.Index, true, false);
  40. }
  41. Report.Preview.RefreshReport();
  42. }
  43. /// <inheritdoc/>
  44. public override void OnMouseUp(MouseEventArgs e)
  45. {
  46. base.OnMouseUp(e);
  47. if (e.Button == MouseButtons.Right && ShowCollapseExpandMenu)
  48. {
  49. CreateMenuItems();
  50. return;
  51. }
  52. if (Matrix != null)
  53. {
  54. if (IsColumn)
  55. Matrix.ToggleColumnVisible(Index);
  56. else
  57. Matrix.ToggleRowVisible(Index);
  58. Report.Refresh();
  59. }
  60. }
  61. }
  62. public partial class MatrixSortButton
  63. {
  64. /// <inheritdoc/>
  65. /// <inheritdoc/>
  66. public override void OnClick(EventArgs e)
  67. {
  68. MatrixSortButtonClick();
  69. }
  70. }
  71. }