ButtonComponent.razor 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. @using System.Windows.Forms
  2. @inherits ButtonBaseComponent<ButtonControl>
  3. <input type="button"
  4. name="@Control.Name"
  5. value="@Control.Text"
  6. style="@GetStyle"
  7. title="@Control.Text"
  8. disabled="@IsDisabled"
  9. @onclick="Click" />
  10. @code {
  11. private void Click()
  12. {
  13. ButtonClick(Control);
  14. // After
  15. WebReport.OnUpdate(true);
  16. }
  17. private void ButtonClick(ButtonControl button)
  18. {
  19. if (button.DialogResult == DialogResult.OK)
  20. {
  21. if (FormClose(button, CloseReason.None))
  22. WebReport.Dialog.CurrentForm++;
  23. }
  24. else if (button.DialogResult == DialogResult.Cancel)
  25. {
  26. if (FormClose(button, CloseReason.UserClosing))
  27. WebReport.Canceled = true;
  28. }
  29. button.OnClick(null);
  30. }
  31. private bool FormClose(ButtonControl button, CloseReason reason)
  32. {
  33. DialogPage dialog = button.Report.Pages[WebReport.Dialog.CurrentForm] as DialogPage;
  34. dialog.Form.DialogResult = button.DialogResult;
  35. FormClosingEventArgs closingArgs = new FormClosingEventArgs(reason, false);
  36. dialog.OnFormClosing(closingArgs);
  37. if (closingArgs.Cancel)
  38. return false;
  39. FormClosedEventArgs closedArgs = new FormClosedEventArgs(reason);
  40. dialog.OnFormClosed(closedArgs);
  41. dialog.ActiveInWeb = false;
  42. return true;
  43. }
  44. protected override string GetStyle
  45. => base.GetStyle + $"{GetControlAlign()} padding:0;margin:0;";
  46. }