xtd 0.2.0
Loading...
Searching...
No Matches
application_settings_without_cmake_setting_commands.cpp

demonstrates the use of xtd::settings component without CMake setting commands.

Windows

macOS

Gnome

#include <xtd/configuration/settings>
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/color_picker>
#include <xtd/forms/form>
using namespace xtd::drawing;
using namespace xtd::forms;
auto main() -> int {
auto main_form = form::create("Settings example", form_start_position::manual);
auto back_color_picker = color_picker::create(main_form, main_form.back_color(), {10, 10}, {75, 25});
back_color_picker.color_picker_changed += [&] {
main_form.back_color(back_color_picker.color());
};
auto save_button = button::create(main_form, "&Save", {90, 10});
save_button.click += [&] {
settings.write("size", main_form.client_size());
settings.write("location", main_form.location());
settings.write("back_color", main_form.back_color());
};
auto reload_button = button::create(main_form, "&Reload", {170, 10});
reload_button.click += [&] {
main_form.client_size(settings.read("size", size {335, 45}));
main_form.location(settings.read("location", point {100, 50}));
main_form.back_color(settings.read("back_color", main_form.back_color()));
back_color_picker.color(main_form.back_color());
};
auto reset_button = button::create(main_form, "R&eset", {250, 10});
reset_button.click += [&] {
reload_button.perform_click();
};
reload_button.perform_click();
application::run(main_form);
}
Represent settings associate to the application.
Definition settings.hpp:174
void save()
Save application settings.
void write(const xtd::string &key, const xtd::string &value)
Writes a specified value for specified key.
xtd::string read(const xtd::string &key, const xtd::string &default_value)
Reads a value for specified key. If not found default value is used.
void reset()
Reset application settings.
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12