summaryrefslogtreecommitdiff
path: root/ElmSharp.Test/TC/RadioTest1.cs
blob: cbb1b9ac1d11ae7bc31a0017ad338f56894144ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ElmSharp.Test
{
    class RadioTest1 : TestCaseBase
    {
        public override string TestName => "RadioTest1";
        public override string TestDescription => "To test basic operation of Radio";

        Label _lb1;

        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);
            conformant.Show();
            Box box = new Box(window);
            conformant.SetContent(box);
            box.Show();

            Radio rd1 = new Radio(window)
            {
                StateValue = 1,
                Text = "<span color=#ffffff>Value #1</span>",
                AlignmentX = -1,
                AlignmentY = 0,
                WeightX = 1,
                WeightY = 1
            };
            Radio rd2 = new Radio(window)
            {
                StateValue = 2,
                Text = "<span color=#ffffff>Value #2</span>",
                AlignmentX = -1,
                AlignmentY = 0,
                WeightX = 1,
                WeightY = 1
            };
            Radio rd3 = new Radio(window)
            {
                StateValue = 3,
                Text = "<span color=#ffffff>Value #3</span>",
                AlignmentX = -1,
                AlignmentY = 0,
                WeightX = 1,
                WeightY = 1
            };
            rd2.SetGroup(rd1);
            rd3.SetGroup(rd2);

            rd1.ValueChanged += OnRadioValueChanged;
            rd2.ValueChanged += OnRadioValueChanged;
            rd3.ValueChanged += OnRadioValueChanged;

            _lb1 = new Label(window)
            {
                AlignmentX = -1,
                AlignmentY = 0,
                WeightX = 1,
                WeightY = 1
            };

            box.PackEnd(_lb1);
            box.PackEnd(rd1);
            box.PackEnd(rd2);
            box.PackEnd(rd3);

            _lb1.Show();
            rd1.Show();
            rd2.Show();
            rd3.Show();
        }

        void OnRadioValueChanged(object sender, EventArgs e)
        {
            _lb1.Text = string.Format("Value Changed: {0}", ((Radio)sender).GroupValue);
            _lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'";
        }
    }
}