xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
seven_segment_display.h
Go to the documentation of this file.
1 #pragma once
7 #include "control.h"
8 #include "segments.h"
9 #include "segment_style.h"
10 
11 namespace xtd {
12  namespace forms {
22  class seven_segment_display : public control {
23  public:
26  double_buffered(true);
27  size_ = default_size();
28  }
29 
33  virtual drawing::color back_segment_color() {return back_segment_color_.value_or(fore_color());}
39  if (!back_segment_color_.has_value() || back_segment_color_.value() != value) {
40  back_segment_color_ = value;
41  invalidate();
42  }
43  return *this;
44  }
45 
48  virtual double back_segment_opacity() const {return back_segment_opacity_;}
54  if (value < 0.0 || value > 1.0) throw argument_out_of_range_exception("value must be between 0.0 and 1.0."_t, current_stack_frame_);
55  if (back_segment_opacity_ != value) {
56  back_segment_opacity_ = value;
57  invalidate();
58  }
59  return *this;
60  }
61 
64  virtual bool show_back_segment() const {return show_back_segment_;}
69  if (show_back_segment_ != value) {
70  show_back_segment_ = value;
71  invalidate();
72  }
73  return *this;
74  }
75 
78  virtual forms::segment_style segment_style() const {return segment_style_;}
83  if (segment_style_ != value) {
84  segment_style_ = value;
85  invalidate();
86  }
87  return *this;
88  }
89 
92  virtual int32_t thickness() const {return thickness_.value_or(size_.height() < 10 ? 1 : (size_.height() / 10 + ((size_.height() / 10) % 2 ? 0 : 1)));}
97  if (!thickness_.has_value() || thickness_.value() != value) {
98  thickness_ = value;
99  invalidate();
100  }
101  return *this;
102  }
103 
106  virtual forms::segments value() const {return value_;}
111  if (value_ != value) {
112  value_ = value;
113  invalidate();
114  }
115  return *this;
116  }
117 
120  virtual bool get_segments(forms::segments segment) const {return (value_ & segment) == segment;}
124  virtual void set_segments(forms::segments segment, bool value) { value_ = value ? (value_ | segment) : (value_ & ~segment); }
125 
126  protected:
127  drawing::size default_size() const override {return {13, 25};}
128 
129  void on_back_color_changed(const event_args& e) override {
131  invalidate();
132  }
133 
134  void on_enabled_changed(const event_args& e) override {
136  invalidate();
137  }
138 
139  void on_fore_color_changed(const event_args& e) override {
141  invalidate();
142  }
143 
144  void on_paint(paint_event_args& e) override {
146  if (back_color() != default_back_color()) e.graphics().clear(back_color());
147  if (show_back_segment_) draw_back_digit(e.graphics());
149  if ((value_ & forms::segments::dp) == forms::segments::dp) draw_dp(e.graphics(), color);
150  if ((value_ & forms::segments::pc) == forms::segments::pc) draw_pc(e.graphics(), color);
151  if ((value_ & forms::segments::a) == forms::segments::a) draw_segment_a(e.graphics(), color);
152  if ((value_ & forms::segments::b) == forms::segments::b) draw_segment_b(e.graphics(), color);
153  if ((value_ & forms::segments::c) == forms::segments::c) draw_segment_c(e.graphics(), color);
154  if ((value_ & forms::segments::d) == forms::segments::d) draw_segment_d(e.graphics(), color);
155  if ((value_ & forms::segments::e) == forms::segments::e) draw_segment_e(e.graphics(), color);
156  if ((value_ & forms::segments::f) == forms::segments::f) draw_segment_f(e.graphics(), color);
157  if ((value_ & forms::segments::g) == forms::segments::g) draw_segment_g(e.graphics(), color);
158  }
159 
160  void on_parent_enabled_changed(const event_args& e) override {
162  invalidate();
163  }
164 
165  drawing::size measure_control() const override {
166  return drawing::size((height() - 3) / 2 + 2, height());
167  }
168 
169  void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override {
171  height = (width - 2) * 2 + 3;
172  specified |= bounds_specified::height;
173  }
175  width = (height - 3) / 2 + 2;
176  specified |= bounds_specified::width;
177  }
178  control::set_bounds_core(x, y, width, height, specified);
179  }
180 
181  void set_client_size_core(int32_t width, int32_t height) override {
182  if (client_size_.height() != height)
183  width = (height - 3) / 2 + 2;
184  if (client_size_.width() != width)
185  height = (width - 2) * 2 + 3;
187  }
188 
191  virtual void draw_back_digit(drawing::graphics& graphics) {
193  draw_segment_a(graphics, color);
194  draw_segment_b(graphics, color);
195  draw_segment_c(graphics, color);
196  draw_segment_d(graphics, color);
197  draw_segment_e(graphics, color);
198  draw_segment_f(graphics, color);
199  draw_segment_g(graphics, color);
200  }
201 
205  virtual void draw_segment_a(drawing::graphics& graphics, const drawing::color& color) {
206  if (segment_style_ == segment_style::standard) {
207  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
208  graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + abs(offset), 1 + thickness() / 2 + offset, size_.width() - 3 - thickness() / 2 - abs(offset), 1 + thickness() / 2 + offset);
209  } else if (segment_style_ == segment_style::modern) {
210  for (int32_t offset = 0; offset < thickness(); offset++)
211  graphics.draw_line(drawing::pen(color), 2 + offset, 1 + offset, size_.width() - 3 - offset, 1 + offset);
212  } else if (segment_style_ == segment_style::mixed) {
213  for (int32_t offset = 0; offset < thickness(); offset++)
214  graphics.draw_line(drawing::pen(color), 2 + offset, 1 + offset, size_.width() - 3 - offset, 1 + offset);
215  } else if (segment_style_ == segment_style::expanded) {
216  for (int32_t offset = 0; offset < thickness(); offset++)
217  graphics.draw_line(drawing::pen(color), 2 + offset, 1 + offset, size_.width() - 3 - offset, 1 + offset);
218  } else if (segment_style_ == segment_style::design) {
219  for (int32_t offset = 0; offset < thickness(); offset++)
220  graphics.draw_line(drawing::pen(color), 2 + thickness(), 1 + offset, size_.width() - 3 - thickness(), 1 + offset);
221  } else if (segment_style_ == segment_style::stick) {
222  for (int32_t offset = 0; offset < thickness(); offset++)
223  graphics.draw_line(drawing::pen(color), 2 + thickness(), 1 + offset, size_.width() - 3 - thickness(), 1 + offset);
224  }
225  }
226 
230  virtual void draw_segment_b(drawing::graphics& graphics, const drawing::color& color) {
231  if (segment_style_ == segment_style::standard) {
232  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
233  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, 2 + thickness() / 2 + abs(offset), size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 - 1 - abs(offset));
234  } else if (segment_style_ == segment_style::modern) {
235  for (int32_t offset = 0; offset < thickness(); offset++)
236  graphics.draw_line(drawing::pen(color), size_.width() - 2 - offset, 2 + offset, size_.width() - 2 - offset, size_.height() / 2 - 1 - offset / 2);
237  } else if (segment_style_ == segment_style::mixed) {
238  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
239  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, 2 + offset + thickness() / 2, size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 - 1 - abs(offset));
240  } else if (segment_style_ == segment_style::expanded) {
241  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
242  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, 2 + offset + thickness() / 2, size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 - 1 - (offset > 0 ? offset : 0));
243  } else if (segment_style_ == segment_style::design) {
244  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
245  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, 1, size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 - 1 - (offset > 0 ? offset : 0));
246  } else if (segment_style_ == segment_style::stick) {
247  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
248  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, 1, size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 - 1);
249  }
250  }
251 
255  virtual void draw_segment_c(drawing::graphics& graphics, const drawing::color& color) {
256  if (segment_style_ == segment_style::standard) {
257  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
258  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), size_.width() - 2 - thickness() / 2 - offset, size_.height() - 3 - thickness() / 2 - abs(offset));
259  } else if (segment_style_ == segment_style::modern) {
260  for (int32_t offset = 0; offset < thickness(); offset++)
261  graphics.draw_line(drawing::pen(color), size_.width() - 2 - offset, size_.height() / 2 + 1 + offset / 2, size_.width() - 2 - offset, size_.height() - 3 - offset);
262  } else if (segment_style_ == segment_style::mixed) {
263  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
264  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), size_.width() - 2 - thickness() / 2 - offset, size_.height() - 3 - thickness() / 2 - offset);
265  } else if (segment_style_ == segment_style::expanded) {
266  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
267  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + (offset > 0 ? offset : 0), size_.width() - 2 - thickness() / 2 - offset, size_.height() - 3 - thickness() / 2 - offset);
268  } else if (segment_style_ == segment_style::design) {
269  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
270  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + (offset > 0 ? offset : 0), size_.width() - 2 - thickness() / 2 - offset, size_.height() - 2);
271  } else if (segment_style_ == segment_style::stick) {
272  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
273  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 + 1, size_.width() - 2 - thickness() / 2 - offset, size_.height() - 2);
274  }
275  }
276 
280  virtual void draw_segment_d(drawing::graphics& graphics, const drawing::color& color) {
281  if (segment_style_ == segment_style::standard) {
282  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
283  graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + abs(offset), size_.height() - 2 - thickness() / 2 - offset, size_.width() - 3 - thickness() / 2 - abs(offset), size_.height() - 2 - thickness() / 2 - offset);
284  } else if (segment_style_ == segment_style::modern) {
285  for (int32_t offset = 0; offset < thickness(); offset++)
286  graphics.draw_line(drawing::pen(color), 2 + offset, size_.height() - 2 - offset, size_.width() - 3 - offset, size_.height() - 2 - offset);
287  } else if (segment_style_ == segment_style::mixed) {
288  for (int32_t offset = 0; offset < thickness(); offset++)
289  graphics.draw_line(drawing::pen(color), 2 + offset, size_.height() - 2 - offset, size_.width() - 3 - offset, size_.height() - 2 - offset);
290  } else if (segment_style_ == segment_style::expanded) {
291  for (int32_t offset = 0; offset < thickness(); offset++)
292  graphics.draw_line(drawing::pen(color), 2 + offset, size_.height() - 2 - offset, size_.width() - 3 - offset, size_.height() - 2 - offset);
293  } else if (segment_style_ == segment_style::design) {
294  for (int32_t offset = 0; offset < thickness(); offset++)
295  graphics.draw_line(drawing::pen(color), 2 + thickness(), size_.height() - 2 - offset, size_.width() - 3 - thickness(), size_.height() - 2 - offset);
296  } else if (segment_style_ == segment_style::stick) {
297  for (int32_t offset = 0; offset < thickness(); offset++)
298  graphics.draw_line(drawing::pen(color), 2 + thickness(), size_.height() - 2 - offset, size_.width() - 3 - thickness(), size_.height() - 2 - offset);
299  }
300  }
301 
305  virtual void draw_segment_e(drawing::graphics& graphics, const drawing::color& color) {
306  if (segment_style_ == segment_style::standard) {
307  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
308  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), 1 + thickness() / 2 + offset, size_.height() - 3 - thickness() / 2 - abs(offset));
309  } else if (segment_style_ == segment_style::modern) {
310  for (int32_t offset = 0; offset < thickness(); offset++)
311  graphics.draw_line(drawing::pen(color), 1 + offset, size_.height() / 2 + 1 + offset / 2, 1 + offset, size_.height() - 3 - offset);
312  } else if (segment_style_ == segment_style::mixed) {
313  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
314  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), 1 + thickness() / 2 + offset, size_.height() - 3 - thickness() / 2 - offset);
315  } else if (segment_style_ == segment_style::expanded) {
316  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
317  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + (offset > 0 ? offset : 0), 1 + thickness() / 2 + offset, size_.height() - 3 - thickness() / 2 - offset);
318  } else if (segment_style_ == segment_style::design) {
319  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
320  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + (offset > 0 ? offset : 0), 1 + thickness() / 2 + offset, size_.height() - 2);
321  } else if (segment_style_ == segment_style::stick) {
322  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
323  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, size_.height() / 2 + 1, 1 + thickness() / 2 + offset, size_.height() - 2);
324  }
325  }
326 
330  virtual void draw_segment_f(drawing::graphics& graphics, const drawing::color& color) {
331  if (segment_style_ == segment_style::standard) {
332  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
333  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, 2 + thickness() / 2 + abs(offset), 1 + thickness() / 2 + offset, size_.height() / 2 - 1 - abs(offset));
334  } else if (segment_style_ == segment_style::modern) {
335  for (int32_t offset = 0; offset < thickness(); offset++)
336  graphics.draw_line(drawing::pen(color), 1 + offset, 2 + offset, 1 + offset, size_.height() / 2 - 1 - offset / 2);
337  } else if (segment_style_ == segment_style::mixed) {
338  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
339  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, 2 + thickness() / 2 + offset, 1 + thickness() / 2 + offset, size_.height() / 2 - 1 - abs(offset));
340  } else if (segment_style_ == segment_style::expanded) {
341  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
342  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, 2 + thickness() / 2 + offset, 1 + thickness() / 2 + offset, size_.height() / 2 - 1 - (offset > 0 ? offset : 0));
343  } else if (segment_style_ == segment_style::design) {
344  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
345  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, 1, 1 + thickness() / 2 + offset, size_.height() / 2 - 1 - (offset > 0 ? offset : 0));
346  } else if (segment_style_ == segment_style::stick) {
347  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
348  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, 1, 1 + thickness() / 2 + offset, size_.height() / 2 - 1);
349  }
350  }
351 
355  virtual void draw_segment_g(drawing::graphics& graphics, const drawing::color& color) {
356  if (segment_style_ == segment_style::standard) {
357  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
358  graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + abs(offset), size_.height() / 2 + offset, size_.width() - 3 - thickness() / 2 - abs(offset), size_.height() / 2 + offset);
359  } else if (segment_style_ == segment_style::modern) {
360  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
361  graphics.draw_line(drawing::pen(color), 2 + abs(2 * offset), size_.height() / 2 + offset, size_.width() - 3 - abs(2 * offset), size_.height() / 2 + offset);
362  } else if (segment_style_ == segment_style::mixed) {
363  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
364  graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + abs(offset), size_.height() / 2 + offset, size_.width() - 3 - thickness() / 2 - abs(offset), size_.height() / 2 + offset);
365  } else if (segment_style_ == segment_style::expanded) {
366  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
367  graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + abs(offset), size_.height() / 2 + offset, size_.width() - 3 - thickness() / 2 - abs(offset), size_.height() / 2 + offset);
368  } else if (segment_style_ == segment_style::design) {
369  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
370  graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + abs(offset), size_.height() / 2 + offset, size_.width() - 3 - thickness() / 2 - abs(offset), size_.height() / 2 + offset);
371  } else if (segment_style_ == segment_style::stick) {
372  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
373  graphics.draw_line(drawing::pen(color), 2 + thickness(), size_.height() / 2 + offset, size_.width() - 3 - thickness(), size_.height() / 2 + offset);
374  }
375  }
376 
380  virtual void draw_dp(drawing::graphics& graphics, const drawing::color& color) {
381  if (segment_style_ == segment_style::standard) {
382  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() - 1 - thickness(), thickness(), thickness());
383  } else if (segment_style_ == segment_style::modern) {
384  for (int32_t offset = 0; offset < thickness(); offset++)
385  graphics.draw_line(drawing::pen(color), size_.width() / 2 - thickness() / 2, size_.height() - 2 - offset, size_.width() / 2 + thickness() / 2, size_.height() - 2 - offset);
386  } else if (segment_style_ == segment_style::mixed) {
387  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() - 1 - thickness(), thickness(), thickness());
388  } else if (segment_style_ == segment_style::expanded) {
389  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() - 1 - thickness(), thickness(), thickness());
390  } else if (segment_style_ == segment_style::design) {
391  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() - 1 - thickness(), thickness(), thickness());
392  } else if (segment_style_ == segment_style::stick) {
393  for (int32_t offset = 0; offset < thickness(); offset++)
394  graphics.draw_line(drawing::pen(color), size_.width() / 2 - thickness() / 2, size_.height() - 2 - offset, size_.width() / 2 + thickness() / 2, size_.height() - 2 - offset);
395  }
396  }
397 
401  virtual void draw_pc(drawing::graphics& graphics, const drawing::color& color) {
402  if (segment_style_ == segment_style::standard) {
403  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2, thickness(), thickness());
404  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 * 2 - thickness() / 2, thickness(), thickness());
405  } else if (segment_style_ == segment_style::modern) {
406  for (int32_t offset = 0; offset < thickness(); offset++) {
407  graphics.draw_line(drawing::pen(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2 + offset, size_.width() / 2 + thickness() / 2, size_.height() / 3 - thickness() / 2 + offset);
408  graphics.draw_line(drawing::pen(color), size_.width() / 2 - thickness() / 2, size_.height() /3 * 2 - thickness() / 2 + offset, size_.width() / 2 + thickness() / 2, size_.height() / 3 * 2 - thickness() / 2 + offset);
409  }
410  } else if (segment_style_ == segment_style::mixed) {
411  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2, thickness(), thickness());
412  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 * 2 - thickness() / 2, thickness(), thickness());
413  } else if (segment_style_ == segment_style::expanded) {
414  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2, thickness(), thickness());
415  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 * 2 - thickness() / 2, thickness(), thickness());
416  } else if (segment_style_ == segment_style::design) {
417  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2, thickness(), thickness());
418  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 * 2 - thickness() / 2, thickness(), thickness());
419  } else if (segment_style_ == segment_style::stick) {
420  for (int32_t offset = 0; offset < thickness(); offset++) {
421  graphics.draw_line(drawing::pen(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2 + offset, size_.width() / 2 + thickness() / 2, size_.height() / 3 - thickness() / 2 + offset);
422  graphics.draw_line(drawing::pen(color), size_.width() / 2 - thickness() / 2, size_.height() /3 * 2 - thickness() / 2 + offset, size_.width() / 2 + thickness() / 2, size_.height() / 3 * 2 - thickness() / 2 + offset);
423  }
424  }
425  }
426 
429  bool show_back_segment_ = true;
430  std::optional<drawing::color> back_segment_color_;
431  double back_segment_opacity_ = 0.95;
433  std::optional<int32_t> thickness_;
435  };
436  }
437 }
Contains xtd::argument_out_of_range_exception exception.
The exception that is thrown when one of the arguments provided to a method is out of range.
Definition: argument_out_of_range_exception.h:18
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
static color average(const color &color1, const color &color2, double weight, bool average_alpha)
Returns the weighted average color between the two given colors.
Definition: color.h:592
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:48
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: pen.h:29
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Defines a xtd::drawing::brush of a single color. Brushes are used to fill graphics shapes,...
Definition: solid_brush.h:22
static xtd::drawing::color gray_text()
Gets a system-defined color that has an ARGB value of 0xFFACA899. This field is constant.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Defines the base class for controls, which are components with visual representation.
Definition: control.h:67
virtual drawing::color default_back_color() const
Gets the default background color of the control.
Definition: control.h:393
virtual bool enabled() const
Gets a value indicating whether the control can respond to user interaction.
Definition: control.h:448
virtual drawing::color fore_color() const
Gets the foreground color of the control.
virtual void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified)
Performs the work of setting the specified bounds of this control.
virtual void set_client_size_core(int32_t width, int32_t height)
Sets the size of the client area of the control.
virtual void invalidate() const
Invalidates the entire surface of the control and causes the control to be redrawn.
Definition: control.h:883
virtual bool double_buffered() const
Gets a value indicating whether this control should redraw its surface using a secondary buffer to re...
Definition: control.h:437
virtual int32_t height() const
Gets the height of the control.
Definition: control.h:486
virtual drawing::color back_color() const
Gets the background color for the control.
virtual int32_t width() const
Gets the width of the control.
Definition: control.h:682
Provides data for the paint event.
Definition: paint_event_args.h:26
Represents a seven segment display class.
Definition: seven_segment_display.h:22
virtual void draw_segment_a(drawing::graphics &graphics, const drawing::color &color)
Draw segment a on specified graphics with specified color.
Definition: seven_segment_display.h:205
void on_fore_color_changed(const event_args &e) override
Raises the control::fore_color_changed event.
Definition: seven_segment_display.h:139
virtual void set_segments(forms::segments segment, bool value)
Sets specified xtd::forms::segments combination to on.
Definition: seven_segment_display.h:124
virtual drawing::color back_segment_color()
Gets background segment color.
Definition: seven_segment_display.h:33
virtual double back_segment_opacity() const
Gets the background segment opacity.
Definition: seven_segment_display.h:48
void set_client_size_core(int32_t width, int32_t height) override
Sets the size of the client area of the control.
Definition: seven_segment_display.h:181
void on_paint(paint_event_args &e) override
Raises the control::paint event.
Definition: seven_segment_display.h:144
virtual seven_segment_display & back_segment_opacity(double value)
Sets the background segment opacity.
Definition: seven_segment_display.h:53
virtual seven_segment_display & back_segment_color(const drawing::color &value)
Sets background segment color.
Definition: seven_segment_display.h:38
drawing::size measure_control() const override
Measure this control.
Definition: seven_segment_display.h:165
virtual seven_segment_display & segment_style(forms::segment_style value)
Sets segment style.
Definition: seven_segment_display.h:82
virtual void draw_segment_d(drawing::graphics &graphics, const drawing::color &color)
Draw segment d on specified graphics with specified color.
Definition: seven_segment_display.h:280
virtual void draw_segment_b(drawing::graphics &graphics, const drawing::color &color)
Draw segment b on specified graphics with specified color.
Definition: seven_segment_display.h:230
void on_back_color_changed(const event_args &e) override
Raises the control::back_color_changed event.
Definition: seven_segment_display.h:129
virtual bool get_segments(forms::segments segment) const
Gets if specified xtd::forms::segments combination is on.
Definition: seven_segment_display.h:120
virtual seven_segment_display & show_back_segment(bool value)
Sets a value indicate if background segments are shown.
Definition: seven_segment_display.h:68
virtual void draw_segment_g(drawing::graphics &graphics, const drawing::color &color)
Draw segment g on specified graphics with specified color.
Definition: seven_segment_display.h:355
void on_parent_enabled_changed(const event_args &e) override
Raises the xtd::control::enabled_changed event when the xtd::control::enabled property value of the c...
Definition: seven_segment_display.h:160
virtual void draw_dp(drawing::graphics &graphics, const drawing::color &color)
Draw segment dot point on specified graphics with specified color.
Definition: seven_segment_display.h:380
virtual void draw_pc(drawing::graphics &graphics, const drawing::color &color)
Draw segment punctuation colon on specified graphics with specified color.
Definition: seven_segment_display.h:401
virtual void draw_segment_c(drawing::graphics &graphics, const drawing::color &color)
Draw segment c on specified graphics with specified color.
Definition: seven_segment_display.h:255
virtual forms::segments value() const
Gets seven_segment_display value.
Definition: seven_segment_display.h:106
virtual forms::segment_style segment_style() const
Gets segment style.
Definition: seven_segment_display.h:78
drawing::size default_size() const override
Gets the default size of the control.
Definition: seven_segment_display.h:127
virtual bool show_back_segment() const
Gets a value indicate if background segments are shown.
Definition: seven_segment_display.h:64
virtual seven_segment_display & value(forms::segments value)
Sets seven_segment_display value.
Definition: seven_segment_display.h:110
virtual seven_segment_display & thickness(int32_t value)
Sets thickness of segment.
Definition: seven_segment_display.h:96
seven_segment_display()
Initialize a new instance of seven_segment_display class.
Definition: seven_segment_display.h:25
void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override
Performs the work of setting the specified bounds of this control.
Definition: seven_segment_display.h:169
virtual void draw_segment_e(drawing::graphics &graphics, const drawing::color &color)
Draw segment e on specified graphics with specified color.
Definition: seven_segment_display.h:305
void on_enabled_changed(const event_args &e) override
Raises the control::enabled_changed event.
Definition: seven_segment_display.h:134
virtual void draw_back_digit(drawing::graphics &graphics)
Draw all background digit on specified graphics.
Definition: seven_segment_display.h:191
virtual void draw_segment_f(drawing::graphics &graphics, const drawing::color &color)
Draw segment f on specified graphics with specified color.
Definition: seven_segment_display.h:330
virtual int32_t thickness() const
Gets thickness of segment.
Definition: seven_segment_display.h:92
Contains xtd::forms::control control.
virtual void on_back_color_changed(const event_args &e)
Raises the control::back_color_changed event.
virtual void on_paint(paint_event_args &e)
Raises the control::paint event.
virtual void on_enabled_changed(const event_args &e)
Raises the control::enabled_changed event.
virtual void on_fore_color_changed(const event_args &e)
Raises the control::fore_color_changed event.
virtual void on_parent_enabled_changed(const event_args &e)
Raises the xtd::control::enabled_changed event when the xtd::control::enabled property value of the c...
#define current_stack_frame_
Provides information about the current stack frame.
Definition: stack_frame.h:201
@ y
The Y key.
@ x
The X key.
@ e
The E key.
bounds_specified
Specifies the bounds of the control to use when defining a control's size and position....
Definition: bounds_specified.h:18
segment_style
Represent segment style used by seven_segment_display, fourteen_segment_display, nine_segment_display...
Definition: segment_style.h:17
segments
Specifies how a control anchors to the edges of its container.
Definition: segments.h:19
@ height
Specifies that the height of the control is defined.
@ width
Specifies that the width of the control is defined.
@ expanded
Expanded segment style.
@ mixed
Mixed (mix between standard and modern) segment style.
@ design
Design segment style.
@ stick
Stick segment style.
@ modern
Modern segment style.
@ standard
Standard segment style.
@ a
The a segment.
@ c
The c segment.
@ d
The d segment.
@ f
The f segment.
@ b
The b segment.
@ dp
The dp segment (dot point).
@ g
The g segment.
@ pc
The cp segment (punctuation colon).
@ e
The e segment.
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
Contains xtd::forms::segment_style enum class.
Contains xtd::forms::segments enum class.
Contains xtd::drawing::system_colors factory.