Пример #1
0
        private void b1_MouseUp(object sender, MouseEventArgs e)
        {
            flag             = false;
            button4.Location = new Point(button1.Location.X / 2, button1.Location.Y);
            button3.Location = new Point(button1.Location.X, button1.Location.Y / 2);
            pictureBox1.Size = new Size((button1.Location.X - panel1.AutoScrollPosition.X), (button1.Location.Y - panel1.AutoScrollPosition.Y));
            //dt.aim = this.pictureBox1.CreateGraphics();
            bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics g = Graphics.FromImage(bmp);

            g.FillRectangle(new SolidBrush(pictureBox1.BackColor), new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
            g.DrawImage(dt.O, 0, 0);
            g.Dispose();
            dt = new DrawTools(pictureBox1.CreateGraphics(), bmp);
        }
Пример #2
0
        private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)//设置背景
        {
            bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics       g    = Graphics.FromImage(bmp); //画板
            OpenFileDialog file = new OpenFileDialog();    //打开文件

            file.ShowDialog();
            Bitmap pic = new Bitmap(file.FileName);//所选文件

            g.DrawImage(pic, 0, 0);
            g.Dispose();
            dt = new DrawTools(pictureBox1.CreateGraphics(), bmp); //实例化dt
            dt.aim.DrawImage(bmp, 0, 0);                           //将所选图片画到目标滑板上
            dt.aim.Dispose();
        }
Пример #3
0
        private void Drawing_Load(object sender, EventArgs e)
        {
            bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics g = Graphics.FromImage(bmp);

            g.FillRectangle(new SolidBrush(pictureBox1.BackColor), new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
            g.Dispose();
            dt = new DrawTools(pictureBox1.CreateGraphics(), bmp);
            pictureBox1.MouseDown  += new MouseEventHandler(this.pic_MouseDown);
            pictureBox1.MouseMove  += new MouseEventHandler(this.pic_MouseMove);
            pictureBox1.MouseUp    += new MouseEventHandler(this.pic_MouseUp);
            pictureBox1.MouseWheel += new MouseEventHandler(this.pic_MouseWheel);
            button1.MouseDown      += new MouseEventHandler(this.b1_MouseDown);
            button1.MouseMove      += new MouseEventHandler(this.b1_MouseMove);
            button1.MouseUp        += new MouseEventHandler(this.b1_MouseUp);
            button3.MouseDown      += new MouseEventHandler(this.b3_MouseDown);
            button3.MouseMove      += new MouseEventHandler(this.b3_MouseMove);
            button3.MouseUp        += new MouseEventHandler(this.b3_MouseUp);
            button4.MouseDown      += new MouseEventHandler(this.b4_MouseDown);
            button4.MouseMove      += new MouseEventHandler(this.b4_MouseMove);
            button4.MouseUp        += new MouseEventHandler(this.b4_MouseUp);
        }