1)我在图片框中创建了一个图,现在我想在图内绘制所有这些图,这有可能吗? 2)
1)I created a figure in a picturebox , and now all of these figures, I want to draw inside the figure, is that possible? 2)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Test_Draw { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.FillPie(Brushes.Azure, 0 - 450, 0, 1000, 1000, 270, 90); e.Graphics.DrawLine(Pens.Blue, 0, 500, 500, 400); Font f = new Font("Arial", 20); e.Graphics.DrawString("We learn to draw!", f, Brushes.Black, 200, 200); }
推荐答案
可能,但毫无意义.最好立即在没有任何图像的控件上进行绘制. PictureBox控件仅对添加现有图像(位图)的非常简单的方式有用.如果您需要动态的东西(交互,动画,任何东西),那么这个中间人图像根本没有帮助,只会迫使您执行不必要的工作并浪费额外的资源.您需要使用常规"控件(从System.Windows.Forms.Control派生的自定义控件,在Panel或类似的控件上). 我会解释该怎么办.请查看我过去的答案: 如何从旧图纸中清除面板 [ ^ ], 在C#中绘制矩形 [ ^ ], 在图片框内添加图片 [ ^ ]. 并且,有关更多详细信息: 在mdi子表单之间画线 [ ^ ], 在面板上捕获图形 [ ^ ], Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [ ^ ].