protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
TextFormat tf=new TextFormat(new SharpDX.DirectWrite.Factory(),"Arial",16);
tf.ParagraphAlignment=ParagraphAlignment.Center;
tf.TextAlignment=SharpDX.DirectWrite.TextAlignment.Center;
TextFormat tf_low=new TextFormat(new SharpDX.DirectWrite.Factory(),"Arial",12);
tf_low.ParagraphAlignment=ParagraphAlignment.Near;
tf_low.TextAlignment=SharpDX.DirectWrite.TextAlignment.Trailing;
TextFormat tf_low2=new TextFormat(new SharpDX.DirectWrite.Factory(),"Arial",12);
tf_low2.ParagraphAlignment=ParagraphAlignment.Near;
tf_low2.TextAlignment=SharpDX.DirectWrite.TextAlignment.Leading;
Print("Точка останова");
for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++)
{
double closeValue = ChartBars.Bars.GetClose(idx);
double openValue = ChartBars.Bars.GetOpen(idx);
double highValue = ChartBars.Bars.GetHigh(idx);
double lowValue = ChartBars.Bars.GetLow(idx);
IEnumerable<ABV> _list = main_list.Where(p => p.Id == idx);
GlyphTypeface gtf=new GlyphTypeface();
System.Windows.Media.Typeface t_face=new System.Windows.Media.Typeface(new System.Windows.Media.FontFamily("Arial"),FontStyles.Normal,FontWeights.Normal,FontStretches.Normal);
t_face.TryGetGlyphTypeface(out gtf);
double h_str=gtf.CapsHeight*16;
int x=chartControl.GetXByBarIndex(ChartBars,idx)-(int)chartControl.BarWidth;
int y_close=chartScale.GetYByValue(closeValue)-(int)(h_str*0.5*1.8);
int y_open=chartScale.GetYByValue(openValue)-(int)(h_str*0.5*1.8);
int y_high=chartScale.GetYByValue(highValue+TickSize)-(int)(h_str*0.5*1.8);
int y_low=chartScale.GetYByValue(lowValue-TickSize)-(int)(h_str*0.5*1.8);
BrushProperties bp2=new BrushProperties();
BrushProperties bp_frame=new BrushProperties();
bp_frame.Opacity=0.99f;
bp2.Opacity=0.7f;
int y3=y_close;
SharpDX.Color clr=SharpDX.Color.Gray;
if (closeValue>openValue)
clr=SharpDX.Color.Green;
else if (closeValue<openValue)
{
clr=SharpDX.Color.Red;
y3=y_open;
}
SharpDX.Direct2D1.SolidColorBrush sb2=new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,clr,bp2);
SharpDX.Direct2D1.SolidColorBrush frame=new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,SharpDX.Color.Black,bp2);
RenderTarget.FillRectangle(new RectangleF(x-10,y3,8,(float)Math.Abs(y_close-y_open)+(int)(h_str*1.8)),sb2);
if (idx==ChartBars.Count-1)
{
foreach(KeyValuePair<double, ABVolume> kvp in _abv)
{
int y=chartScale.GetYByValue(kvp.Key)-(int)(h_str*0.5*1.8);
int y2=chartScale.GetYByValue(kvp.Key+TickSize)-(int)(h_str);
string str="";
str=kvp.Value.ask_volume.ToString()+" x "+kvp.Value.bid_volume.ToString();
BrushProperties bp=new BrushProperties();
bp.Opacity=0.7f;
SharpDX.Color clr2=SharpDX.Color.Green;
if (kvp.Value.ask_volume<kvp.Value.bid_volume)
clr2=SharpDX.Color.Red;
SharpDX.Direct2D1.SolidColorBrush sb=new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,clr2,bp);
RenderTarget.FillRectangle(new RectangleF(x,y,(int)chartControl.BarWidth*2,(float)(h_str*1.8)),sb);
if (kvp.Key==Close[0])
RenderTarget.DrawRectangle(new RectangleF(x,y,(int)chartControl.BarWidth*2,(float)(h_str*1.8)),frame,3);
RenderTarget.DrawText(str,tf,new RectangleF(x,y,(int)chartControl.BarWidth*2,(float)(h_str*1.8)),
new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,SharpDX.Color.Black),
DrawTextOptions.None,MeasuringMode.GdiClassic);
}
}
else
{
double delta=0;
double max_delta=0;
double curr_delta=0;
foreach (ABV t in _list)
{
curr_delta=t.Vol_ask+t.Vol_bid;
if (curr_delta>max_delta)
max_delta=curr_delta;
}
foreach (ABV t in _list)
{
int y=chartScale.GetYByValue(t.Price)-(int)(h_str*0.5*1.8);
int y2=chartScale.GetYByValue(t.Price+TickSize)-(int)(h_str);
string str="";
str=t.Vol_ask.ToString()+" x "+t.Vol_bid.ToString();
delta+=t.Vol_ask;
delta-=t.Vol_bid;
curr_delta=t.Vol_ask+t.Vol_bid;
double curr_procent=100*curr_delta/max_delta;
double curr_opacity=Math.Round(curr_procent/100*0.8,1);
BrushProperties bp=new BrushProperties();
bp.Opacity=(float)curr_opacity;
SharpDX.Color clr3=SharpDX.Color.Green;
if (t.Vol_ask<t.Vol_bid)
clr3=SharpDX.Color.Red;
SharpDX.Direct2D1.SolidColorBrush sb=new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,clr3,bp);
RenderTarget.FillRectangle(new RectangleF(x,y,(int)chartControl.BarWidth*2,(float)(h_str*1.8)),sb);
RenderTarget.DrawText(str,tf,new RectangleF(x,y,(int)chartControl.BarWidth*2,(float)(h_str*1.8)),
new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,SharpDX.Color.Black),
DrawTextOptions.None,MeasuringMode.GdiClassic);
}
RenderTarget.DrawText(delta.ToString(),tf_low,new RectangleF(x,y_low,(int)chartControl.BarWidth*2,(float)(h_str*1.8)),
new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,SharpDX.Color.Black),DrawTextOptions.None,MeasuringMode.GdiClassic);
//RenderTarget.DrawText(Volume[ChartBars.Count-idx-1].ToString(),tf_low2,new RectangleF(x,y_low,(int)chartControl.BarWidth*2,(float)(h_str*1.8)),
// new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,SharpDX.Color.Black),DrawTextOptions.None,MeasuringMode.GdiClassic);
}
}
}