Exemplo n.º 1
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.Clear(Color.White);

            // レイヤークリップ前
            e.RenderTarget.SetTransform(50, 50);
            e.RenderTarget.DrawBitmap(e.Resources["fish bitmap"], new RectangleF(0, 0, 205, 141));
            e.RenderTarget.FillRectangle(new RectangleF(0, 0, 25, 25), e.Resources["brush"]);
            e.RenderTarget.FillRectangle(new RectangleF(25, 25, 25, 25), e.Resources["brush"]);
            e.RenderTarget.FillRectangle(new RectangleF(50, 50, 25, 25), e.Resources["brush"]);
            e.RenderTarget.FillRectangle(new RectangleF(75, 75, 25, 25), e.Resources["brush"]);
            e.RenderTarget.FillRectangle(new RectangleF(100, 100, 25, 25), e.Resources["brush"]);
            e.RenderTarget.FillRectangle(new RectangleF(125, 125, 25, 25), e.Resources["brush"]);

            // レイヤークリップ後
            e.RenderTarget.SetTransform(350, 50);
            using (var layer = e.RenderTarget.CreateLayer()) {
                layer.Parameters.GeometricMask = e.Resources["path geometry"];
                e.RenderTarget.PushLayer(layer);

                e.RenderTarget.DrawBitmap(e.Resources["fish bitmap"], new RectangleF(0, 0, 205, 141));
                e.RenderTarget.FillRectangle(new RectangleF(0, 0, 25, 25), e.Resources["brush"]);
                e.RenderTarget.FillRectangle(new RectangleF(25, 25, 25, 25), e.Resources["brush"]);
                e.RenderTarget.FillRectangle(new RectangleF(50, 50, 25, 25), e.Resources["brush"]);
                e.RenderTarget.FillRectangle(new RectangleF(75, 75, 25, 25), e.Resources["brush"]);
                e.RenderTarget.FillRectangle(new RectangleF(100, 100, 25, 25), e.Resources["brush"]);
                e.RenderTarget.FillRectangle(new RectangleF(125, 125, 25, 25), e.Resources["brush"]);

                e.RenderTarget.PopLayer();
            }
        }
Exemplo n.º 2
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.SetTransform();

            // 背景消去
            e.RenderTarget.Clear(Color.White);

            //
            e.RenderTarget.FillRectangle(new RectangleF(0, 0, this.ClientSize.Width, this.ClientSize.Height), e.Resources["GridPatternBitmapBrush"]);

            var originalShapeBrush    = (VisualResourceOfSolidColorBrush)e.Resources["OriginalShapeBrush"];
            var fillBrush             = (VisualResourceOfSolidColorBrush)e.Resources["FillBrush"];
            var stroke                = (VisualResourceOfStrokeStyle)e.Resources["stoke"];
            var transformedShapeBrush = (VisualResourceOfSolidColorBrush)e.Resources["TransformedShapeBrush"];
            var format                = (VisualResourceOfTextFormat)e.Resources["text format"];
            var textBrush             = (VisualResourceOfSolidColorBrush)e.Resources["TextBrush"];

            originalShapeBrush.SetOpacity(128);
            fillBrush.SetOpacity(128);

            // 変形トランスフォームを作成し、レンダリングターゲットに適用します
            this.DrawAndTranslateARectangle(e.RenderTarget, originalShapeBrush, fillBrush, stroke, transformedShapeBrush, format, textBrush);

            // 回転トランスフォームを作成し、レンダリングターゲットに適用します
            this.DrawAndRotateARectangle(e.RenderTarget, originalShapeBrush, fillBrush, stroke, transformedShapeBrush, format, textBrush);

            // スケールトランスフォームを作成し、レンダリングターゲットに適用します
            this.DrawAndScaleARectangle(e.RenderTarget, originalShapeBrush, fillBrush, stroke, transformedShapeBrush, format, textBrush);

            // 変形トランスフォームを作成し、レンダリングターゲットに適用します
            this.DrawAndSkewARectangle(e.RenderTarget, originalShapeBrush, fillBrush, stroke, transformedShapeBrush, format, textBrush);
        }
