Is it possible to move panels on screen with mouse

Created at 21 Mar 2020, 01:34
SA

sascha.dawe

Joined 11.02.2019

Is it possible to move panels on screen with mouse
21 Mar 2020, 01:34


Hi, 

Is there a method to move custom UI elements (introduced in 3.6) around the chart with a mouse? Such as the quick trading panel, for example. I feel this would be more natural for the user, rather than specifying vertical and horizontal alignment.

Also, is there a way to get more control on placement, rather than vertical alignment top horizontal alignment right. Can we specify x and y coordinates instead?

 

Thanks,

Sascha


@sascha.dawe
Replies

PanagiotisCharalampous
23 Mar 2020, 10:18

Hi Sascha,

See an example below

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        Button _button;
        protected override void OnStart()
        {
            _button = new Button 
            {
                Text = "Click Me 1",
                Top = 100,
                Left = 100
            };
            var canvas = new Canvas 
            {
                            };
            canvas.AddChild(_button);
            Chart.AddControl(canvas);
            Chart.MouseMove += OnChartMouseMove;
        }

        void OnChartMouseMove(ChartMouseEventArgs obj)
        {
            _button.Top = obj.MouseY;
            _button.Left = obj.MouseX;
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

sascha.dawe
23 Mar 2020, 11:59

RE:

Fantastic,

This is a good starting point.

 

Thanks,

Sascha

 


@sascha.dawe