/// <summary> /// This method creates the render target and all associated D2D and DWrite resources /// </summary> void CreateDeviceResources() { // Only calls if resources have not been initialize before if (renderTarget == null) { // The text format textFormat = dwriteFactory.CreateTextFormat("Bodoni MT", 24, DWrite.FontWeight.Normal, DWrite.FontStyle.Italic, DWrite.FontStretch.Normal); // Create the render target SizeU size = new SizeU((uint)host.ActualWidth, (uint)host.ActualHeight); RenderTargetProperties props = new RenderTargetProperties(); HwndRenderTargetProperties hwndProps = new HwndRenderTargetProperties(host.Handle, size, PresentOptions.None); renderTarget = d2dFactory.CreateHwndRenderTarget(props, hwndProps); // A black brush to be used for drawing text ColorF cf = new ColorF(0, 0, 0, 1); blackBrush = renderTarget.CreateSolidColorBrush(cf); // Create a linear gradient. GradientStop[] stops = { new GradientStop(1, new ColorF(1f, 0f, 0f, 0.25f)), new GradientStop(0, new ColorF(0f, 0f, 1f, 1f)) }; GradientStopCollection pGradientStops = renderTarget.CreateGradientStopCollection(stops, Gamma.Linear, ExtendMode.Wrap); LinearGradientBrushProperties gradBrushProps = new LinearGradientBrushProperties(new Point2F(50, 25), new Point2F(25, 50)); linearGradientBrush = renderTarget.CreateLinearGradientBrush(gradBrushProps, pGradientStops); gridPatternBitmapBrush = CreateGridPatternBrush(renderTarget); solidBrush1 = renderTarget.CreateSolidColorBrush(new ColorF(0.3F, 0.5F, 0.65F, 0.25F)); solidBrush2 = renderTarget.CreateSolidColorBrush(new ColorF(0.0F, 0.0F, 0.65F, 0.5F)); solidBrush3 = renderTarget.CreateSolidColorBrush(new ColorF(0.9F, 0.5F, 0.3F, 0.75F)); // Create a linear gradient. stops[0] = new GradientStop(1, new ColorF(0f, 0f, 0f, 0.25f)); stops[1] = new GradientStop(0, new ColorF(1f, 1f, 0.2f, 1f)); GradientStopCollection radiantGradientStops = renderTarget.CreateGradientStopCollection(stops, Gamma.Linear, ExtendMode.Wrap); RadialGradientBrushProperties radialBrushProps = new RadialGradientBrushProperties(new Point2F(25, 25), new Point2F(0, 0), 10, 10); radialGradientBrush = renderTarget.CreateRadialGradientBrush(radialBrushProps, radiantGradientStops); } }
/// <summary> /// This method creates the render target and associated D2D and DWrite resources /// </summary> void CreateDeviceResources() { // Only calls if resources have not been initialize before if (renderTarget == null) { // Create the render target SizeU size = new SizeU((uint)renderControl.ClientSize.Width, (uint)renderControl.ClientSize.Height); HwndRenderTargetProperties hwndProps = new HwndRenderTargetProperties(renderControl.Handle, size, PresentOptions.RetainContents); renderTarget = d2dFactory.CreateHwndRenderTarget(renderProps, hwndProps); // Create an initial black brush brushes.Add(renderTarget.CreateSolidColorBrush(new ColorF(Color.Black.ToArgb()))); currentBrushIndex = 0; } }
/// <summary> /// This method creates the render target and all associated D2D and DWrite resources /// </summary> void CreateDeviceResources() { // Only calls if resources have not been initialize before if (renderTarget == null) { // The text format textFormat = dwriteFactory.CreateTextFormat("Bodoni MT", 24, DWrite.FontWeight.Normal, DWrite.FontStyle.Italic, DWrite.FontStretch.Normal); // Create the render target SizeU size = new SizeU((uint)host.ActualWidth, (uint)host.ActualHeight); RenderTargetProperties props = new RenderTargetProperties(); HwndRenderTargetProperties hwndProps = new HwndRenderTargetProperties(host.Handle, size, PresentOptions.None); renderTarget = d2dFactory.CreateHwndRenderTarget(props, hwndProps); // A black brush to be used for drawing text ColorF cf = new ColorF(0, 0, 0, 1); blackBrush = renderTarget.CreateSolidColorBrush(cf); // Create a linear gradient. GradientStop[] stops = { new GradientStop(1, new ColorF(1f, 0f, 0f, 0.25f)), new GradientStop(0, new ColorF(0f, 0f, 1f, 1f)) }; GradientStopCollection pGradientStops = renderTarget.CreateGradientStopCollection(stops, Gamma.Linear, ExtendMode.Wrap); LinearGradientBrushProperties gradBrushProps = new LinearGradientBrushProperties(new Point2F(50, 25), new Point2F(25, 50)); linearGradientBrush = renderTarget.CreateLinearGradientBrush(gradBrushProps, pGradientStops); gridPatternBitmapBrush = CreateGridPatternBrush(renderTarget); solidBrush1 = renderTarget.CreateSolidColorBrush(new ColorF(0.3F, 0.5F, 0.65F, 0.25F)); solidBrush2 = renderTarget.CreateSolidColorBrush(new ColorF(0.0F, 0.0F, 0.65F, 0.5F)); solidBrush3 = renderTarget.CreateSolidColorBrush(new ColorF(0.9F, 0.5F, 0.3F, 0.75F)); // Create a linear gradient. stops[0] = new GradientStop(1, new ColorF(0f, 0f, 0f, 0.25f)); stops[1] = new GradientStop(0, new ColorF(1f, 1f, 0.2f, 1f)); GradientStopCollection radiantGradientStops = renderTarget.CreateGradientStopCollection(stops, Gamma.Linear, ExtendMode.Wrap); RadialGradientBrushProperties radialBrushProps = new RadialGradientBrushProperties(new Point2F(25, 25), new Point2F(0, 0), 10, 10); radialGradientBrush = renderTarget.CreateRadialGradientBrush(radialBrushProps, radiantGradientStops); } }
/// <summary> /// This method creates the render target and all associated D2D and DWrite resources /// </summary> void CreateDeviceResources() { // Only calls if resources have not been initialize before if (renderTarget == null) { // Create the render target SizeU size = new SizeU((uint)host.ActualWidth, (uint)host.ActualHeight); RenderTargetProperties props = new RenderTargetProperties(); HwndRenderTargetProperties hwndProps = new HwndRenderTargetProperties(host.Handle, size, PresentOptions.None); renderTarget = d2dFactory.CreateHwndRenderTarget(props, hwndProps); // Create the black brush for text blackBrush = renderTarget.CreateSolidColorBrush(new ColorF(0, 0, 0, 1)); inlineImage = new ImageInlineObject(renderTarget, wicFactory, "TextInlineImage.img1.jpg"); TextRange textRange = new TextRange(14, 1); textLayout.SetInlineObject(inlineImage, textRange); } }
/// <summary> /// This method creates the render target and all associated D2D and DWrite resources /// </summary> void CreateDeviceResources() { // Only calls if resources have not been initialize before if (renderTarget == null) { // Create the render target SizeU size = new SizeU((uint)host.ActualWidth, (uint)host.ActualHeight); RenderTargetProperties props = new RenderTargetProperties(); HwndRenderTargetProperties hwndProps = new HwndRenderTargetProperties(host.Handle, size, PresentOptions.None); renderTarget = d2dFactory.CreateHwndRenderTarget(props, hwndProps); // Create the black brush for text blackBrush = renderTarget.CreateSolidColorBrush(new ColorF(0 ,0, 0, 1)); inlineImage = new ImageInlineObject(renderTarget, wicFactory, "TextInlineImage.img1.jpg"); TextRange textRange = new TextRange(14, 1); textLayout.SetInlineObject(inlineImage, textRange); } }
/// <summary> /// This method creates the render target and associated D2D and DWrite resources /// </summary> void CreateDeviceResources() { // Only calls if resources have not been initialize before if (renderTarget == null) { // Create the render target SizeU size = new SizeU((uint)renderControl.ClientSize.Width, (uint)renderControl.ClientSize.Height); HwndRenderTargetProperties hwndProps = new HwndRenderTargetProperties(renderControl.Handle, size, PresentOptions.RetainContents); renderTarget = d2dFactory.CreateHwndRenderTarget(renderProps, hwndProps); // Create an initial black brush brushes.Add(renderTarget.CreateSolidColorBrush(new ColorF(Color.Black.ToArgb()))); currentBrushIndex = 0; } }
private void DrawImageResizeArea(HwndRenderTarget renderTarget) { switch(renderMode) { case ImageRenderMode.ModeNomal: { if(targetImage != null) { //Rectangle rect = new Rectangle((int)resizeHotRect.Left, (int)resizeHotRect.Top, (int)resizeHotRect.Width, (int)resizeHotRect.Height); //Point newPoint = this.PointToClient(Cursor.Position); const int delta = 10; resizeHotRect = new RectF(renderRect.Width - delta, renderRect.Height - delta, renderRect.Width + delta, renderRect.Height + delta); renderTarget.DrawRectangle(resizeHotRect, renderTarget.CreateSolidColorBrush(new ColorF(Color.Red.ToArgb())), 1, d2dFactory.CreateStrokeStyle(new StrokeStyleProperties(CapStyle.Square, CapStyle.Square, CapStyle.Square, LineJoin.Miter, 1, DashStyle.Dash, 3))); if (lockResizeHotRectFlag) { renderTarget.FillRoundedRectangle(new RoundedRect(resizeHotRect,3,3), renderTarget.CreateSolidColorBrush(new ColorF(Color.Green.ToArgb()))); //renderTarget.DrawText(this.PointToClient(Cursor.Position).ToString(),, } } break; } } }