xtd.forms - Reference Guide  0.1.0
Modern c++17 library containing classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows, Apple macOS and Linux like Ubuntu operating system.
seven_segment_display.h
1 #pragma once
2 #include "control.h"
3 #include "segments.h"
4 #include "segment_style.h"
5 
6 namespace xtd {
7  namespace forms {
9  class seven_segment_display : public control {
10  public:
12  double_buffered(true);
13  size_ = default_size();
14  }
15 
16  virtual drawing::color background_segment_color() {return background_segment_color_.value_or(drawing::color::average(fore_color(), back_color(), background_segment_transparency_));}
17  virtual seven_segment_display& background_segment_color(const drawing::color& value) {
18  if (!background_segment_color_.has_value() || background_segment_color_.value() != value) {
19  background_segment_color_ = value;
20  invalidate();
21  }
22  return *this;
23  }
24 
25  virtual double background_segment_transparency() const {return background_segment_transparency_;}
26  virtual seven_segment_display& background_segment_transparency(double value) {
27  if (background_segment_transparency_ != value) {
28  background_segment_transparency_ = value;
29  invalidate();
30  }
31  return *this;
32  }
33 
34  virtual bool show_background_segment() const {return show_background_segment_;}
35  virtual seven_segment_display& show_background_segment(bool value) {
36  if (show_background_segment_ != value) {
37  show_background_segment_ = value;
38  invalidate();
39  }
40  return *this;
41  }
42 
43  virtual forms::segments value() const {return value_;}
45  if (value_ != segments) {
46  value_ = segments;
47  invalidate();
48  }
49  return *this;
50  }
51 
52  virtual forms::segment_style segment_style() const {return segment_style_;}
53  virtual seven_segment_display& segment_style(forms::segment_style value) {
54  if (segment_style_ != value) {
55  segment_style_ = value;
56  invalidate();
57  }
58  return *this;
59  }
60 
61  virtual int32_t thickness() const {return thickness_.value_or(size_.height() < 10 ? 1 : (size_.height() / 10 + ((size_.height() / 10) % 2 ? 0 : 1)));}
62  virtual seven_segment_display& thickness(int32_t value) {
63  if (!thickness_.has_value() || thickness_.value() != value) {
64  thickness_ = value;
65  invalidate();
66  }
67  return *this;
68  }
69 
70  virtual bool get_segments(forms::segments segment) const {return (value_ & segment) == segment;}
71  virtual void set_segments(forms::segments segment, bool value) { value_ = value ? (value_ | segment) : (value_ & ~segment); }
72 
73  protected:
74  drawing::size default_size() const override {return {13, 25};}
75 
76  void on_paint(paint_event_args& e) override {
77  drawing::graphics graphics = e.graphics();
78  graphics.clear(back_color());
79  if (show_background_segment_ && value_ != forms::segments::dp && value_ != forms::segments::pc) draw_background_digit(graphics);
80  if ((value_ & forms::segments::dp) == forms::segments::dp) draw_dp(graphics, fore_color());
81  if ((value_ & forms::segments::pc) == forms::segments::pc) draw_pc(graphics, fore_color());
82  if ((value_ & forms::segments::a) == forms::segments::a) draw_segment_a(graphics, fore_color());
83  if ((value_ & forms::segments::b) == forms::segments::b) draw_segment_b(graphics, fore_color());
84  if ((value_ & forms::segments::c) == forms::segments::c) draw_segment_c(graphics, fore_color());
85  if ((value_ & forms::segments::d) == forms::segments::d) draw_segment_d(graphics, fore_color());
86  if ((value_ & forms::segments::e) == forms::segments::e) draw_segment_e(graphics, fore_color());
87  if ((value_ & forms::segments::f) == forms::segments::f) draw_segment_f(graphics, fore_color());
88  if ((value_ & forms::segments::g) == forms::segments::g) draw_segment_g(graphics, fore_color());
89  }
90 
91  drawing::size measure_control() const override {
92  return drawing::size((height() - 3) / 2 + 2, height());
93  }
94 
95  void set_bounds_core(int32_t x, int32_t y, int32_t width, int32_t height, bounds_specified specified) override {
97  height = (width - 2) * 2 + 3;
98  specified |= bounds_specified::height;
99  }
100  if ((specified & bounds_specified::height) == forms::bounds_specified::height) {
101  width = (height - 3) / 2 + 2;
102  specified |= bounds_specified::width;
103  }
104  control::set_bounds_core(x, y, width, height, specified);
105  }
106 
107  void set_client_size_core(int32_t width, int32_t height) override {
108  if (client_size_.height() != height)
109  width = (height - 3) / 2 + 2;
110  if (client_size_.width() != width)
111  height = (width - 2) * 2 + 3;
112  control::set_client_size_core(width, height);
113  }
114 
115  virtual void draw_background_digit(drawing::graphics& graphics) {
116  draw_segment_a(graphics, background_segment_color());
117  draw_segment_b(graphics, background_segment_color());
118  draw_segment_c(graphics, background_segment_color());
119  draw_segment_d(graphics, background_segment_color());
120  draw_segment_e(graphics, background_segment_color());
121  draw_segment_f(graphics, background_segment_color());
122  draw_segment_g(graphics, background_segment_color());
123  }
124 
125  virtual void draw_segment_a(drawing::graphics& graphics, const drawing::color& color) {
126  if (segment_style_ == segment_style::standard) {
127  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
128  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);
129  } else if (segment_style_ == segment_style::modern) {
130  for (int32_t offset = 0; offset < thickness(); offset++)
131  graphics.draw_line(drawing::pen(color), 2 + offset, 1 + offset, size_.width() - 3 - offset, 1 + offset);
132  } else if (segment_style_ == segment_style::mixed) {
133  for (int32_t offset = 0; offset < thickness(); offset++)
134  graphics.draw_line(drawing::pen(color), 2 + offset, 1 + offset, size_.width() - 3 - offset, 1 + offset);
135  } else if (segment_style_ == segment_style::expanded) {
136  for (int32_t offset = 0; offset < thickness(); offset++)
137  graphics.draw_line(drawing::pen(color), 2 + offset, 1 + offset, size_.width() - 3 - offset, 1 + offset);
138  } else if (segment_style_ == segment_style::design) {
139  for (int32_t offset = 0; offset < thickness(); offset++)
140  graphics.draw_line(drawing::pen(color), 2 + thickness(), 1 + offset, size_.width() - 3 - thickness(), 1 + offset);
141  } else if (segment_style_ == segment_style::stick) {
142  for (int32_t offset = 0; offset < thickness(); offset++)
143  graphics.draw_line(drawing::pen(color), 2 + thickness(), 1 + offset, size_.width() - 3 - thickness(), 1 + offset);
144  }
145  }
146 
147  virtual void draw_segment_b(drawing::graphics& graphics, const drawing::color& color) {
148  if (segment_style_ == segment_style::standard) {
149  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
150  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));
151  } else if (segment_style_ == segment_style::modern) {
152  for (int32_t offset = 0; offset < thickness(); offset++)
153  graphics.draw_line(drawing::pen(color), size_.width() - 2 - offset, 2 + offset, size_.width() - 2 - offset, size_.height() / 2 - 1 - offset / 2);
154  } else if (segment_style_ == segment_style::mixed) {
155  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
156  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));
157  } else if (segment_style_ == segment_style::expanded) {
158  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
159  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));
160  } else if (segment_style_ == segment_style::design) {
161  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
162  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));
163  } else if (segment_style_ == segment_style::stick) {
164  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
165  graphics.draw_line(drawing::pen(color), size_.width() - 2 - thickness() / 2 - offset, 1, size_.width() - 2 - thickness() / 2 - offset, size_.height() / 2 - 1);
166  }
167  }
168 
169  virtual void draw_segment_c(drawing::graphics& graphics, const drawing::color& color) {
170  if (segment_style_ == segment_style::standard) {
171  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
172  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));
173  } else if (segment_style_ == segment_style::modern) {
174  for (int32_t offset = 0; offset < thickness(); offset++)
175  graphics.draw_line(drawing::pen(color), size_.width() - 2 - offset, size_.height() / 2 + 1 + offset / 2, size_.width() - 2 - offset, size_.height() - 3 - offset);
176  } else if (segment_style_ == segment_style::mixed) {
177  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
178  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);
179  } else if (segment_style_ == segment_style::expanded) {
180  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
181  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);
182  } else if (segment_style_ == segment_style::design) {
183  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
184  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);
185  } else if (segment_style_ == segment_style::stick) {
186  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
187  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);
188  }
189  }
190 
191  virtual void draw_segment_d(drawing::graphics& graphics, const drawing::color& color) {
192  if (segment_style_ == segment_style::standard) {
193  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
194  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);
195  } else if (segment_style_ == segment_style::modern) {
196  for (int32_t offset = 0; offset < thickness(); offset++)
197  graphics.draw_line(drawing::pen(color), 2 + offset, size_.height() - 2 - offset, size_.width() - 3 - offset, size_.height() - 2 - offset);
198  } else if (segment_style_ == segment_style::mixed) {
199  for (int32_t offset = 0; offset < thickness(); offset++)
200  graphics.draw_line(drawing::pen(color), 2 + offset, size_.height() - 2 - offset, size_.width() - 3 - offset, size_.height() - 2 - offset);
201  } else if (segment_style_ == segment_style::expanded) {
202  for (int32_t offset = 0; offset < thickness(); offset++)
203  graphics.draw_line(drawing::pen(color), 2 + offset, size_.height() - 2 - offset, size_.width() - 3 - offset, size_.height() - 2 - offset);
204  } else if (segment_style_ == segment_style::design) {
205  for (int32_t offset = 0; offset < thickness(); offset++)
206  graphics.draw_line(drawing::pen(color), 2 + thickness(), size_.height() - 2 - offset, size_.width() - 3 - thickness(), size_.height() - 2 - offset);
207  } else if (segment_style_ == segment_style::stick) {
208  for (int32_t offset = 0; offset < thickness(); offset++)
209  graphics.draw_line(drawing::pen(color), 2 + thickness(), size_.height() - 2 - offset, size_.width() - 3 - thickness(), size_.height() - 2 - offset);
210  }
211  }
212 
213  virtual void draw_segment_e(drawing::graphics& graphics, const drawing::color& color) {
214  if (segment_style_ == segment_style::standard) {
215  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
216  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));
217  } else if (segment_style_ == segment_style::modern) {
218  for (int32_t offset = 0; offset < thickness(); offset++)
219  graphics.draw_line(drawing::pen(color), 1 + offset, size_.height() / 2 + 1 + offset / 2, 1 + offset, size_.height() - 3 - offset);
220  } else if (segment_style_ == segment_style::mixed) {
221  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
222  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);
223  } else if (segment_style_ == segment_style::expanded) {
224  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
225  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);
226  } else if (segment_style_ == segment_style::design) {
227  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
228  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);
229  } else if (segment_style_ == segment_style::stick) {
230  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
231  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, size_.height() / 2 + 1, 1 + thickness() / 2 + offset, size_.height() - 2);
232  }
233  }
234 
235  virtual void draw_segment_f(drawing::graphics& graphics, const drawing::color& color) {
236  if (segment_style_ == segment_style::standard) {
237  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
238  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));
239  } else if (segment_style_ == segment_style::modern) {
240  for (int32_t offset = 0; offset < thickness(); offset++)
241  graphics.draw_line(drawing::pen(color), 1 + offset, 2 + offset, 1 + offset, size_.height() / 2 - 1 - offset / 2);
242  } else if (segment_style_ == segment_style::mixed) {
243  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
244  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, 2 + thickness() / 2 + offset, 1 + thickness() / 2 + offset, size_.height() / 2 - 1 - abs(offset));
245  } else if (segment_style_ == segment_style::expanded) {
246  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
247  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));
248  } else if (segment_style_ == segment_style::design) {
249  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
250  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, 1, 1 + thickness() / 2 + offset, size_.height() / 2 - 1 - (offset > 0 ? offset : 0));
251  } else if (segment_style_ == segment_style::stick) {
252  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
253  graphics.draw_line(drawing::pen(color), 1 + thickness() / 2 + offset, 1, 1 + thickness() / 2 + offset, size_.height() / 2 - 1);
254  }
255  }
256 
257  virtual void draw_segment_g(drawing::graphics& graphics, const drawing::color& color) {
258  if (segment_style_ == segment_style::standard) {
259  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
260  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);
261  } else if (segment_style_ == segment_style::modern) {
262  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
263  graphics.draw_line(drawing::pen(color), 2 + abs(2 * offset), size_.height() / 2 + offset, size_.width() - 3 - abs(2 * offset), size_.height() / 2 + offset);
264  } else if (segment_style_ == segment_style::mixed) {
265  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
266  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);
267  } else if (segment_style_ == segment_style::expanded) {
268  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
269  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);
270  } else if (segment_style_ == segment_style::design) {
271  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
272  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);
273  } else if (segment_style_ == segment_style::stick) {
274  for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
275  graphics.draw_line(drawing::pen(color), 2 + thickness(), size_.height() / 2 + offset, size_.width() - 3 - thickness(), size_.height() / 2 + offset);
276  }
277  }
278 
279  virtual void draw_dp(drawing::graphics& graphics, const drawing::color& color) {
280  if (segment_style_ == segment_style::standard) {
281  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() - 1 - thickness(), thickness(), thickness());
282  } else if (segment_style_ == segment_style::modern) {
283  for (int32_t offset = 0; offset < thickness(); offset++)
284  graphics.draw_line(drawing::pen(color), size_.width() / 2 - thickness() / 2, size_.height() - 2 - offset, size_.width() / 2 + thickness() / 2, size_.height() - 2 - offset);
285  } else if (segment_style_ == segment_style::mixed) {
286  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() - 1 - thickness(), thickness(), thickness());
287  } else if (segment_style_ == segment_style::expanded) {
288  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() - 1 - thickness(), thickness(), thickness());
289  } else if (segment_style_ == segment_style::design) {
290  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() - 1 - thickness(), thickness(), thickness());
291  } else if (segment_style_ == segment_style::stick) {
292  for (int32_t offset = 0; offset < thickness(); offset++)
293  graphics.draw_line(drawing::pen(color), size_.width() / 2 - thickness() / 2, size_.height() - 2 - offset, size_.width() / 2 + thickness() / 2, size_.height() - 2 - offset);
294  }
295  }
296 
297  virtual void draw_pc(drawing::graphics& graphics, const drawing::color& color) {
298  if (segment_style_ == segment_style::standard) {
299  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2, thickness(), thickness());
300  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 * 2 - thickness() / 2, thickness(), thickness());
301  } else if (segment_style_ == segment_style::modern) {
302  for (int32_t offset = 0; offset < thickness(); offset++) {
303  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);
304  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);
305  }
306  } else if (segment_style_ == segment_style::mixed) {
307  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2, thickness(), thickness());
308  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 * 2 - thickness() / 2, thickness(), thickness());
309  } else if (segment_style_ == segment_style::expanded) {
310  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2, thickness(), thickness());
311  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 * 2 - thickness() / 2, thickness(), thickness());
312  } else if (segment_style_ == segment_style::design) {
313  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 - thickness() / 2, thickness(), thickness());
314  graphics.fill_ellipse(drawing::solid_brush(color), size_.width() / 2 - thickness() / 2, size_.height() / 3 * 2 - thickness() / 2, thickness(), thickness());
315  } else if (segment_style_ == segment_style::stick) {
316  for (int32_t offset = 0; offset < thickness(); offset++) {
317  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);
318  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);
319  }
320  }
321  }
322 
325  bool show_background_segment_ = true;
326  std::optional<drawing::color> background_segment_color_;
327  double background_segment_transparency_ = 0.05;
328  forms::segment_style segment_style_ = forms::segment_style::standard;
329  std::optional<int32_t> thickness_;
331  };
332  }
333 }
Specifies that both the width and height property values of the control are defined.
The dp segment (dot point).
virtual drawing::color back_color() const
Gets the background color for the control.
Definition: control.h:221
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Specifies that the height of the control is defined.
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:95
virtual void set_client_size_core(int32_t width, int32_t height)
Sets the size of the client area of the control.
segments
Specifies how a control anchors to the edges of its container.
Definition: segments.h:11
Specifies that the width of the control is defined.
Definition: paint_event_args.h:15
Specifies that the left edge of the control is defined.
Specifies that the top edge of the control is defined.
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:107
drawing::size measure_control() const override
Measure this control.
Definition: seven_segment_display.h:91
Defines the base class for controls, which are components with visual representation.
Definition: control.h:59
static color average(const color &color1, const color &color2, double weight)
bounds_specified
Specifies the bounds of the control to use when defining a control&#39;s size and position.
Definition: bounds_specified.h:10
represent a seven segment display class
Definition: seven_segment_display.h:9
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.
The cp segment (punctuation colon).