FileSelectionEventArgs.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (c) 2021 Vuplex Inc. All rights reserved.
  3. *
  4. * Licensed under the Vuplex Commercial Software Library License, you may
  5. * not use this file except in compliance with the License. You may obtain
  6. * a copy of the License at
  7. *
  8. * https://vuplex.com/commercial-library-license
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. using System;
  17. namespace Vuplex.WebView {
  18. /// <summary>
  19. /// Event args for `FileSelectionRequested`. To handle file selection, the application
  20. /// must either call `Continue()` to select files or call `Cancel()` to cancel file selection.
  21. /// <summary>
  22. public class FileSelectionEventArgs : EventArgs {
  23. public FileSelectionEventArgs(string[] acceptFilters, bool multipleAllowed, Action<string[]> continueCallback, Action cancelCallback) {
  24. AcceptFilters = acceptFilters;
  25. MultipleAllowed = multipleAllowed;
  26. Continue = continueCallback;
  27. Cancel = cancelCallback;
  28. }
  29. /// <summary>
  30. /// Filters provided by the page to specify the allowed file types.
  31. /// For more info, see [MDN's documentation for the file input `accept` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept).
  32. /// </summary>
  33. public readonly string[] AcceptFilters;
  34. /// <summary>
  35. /// Indicates whether multiple files are permitted.
  36. /// For more info, see [MDN's documentation for the file input `multiple` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#multiple).
  37. /// </summary>
  38. public readonly bool MultipleAllowed;
  39. /// <summary>
  40. /// To select files, call this callback with an array of one or more absolute file paths.
  41. /// </summary>
  42. public readonly Action<string[]> Continue;
  43. /// <summary>
  44. /// Call this callback to cancel file selection.
  45. /// </summary>
  46. public readonly Action Cancel;
  47. }
  48. }