Add cell background color parameter to News indicator
This commit is contained in:
parent
fcb2027400
commit
4052912340
@ -47,6 +47,7 @@ namespace NinjaTrader.NinjaScript.Indicators
|
|||||||
HorizontalPadding = 20;
|
HorizontalPadding = 20;
|
||||||
VerticalPadding = 5;
|
VerticalPadding = 5;
|
||||||
YOffset = 0;
|
YOffset = 0;
|
||||||
|
CellBackgroundColor = Brushes.Transparent;
|
||||||
}
|
}
|
||||||
else if (State == State.Configure)
|
else if (State == State.Configure)
|
||||||
{
|
{
|
||||||
@ -199,20 +200,21 @@ namespace NinjaTrader.NinjaScript.Indicators
|
|||||||
var currencySize = MeasureString(newsEvent.Currency, eventTextFormat);
|
var currencySize = MeasureString(newsEvent.Currency, eventTextFormat);
|
||||||
var titleSize = MeasureString(newsEvent.Title, eventTextFormat);
|
var titleSize = MeasureString(newsEvent.Title, eventTextFormat);
|
||||||
|
|
||||||
|
// Draw cell backgrounds
|
||||||
RectangleF timeRect = new RectangleF(x, y, maxColWidth, rowHeight);
|
RectangleF timeRect = new RectangleF(x, y, maxColWidth, rowHeight);
|
||||||
|
RenderTarget.FillRectangle(timeRect, CellBackgroundColor.ToDxBrush(RenderTarget));
|
||||||
|
|
||||||
|
RectangleF currencyRect = new RectangleF(x + maxColWidth, y, maxColWidth, rowHeight);
|
||||||
|
RenderTarget.FillRectangle(currencyRect, CellBackgroundColor.ToDxBrush(RenderTarget));
|
||||||
|
|
||||||
|
RectangleF titleRect = new RectangleF(x + (2 * maxColWidth), y, maxColWidth, rowHeight);
|
||||||
|
RenderTarget.FillRectangle(titleRect, CellBackgroundColor.ToDxBrush(RenderTarget));
|
||||||
|
|
||||||
|
// Draw text
|
||||||
DrawText(newsEvent.Time, x + (maxColWidth - timeSize.Width) / 2, y + (rowHeight - timeSize.Height) / 2, EventTextColor, eventTextFormat, rowHeight);
|
DrawText(newsEvent.Time, x + (maxColWidth - timeSize.Width) / 2, y + (rowHeight - timeSize.Height) / 2, EventTextColor, eventTextFormat, rowHeight);
|
||||||
|
DrawText(newsEvent.Currency, x + maxColWidth + (maxColWidth - currencySize.Width) / 2, y + (rowHeight - currencySize.Height) / 2, EventTextColor, eventTextFormat, rowHeight);
|
||||||
|
DrawText(newsEvent.Title, x + (2 * maxColWidth) + (maxColWidth - titleSize.Width) / 2, y + (rowHeight - titleSize.Height) / 2, EventTextColor, eventTextFormat, rowHeight);
|
||||||
|
|
||||||
x += maxColWidth;
|
|
||||||
|
|
||||||
RectangleF currencyRect = new RectangleF(x, y, maxColWidth, rowHeight);
|
|
||||||
DrawText(newsEvent.Currency, x + (maxColWidth - currencySize.Width) / 2, y + (rowHeight - currencySize.Height) / 2, EventTextColor, eventTextFormat, rowHeight);
|
|
||||||
|
|
||||||
x += maxColWidth;
|
|
||||||
|
|
||||||
RectangleF titleRect = new RectangleF(x, y, maxColWidth, rowHeight);
|
|
||||||
DrawText(newsEvent.Title, x + (maxColWidth - titleSize.Width) / 2, y + (rowHeight - titleSize.Height) / 2, EventTextColor, eventTextFormat, rowHeight);
|
|
||||||
|
|
||||||
x = ChartPanel.W - (maxColWidth * 3) - HorizontalPadding;
|
|
||||||
y += rowHeight;
|
y += rowHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,6 +292,17 @@ namespace NinjaTrader.NinjaScript.Indicators
|
|||||||
|
|
||||||
[Display(Name = "Event Font", GroupName = "News", Order = 8)]
|
[Display(Name = "Event Font", GroupName = "News", Order = 8)]
|
||||||
public SimpleFont EventFont { get; set; }
|
public SimpleFont EventFont { get; set; }
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
[Display(Name = "Cell Background", GroupName = "News", Order = 9)]
|
||||||
|
public Brush CellBackgroundColor { get; set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
public string CellBackgroundColorSerialization
|
||||||
|
{
|
||||||
|
get { return Serialize.BrushToString(CellBackgroundColor); }
|
||||||
|
set { CellBackgroundColor = Serialize.StringToBrush(value); }
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user