是否可以在不删除主要图形的情况下绘制PictureBox [英] Is it possible to draw in PictureBox, without erasing the main figure

查看:40
本文介绍了是否可以在不删除主要图形的情况下绘制PictureBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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(...)) [
It is possible but makes no sense, whatsoever. It''s much better to draw immediately on some control without any images in it. The PictureBox control is only useful for very simple way of adding already existing images (bitmaps). If you need something dynamic (interactive, animated, anything), this middleman image does not help at all, only forces you in doing unnecessary job and waste extra resources. You need to draw on a "regular" control (a custom one derived from System.Windows.Forms.Control, on Panel or something like that).

I''ll explain what to do. Please see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^].

And, for some more detail:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].

—SA


这篇关于是否可以在不删除主要图形的情况下绘制PictureBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