Skip to content

ColorPicker

Summary

Represents the ColorPicker control.

Signature

1
public class ColorPicker : ControlBase

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 using cAlgo.API;
 namespace cAlgo.Robots;
 [Robot(AccessRights = AccessRights.None)]
 public class TestExample : Robot
 {
    protected override void OnStart()
    {
        var colorPicker = new ColorPicker {SelectedColor = Color.FromHex("#eb4034"), IsStretched = true};
        var hexColorTextBox = new TextBox {Text = "#eb4034"};
        colorPicker.SelectedColorChanged += args => hexColorTextBox.Text = colorPicker.SelectedColor.ToHexString();
        var changeColorButton = new Button {Text = "Change Color"};
        changeColorButton.Click += args => colorPicker.SelectedColor = Color.FromHex(hexColorTextBox.Text);
        var panel = new StackPanel 
        {
             Orientation = Orientation.Vertical,
             HorizontalAlignment = HorizontalAlignment.Center,
             VerticalAlignment = VerticalAlignment.Center
        };
        panel.AddChild(colorPicker);
        panel.AddChild(hexColorTextBox);
        panel.AddChild(changeColorButton);
        Chart.AddControl(panel);
    }
 }
 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
 import clr
 clr.AddReference("cAlgo.API")
 # Import cAlgo API types
 from cAlgo.API import *
 # Import trading wrapper functions
 from robot_wrapper import *
 class Test():
     def on_start(self):
         self.colorPicker = ColorPicker()
         self.colorPicker.SelectedColor = Color.FromHex("#eb4034")
         self.colorPicker.IsStretched = True
         self.hexColorTextBox = TextBox()
         self.hexColorTextBox.Text = "#eb4034"
         self.colorPicker.SelectedColorChanged += self.on_selected_color_changed
         changeColorButton = Button()
         changeColorButton.Text = "Change Color"
         changeColorButton.Click += self.on_change_color_button_clicked
         panel = StackPanel()
         panel.Orientation = Orientation.Vertical
         panel.HorizontalAlignment = HorizontalAlignment.Center
         panel.VerticalAlignment = VerticalAlignment.Center
         panel.AddChild(self.colorPicker)
         panel.AddChild(self.hexColorTextBox)
         panel.AddChild(changeColorButton)
         api.Chart.AddControl(panel)
     def on_selected_color_changed(self, args):
         self.hexColorTextBox.Text = args.ColorPicker.SelectedColor.ToHexString()
     def on_change_color_button_clicked(self, args):
         self.colorPicker.SelectedColor = Color.FromHex(self.hexColorTextBox.Text)

Methods

RaiseSelectedColorChanged

Signature

1
internal void RaiseSelectedColorChanged(Color newSelectedColor)

Parameters

Name Type Description
newSelectedColor Color

Return Value

void

Accept

Signature

1
internal void Accept(IChartControlVisitor visitor)

Parameters

Name Type Description
visitor IChartControlVisitor

Return Value

void

Properties

SelectedColor

Summary

Gets or sets selected color.

Signature

1
public Color SelectedColor {get; set;}

Return Value

Color

IsStretched

Summary

Gets or sets if color picker is stretched or not.

Signature

1
public bool IsStretched {get; set;}

Return Value

bool

Events

SelectedColorChanged

Summary

Occurs when selected color is changed.

Signature

1
public event Action<ColorPickerSelectedColorChangedEventArgs> SelectedColorChanged;