xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
dot_matrix_display.cpp

The following code example demonstrate the use of dot matrix display control.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace std::literals;
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
dot_matrix_display1.height(250);
dot_matrix_display1.location({(client_size().width() - dot_matrix_display1.width()) / 2, (client_size().height() - dot_matrix_display1.height()) / 2});
dot_matrix_display1.parent(*this);
dot_matrix_display1.fore_color(color::red);
dot_matrix_display1.anchor(anchor_styles::top|anchor_styles::bottom);
timer1.interval(300ms);
timer1.enabled(true);
timer1.tick += [&] {
dot_matrix_display1.dot_matrix_style(dot_matrix_styles[(counter / chaser.size()) % dot_matrix_styles.size()]);
dot_matrix_display1.set_dots(chaser[counter++ % chaser.size()]);
};
back_color(color::average(color::black, dot_matrix_display1.fore_color(), 0.20));
text("Dot matrix display example");
resize += [&] {
dot_matrix_display1.left((client_size().width() - dot_matrix_display1.width()) / 2);
};
}
private:
int counter = 0;
std::vector<dot_matrix_display::points_collection> chaser = {
{},
{{3, 3}},
{{3, 3}, {2, 2}, {2, 3}, {2, 4}, {3, 2}, {3, 4}, {4, 2}, {4, 3}, {4, 4}},
{{3, 3}, {2, 2}, {2, 3}, {2, 4}, {3, 2}, {3, 4}, {4, 2}, {4, 3}, {4, 4}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 5}, {4, 1}, {4, 5}, {5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}},
{{3, 3}, {2, 2}, {2, 3}, {2, 4}, {3, 2}, {3, 4}, {4, 2}, {4, 3}, {4, 4}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 5}, {4, 1}, {4, 5}, {5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}, {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {1, 0}, {1, 6}, {2, 0}, {2, 6}, {3, 0}, {3, 6}, {4, 0}, {4, 6}, {5, 0}, {5, 6}, {6, 0}, {6, 1}, {6, 2}, {6, 3}, {6, 4}, {6, 5}, {6, 6}},
};
dot_matrix_display dot_matrix_display1;
std::vector<dot_matrix_style> dot_matrix_styles = {
dot_matrix_style::standard,
dot_matrix_style::square
};
timer timer1;
};
int main() {
application::run(form1());
}
virtual int32_t height() const
Gets the height of the control.
Definition: control.h:486
Represents a dot matrix display class.
Definition: dot_matrix_display.h:23
Represents a window or dialog box that makes up an application's user interface.
Definition: form.h:40
Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in...
Definition: timer.h:29
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition: bitmap.h:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17