Introducing Chart Controls in Automate API

PRESS BUTTON - TO RUN MORE THAN ONE EVENT

//-----------------------------------------------------------
//           PRESS BUTTON - TO  RUN MORE THAN ONE EVENT
//-----------------------------------------------------------

// ---------- This to be added just before protected override void Initialize() and OnStart()  below The Declaration of supplementary objects and variables Area.

        int x =0;

        public event Action On;
        public event Action Off;

//-----------------------------------------------------------
//----------- This code must be added Only to - protected override void Initialize() and OnStart() otherwise freezes - for good reason..
            var buttonStyle = new Style();
            buttonStyle.Set(ControlProperty.BackgroundColor, Color.Red, ControlState.DarkTheme);
            buttonStyle.Set(ControlProperty.BackgroundColor, Color.Green, ControlState.DarkTheme | ControlState.Checked);
            var checkBox = new CheckBox 
            {
                Style = buttonStyle,
                Width = 50,
                Height = 200,
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Right,
                Margin = 5,
                Padding = "10 4 10 4"
            };
            checkBox.Checked += args => On.Invoke();
            On += () =>
            {
                x = 2;
                if (x == 2)
                    Chart.DrawStaticText("NOTES3", "\nHELLO ", VerticalAlignment.Top, HorizontalAlignment.Center, Color.White);
//-----------write your code. for when the button is clicked on, and turns Green.
            };

            checkBox.Unchecked += args => Off.Invoke();
            Off += () =>
            {
                x = 3;
                if (x == 3)
                    Chart.DrawStaticText("NOTES3", "\nGOODBYE ", VerticalAlignment.Top, HorizontalAlignment.Center, Color.White);
//-----------write your code. for when the button is clicked Off, and turns Red.
//-----------Please note .. you can only use the variables here,  x is only 3 while here, and will not change in your main program, when the button is pressed.
            };

 Chart.AddControl(checkBox);