Skip to content

DropZone

Summary

Represents the DropZone control that can be used as a file(s) input.

Signature

1
public class DropZone : 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
25
26
27
28
29
30
31
32
33
 using cAlgo.API;
 namespace cAlgo.Robots;
 [Robot(AccessRights = AccessRights.None)]
 public class TestExample : Robot
 {
     protected override void OnStart()
     {
         var dropZone = new DropZone
         {
             Child = new TextBlock
             {
                 Text = "Drop / Select Files and Directories",
                 BackgroundColor = Color.Blue,
                 Height = 200,
                 Width = 350,
             },
             IsDirectoryDropAllowed = true,
             // Only these extensions will be accepted
             FilterExtensions = new[] { "txt", "algo", "cs" },
             HorizontalAlignment = HorizontalAlignment.Center,
             VerticalAlignment = VerticalAlignment.Center,
         };
         dropZone.Dropped += args =>
         {
             // Here you can access the dropped files and directories, open, read, etc...
             foreach (var path in args.FilePaths)
             {
                 Print($"File or directory '{path}' dropped");
             }
         };
         Chart.AddControl(dropZone);
     }
 }
 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
 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):
         dropZone = DropZone()
         dropZoneChild = TextBlock()
         dropZoneChild.Text = "Drop / Select Files and Directories"
         dropZoneChild.BackgroundColor = Color.Blue
         dropZoneChild.Height = 200
         dropZoneChild.Width = 350
         dropZone.Child = dropZoneChild
         dropZone.IsDirectoryDropAllowed = True
         # Only these extensions will be accepted
         dropZone.FilterExtensions = ["txt", "algo", "cs"]
         dropZone.HorizontalAlignment = HorizontalAlignment.Center
         dropZone.VerticalAlignment = VerticalAlignment.Center
         dropZone.Dropped += self.on_dropped
         api.Chart.AddControl(dropZone)
     def on_dropped(self, args):
         # Here you can access the dropped files and directories, open, read, etc...
         for path in args.FilePaths:
             print(f"File or directory '{path}' dropped")

Properties

Child

Summary

Gets or sets the drop zone child object.

Signature

1
public ControlBase Child {get; set;}

Return Value

ControlBase

FilterExtensions

Summary

Gets or sets the file extensions filter.

Signature

1
public string[] FilterExtensions {get; set;}

Return Value

string[]

IsDirectoryDropAllowed

Summary

Gets or sets whether user can drop directories or not.

Signature

1
public bool IsDirectoryDropAllowed {get; set;}

Return Value

bool

Events

Dropped

Summary

Occurs when files are dropped.

Signature

1
public event Action<DroppedEventArgs> Dropped;