xtd 0.2.0
seven_segment_display.cpp

demonstrates how to use xtd::forms::seven_segment_display control.

Windows

macOS

Gnome

#include <xtd/drawing/color_converter>
#include <xtd/forms/Application>
#include <xtd/forms/form>
#include <xtd/forms/seven_segment_display>
#include <xtd/forms/timer>
using namespace xtd;
using namespace xtd::collections::generic;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
seven_segment_display1.height(250);
seven_segment_display1.location({(client_size().width - seven_segment_display1.width()) / 2, (client_size().height - seven_segment_display1.height()) / 2});
seven_segment_display1.parent(*this);
seven_segment_display1.fore_color(color::red);
seven_segment_display1.anchor(anchor_styles::top | anchor_styles::bottom);
timer1.interval(300_ms);
timer1.enabled(true);
timer1.tick += [&] {
seven_segment_display1.segment_style(segment_styles[(counter / chase.size()) % segment_styles.size()]);
seven_segment_display1.value(chase[counter++ % chase.size()]);
};
back_color(color_converter::average(color::black, seven_segment_display1.fore_color(), 0.20));
text("Seven segment display example");
resize += [&] {
seven_segment_display1.left((client_size().width - seven_segment_display1.width()) / 2);
};
}
private:
int counter = 0;
list<segments> chase = {
};
list<segment_style> segment_styles = {
};
seven_segment_display seven_segment_display1;
timer timer1;
};
auto main() -> int {
application::run(form1 {});
}
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
static xtd::drawing::color average(const xtd::drawing::color &color1, const xtd::drawing::color &color2, double weight) noexcept
Returns the weighted average color between the two given colors.
static const xtd::drawing::color red
Gets a system-defined color that has an ARGB value of 0xFFFF0000. This field is constant.
Definition color.hpp:401
static const xtd::drawing::color black
Gets a system-defined color that has an ARGB value of 0xFF000000. This field is constant.
Definition color.hpp:80
static void run()
Begins running a standard application message loop on the current thread, without a form.
virtual int32 height() const noexcept
Gets the height of the control.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Represents a seven segment display class.
Definition seven_segment_display.hpp:32
Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in...
Definition timer.hpp:38
@ height
Specifies that the height of the control is defined.
Definition bounds_specified.hpp:34
@ width
Specifies that the width of the control is defined.
Definition bounds_specified.hpp:32
@ expanded
Expanded segment style.
Definition segment_style.hpp:29
@ mixed
Mixed (mix between standard and modern) segment style.
Definition segment_style.hpp:27
@ design
Design segment style.
Definition segment_style.hpp:31
@ stick
Stick segment style.
Definition segment_style.hpp:33
@ modern
Modern segment style.
Definition segment_style.hpp:25
@ standard
Standard segment style.
Definition segment_style.hpp:23
@ a
The a segment.
Definition segments.hpp:27
@ none
no segment.
Definition segments.hpp:25
@ c
The c segment.
Definition segments.hpp:31
@ d
The d segment.
Definition segments.hpp:33
@ f
The f segment.
Definition segments.hpp:37
@ b
The b segment.
Definition segments.hpp:29
@ dp
The dp segment (dot point).
Definition segments.hpp:65
@ g
The g segment.
Definition segments.hpp:39
@ pc
The cp segment (punctuation colon).
Definition segments.hpp:67
@ e
The e segment.
Definition segments.hpp:35
@ bottom
Bind control edges to the bottom of its container.
Definition anchor_styles.hpp:25
@ top
Bind control edges to the top of its container.
Definition anchor_styles.hpp:23
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217
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