FileSelectionEventArgs.cs 2.3 KB

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