@@ -158,19 +158,30 @@ internal SharpDX.RectangleF GetBarRect(
158158 ypos += halfBarDistance ;
159159
160160 // bar width and X
161- int chartBarWidth = ( int ) ( chartControl . BarWidth + chartControl . BarMarginLeft ) ;
161+ int chartBarWidth ;
162162 int startX = ( inWindow ) ? (
163163 Math . Max ( chartControl . GetXByBarIndex ( chartBars , profile . StartBar ) , chartControl . CanvasLeft )
164164 ) : chartControl . GetXByBarIndex ( chartBars , profile . StartBar ) ;
165165 int endX = ( inWindow ) ? (
166166 Math . Min ( chartControl . GetXByBarIndex ( chartBars , profile . EndBar ) , chartControl . CanvasRight )
167167 ) : chartControl . GetXByBarIndex ( chartBars , profile . EndBar ) ;
168+ if ( profile . StartBar > 0 )
169+ {
170+ chartBarWidth = (
171+ chartControl . GetXByBarIndex ( chartBars , profile . StartBar ) -
172+ chartControl . GetXByBarIndex ( chartBars , profile . StartBar - 1 )
173+ ) / 2 ;
174+ }
175+ else
176+ {
177+ chartBarWidth = chartControl . GetBarPaintWidth ( chartBars ) ;
178+ }
168179 float xpos = ( float ) startX - chartBarWidth ;
169180 int maxWidth = Math . Max ( endX - startX , chartBarWidth ) ;
170181 float barWidth = ( fullwidth ) ? maxWidth : (
171182 maxWidth * ( volume / ( float ) profile . MaxVolume ) * WidthPercent
172183 ) ;
173- return new SharpDX . RectangleF ( startX , ypos , barWidth , barHeight ) ;
184+ return new SharpDX . RectangleF ( xpos , ypos , barWidth , barHeight ) ;
174185 }
175186
176187 internal void RenderProfile ( FofVolumeProfileData profile , Brush volumeBrush )
@@ -312,6 +323,9 @@ internal void RnederText(string text, SharpDX.Vector2 position, Brush brush, flo
312323 30
313324 ) ;
314325 textLayout . TextAlignment = align ;
326+ textLayout . WordWrapping = WordWrapping . NoWrap ;
327+ var textWidth = textLayout . Metrics . Width ;
328+ if ( textWidth > maxWidth ) return ;
315329 renderTarget . DrawTextLayout ( position , textLayout , brush ) ;
316330 }
317331
@@ -320,15 +334,22 @@ internal void RenderTotalVolume(FofVolumeProfileData profile, Brush textBrush)
320334 var maxPrice = profile . Keys . Max ( ) ;
321335 var minPrice = profile . Keys . Min ( ) ;
322336 var textFormat = chartControl . Properties . LabelFont . ToDirectWriteTextFormat ( ) ;
323- var textLayout = new SharpDX . DirectWrite . TextLayout (
337+ textFormat . WordWrapping = WordWrapping . NoWrap ;
338+ var textLayout = new TextLayout (
324339 NinjaTrader . Core . Globals . DirectWriteFactory ,
325340 string . Format ( "∑ {0} / {1}" , profile . TotalVolume , maxPrice - minPrice ) ,
326341 textFormat ,
327- 300 , 30
342+ 300 ,
343+ textFormat . FontSize + 4
328344 ) ;
329345 var barRect = GetBarRect ( profile , minPrice , 0 , false ) ;
330- var textPos = new SharpDX . Vector2 ( barRect . Left , barRect . Top ) ;
331- renderTarget . DrawTextLayout ( textPos , textLayout , textBrush ) ;
346+ RnederText (
347+ string . Format ( "∑ {0} / {1}" , profile . TotalVolume , maxPrice - minPrice ) ,
348+ new SharpDX . Vector2 ( barRect . Left , barRect . Top ) ,
349+ textBrush ,
350+ barRect . Width ,
351+ TextAlignment . Leading
352+ ) ;
332353 }
333354 }
334355 #endregion
0 commit comments