protected internal StrokeStyle RandomStrokeStyle() { var strokeStyleProperties = new StrokeStyleProperties( RandomCapStyle(), RandomCapStyle(), RandomCapStyle(), RandomLineJoin(), 1.0f + 2.0f * (float)Random.NextDouble(), RandomDashStyle(), 5.0f * (float)Random.NextDouble()); if (strokeStyleProperties.DashStyle == DashStyle.Custom) { return(d2DFactory.CreateStrokeStyle(strokeStyleProperties, RandomDashes())); } else { return(d2DFactory.CreateStrokeStyle(strokeStyleProperties)); } }
private void LoadDeviceIndependentResource() { // Create the D2D Factory // This really needs to be set to type MultiThreaded if rendering is to be performed by multiple threads, // such as if used in a control similar to DirectControl sample control where rendering is done by a dedicated render thread, // especially if multiple such controls are used in one application, but also when multiple applications use D2D Factories. // // In this sample - SingleThreaded type is used because rendering is only done by the main/UI thread and only when required // (when the surface gets invalidated) making the risk of synchronization problems - quite low. d2dFactory = D2DFactory.CreateFactory(D2DFactoryType.Multithreaded); // Create the DWrite Factory dwriteFactory = DWriteFactory.CreateFactory(); // Create the WIC Factory wicFactory = ImagingFactory.Create(); TextBoxStroke = d2dFactory.CreateStrokeStyle( new StrokeStyleProperties( CapStyle.Flat, CapStyle.Flat, CapStyle.Round, LineJoin.Miter, 5.0f, DashStyle.Dash, 3f), null); }