private void MainWindow_Load(object sender, EventArgs e) { DirectWriteFactory f = DirectWriteFactory.Create(DirectWriteFactoryType.Shared); _textFormat = f.CreateTextFormat("Verdana", 110, FontWeight.Normal, FontStyle.Normal, FontStretch.Normal); _textFormat.ParagraphAlignment = ParagraphAlignment.Far; _textFormat.TextAlignment = TextAlignment.Center; ClientSize = new System.Drawing.Size(600, 600); _factory = Direct2DFactory.CreateFactory(FactoryType.SingleThreaded, DebugLevel.None, FactoryVersion.Auto); _renderTarget = _factory.CreateWindowRenderTarget(this, PresentOptions.None, RenderTargetProperties.Default); AntialiasMode amode = _renderTarget.AntialiasMode; TextAntialiasMode tamode = _renderTarget.TextAntialiasMode; _strokeBrush = _renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.Cyan, 1)); try { _strokeStyle = _factory.CreateStrokeStyle(new StrokeStyleProperties1(LineCapStyle.Flat, LineCapStyle.Flat, LineCapStyle.Round, LineJoin.Miter, 10, DashStyle.Dot, 0, StrokeTransformType.Normal), null); } catch (NotSupportedException) { _strokeStyle = _factory.CreateStrokeStyle(new StrokeStyleProperties(LineCapStyle.Flat, LineCapStyle.Flat, LineCapStyle.Round, LineJoin.Miter, 10, DashStyle.Dot, 0), null); } Resize += new EventHandler(MainWindow_Resize); }
private void MainWindow_Load(object sender, EventArgs e) { _factory = Direct2DFactory.CreateFactory(FactoryType.SingleThreaded, DebugLevel.None); StrokeStyleProperties ssp = new StrokeStyleProperties(LineCapStyle.Round, LineCapStyle.Round, LineCapStyle.Round, LineJoin.Round, 10, DashStyle.Solid, 0); _strokeStyle = _factory.CreateStrokeStyle(ssp, null); _renderTarget = _factory.CreateWindowRenderTarget(this); Resize += new EventHandler(MainWindow_Resize); }
protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory) { base.OnCreateDeviceIndependentResources(factory); this._textFormat = DirectWriteFactory.CreateTextFormat("Verdana", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 10.5f); this._textFormat.TextAlignment = TextAlignment.Center; float[] dashes = new float[] { 1, 1, 2, 3, 5 }; this._strokeStyle = factory.CreateStrokeStyle( new StrokeStyleProperties(LineCapStyle.Flat, LineCapStyle.Flat, LineCapStyle.Round, LineJoin.Round, 10, DashStyle.Custom, 0), dashes); CreateGeometries(factory); }
protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory) { base.OnCreateDeviceIndependentResources(factory); this._textFormat = DirectWriteFactory.CreateTextFormat("Verdana", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 10.5f); this._textFormat.TextAlignment = TextAlignment.Center; float[] dashes = new float[] { 1, 1, 2, 3, 5 }; this._strokeStyle = factory.CreateStrokeStyle( new StrokeStyleProperties(LineCapStyle.Flat, LineCapStyle.Flat, LineCapStyle.Round, LineJoin.Round, 10, DashStyle.Custom, 0), dashes); CreateGeometries(factory); }