IStandaloneFileBrowser.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. namespace TriLibCore.SFB
  4. {
  5. /// <summary>Represents a series of methods to operate platform-specific file pickers.</summary>
  6. /// <typeparam name="T">File picker return type.</typeparam>
  7. public interface IStandaloneFileBrowser<T>
  8. {
  9. /// <summary>Opens the platform-specific file selection panel.</summary>
  10. /// <param name="title">The dialog title.</param>
  11. /// <param name="directory">The initial file panel directory.</param>
  12. /// <param name="extensions">The allowed extensions.</param>
  13. /// <param name="multiselect">Pass <c>true</c> to enable multi-selection.</param>
  14. /// <returns>The list of selected files.</returns>
  15. IList<T> OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect);
  16. /// <summary>Opens the platform-specific folder selection panel.</summary>
  17. /// <param name="title">The dialog title.</param>
  18. /// <param name="directory">The initial file panel directory.</param>
  19. /// <param name="multiselect">Pass <c>true</c> to enable multi-selection.</param>
  20. /// <returns>The list of selected folders.</returns>
  21. IList<T> OpenFolderPanel(string title, string directory, bool multiselect);
  22. /// <summary>Opens the platform-specific file save panel.</summary>
  23. /// <param name="title">The dialog title.</param>
  24. /// <param name="directory">The initial file panel directory.</param>
  25. /// <param name="defaultName">The initial filename.</param>
  26. /// <param name="extensions">The allowed extensions.</param>
  27. /// <returns>The saved file.</returns>
  28. T SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions);
  29. /// <summary>Opens the platform-specific file selection panel Asynchronously.</summary>
  30. /// <param name="title">The dialog title.</param>
  31. /// <param name="directory">The initial file panel directory.</param>
  32. /// <param name="extensions">The allowed extensions.</param>
  33. /// <param name="multiselect">Pass <c>true</c> to enable multi-selection.</param>
  34. /// <param name="cb">The Method to call when the user selects or cancel the file selection dialog.</param>
  35. void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<IList<T>> cb);
  36. /// <summary>Opens the platform-specific folder selection panel Asynchronously.</summary>
  37. /// <param name="title">The dialog title.</param>
  38. /// <param name="directory">The initial file panel directory.</param>
  39. /// <param name="multiselect">Pass <c>true</c> to enable multi-selection.</param>
  40. /// <param name="cb">The Method to call when the user selects or cancel the file selection dialog.</param>
  41. void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<IList<T>> cb);
  42. /// <summary>Opens the platform-specific file save panel Asynchronously.</summary>
  43. /// <param name="title">The dialog title.</param>
  44. /// <param name="directory">The initial file panel directory.</param>
  45. /// <param name="defaultName">The initial filename.</param>
  46. /// <param name="extensions">The allowed extensions.</param>
  47. /// <param name="cb">The Method to call when the user selects or cancel the file selection dialog.</param>
  48. void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<T> cb);
  49. }
  50. }