Exemplo n.º 3
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.SetTransform();
            e.RenderTarget.Clear(Color.White);
            e.RenderTarget.FillRectangle(new RectangleF(0, 0, this.Width, this.Height), e.Resources["GridPatternBitmapBrush"]);

            // テキストを中央揃え
            var textFormat = (VisualResourceOfTextFormat)e.Resources["text format"];

            textFormat.SetTextAlignment(DWriteTextAligment.DWRITE_TEXT_ALIGNMENT_CENTER);

            //
            e.RenderTarget.FillGeometry(e.Resources["GeoGroup_AlternateFill"], e.Resources["FillBrush"]);
            e.RenderTarget.DrawGeometry(e.Resources["GeoGroup_AlternateFill"], e.Resources["StrokeBrush"], 1);
            e.RenderTarget.DrawText("D2D1_FILL_MODE_ALTERNATE",
                                    textFormat,
                                    new RectangleF(5, 215, 205, 240),
                                    e.Resources["StrokeBrush"],
                                    DrawTextOptions.DRAW_TEXT_OPTIONS_NONE,
                                    DWriteMeasuringMode.DWRITE_MEASURING_MODE_NATURAL);
            //
            e.RenderTarget.SetTransform(300, 0);

            //
            e.RenderTarget.FillGeometry(e.Resources["GeoGroup_WindingFill"], e.Resources["FillBrush"]);
            e.RenderTarget.DrawGeometry(e.Resources["GeoGroup_WindingFill"], e.Resources["StrokeBrush"], 1);
            e.RenderTarget.DrawText("D2D1_FILL_MODE_ALTERNATE",
                                    textFormat,
                                    new RectangleF(5, 215, 205, 240),
                                    e.Resources["StrokeBrush"],
                                    DrawTextOptions.DRAW_TEXT_OPTIONS_NONE,
                                    DWriteMeasuringMode.DWRITE_MEASURING_MODE_NATURAL);
        }
Exemplo n.º 4
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            var rcBrushRect = new RectangleF(0, 0, 205, 141);

            // 背景色塗り潰し
            e.RenderTarget.Clear(Color.White);

            // オリジナルビットマップ
            e.RenderTarget.SetTransform(5, 5);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["original"]);

            // マスクビットマップ
            e.RenderTarget.SetTransform(255, 5);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["mask"]);

            // 重ね合わせ
            e.RenderTarget.SetTransform(500, 5);
            e.RenderTarget.SetAntialiasMode(AntialiasMode.ANTIALIAS_MODE_ALIASED);

            e.RenderTarget.FillOpacityMask(e.Resources["mask bitmap"],
                                           e.Resources["original"],
                                           OpacityMaskContent.OPACITY_MASK_CONTENT_GRAPHICS,
                                           rcBrushRect);

            e.RenderTarget.SetAntialiasMode(AntialiasMode.ANTIALIAS_MODE_PER_PRIMITIVE);
        }
Exemplo n.º 5
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.Clear(Color.White);

            e.RenderTarget.FillRectangle(this.ClientRectangle, e.Resources["bitmap"]);

            e.RenderTarget.FillGeometry(e.Resources["sun geometry"], e.Resources["grad"]);

            var brush = (VisualResourceOfSolidColorBrush)e.Resources["brush"];

            brush.SetColor(Color.Black);
            e.RenderTarget.DrawGeometry(e.Resources["sun geometry"], e.Resources["brush"], 1.0f);

            // 左の山
            brush.SetColor(Color.OliveDrab);
            e.RenderTarget.FillGeometry(e.Resources["left mountain"], e.Resources["brush"]);
            brush.SetColor(Color.Black);
            e.RenderTarget.DrawGeometry(e.Resources["left mountain"], e.Resources["brush"], 1.0f);

            // 川
            brush.SetColor(Color.LightSkyBlue);
            e.RenderTarget.FillGeometry(e.Resources["river geometry"], e.Resources["brush"]);
            brush.SetColor(Color.Black);
            e.RenderTarget.DrawGeometry(e.Resources["river geometry"], e.Resources["brush"], 1.0f);

            // 右の山
            brush.SetColor(Color.YellowGreen);
            e.RenderTarget.FillGeometry(e.Resources["right mountain"], e.Resources["brush"]);
            brush.SetColor(Color.Black);
            e.RenderTarget.DrawGeometry(e.Resources["right mountain"], e.Resources["brush"], 1.0f);
        }
