void CreateDeviceIndependentResources() { string msc_fontName = "Verdana"; float msc_fontSize = 50; string fps_fontName = "Courier New"; float fps_fontSize = 12; GeometrySink spSink; // Create D2D factory d2DFactory = D2DFactory.CreateFactory(D2DFactoryType.SingleThreaded); // Create WIC factory imagingFactory = ImagingFactory.Create(); // Create DWrite factory dWriteFactory = DWriteFactory.CreateFactory(); // Create DWrite text format object textFormat = dWriteFactory.CreateTextFormat( msc_fontName, msc_fontSize); textFormat.TextAlignment = Microsoft.WindowsAPICodePack.DirectX.DirectWrite.TextAlignment.Center; textFormat.ParagraphAlignment = Microsoft.WindowsAPICodePack.DirectX.DirectWrite.ParagraphAlignment.Center; // Create DWrite text format object textFormatFps = dWriteFactory.CreateTextFormat( fps_fontName, fps_fontSize); textFormatFps.TextAlignment = Microsoft.WindowsAPICodePack.DirectX.DirectWrite.TextAlignment.Leading; textFormatFps.ParagraphAlignment = Microsoft.WindowsAPICodePack.DirectX.DirectWrite.ParagraphAlignment.Near; // Create the path geometry. pathGeometry = d2DFactory.CreatePathGeometry(); // Write to the path geometry using the geometry sink. We are going to create an // hour glass. spSink = pathGeometry.Open(); spSink.SetFillMode(Microsoft.WindowsAPICodePack.DirectX.Direct2D1.FillMode.Alternate); spSink.BeginFigure( new Point2F(0, 0), FigureBegin.Filled ); spSink.AddLine(new Point2F(200, 0)); spSink.AddBezier( new BezierSegment( new Point2F(150, 50), new Point2F(150, 150), new Point2F(200, 200) )); spSink.AddLine( new Point2F(0, 200) ); spSink.AddBezier( new BezierSegment( new Point2F(50, 150), new Point2F(50, 50), new Point2F(0, 0) )); spSink.EndFigure( FigureEnd.Closed ); spSink.Close( ); }
void CreateDeviceIndependentResources() { string msc_fontName = "Verdana"; float msc_fontSize = 50; string fps_fontName = "Courier New"; float fps_fontSize = 12; GeometrySink spSink; // Create D2D factory d2DFactory = D2DFactory.CreateFactory(D2DFactoryType.SingleThreaded); // Create WIC factory imagingFactory = ImagingFactory.Create(); // Create DWrite factory dWriteFactory = DWriteFactory.CreateFactory(); // Create DWrite text format object textFormat = dWriteFactory.CreateTextFormat( msc_fontName, msc_fontSize); textFormat.TextAlignment = Microsoft.WindowsAPICodePack.DirectX.DirectWrite.TextAlignment.Center; textFormat.ParagraphAlignment = Microsoft.WindowsAPICodePack.DirectX.DirectWrite.ParagraphAlignment.Center; // Create DWrite text format object textFormatFps = dWriteFactory.CreateTextFormat( fps_fontName, fps_fontSize); textFormatFps.TextAlignment = Microsoft.WindowsAPICodePack.DirectX.DirectWrite.TextAlignment.Leading; textFormatFps.ParagraphAlignment = Microsoft.WindowsAPICodePack.DirectX.DirectWrite.ParagraphAlignment.Near; // Create the path geometry. pathGeometry = d2DFactory.CreatePathGeometry(); // Write to the path geometry using the geometry sink. We are going to create an // hour glass. spSink = pathGeometry.Open(); spSink.SetFillMode(Microsoft.WindowsAPICodePack.DirectX.Direct2D1.FillMode.Alternate); spSink.BeginFigure( new Point2F(0, 0), FigureBegin.Filled ); spSink.AddLine(new Point2F(200, 0)); spSink.AddBezier( new BezierSegment( new Point2F(150, 50), new Point2F(150, 150), new Point2F(200, 200) )); spSink.AddLine( new Point2F(0, 200) ); spSink.AddBezier( new BezierSegment( new Point2F(50, 150), new Point2F(50, 50), new Point2F(0, 0) )); spSink.EndFigure( FigureEnd.Closed ); spSink.Close( ); }