xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
open_file_box.h
Go to the documentation of this file.
1 #pragma once
5 #include <xtd/static.h>
6 #include "open_file_dialog.h"
8 
10 namespace xtd {
12  namespace forms {
22  class open_file_box final static_ {
23  public:
30  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::forms::iwin32_window& owner, const xtd::ustring& title) {return show_open_file_box<false>(file_name, title, "", "", open_file_box_options::none, &owner);}
31 
39  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) {return show_open_file_box<false>(file_name, title, "", "", options, &owner);}
40 
48  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) {return show_open_file_box<false>(file_name, title, initial_directory, "", open_file_box_options::none, &owner);}
49 
58  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) {return show_open_file_box<false>(file_name, title, initial_directory, "", options, &owner);}
59 
68  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) {return show_open_file_box<false>(file_name, title, initial_directory, filter, open_file_box_options::none, &owner);}
69 
79  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) {return show_open_file_box<false>(file_name, title, initial_directory, filter, options, &owner);}
80 
86  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title) {return show_open_file_box<false>(file_name, title, "", "", open_file_box_options::none, nullptr);}
87 
94  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title, const open_file_box_options options) {return show_open_file_box<false>(file_name, title, "", "", options, nullptr);}
95 
102  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title, const xtd::ustring& initial_directory) {return show_open_file_box<false>(file_name, title, initial_directory, "", open_file_box_options::none, nullptr);}
103 
111  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) {return show_open_file_box<false>(file_name, title, initial_directory, "", options, nullptr);}
112 
120  static xtd::forms::dialog_result show(xtd::ustring& file_name, const xtd::ustring& title, const xtd::ustring& initial_directory, const xtd::ustring& filter) {return show_open_file_box<false>(file_name, title, initial_directory, filter, open_file_box_options::none, nullptr);}
121 
130  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) {return show_open_file_box<false>(file_name, title, initial_directory, filter, options, nullptr);}
131 
137  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::forms::iwin32_window& owner, const xtd::ustring& title) {return show_open_file_box<true>(file_names, title, "", "", open_file_box_options::none, &owner);}
138 
146  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) {return show_open_file_box<true>(file_names, title, "", "", options, &owner);}
147 
155  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) {return show_open_file_box<true>(file_names, title, initial_directory, "", open_file_box_options::none, &owner);}
156 
165  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) {return show_open_file_box<true>(file_names, title, initial_directory, "", options, &owner);}
166 
175  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) {return show_open_file_box<true>(file_names, title, initial_directory, filter, open_file_box_options::none, &owner);}
176 
186  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) {return show_open_file_box<true>(file_names, title, initial_directory, filter, options, &owner);}
187 
193  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title) {return show_open_file_box<true>(file_names, title, "", "", open_file_box_options::none, nullptr);}
194 
201  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title, const open_file_box_options options) {return show_open_file_box<true>(file_names, title, "", "", options, nullptr);}
202 
209  static xtd::forms::dialog_result show(std::vector<xtd::ustring>& file_names, const xtd::ustring& title, const xtd::ustring& initial_directory) {return show_open_file_box<true>(file_names, title, initial_directory, "", open_file_box_options::none, nullptr);}
210 
218  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) {return show_open_file_box<true>(file_names, title, initial_directory, "", options, nullptr);}
219 
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) {return show_open_file_box<true>(file_names, title, initial_directory, filter, open_file_box_options::none, nullptr);}
228 
237  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) {return show_open_file_box<true>(file_names, title, initial_directory, filter, options, nullptr);}
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 iwin32_window* owner = nullptr) {
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)
248  .dereference_link(options & open_file_box_options::dereference_link)
249  .validate_names(options & open_file_box_options::validate_names)
250  .restore_directory(options & open_file_box_options::restore_directory)
251  .auto_upgrade_enabled(options & open_file_box_options::enable_auto_upgrade)
252  .show_hidden_files(options & open_file_box_options::show_hidden_files)
253  .show_help(options & open_file_box_options::show_help)
254  .show_preview(options & open_file_box_options::show_preview)
255  .support_multi_dotted_extensions(options & 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) {
259  if constexpr (multiselect)
260  output = dialog.file_names();
261  else
262  output = dialog.file_name();
263  }
264  return res;
265  }
266  };
267  }
268 }
Contains xtd::static_object class.
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)
Displays a multiple file select dialog box in front of a specified window.
Definition: open_file_box.h:155
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.
virtual bool multiselect() const
Gets a value indicating whether the dialog box allows multiple files to be selected.
Definition: open_file_dialog.h:33
static xtd::forms::dialog_result show(std::vector< xtd::ustring > &file_names, const xtd::ustring &title)
Displays a multiple file select dialog box.
Definition: open_file_box.h:193
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)
Displays a multiple file select dialog box.
Definition: open_file_box.h:237
xtd::forms::dialog_result show_dialog()
Runs a common dialog box with a default owner.
Definition: common_dialog.h:60
dialog_result
Specifies identifiers to indicate the return value of a dialog box.
Definition: dialog_result.h:39
static xtd::forms::dialog_result show(xtd::ustring &file_name, const xtd::forms::iwin32_window &owner, const xtd::ustring &title)
Displays a select file dialog box in front of a specified window.
Definition: open_file_box.h:30
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:38
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)
Displays a select file dialog box in front of a specified window.
Definition: open_file_box.h:39
Whether this xtd::forms::file_dialog instance should automatically upgrade appearance and behavior wh...
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)
Displays a select file dialog box in front of a specified window.
Definition: open_file_box.h:48
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual const std::vector< xtd::ustring > file_names() const
Gets the file names of all selected files in the dialog box.
Definition: file_dialog.h:140
static xtd::forms::dialog_result show(xtd::ustring &file_name, const xtd::ustring &title, const xtd::ustring &initial_directory, const xtd::ustring &filter)
Displays a select file dialog box.
Definition: open_file_box.h:120
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:18
static xtd::forms::dialog_result show(std::vector< xtd::ustring > &file_names, const xtd::forms::iwin32_window &owner, const xtd::ustring &title)
Displays a multiple file select dialog box in front of a specified window.
Definition: open_file_box.h:137
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
static xtd::forms::dialog_result show(xtd::ustring &file_name, const xtd::ustring &title, const open_file_box_options options)
Displays a select file dialog box.
Definition: open_file_box.h:94
Whether preview file is displayed in the file dialog box.
Provides an interface to expose Win32 HWND handles.
Definition: iwin32_window.h:19
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)
Displays a select file dialog box in front of a specified window.
Definition: open_file_box.h:68
Whether hidden files are displayed in the file dialog box.
virtual const xtd::ustring & file_name() const
Gets a string containing the file name selected in the file dialog box.
Definition: file_dialog.h:125
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)
Displays a select file dialog box.
Definition: open_file_box.h:130
Displays a standard dialog box that prompts the user to open a file. This class cannot be inherited...
Definition: open_file_dialog.h:21
xtd::forms::dialog_result show_sheet_dialog(const iwin32_window &owner)
Runs a common dialog box with the specified owner.
Definition: common_dialog.h:91
static xtd::forms::dialog_result show(std::vector< xtd::ustring > &file_names, const xtd::ustring &title, const open_file_box_options options)
Displays a multiple file select dialog box.
Definition: open_file_box.h:201
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)
Displays a select file dialog box in front of a specified window.
Definition: open_file_box.h:58
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)
Displays a multiple file select dialog box in front of a specified window.
Definition: open_file_box.h:146
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)
Displays a multiple file select dialog box.
Definition: open_file_box.h:218
static xtd::forms::dialog_result show(xtd::ustring &file_name, const xtd::ustring &title)
Displays a select file dialog box.
Definition: open_file_box.h:86
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)
Displays a multiple file select dialog box in front of a specified window.
Definition: open_file_box.h:165
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)
Displays a multiple file select dialog box.
Definition: open_file_box.h:227
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)
Displays a multiple file select dialog box in front of a specified window.
Definition: open_file_box.h:186
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:22
static xtd::forms::dialog_result show(std::vector< xtd::ustring > &file_names, const xtd::ustring &title, const xtd::ustring &initial_directory)
Displays a multiple file select dialog box.
Definition: open_file_box.h:209
static xtd::forms::dialog_result show(xtd::ustring &file_name, const xtd::ustring &title, const xtd::ustring &initial_directory)
Displays a select file dialog box.
Definition: open_file_box.h:102
Whether the Help button is displayed in the file dialog box.
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)
Displays a select file dialog box in front of a specified window.
Definition: open_file_box.h:79
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)
Displays a multiple file select dialog box in front of a specified window.
Definition: open_file_box.h:175
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)
Displays a select file dialog box.
Definition: open_file_box.h:111