Exemplo n.º 6
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.SetTransform();

            // 背景消去
            e.RenderTarget.Clear(Color.White);

            //
            e.RenderTarget.FillRectangle(new RectangleF(0, 0, this.ClientSize.Width, this.ClientSize.Height), e.Resources["GridPatternBitmapBrush"]);

            var originalShapeBrush    = (VisualResourceOfSolidColorBrush)e.Resources["OriginalShapeBrush"];
            var fillBrush             = (VisualResourceOfSolidColorBrush)e.Resources["FillBrush"];
            var stroke                = (VisualResourceOfStrokeStyle)e.Resources["stoke"];
            var transformedShapeBrush = (VisualResourceOfSolidColorBrush)e.Resources["TransformedShapeBrush"];
            var format                = (VisualResourceOfTextFormat)e.Resources["text format"];
            var textBrush             = (VisualResourceOfSolidColorBrush)e.Resources["TextBrush"];

            originalShapeBrush.SetOpacity(128);
            fillBrush.SetOpacity(128);

            // 移動し、次に回転します。
            this.TranslationRotation(e.RenderTarget, originalShapeBrush, fillBrush, stroke, transformedShapeBrush, format, textBrush);

            // 回転し、次に移動します
            this.RotationTranslation(e.RenderTarget, originalShapeBrush, fillBrush, stroke, transformedShapeBrush, format, textBrush);
        }
Exemplo n.º 7
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.Clear(Color.White);

            // ブラシ塗りつぶし矩形領域
            var rcBrushRect = new RectangleF(0, 0, 148, 148);

            //-------------------------
            // リニアグラデーション
            e.RenderTarget.SetTransform(5, 5);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["linearFadeFlowersBitmap"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);

            e.RenderTarget.SetTransform(205, 5);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["linearGradientBrush"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);

            // 不透明マスクとして線形グラデーションブラシを使用
            e.RenderTarget.SetTransform(405, 5);
            e.RenderTarget.FillGeometry(e.Resources["rectGeo"], e.Resources["linearFadeFlowersBitmap"], e.Resources["linearGradientBrush"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);

            //-------------------------
            // ラジアルグラデーション
            e.RenderTarget.SetTransform(5, 205);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["radialFadeFlowersBitmapBrush"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);

            e.RenderTarget.SetTransform(205, 205);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["radialGradientBrush"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);

            // 不透明マスクとして放射グラデーションブラシを使用
            e.RenderTarget.SetTransform(405, 205);
            e.RenderTarget.FillGeometry(e.Resources["rectGeo"], e.Resources["radialFadeFlowersBitmapBrush"], e.Resources["radialGradientBrush"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);

            //-------------------------
            // ビットマップマスク
            e.RenderTarget.SetTransform(5, 405);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["fernBitmapBrush"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);

            e.RenderTarget.SetTransform(205, 405);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["bitmapMaskBrush"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);

            // 不透明マスクとしてビットマップブラシを使用
            e.RenderTarget.SetTransform(405, 405);
            e.RenderTarget.SetAntialiasMode(AntialiasMode.ANTIALIAS_MODE_ALIASED);
            e.RenderTarget.FillOpacityMask(e.Resources["bitmapMask"],
                                           e.Resources["fernBitmapBrush"],
                                           OpacityMaskContent.OPACITY_MASK_CONTENT_GRAPHICS,
                                           rcBrushRect);
            e.RenderTarget.SetAntialiasMode(AntialiasMode.ANTIALIAS_MODE_PER_PRIMITIVE);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["blackBrush"], 1);
        }
