Toolbar.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text.Encodings.Web;
  6. using System.Threading.Tasks;
  7. using FastReport.Web.Toolbar;
  8. namespace FastReport.Web.Blazor.Components
  9. {
  10. public partial class Toolbar
  11. {
  12. float currentZoom;
  13. bool isFirstPage;
  14. bool isLastPage;
  15. bool isSinglePage;
  16. static readonly float[] zoomList = new[] { 300f, 200f, 150f, 100f, 90f, 75f, 50f, 25f };
  17. private ToolbarLocalization Localization;
  18. private int CurrentPage
  19. {
  20. get => WebReport.CurrentPageIndex + 1;
  21. set => WebReport.CurrentPageIndex = value + 1;
  22. }
  23. private int InputValue
  24. {
  25. get => WebReport.TotalPages == 0 ? 0 : CurrentPage;
  26. set
  27. {
  28. if (value != CurrentPage)
  29. {
  30. // Check bounds
  31. if (value > 0 && value < WebReport.TotalPages + 1)
  32. {
  33. WebReport.GotoPage(value - 1);
  34. PageChanged.Invoke();
  35. }
  36. }
  37. }
  38. }
  39. public Toolbar()
  40. {
  41. }
  42. private void Reload()
  43. {
  44. WebReport.OnUpdate(true);
  45. }
  46. private void Zoom(float value)
  47. {
  48. WebReport.Zoom = value / 100;
  49. WebReport.OnUpdate();
  50. }
  51. private enum PrintTypes
  52. {
  53. HTML,
  54. PDF
  55. }
  56. private void InvokeInputAction(string inputValue, ElementChangeAction action)
  57. {
  58. action?.OnChangeAction?.Invoke(WebReport, inputValue);
  59. }
  60. private void InvokeAction(ElementClickAction toolbarAction)
  61. {
  62. toolbarAction?.OnClickAction?.Invoke(WebReport);
  63. WebReport.OnUpdate(true);
  64. }
  65. private void GotoFirst()
  66. {
  67. WebReport.FirstPage();
  68. PageChanged.Invoke();
  69. }
  70. private void GotoPrevious()
  71. {
  72. if (CurrentPage - 1 > 0)
  73. {
  74. WebReport.PrevPage();
  75. PageChanged.Invoke();
  76. }
  77. }
  78. private void GotoNext()
  79. {
  80. if (CurrentPage < WebReport.TotalPages)
  81. {
  82. WebReport.NextPage();
  83. PageChanged.Invoke();
  84. }
  85. }
  86. private void GotoLast()
  87. {
  88. WebReport.LastPage();
  89. PageChanged.Invoke();
  90. }
  91. }
  92. }