xtd 0.2.0
open_file_box.h
Go to the documentation of this file.
1 #pragma once
6 #include "open_file_dialog.h"
7 #include <xtd/static>
8 
10 namespace xtd {
12  namespace forms {
29  class forms_export_ open_file_box final static_ {
30  public:
32 
39  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::forms::iwin32_window& owner);
46  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::forms::iwin32_window& owner, const xtd::ustring& title);
54  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const open_file_box_options options);
62  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const xtd::ustring& initial_directory);
71  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const xtd::ustring& initial_directory, const open_file_box_options options);
80  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter);
90  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter, const open_file_box_options options);
95  static xtd::forms::dialog_result show(xtd::ustring& file_name);
101  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title);
102 
109  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title, const open_file_box_options options);
116  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title, const xtd::ustring& initial_directory);
124  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title, const xtd::ustring& initial_directory, const open_file_box_options options);
132  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter);
141  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter, const open_file_box_options options);
147  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::forms::iwin32_window& owner, const xtd::ustring& title);
155  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const open_file_box_options options);
163  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const xtd::ustring& initial_directory);
172  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const xtd::ustring& initial_directory, const open_file_box_options options);
181  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter);
191  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::forms::iwin32_window& owner, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter, const open_file_box_options options);
197  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title);
204  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title, const open_file_box_options options);
211  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title, const xtd::ustring& initial_directory);
219  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title, const xtd::ustring& initial_directory, const open_file_box_options options);
227  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter);
236  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter, const open_file_box_options options);
238 
239  private:
240  template<const bool multiselect, typename output_t>
241  static xtd::forms::dialog_result show_open_file_box(output_t& output, const xtd::ustring& title, const xtd::ustring& initial_directory = "", const xtd::ustring& filter = "", const open_file_box_options options = open_file_box_options::none, const xtd::forms::iwin32_window* owner = nullptr) {
242  auto dialog = xtd::forms::open_file_dialog {};
243  dialog.multiselect(multiselect)
244  .title(title)
245  .initial_directory(initial_directory)
246  .filter(filter)
247  .check_file_exists((options & open_file_box_options::check_file_exists) == open_file_box_options::check_file_exists)
248  .dereference_link((options & open_file_box_options::dereference_link) == open_file_box_options::dereference_link)
249  .validate_names((options & open_file_box_options::validate_names) == open_file_box_options::validate_names)
250  .restore_directory((options & open_file_box_options::restore_directory) == open_file_box_options::restore_directory)
251  .auto_upgrade_enabled((options & open_file_box_options::enable_auto_upgrade) == open_file_box_options::enable_auto_upgrade)
252  .show_hidden_files((options & open_file_box_options::show_hidden_files) == open_file_box_options::show_hidden_files)
253  .show_help((options & open_file_box_options::show_help) == open_file_box_options::show_help)
254  .show_preview((options & open_file_box_options::show_preview) == open_file_box_options::show_preview)
255  .support_multi_dotted_extensions((options & open_file_box_options::support_multi_dotted_extensions) == open_file_box_options::support_multi_dotted_extensions);
256  if constexpr(!multiselect) dialog.file_name(output);
257  const auto res = owner ? dialog.show_sheet_dialog(*owner) : dialog.show_dialog();
258  if (res != dialog_result::ok) return res;
259  if constexpr(multiselect) output = dialog.file_names();
260  else output = dialog.file_name();
261  return res;
262  }
263  };
264  }
265 }
Whether the dialog box displays a warning if the user specifies a file name that does not exist...
Contains xtd::forms::open_file_box_options control.
dialog_result
Specifies identifiers to indicate the return value of a dialog box.
Definition: dialog_result.h:41
Whether the dialog box supports displaying and saving files that have multiple file name extensions...
#define static_
This keyword is use to represent a static object. A static object can&#39;t be instantiated (constructors...
Definition: static.h:37
virtual bool multiselect() const noexcept
Gets a value indicating whether the dialog box allows multiple files to be selected.
Whether this xtd::forms::file_dialog instance should automatically upgrade appearance and behavior wh...
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Whether the dialog box restores the directory to the previously selected directory before closing...
open_file_box_options
Specifies options on a xtd::forms::open_file_box.
Definition: open_file_box_options.h:20
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Whether preview file is displayed in the file dialog box.
Provides an interface to expose Win32 HWND handles.
Definition: iwin32_window.h:21
Whether hidden files are displayed in the file dialog box.
Displays a standard dialog box that prompts the user to open a file. This class cannot be inherited...
Definition: open_file_dialog.h:28
Contains xtd::forms::open_file_dialog dialog.
Whether the dialog box accepts only valid file names.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Whether the dialog box returns the location of the file referenced by the shortcut (...
The dialog box return value is OK (usually sent from a button labeled OK).
Represents a common dialog box that displays a file selection dialog. This class cannot be inherited...
Definition: open_file_box.h:29
Whether the Help button is displayed in the file dialog box.