前言:
眼前姐妹们对“用vbnet编写画图程序”大致比较关切,我们都想要剖析一些“用vbnet编写画图程序”的相关文章。那么小编同时在网络上收集了一些有关“用vbnet编写画图程序””的相关内容,希望大家能喜欢,朋友们一起来了解一下吧!添加2D形状
以与Canvas Lines类似的方式添加Canvas Shapes。以下示例在图表区域的中心添加一个Rectangle:
2D图表
2D图表仅支持2D形状。
[C#]
private void tChart1_AfterDraw(object sender,Steema.TeeChart.Drawing.Graphics3D g){ Size s = new Size(100,100); Point l = new Point(g.ChartXCenter - (s.Width / 2),g.ChartYCenter - (s.Height / 2)); Rectangle r = new Rectangle(l,s); g.Pen.Color = Color.Aquamarine; g.Brush.Color = Color.Blue; g.Rectangle(R); }
[VB.Net]
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw Dim S As New Size(100, 100) Dim L As New Point(g.ChartXCenter - (S.Width / 2), g.ChartYCenter - (S.Height / 2)) Dim R As New Rectangle(L, S) g.Pen.Color = Color.Aquamarine g.Brush.Color = Color.Blue g.Rectangle(R) End Sub
3D图表
在3D图表上,您也可以在Z平面中移动矩形。请参阅RectangleWithZ方法。此示例将矩形放置在左侧墙壁上,但将其移向图表后部的中间位置(朝向后墙)。
[C#]
private void Form1_Load(object sender, System.EventArgs e) { point3DSeries1.LinePen.Visible = false; point3DSeries1.FillSampleValues(20); point3DSeries1.VertAxis = VerticalAxis.Both; point3DSeries1.HorizAxis = HorizontalAxis.Both; tChart1.Aspect.Chart3DPercent = 50; tChart1.Axes.Depth.Visible = true; } private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { Size s = new Size(100,100); Point l = new Point(tChart1.Axes.Left.Position, g.ChartYCenter - (s.Height / 2)); Rectangle r = new Rectangle(l,s); g.Pen.Color = Color.Aquamarine; g.Brush.Color = Color.Blue; g.Rectangle(r, tChart1.Aspect.Width3D/2); }
[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Point3DSeries1.LinePen.Visible = False Point3DSeries1.FillSampleValues(20) Point3DSeries1.VertAxis = Steema.TeeChart.VerticalAxis.Both Point3DSeries1.HorizAxis = Steema.TeeChart.HorizontalAxis.Both TChart1.Aspect.Chart3DPercent = 50 TChart1.Axes.Depth.Visible = True End Sub Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw Dim S As New Size(100, 100) Dim L As New Point(TChart1.Axes.Left.Position, g.ChartYCenter - (S.Height / 2)) Dim R As New Rectangle(L, S) g.Pen.Color = Color.Aquamarine g.Brush.Color = Color.Blue g.Rectangle(R, TChart1.Aspect.Width3D / 2) End Sub
添加3D形状
您可以将3D形状添加到3D图表中。此示例在Chart矩形的中间绘制一个Cube:
[C#]
private void Form1_Load(object sender, System.EventArgs e) { point3DSeries1.LinePen.Visible = false; point3DSeries1.FillSampleValues(20); tChart1.Aspect.Chart3DPercent = 50; tChart1.Legend.Visible = false; tChart1.Axes.Depth.Visible = true; } private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { Size s = new Size(50,50); Point p = new Point(g.ChartXCenter - (s.Width/2), g.ChartYCenter - (s.Height/2)); Rectangle r = new Rectangle(p,s); g.Cube(r, 0, 20, true); }
[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Point3DSeries1.LinePen.Visible = False Point3DSeries1.FillSampleValues(20) TChart1.Aspect.Chart3DPercent = 50 TChart1.Legend.Visible = False TChart1.Axes.Depth.Visible = True End Sub Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw Dim S As New Size(50, 50) Dim P As New Point(g.ChartXCenter - (S.Width / 2), g.ChartYCenter - (S.Height / 2)) Dim R As New Rectangle(P, S) g.Cube(R, 0, 20, True) End Sub
添加文字
2D文本位置
将文本添加到最后一个矩形:
[C#]
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { string text = "My Text"; Size s = new Size(150, 50); Point p = new Point(g.ChartXCenter - (s.Width/2), g.ChartYCenter - (s.Height/2)); Rectangle r = new Rectangle(p,s); g.Pen.Color = Color.Blue; g.Rectangle(r); g.TextOut(Convert.ToInt32(g.ChartXCenter - (g.TextWidth(text)/2)), Convert.ToInt32(g.ChartYCenter - (g.TextHeight(text)/2)), text); }
[VB.Net]
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw Dim Text As String = "My Text" Dim S As New Size(50, 50) Dim P As New Point(g.ChartXCenter - (S.Width / 2), g.ChartYCenter - (S.Height / 2)) Dim R As New Rectangle(P, S) g.Pen.Color = Color.Blue g.Rectangle(R) g.TextOut(Convert.ToInt32(g.ChartXCenter - (g.TextWidth(Text) / 2)), Convert.ToInt32(g.ChartYCenter - (g.TextHeight(Text) / 2)), Text) End Sub
3D文字位置
通过使用带有az坐标的TextOut重载,可以将文本放置在不同的3D平面中。
[c#]
private void Form1_Load(object sender, System.EventArgs e) { point3DSeries1.FillSampleValues(20); point3DSeries1.LinePen.Visible = false; tChart1.Aspect.Chart3DPercent = 50; } private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { string text = "My Text"; g.TextOut(g.ChartXCenter, g.ChartYCenter, tChart1.Aspect.Width3D / 2, text); }
[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Point3DSeries1.FillSampleValues(20) Point3DSeries1.LinePen.Visible = False TChart1.Aspect.Chart3DPercent = 50 End Sub Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw Dim Text As String = "My Text" g.TextOut(g.ChartXCenter, g.ChartYCenter, TChart1.Aspect.Width3D / 2, Text) End Sub
应用示例
此示例获取系列的第3和第10个值,在它们之间绘制一条直线,并告诉我们新线的第一个和最后一个点的值以及它们之间的差异:
[c#]
private void Form1_Load(object sender, System.EventArgs e) { tChart1.Aspect.View3D = false; line1.FillSampleValues(20); } private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { if(tChart1.Series.Count > 0){ if(tChart1.Series[0].Count > 10) { Series s = tChart1.Series[0]; int h = Convert.ToInt32(g.TextHeight("H")); Point p1 = new Point(s.CalcXPos(3), s.CalcYPos(3)); Point p2 = new Point(s.CalcXPos(10), s.CalcYPos(10)); g.Pen.Color = Color.Blue; g.Pen.Width = 2; g.Pen.Style = System.Drawing.Drawing2D.DashStyle.Dash; g.MoveTo(p1); g.LineTo(p2, 0); g.TextOut(p1.X, p1.Y - h, "Point value: " + s.YValues[3].ToString()); g.TextOut(p2.X, p2.Y, "Point value: " + s.YValues[10].ToString()); g.TextOut(p2.X, p2.Y + h, "Change is: " + Convert.ToString(s.YValues[3] - s.YValues[10])); } } }
[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TChart1.Aspect.View3D = False Line1.FillSampleValues(20) End Sub Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw If TChart1.Series.Count > 0 Then If TChart1.Series(0).Count > 10 Then Dim S As Steema.TeeChart.Series = TChart1.Series(0) Dim H As Integer = Convert.ToInt32(g.TextHeight("H")) Dim P1 As New Point(S.CalcXPos(3), S.CalcYPos(3)) Dim P2 As New Point(S.CalcXPos(10), S.CalcYPos(10)) g.Pen.Color = Color.Blue g.Pen.Width = 2 g.Pen.Style = System.Drawing.Drawing2D.DashStyle.Dash g.MoveTo(P1) g.LineTo(P2, 0) g.TextOut(P1.X, P1.Y - H, "Point value: " & S.YValues(3)) g.TextOut(P2.X, P2.Y, "Point value: " & S.YValues(10)) g.TextOut(P2.X, P2.Y + H, "Change is: " & (S.YValues(3) - S.YValues(10))) End If End If End Sub
点击“了解更多”下载产品最新版
↓↓↓
标签: #用vbnet编写画图程序