Skip to content

ApplicationDraggable

Summary

Represents a draggable box that can host a control and shown over application.

Signature

1
public abstract interface ApplicationDraggable

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 [Robot(AccessRights = AccessRights.None)]
 public class TestExample : Robot
 {
    private const string Label = "Draggable";
    protected override void OnStart()
    {
        var openPositionButton = new Button {Text = "Open Position"};
        openPositionButton.Click += _ => ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, Label);
        var closePositionsButton = new Button {Text = "Close Position"};
        closePositionsButton.Click += _ => Positions.Find(Label)?.Close();
        var panel = new StackPanel {Orientation = Orientation.Vertical, BackgroundColor = Color.Red};
        panel.AddChild(openPositionButton);
        panel.AddChild(closePositionsButton);
        var draggable = Application.Draggables.Add();
        draggable.ShowGrip = true;
        draggable.Child = panel;
        draggable.LocationChanged += args => Print($"Draggable Location Changed: {args.Draggable.X}, {args.Draggable.Y}");
    }
 }
 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
 import clr
 clr.AddReference("cAlgo.API")
 # Import cAlgo API types
 from cAlgo.API import *
 # Import trading wrapper functions
 from robot_wrapper import *
 from System import Action
 class Test():
     Label = "Draggable"
     def on_start(self):
         openPositionButton = Button()
         openPositionButton.Text = "Open Position"    
         openPositionButton.Click += self.open_position
         closePositionsButton = Button()
         closePositionsButton.Text = "Close Position"
         closePositionsButton.Click += self.close_position
         panel = StackPanel()
         panel.Orientation = Orientation.Vertical
         panel.BackgroundColor = Color.Red
         panel.AddChild(openPositionButton)
         panel.AddChild(closePositionsButton)
         draggable = api.Application.Draggables.Add()
         draggable.ShowGrip = True
         draggable.Child = panel
         draggable.LocationChanged += lambda args: print(f"Draggable Location Changed: {args.Draggable.X}, {args.Draggable.Y}")
     def open_position(self, args):
         api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, api.Symbol.VolumeInUnitsMin, self.Label)
     def close_position(self, args):
         position = api.Positions.Find(self.Label)
         if position is not None:
             position.Close()

See Also

Properties

Id

Summary

Get unique ID of the Draggable.

Signature

1
public abstract string Id {get;}

Return Value

string

Child

Summary

Get / set the content control inside the draggable.

Signature

1
public abstract ControlBase Child {get; set;}

Return Value

ControlBase

X

Summary

Get / set X coordinate (default: 0).

Signature

1
public abstract double X {get; set;}

Return Value

double

Y

Summary

Get / set Y coordinate (default: 0).

Signature

1
public abstract double Y {get; set;}

Return Value

double

ShowGrip

Summary

Get / set move grip visibility (default: true).

Signature

1
public abstract bool ShowGrip {get; set;}

Return Value

bool

IsVisible

Summary

Get / set visibility of draggable.

Signature

1
public abstract bool IsVisible {get; set;}

Return Value

bool

Events

LocationChanged

Summary

Occurs when the draggable's location is changed.

Signature

1
public abstract event Action<ApplicationDraggableLocationChangedEventArgs> LocationChanged;