如何使得picturebox2不覆盖红色画出来的线?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
pictureBox2.Parent = pictureBox1;
}
private Point _pictureBoxBigXY_L; //存放[波形放大方框]的起点坐标
private Point _pictureBoxBigXY_R; //存放鼠标移动时的坐标
private Point _pictureBoxBigXY_M; //存放最后调整后[波形放大框]的位置坐标
private Color BigXYBackColor = Color.FromArgb(255, 255, 255);
private Color BigXYButtonBackColor = Color.FromArgb(200, 255, 255, 255);
private Color BigXYButtonForeColor = Color.FromArgb(0, 0, 0);
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Graphics ag = this.pictureBox1.CreateGraphics();
ag.DrawLine(new Pen(Color.Red, 2), 10, 10, 500, 500);
if (e.Button == MouseButtons.Left)
{
_pictureBoxBigXY_L.X = e.X;
_pictureBoxBigXY_L.Y = e.Y;
pictureBox2.Location = _pictureBoxBigXY_L; //更新[波形放大框]位置坐标
pictureBox2.Width = 200;
pictureBox2.Height = 200;
return;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void pictureBox2_Paint(object sender, PaintEventArgs e)
{
this.pictureBox2.BackColor = Color.FromArgb(50, Color.Transparent);
}
}
}