Skip to content

DropZone

class cAlgo.API Since 5.1

DesktopCLICloud

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

Environment behaviour

CLI — not supported. Accepted without error but never displayed, so control events such as Click are never raised.

Cloud — not supported. Accepted without error but never displayed, so control events such as Click are never raised.

Definition

public class DropZone : ControlBase

Namespace: cAlgo.API · Group: Controls · Inherits: ControlBase

Examples

using cAlgo.API;

namespace cAlgo.Robots;

public partial 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);
    }
}
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:
            api.Print(f"File or directory '{path}' dropped")
{
  "AccessRights": "None"
}

Constructors

Name Description
DropZoneDesktopCLICloud Initializes a new instance of the DropZone class.

Properties

Name Description
ChildDesktopCLICloudControlBase Gets or sets the drop zone child object.
FilterExtensionsDesktopCLICloudstring[] Gets or sets the file extensions filter.
IsDirectoryDropAllowedDesktopCLICloudbool Gets or sets whether user can drop directories or not.

Events

Name Description
DroppedDesktopCLICloudAction<DroppedEventArgs> Occurs when files are dropped.

Inherited members

From ControlBase: ResetProperty, UniqueId, Style, Left, Top, Right, Bottom, Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight, IsEnabled, IsVisible, Opacity, Margin, VerticalAlignment, HorizontalAlignment, Dock, IsHitTestVisible