#include <xtd/drawing/texts>
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/choice>
#include <xtd/forms/form>
#include <xtd/forms/label>
#include <xtd/forms/picture_box>
#include <xtd/drawing/system_colors>
namespace example {
class form1 :
public form {
public:
form1() {
client_size({430, 530});
minimum_client_size(client_size());
controls().push_back_range({choice_theme, choice_context, choice_size, picture, label_picture_name, button_previous, button_next});
picture.bounds({75, 125, 280, 280});
choice_theme.bounds({75, 25, 280, 25});
choice_theme.items().push_back("current theme");
sort(names.begin(), names.end());
choice_theme.items().push_back_range(names);
choice_theme.selected_index(0);
choice_theme.selected_index_changed += event_handler(*this, &form1::update_form);
choice_context.bounds({75, 55, 280, 25});
choice_context.selected_index(0);
choice_context.selected_index_changed += [&] {
current_image_index = 0;
update_form();
};
choice_size.bounds({75, 85, 280, 25});
choice_size.items().push_back({string::format(
"{}x{} pixels",
size.width,
size.height),
size});
choice_size.selected_index(7);
choice_size.selected_index_changed += event_handler(*this, &form1::update_form);
label_picture_name.bounds({75, 420, 280, label_picture_name.height()});
button_previous.auto_repeat(true);
button_previous.bounds({75, 460, 125, 40});
button_previous.enabled(false);
button_previous.click += [&] {
if (current_image_index > 0) --current_image_index;
update_form();
};
button_next.auto_repeat(true);
button_next.bounds({230, 460, 125, 40});
button_next.click += [&] {
if (current_image_index <
images::names(choice_context.selected_item().value()).size()) ++current_image_index;
update_form();
};
update_form();
}
private:
void update_form() {
label_picture_name.text(
images::names(choice_context.selected_item().value())[current_image_index]);
button_previous.enabled(current_image_index > 0);
button_next.enabled(current_image_index <
images::names(choice_context.selected_item().value()).size() - 1);
}
size_t current_image_index = 0;
label label_picture_name;
};
}
auto main() -> int {
}
static image empty
Represent an empty xtd::drawing::image.
Definition image.hpp:65
static xtd::drawing::color window()
Gets a xtd::drawing::color structure that is the color of the background in the client area of a wind...
static xtd::string previous()
Gets a system-defined text that has a string value of "&Previous". This field is constant.
static xtd::string next()
Gets a system-defined text that has a string value of "&Next". This field is constant.
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8