Exemplo n.º 8
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            // 背景色を塗りつぶす
            e.RenderTarget.Clear(Color.White);

            var rcBrushRect = new RectangleF(0, 0, 378, 284);

            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["bitmap"]);

            e.RenderTarget.SetTransform(420, 0);
            e.RenderTarget.PushAxisAlignedClip(new RectangleF(100, 20, 100, 100), AntialiasMode.ANTIALIAS_MODE_PER_PRIMITIVE);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["bitmap"]);
            e.RenderTarget.PopAxisAlignedClip();
        }
Exemplo n.º 9
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.Clear(Color.White);
            e.RenderTarget.SetTransform(20, 20);

            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 10);
            e.RenderTarget.FillGeometry(e.Resources["path geometry"], e.Resources["LGBrush"]);

            var sz = Matrix.Scale(0.5f, 0.5f);
            var tn = Matrix.Translation(this.Width / 2 - 50.0f, this.Height / 2 - 50.0f);

            e.RenderTarget.SetTransform(sz * tn);

            e.RenderTarget.FillGeometry(e.Resources["path geometry"], e.Resources["LGBrush"]);
            e.RenderTarget.FillGeometry(e.Resources["trans geometry"], e.Resources["LGBrush"]);
        }
Exemplo n.º 10
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.SetTransform();
            e.RenderTarget.Clear(Color.White);
            e.RenderTarget.FillRectangle(new RectangleF(0, 0, this.Width, this.Height), e.Resources["GridPatternBitmapBrush"]);

            e.RenderTarget.SetTransform(10, 10);
            e.RenderTarget.DrawGeometry(e.Resources["pathGeometry"], e.Resources["brush"], 5);

            e.RenderTarget.SetTransform(500, 65);
            e.RenderTarget.DrawEllipse(new Ellipse(new PointF(100, 60), 100, 50), e.Resources["brush"], 5);

            e.RenderTarget.SetTransform(500, 5);
            e.RenderTarget.DrawGeometry(e.Resources["ellipseGeometry"], e.Resources["brush"], 5);

            e.RenderTarget.SetTransform(500, 200);
            e.RenderTarget.DrawGeometry(e.Resources["pathGeometry1"], e.Resources["brush"], 5);
        }
Exemplo n.º 11
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            // ブラシで塗りつぶす矩形の形状を定義する
            var rcBrushRect = new RectangleF(5, 0, 150, 150);

            // キャプションが描画される領域を定義する
            var rcTextRect = new RectangleF(5, 165, 175, 200);

            // 背景色を塗りつぶす
            e.RenderTarget.Clear(Color.White);

            // 単色ブラシ
            e.RenderTarget.SetTransform(5, 5);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["yellow brush"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["brush"], 1);
            e.RenderTarget.DrawText("ID2D1SolidColorBrush", e.Resources["text format"], rcTextRect, e.Resources["brush"]);

            // ライングラデーションブラシ
            e.RenderTarget.SetTransform(200, 5);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["line"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["brush"], 1);
            e.RenderTarget.DrawText("ID2D1LinearGradientBrush", e.Resources["text format"], rcTextRect, e.Resources["brush"]);

            // 放射グラデーションブラシ
            e.RenderTarget.SetTransform();
            e.RenderTarget.SetTransform(5, 200);

            var ellipse = new Ellipse(new PointF(75.0f, 75.0f), 75.0f, 75.0f);

            e.RenderTarget.FillEllipse(ellipse, e.Resources["radial"]);
            e.RenderTarget.DrawEllipse(ellipse, e.Resources["brush"], 1);
            e.RenderTarget.DrawText("ID2D1RadialGradientBrush", e.Resources["text format"], rcTextRect, e.Resources["brush"]);

            // ビットマップブラシ
            e.RenderTarget.SetTransform(200, 200);
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["bitmap"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["brush"], 1);
            e.RenderTarget.DrawText("ID2D1BitmapBrush", e.Resources["text format"], rcTextRect, e.Resources["brush"]);
        }
