xtd 0.2.0
lcd_label2.cpp

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

Windows

macOS

Gnome

#define DEBUG
#include <xtd/diagnostics/debug>
#include <xtd/diagnostics/stopwatch>
#include <xtd/drawing/color_converter>
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/lcd_label>
using namespace xtd;
using namespace xtd::diagnostics;
using namespace xtd::drawing;
using namespace xtd::forms;
auto main() -> int {
timer.interval(100_ms);
stopwatch chrono;
form form_main;
form_main.double_buffered(true);
form_main.text("Lcd label example 2");
form_main.client_size({1456, 503});
label.parent(form_main);
label.text(" 0.0");
timer.tick += [&] {
label.text(string::format("{,5:F1}", chrono.elapsed_milliseconds() / 1000.0));
debug::write_line(string::format("{,5:F1}", chrono.elapsed_milliseconds() / 1000.0));
};
label.mouse_down += [&] {
if (timer.enabled()) chrono.start();
else chrono.stop();
} else {
if (timer.enabled()) chrono.restart();
else chrono.reset();
label.text(" 0.0");
}
};
application::run(form_main);
}
static void write_line()
Writes a line terminator to the trace listeners in the listeners collection.
Definition debug.hpp:361
Provides a set of methods and properties that you can use to accurately measure elapsed time.
Definition stopwatch.hpp:36
void stop() noexcept
Stops measuring elapsed time for an interval.
void reset() noexcept
Stops time interval measurement and resets the elapsed time to zero.
void start() noexcept
Starts, or resumes, measuring elapsed time for an interval.
int64 elapsed_milliseconds() const noexcept
Gets the total elapsed time measured by the current instance, in milliseconds.
void restart() noexcept
stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.
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 blue
Gets a system-defined color that has an ARGB value of 0xFF0000FF. This field is constant.
Definition color.hpp:86
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 drawing::color fore_color() const noexcept
Gets the foreground color of the control.
virtual const drawing::size & client_size() const noexcept
Gets the height and width of the client area of the control.
virtual bool double_buffered() const noexcept
Gets a value indicating whether this control should redraw its surface using a secondary buffer to re...
event< control, mouse_event_handler > mouse_down
Occurs when the mouse pointer is over the xtd::forms::control and a mouse button is pressed.
Definition control.hpp:1713
virtual dock_style dock() const noexcept
Gets which control borders are docked to its parent control and determines how a control is resized w...
virtual drawing::color back_color() const noexcept
Gets the background color for the control.
virtual const xtd::string & text() const noexcept
Gets the text associated with this control.
static forms::mouse_buttons mouse_buttons() noexcept
Gets a value indicating which of the mouse buttons is in a pressed state.
virtual std::optional< control_ref > parent() const noexcept
Gets the parent container of the control.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
virtual forms::auto_size_mode auto_size_mode() const noexcept
Gets the mode by which the form automatically resizes itself.
virtual form_start_position start_position() const noexcept
Gets the starting position of the form at run time.
Represents a standard Windows label.
Definition label.hpp:38
Represents a lcd label.
Definition lcd_label.hpp:40
Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in...
Definition timer.hpp:38
virtual time_span interval() const noexcept
Gets the time, in milliseconds, before the tick event is raised relative to the last occurrence of th...
virtual bool enabled() const noexcept
Gets whether the timer is running.
event< timer, event_handler > tick
Occurs when the specified timer interval has elapsed and the timer is enabled.
Definition timer.hpp:130
@ grow_and_shrink
The control grows or shrinks to fit its contents. The control cannot be resized manually.
Definition auto_size_mode.hpp:24
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...
Definition dock_style.hpp:35
@ center_screen
The form is centered on the current display, and has the dimensions specified in the form's size.
Definition form_start_position.hpp:26
@ left
The left mouse button was pressed.
Definition mouse_buttons.hpp:26
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
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
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8