public override void Load( CanvasRenderArguments args ) { if ( lineBrush != null && !lineBrush.IsDisposed ) lineBrush.Dispose(); if (DW_textFormat != null && !DW_textFormat.IsDisposed) DW_textFormat.Dispose(); // init the lines brushs lineBrush = new SolidColorBrush( args.renderTarget, _FontColor ); _TextFormat.fontCollection = args.WriteFactory.GetSystemFontCollection(false); // init the text format DW_textFormat = new SharpDX.DirectWrite.TextFormat( args.WriteFactory, _TextFormat.familyName, _TextFormat.fontCollection, _TextFormat.weight, _TextFormat.fontStyle, _TextFormat.fontStretch, _TextFormat.fontSize, "en-us" ); // get the size of the string SharpDX.DirectWrite.TextLayout textL= new SharpDX.DirectWrite.TextLayout( args.WriteFactory, Internal_String, DW_textFormat, 1500, 1500 ); Size = new Vector.FxVector2f(textL.GetFontSize(0) * Internal_String.Length, textL.GetFontSize(0)); textL.Dispose(); // init text rectangle textRectangle = new RectangleF( 0, 0, Size.x, Size.y ); }
public override void Load( CanvasRenderArguments args ) { // dispose the old brush if (lineBrush != null && !lineBrush.IsDisposed) lineBrush.Dispose(); if (DW_textFormat != null && !DW_textFormat.IsDisposed) DW_textFormat.Dispose(); // init the lines brushs lineBrush = new SolidColorBrush( args.renderTarget, _AxesColor.ToColor4() ); _TextFormat.fontCollection = args.WriteFactory.GetSystemFontCollection(false); // init the text format DW_textFormat = new SharpDX.DirectWrite.TextFormat(args.WriteFactory, _TextFormat.familyName, _TextFormat.fontCollection, _TextFormat.weight, _TextFormat.fontStyle, _TextFormat.fontStretch, _TextFormat.fontSize, "en-us"); // get the size of the string SharpDX.DirectWrite.TextLayout textL = new SharpDX.DirectWrite.TextLayout(args.WriteFactory, "(0,0)", DW_textFormat, 1500, 1500); // init text rectangle textRectangle = new RectangleF(0, 0, textL.GetFontSize(0) * 10, textL.GetFontSize(0)); textL.Dispose(); // refresh the geometrys RefreshGeometry( args.renderTarget ); }