#include <xtd/drawing//system_brushes>
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/user_control>
namespace toggle_light_example {
public:
toggle_light() = default;
protected:
on = !on;
refresh();
}
e.graphics().clear(back_color());
if (on) e.graphics().fill_ellipse(system_brushes::accent(), e.clip_rectangle());
}
private:
bool on = false;
};
class main_form :
public form {
public:
main_form() {
text("Toggle light");
client_size({600, 600});
for (auto y = 0; y < num_y; ++y)
for (auto x = 0; x < num_x; ++x)
toggle_lights[x][y].parent(*this);
}
static void main() {
application::run(main_form {});
}
protected:
auto step_x = client_size().width() / num_x;
auto step_y = client_size().height() / num_y;
for (auto y = 0; y < num_y; ++y)
for (auto x = 0; x < num_x; ++x)
toggle_lights[x][y].bounds({x * step_x, y * step_y, step_x, step_y});
}
private:
static constexpr int num_x = 20;
static constexpr int num_y = 20;
std::array<std::array<toggle_light, num_y>, num_x> toggle_lights;
};
}
auto main() -> int {
application::run(toggle_light_example::main_form {});
}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.h:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10