Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ImageButton.cs
1using Microsoft.Maui.Controls.Shapes;
3using PathShape = Microsoft.Maui.Controls.Shapes.Path;
4
6{
7 public class ImageButton : TemplatedButton, IBorderDataElement, IPathDataElement
8 {
9 private readonly Border innerBorder;
10 private readonly PathShape innerPath;
11
13 public static readonly BindableProperty BorderStyleProperty = BorderDataElement.BorderStyleProperty;
14
16 public static readonly BindableProperty PathDataProperty = PathDataElement.PathDataProperty;
17
19 public static readonly BindableProperty PathStyleProperty = PathDataElement.PathStyleProperty;
20
21 public void OnBorderStylePropertyChanged(Style OldValue, Style NewValue)
22 {
23 this.innerBorder.Style = NewValue;
24 }
25
26 public void OnPathDataPropertyChanged(Geometry OldValue, Geometry NewValue)
27 {
28 this.innerPath.Data = NewValue;
29 }
30
31 public void OnPathStylePropertyChanged(Style OldValue, Style NewValue)
32 {
33 this.innerPath.Style = NewValue;
34 }
35
36 public Geometry PathData
37 {
38 get => (Geometry)this.GetValue(PathDataElement.PathDataProperty);
39 set => this.SetValue(PathDataElement.PathDataProperty, value);
40 }
41
42 public Style BorderStyle
43 {
44 get => (Style)this.GetValue(BorderDataElement.BorderStyleProperty);
45 set => this.SetValue(BorderDataElement.BorderStyleProperty, value);
46 }
47
48 public Style PathStyle
49 {
50 get => (Style)this.GetValue(PathDataElement.PathStyleProperty);
51 set => this.SetValue(PathDataElement.PathStyleProperty, value);
52 }
53
54 public ImageButton()
55 : base()
56 {
57 this.innerPath = new()
58 {
59 HeightRequest = 24,
60 WidthRequest = 24,
61 Aspect = Stretch.Uniform,
62 Style = this.PathStyle
63 };
64
65 this.innerBorder = new()
66 {
67 StrokeThickness = 2,
68 Content = this.innerPath,
69 Style = this.BorderStyle
70 };
71
72 this.Content = this.innerBorder;
73 }
74 }
75}
static readonly BindableProperty BorderStyleProperty
Bindable property for BorderStyle.
Definition: ImageButton.cs:13
static readonly BindableProperty PathDataProperty
Bindable property for PathData.
Definition: ImageButton.cs:16
static readonly BindableProperty PathStyleProperty
Bindable property for PathStyle.
Definition: ImageButton.cs:19
TemplatedButton represents a generalization of a Button whose appearance is defined by a ControlTempl...