Table of Contents

Class SmartDomColumn

Namespace
ATAS.Indicators.SmartDom
Assembly
ATAS.Indicators.dll

Base class of a SmartDOM column written in a custom assembly. Derive from it, mark the class with SmartDomColumnAttribute, give it a public parameterless constructor and override OnDrawCell(RenderContext, SmartDomCell); the other hooks are optional.

Not in ATAS 8.0.15 yet: available from the next version.

[Obfuscation(Feature = "renaming", ApplyToMembers = true, Exclude = true)]
public abstract class SmartDomColumn
Inheritance
object
SmartDomColumn
Extension Methods

Remarks

The platform never calls one column instance concurrently: data callbacks, the timer and the drawing are serialized, so the column needs no locks for its own fields. Data callbacks are delivered on a platform thread shortly after the data arrives (in arrival order), never on the thread of the data feed.

Public read/write properties are the column settings: they are shown in the column settings (use [Display] for names, groups and order, [Browsable(false)] to hide one) and saved with the workspace. OnSettingsChanged() is called after the user changed them.

If an override throws, the platform logs the exception, releases the instance (OnDispose()) and shows the error in the column header; changing one of the column settings or loading the layout again starts a new instance with the saved settings.

Constructors

SmartDomColumn()

Initializes the column. The platform creates it with its parameterless constructor; the column is attached to its SmartDOM afterwards, so do not use the platform services here.

protected SmartDomColumn()

Properties

Context

The SmartDOM the column is shown in. Available from OnInitialize() on.

protected ISmartDomColumnContext Context { get; }

Property Value

ISmartDomColumnContext

Exceptions

InvalidOperationException

The column is not attached to a SmartDOM yet.

IsAttached

True once the column is attached to a SmartDOM (Context is available).

protected bool IsAttached { get; }

Property Value

bool

Methods

OnBestBidAskChanged(MarketDataArg)

The best bid or the best ask changed (DataType tells which).

protected virtual void OnBestBidAskChanged(MarketDataArg bestPrice)

Parameters

bestPrice MarketDataArg

OnCellClick(SmartDomCell, RenderControlMouseEventArgs)

The user clicked a cell of the column. Return true if the column handled the click (the SmartDOM then shows no context menu for a right click).

protected virtual bool OnCellClick(SmartDomCell cell, RenderControlMouseEventArgs e)

Parameters

cell SmartDomCell
e RenderControlMouseEventArgs

Returns

bool

OnDispose()

The platform stops using this instance: the column was removed from the SmartDOM or its layout was replaced, the SmartDOM was closed (also when the workspace is switched or the platform exits), the column was stopped by an error, the tariff no longer allows custom columns, its settings were replaced as a whole, or the assembly was reloaded. Called exactly once for every instance whose constructor completed, even if OnInitialize() was not reached or threw. Release what the column created (timers, files, subscriptions to your own services, native resources) here; no other method is called afterwards. An exception thrown here is logged and ignored.

protected virtual void OnDispose()

OnDrawCell(RenderContext, SmartDomCell)

Draws one cell. The platform has already filled the cell with the column background; draw the content within Bounds. Called for every visible row of every frame — keep it cheap.

protected abstract void OnDrawCell(RenderContext context, SmartDomCell cell)

Parameters

context RenderContext
cell SmartDomCell

OnDrawColumn(RenderContext, Rectangle)

Called once per frame before the cells are drawn, with the rectangle of the whole column (header included). Use it for drawings that span several rows.

protected virtual void OnDrawColumn(RenderContext context, Rectangle bounds)

Parameters

context RenderContext
bounds Rectangle

OnDrawHeader(RenderContext, Rectangle, string)

Draws the column header. The default implementation fills the header with the standard header background and draws text (the header set by the user) in its center.

protected virtual void OnDrawHeader(RenderContext context, Rectangle bounds, string text)

Parameters

context RenderContext
bounds Rectangle
text string

OnInitialize()

Called when the column is attached to a SmartDOM (normally once per instance), after its saved settings were restored. Context is available from here on.

protected virtual void OnInitialize()

OnInstrumentChanged()

Called after the SmartDOM switched to another instrument: reset the accumulated data here.

protected virtual void OnInstrumentChanged()

OnMarketDepthChanged(IReadOnlyList<MarketDataArg>)

Changed order book levels (DataType is Bid or Ask; a zero volume removes the level). The current book is available through GetBidVolume(decimal), GetAskVolume(decimal) and GetDepth(bool).

protected virtual void OnMarketDepthChanged(IReadOnlyList<MarketDataArg> levels)

Parameters

levels IReadOnlyList<MarketDataArg>

OnNewTrades(IReadOnlyList<MarketDataArg>)

New trades of the instrument, oldest first. Do not keep the list: it belongs to this call.

protected virtual void OnNewTrades(IReadOnlyList<MarketDataArg> trades)

Parameters

trades IReadOnlyList<MarketDataArg>

OnSettingsChanged()

Called after the column settings changed (and once after OnInitialize()).

protected virtual void OnSettingsChanged()

OnTimer()

Called about ten times per second while the SmartDOM is visible.

protected virtual void OnTimer()