🌟 クイックスタート

Graphic2DControl クイックスタート

Graphic2DControl をフォームに配置するまで(約1分)

Step 1:NuGet からインストール

プロジェクトを右クリックし、
「NuGet パッケージの管理」 を開きます。

NuGet 管理

検索欄に graphicbox と入力し、
GraphicBox2D をインストールします。

インストール
💡 ポイント
インストール後、自動的にツールボックスに追加されます。
手動で DLL を選択する必要はありません。

Step 2:ツールボックスから配置

ツールボックスに表示されている Graphic2DControl を、
フォームに ドラッグ&ドロップ してください。

ツールボックス表示

Step 3:配置完了

フォーム上にコントロールが配置されれば準備完了です。

配置
💡 ヒント
デフォルトサイズは 500 × 500 です。
必要に応じて自由にサイズ変更できます。

Step 4:サンプルコードを実行

ボタンを追加し、ボタンクリックイベント内に以下のソースを張り付けて、実行します。

            Layer2D layer2D = new Layer2D();
            layer2D.LayerName = "Layer1";
            layer2D.ZOrder = 0;
            layer2D.IsVisible = true;

            this.graphic2dControl1.Layers.Add(layer2D);

            // Point
            Point2D point = new Point2D();
            point.X = -1;
            point.Y = -1;
            this.graphic2dControl1.Layers[0].Points.Add(point);

            // Circle
            Circle2D circle = new Circle2D();
            circle.X = 3;
            circle.Y = 3;
            circle.R = 1.0f;
            circle.IsFilled = false;
            circle.LineColor = Color.Red;
            this.graphic2dControl1.Layers[0].Circles.Add(circle);

            // Polygon
            Polygon2D polygon2D = new Polygon2D();
            polygon2D.LineColor = Color.Yellow;
            polygon2D.LineStyle = LineStyle.Solid;
            polygon2D.IsFilled = true;
            polygon2D.FillColor = Color.Green;
            polygon2D.Points.Add(new PointF(-2, 2));
            polygon2D.Points.Add(new PointF(-1, 4));
            polygon2D.Points.Add(new PointF(0, 2));
            this.graphic2dControl1.Layers[0].Polygons.Add(polygon2D);

            // Text : Welcome
            Text2D text = new Text2D();
            text.X = -3;
            text.Y = -3;
            text.FontSize = 16.0f;
            text.Text = "Welcome to the graphicBox2d";
            text.Angle = 30.0f;
            this.graphic2dControl1.Layers[0].Texts.Add(text);

            Group2D group = new Group2D();

            // Arrow
            Arrow2D arrow = new Arrow2D();
            arrow.Start = new Point(0, 0);
            arrow.End = new Point(3, 3);
            arrow.Color = Color.Green;
            arrow.Style = LineStyle.Solid;
            group.ObjectList.Add(new Group2DItem(arrow, 0));

            // Text : Angle
            Text2D text2 = new Text2D();
            text2.X = 0.4f;
            text2.Y = 0.4f;
            text2.FontSize = 11.0f;
            text2.Text = "45°";
            text2.Color = Color.Cyan;
            group.ObjectList.Add(new Group2DItem(text2, 1));

            // Arc
            Arc2D arc = new Arc2D();
            arc.X = 0;
            arc.Y = 0;
            arc.R = 1.0f;
            arc.StartAngle = 0f;
            arc.EndAngle = 45.0f;
            arc.IsFilled = false;
            arc.LineColor = Color.Cyan;
            group.ObjectList.Add(new Group2DItem(arc, 2));

            this.graphic2dControl1.Layers[0].Groups.Add(group);

            // Text : cosθ
            Text2D text3 = new Text2D();
            text3.X = 1.5f;
            text3.Y = 1.0f;
            text3.FontSize = 16.0f;
            text3.Text = "cosθ";
            this.graphic2dControl1.Layers[0].Texts.Add(text3);

            // Graph
            MathGraph2D graph = new MathGraph2D();
            graph.Susiki = "cos(x)";
            graph.StartX = -50.0f;
            graph.EndX = 50.0f;
            graph.Color = Color.White;
            graph.CalculateInterval = 0.05f;
            graph.CalculateGraphPoints();
            this.graphic2dControl1.Layers[0].MathGraphs.Add(graph);

            // Redraw
            this.graphic2dControl1.Invalidate();
Graphic2DControl クイックスタート

様々な図形が描画されます。

🎉 完了!

  • 📘 プロパティリファレンス
  • ⚙ メソッドリファレンス
  • 🖱 イベントリファレンス