Exemplo n.º 12
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            var rcBrushRect            = new RectangleF(5, 5, 150, 150);
            var rcTransformedBrushRect = new RectangleF(100, 100, 100, 100);

            // 背景塗りつぶし
            e.RenderTarget.Clear(Color.White);

            // オリジナル画像
            e.RenderTarget.FillRectangle(rcBrushRect, e.Resources["bitmap"]);
            e.RenderTarget.DrawRectangle(rcBrushRect, e.Resources["brush"], 1);

            // 部分描画
            e.RenderTarget.FillRectangle(rcTransformedBrushRect, e.Resources["bitmap"]);

            // 部分を移動して描画
            var brush = (VisualResourceOfBitmapBrush)e.Resources["bitmap"];

            brush.SetTransform(Matrix.Translation(50, 50));
            e.RenderTarget.FillRectangle(rcTransformedBrushRect, e.Resources["bitmap"]);
            e.RenderTarget.DrawRectangle(rcTransformedBrushRect, e.Resources["brush"], 1);
        }
Exemplo n.º 13
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.SetTransform();

            // 背景クリア
            e.RenderTarget.Clear(Color.White);

            // 背景描画
            e.RenderTarget.FillRectangle(new RectangleF(0, 0, this.mainControl.Width, this.mainControl.Height), e.Resources["grid pattern"]);

            // Line Join Styles
            e.RenderTarget.SetTransform(10, 20);
            e.RenderTarget.DrawRectangle(new RectangleF(0.0f, 0.0f, 180.0f, 150.0f), e.Resources["brush"], 1);
            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 16, e.Resources["strokeStyleSolidMiter"]);
            e.RenderTarget.DrawText("Miter Line Join", e.Resources["text format"], new RectangleF(2, 150, 215, 215), e.Resources["brush"]);

            e.RenderTarget.SetTransform(10, 210);
            e.RenderTarget.DrawRectangle(new RectangleF(0.0f, 0.0f, 180.0f, 150.0f), e.Resources["brush"], 1);
            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 16, e.Resources["strokeStyleSolidBevel"]);
            e.RenderTarget.DrawText("Bevel Line Join", e.Resources["text format"], new RectangleF(2, 150, 215, 215), e.Resources["brush"]);

            e.RenderTarget.SetTransform(230, 20);
            e.RenderTarget.DrawRectangle(new RectangleF(0.0f, 0.0f, 180.0f, 150.0f), e.Resources["brush"], 1);
            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 16, e.Resources["strokeStyleSolidRoundwRoundCap"]);
            e.RenderTarget.DrawText("Round Line Join", e.Resources["text format"], new RectangleF(2, 150, 215, 215), e.Resources["brush"]);

            e.RenderTarget.SetTransform(230, 210);
            e.RenderTarget.DrawRectangle(new RectangleF(0.0f, 0.0f, 180.0f, 150.0f), e.Resources["brush"], 1);
            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 16, e.Resources["strokeStyleSolidMiterOrBevel"]);
            e.RenderTarget.DrawText("Miter or Bevel Line Join", e.Resources["text format"], new RectangleF(2, 150, 215, 215), e.Resources["brush"]);

            // Cap Styles
            e.RenderTarget.SetTransform(480, 20);
            e.RenderTarget.DrawRectangle(new RectangleF(0.0f, 0.0f, 180.0f, 150.0f), e.Resources["brush"], 1);
            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 16, e.Resources["strokeStyleSolidRoundwRoundCap"]);
            e.RenderTarget.DrawText("Round Caps", e.Resources["text format"], new RectangleF(2, 150, 215, 215), e.Resources["brush"]);

            e.RenderTarget.SetTransform(700, 20);
            e.RenderTarget.DrawRectangle(new RectangleF(0.0f, 0.0f, 180.0f, 150.0f), e.Resources["brush"], 1);
            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 16, e.Resources["strokeStyleSolidRoundwFlatCap"]);
            e.RenderTarget.DrawText("Flat Caps", e.Resources["text format"], new RectangleF(2, 150, 215, 215), e.Resources["brush"]);

            e.RenderTarget.SetTransform(480, 210);
            e.RenderTarget.DrawRectangle(new RectangleF(0.0f, 0.0f, 180.0f, 150.0f), e.Resources["brush"], 1);
            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 16, e.Resources["strokeStyleSolidRoundwSquareCap"]);
            e.RenderTarget.DrawText("Square Caps", e.Resources["text format"], new RectangleF(2, 150, 215, 215), e.Resources["brush"]);

            e.RenderTarget.SetTransform(700, 210);
            e.RenderTarget.DrawRectangle(new RectangleF(0.0f, 0.0f, 180.0f, 150.0f), e.Resources["brush"], 1);
            e.RenderTarget.DrawGeometry(e.Resources["path geometry"], e.Resources["brush"], 16, e.Resources["strokeStyleSolidRoundwTriangleCap"]);
            e.RenderTarget.DrawText("Triangle Caps", e.Resources["text format"], new RectangleF(2, 150, 215, 215), e.Resources["brush"]);

            // Dash Styles
            e.RenderTarget.SetTransform(Matrix.Translation(10, 405));
            e.RenderTarget.DrawLine(new PointF(0, 10), new PointF(200, 10), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleSolidMiter"]);
            e.RenderTarget.DrawText("Dash Style -- Solid", e.Resources["text format"], new RectangleF(0, 20, 200, 315), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 70), new PointF(200, 70), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleDash"]);
            e.RenderTarget.DrawText("Dash Style -- Dash", e.Resources["text format"], new RectangleF(0, 80, 200, 315), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 130), new PointF(200, 130), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleDot"]);
            e.RenderTarget.DrawText("Dash Style -- Dot", e.Resources["text format"], new RectangleF(0, 140, 200, 315), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 190), new PointF(200, 190), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleDashDot"]);
            e.RenderTarget.DrawText("Dash Style -- Dash Dot", e.Resources["text format"], new RectangleF(0, 200, 200, 315), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 250), new PointF(200, 250), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleDashDotDot"]);
            e.RenderTarget.DrawText("Dash Style -- Dash Dot Dot", e.Resources["text format"], new RectangleF(0, 260, 200, 315), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 310), new PointF(200, 310), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleCustomOffsetZero"]);
            e.RenderTarget.DrawText("Dash Style -- Custom", e.Resources["text format"], new RectangleF(0, 320, 200, 315), e.Resources["brush"]);

            // Dash Offsets
            e.RenderTarget.SetTransform(Matrix.Translation(300, 405));
            e.RenderTarget.DrawLine(new PointF(0, 10), new PointF(200, 10), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleCustomOffsetNegTwo"]);
            e.RenderTarget.DrawText("-2", e.Resources["text format"], new RectangleF(0, 20, 200, 295), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 70), new PointF(200, 70), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleCustomOffsetNegOne"]);
            e.RenderTarget.DrawText("-1", e.Resources["text format"], new RectangleF(0, 80, 200, 295), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 130), new PointF(200, 130), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleCustomOffsetZero"]);
            e.RenderTarget.DrawText("-0", e.Resources["text format"], new RectangleF(0, 140, 200, 295), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 190), new PointF(200, 190), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleCustomOffsetPosOne"]);
            e.RenderTarget.DrawText("1", e.Resources["text format"], new RectangleF(0, 200, 200, 295), e.Resources["brush"]);

            e.RenderTarget.DrawLine(new PointF(0, 250), new PointF(200, 250), e.Resources["cornflower blue"],
                                    10, e.Resources["strokeStyleCustomOffsetPosTwo"]);
            e.RenderTarget.DrawText("2", e.Resources["text format"], new RectangleF(0, 260, 200, 295), e.Resources["brush"]);
        }
Exemplo n.º 14
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.Clear(Color.White);

            var exampleRectangle = new RectangleF(0, 0, 88, 88);
            var captionBounds    = new RectangleF(0, 90, 100, 35);

            var brush = (VisualResourceOfD2BitmapBrush)e.Resources["BitmapBrush"];

            // 1
            e.RenderTarget.SetTransform(5, 5);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_CLAMP;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_CLAMP;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("CLAMP for X\nCLAMP for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);

            // 2
            e.RenderTarget.SetTransform(115, 5);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_CLAMP;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_WRAP;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("CLAMP for X\nWRAP for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);

            // 3
            e.RenderTarget.SetTransform(225, 5);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_CLAMP;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_MIRROR;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("CLAMP for X\nMIRROR for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);

            // 4
            e.RenderTarget.SetTransform(5, 155);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_WRAP;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_CLAMP;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("WRAP for X\nCLAMP for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);

            // 5
            e.RenderTarget.SetTransform(115, 155);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_WRAP;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_WRAP;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("WRAP for X\nWRAP for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);

            // 6
            e.RenderTarget.SetTransform(225, 155);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_WRAP;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_MIRROR;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("WRAP for X\nMIRROR for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);

            // 7
            e.RenderTarget.SetTransform(5, 305);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_MIRROR;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_CLAMP;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("MIRROR for X\nCLAMP for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);

            // 8
            e.RenderTarget.SetTransform(115, 305);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_MIRROR;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_WRAP;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("MIRROR for X\nWRAP for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);

            // 9
            e.RenderTarget.SetTransform(225, 305);
            brush.Properties.ExtendModeX = ExtendModeParameter.EXTEND_MODE_MIRROR;
            brush.Properties.ExtendModeY = ExtendModeParameter.EXTEND_MODE_MIRROR;
            e.RenderTarget.FillRectangle(exampleRectangle, brush);
            e.RenderTarget.DrawRectangle(exampleRectangle, e.Resources["black brush"], 1);
            e.RenderTarget.DrawText("MIRROR for X\nMIRROR for Y", e.Resources["format"], captionBounds, e.Resources["black brush"]);
        }
Exemplo n.º 15
0
        private void mainlControl_Rendering(object sender, ControlOfDX.VisualRenderEventArgs e)
        {
            e.RenderTarget.SetTransform();
            e.RenderTarget.Clear(Color.White);

            // 背景処理
            e.RenderTarget.FillRectangle(new RectangleF(0, 0, this.Width, this.Height), e.Resources["GridPatternBitmapBrush"]);

            // 結合前ジオメトリ描画
            e.RenderTarget.FillGeometry(e.Resources["CircleGeometry1"], e.Resources["ShapeFillBrush"]);
            e.RenderTarget.DrawGeometry(e.Resources["CircleGeometry1"], e.Resources["OutlineBrush"], 1);
            e.RenderTarget.FillGeometry(e.Resources["CircleGeometry2"], e.Resources["ShapeFillBrush"]);
            e.RenderTarget.DrawGeometry(e.Resources["CircleGeometry2"], e.Resources["OutlineBrush"], 1);
            e.RenderTarget.DrawText("The circles before combining", e.Resources["format"], new RectangleF(25, 130, 175, 100), e.Resources["TextBrush"]);

            // 結合ジオメトリ描画
            e.RenderTarget.SetTransform(200, 0);
            e.RenderTarget.FillGeometry(e.Resources["PathGeometryUnion"], e.Resources["ShapeFillBrush"]);
            e.RenderTarget.DrawGeometry(e.Resources["PathGeometryUnion"], e.Resources["OutlineBrush"], 1);
            e.RenderTarget.DrawText("D2D1_COMBINE_MODE_UNION", e.Resources["format"], new RectangleF(25, 130, 175, 100), e.Resources["TextBrush"]);

            // 共通部ジオメトリ描画
            e.RenderTarget.SetTransform(400, 0);
            e.RenderTarget.FillGeometry(e.Resources["PathGeometryIntersect"], e.Resources["ShapeFillBrush"]);
            e.RenderTarget.DrawGeometry(e.Resources["PathGeometryIntersect"], e.Resources["OutlineBrush"], 1);
            e.RenderTarget.DrawText("D2D1_COMBINE_MODE_INTERSECT", e.Resources["format"], new RectangleF(25, 130, 200, 100), e.Resources["TextBrush"]);

            // 排他ジオメトリ描画
            e.RenderTarget.SetTransform(200, 150);
            e.RenderTarget.FillGeometry(e.Resources["PathGeometryXor"], e.Resources["ShapeFillBrush"]);
            e.RenderTarget.DrawGeometry(e.Resources["PathGeometryXor"], e.Resources["OutlineBrush"], 1);
            e.RenderTarget.DrawText("D2D1_COMBINE_MODE_XOR", e.Resources["format"], new RectangleF(25, 130, 200, 100), e.Resources["TextBrush"]);

            // 以外ジオメトリ描画
            e.RenderTarget.SetTransform(400, 150);
            e.RenderTarget.FillGeometry(e.Resources["PathGeometryExclude"], e.Resources["ShapeFillBrush"]);
            e.RenderTarget.DrawGeometry(e.Resources["PathGeometryExclude"], e.Resources["OutlineBrush"], 1);
            e.RenderTarget.DrawText("D2D1_COMBINE_MODE_EXCLUDE", e.Resources["format"], new RectangleF(25, 130, 200, 100), e.Resources["TextBrush"]);

            var circleGeometry1 = (VisualResourceOfGeometry)e.Resources["CircleGeometry1"];
            var circleGeometry2 = (VisualResourceOfGeometry)e.Resources["CircleGeometry2"];

            // 次のコードは、さまざまな幾何学的操作を呼び出す方法を示しています。 ニーズに応じて、これらの出力値の使用方法を決定できます。
            var result = circleGeometry1.CompareWithGeometry(circleGeometry2, Matrix.Identity(), 1);

            if (result == GeometryRelation.GEOMETRY_RELATION_OVERLAP)
            {
                e.RenderTarget.DrawText("Two circles overlap.", e.Resources["format"], new RectangleF(25, 160, 200, 100), e.Resources["TextBrush"]);
            }

            var area   = circleGeometry1.ComputeArea(Matrix.Identity());
            var length = circleGeometry1.ComputeLength(Matrix.Identity());

            var pointAtLength = circleGeometry1.ComputePointAtLength(10);


            /*
             * D2D1_RECT_F bounds;
             *
             * hr = m_pCircleGeometry1->GetBounds(
             *    D2D1::IdentityMatrix(),
             *    &bounds
             *   );
             *
             * if (SUCCEEDED(hr))
             * {
             *  // Retrieve the bounds.
             * }
             *
             * D2D1_RECT_F bounds1;
             * hr = m_pCircleGeometry1->GetWidenedBounds(
             *    5.0,
             *    m_pStrokeStyle,
             *    D2D1::IdentityMatrix(),
             *    &bounds1
             *   );
             * if (SUCCEEDED(hr))
             * {
             *  // Retrieve the widened bounds.
             * }
             *
             * BOOL containsPoint;
             *
             * hr = m_pCircleGeometry1->StrokeContainsPoint(
             *  D2D1::Point2F(0,0),
             *  10,     // stroke width
             *  NULL,   // stroke style
             *  NULL,   // world transform
             *  &containsPoint
             *  );
             *
             * if (SUCCEEDED(hr))
             * {
             *  // Process containsPoint.
             * }
             *
             * BOOL containsPoint1;
             * hr = m_pCircleGeometry1->FillContainsPoint(
             *  D2D1::Point2F(0,0),
             *  D2D1::Matrix3x2F::Identity(),
             *  &containsPoint1
             *  );
             *
             * if (SUCCEEDED(hr))
             * {
             *  // Process containsPoint.
             * }
             */
        }