Putting the finishing touches to an EcoSystem update and I have an issue.
I am using SharpDx to write the text for a counter like so
SharpDX.DirectWrite.TextLayout textLayout1 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Gl obals.DirectWriteFactory, timeLeft, textFormat1, ChartPanel.X + ChartPanel.W, textFormat1.FontSize);It's always in the format "HH:mm:ss";
However I am putting some text underneath the first line and I am trying to find the 'centre' of this first line.
I tried finding the text width via
TextSize = textLayout1.Metrics.Width;
and then my new lower string placement would be
+"\n".PadRight((int)TextSize/2);
I then realised that of course the text itself changes so I tried using an unused dummy layout
SharpDX.DirectWrite.TextLayout dummyLayout1 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Gl obals.DirectWriteFactory, "00:00:00", textFormat1, ChartPanel.X + ChartPanel.W, textFormat1.FontSize);
TextSize =dummyLayout1.Metrics.Width;
This also does not work so what am I doing wrong?
Comment