IWithFileSelection.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /// An interface implemented by a webview if it supports file selection.
  18. /// This interface doesn't cause a file selection UI to automatically be shown, but the application
  19. /// can use this interface's FileSelectionRequested event to detect when file selection is requested
  20. /// and then use a system API or third party asset to present the user with a file selection UI.
  21. /// </summary>
  22. /// <example>
  23. /// <code>
  24. /// await webViewPrefab.WaitUntilInitialized();
  25. /// var webViewWithFileSelection = webViewPrefab.WebView as IWithFileSelection;
  26. /// if (webViewWithFileSelection != null) {
  27. /// webViewWithFileSelection.FileSelectionRequested += (sender, eventArgs) => {
  28. /// // Note: Here's where the application could use a system API or third party
  29. /// // asset to show a file selection UI and then pass the selected file(s) to
  30. /// // the Continue() callback.
  31. /// var filePaths = new string[] { "C:\\Users\\YourUser\\Desktop\\selected-file.txt" };
  32. /// eventArgs.Continue(filePaths);
  33. /// };
  34. /// }
  35. /// </code>
  36. /// </example>
  37. public interface IWithFileSelection {
  38. /// <summary>
  39. /// Indicates that the page requested a file selection dialog. This can happen, for example, when a file input
  40. /// is activated. Call the event args' Continue(filePaths) callback to provide a file selection or call
  41. /// Cancel() to cancel file selection.
  42. /// </summary>
  43. event EventHandler<FileSelectionEventArgs> FileSelectionRequested;
  44. }
  45. }