基本信息
源码名称:C# 画梅花(基于System.Drawing)
源码大小:1.42M
文件格式:.rar
开发语言:C#
更新时间:2020-08-16
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;

namespace PtechClassLibrary
{
    public class Class1
    {
        public void DrawPic(MouseEventArgs e,int flag,PictureBox petchPic)
        {
            Point myPT = new Point(e.X, e.Y);//获取鼠标单击位置
            PictureBox pbox = new PictureBox();//实例化PictureBox控件
            pbox.Location = myPT;//指定PictureBox控件的位置
            pbox.BackColor = Color.Transparent;//设置PictureBox控件的背景色
            pbox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;//设置PictureBox控件的图片显示方式
            switch (flag)//判断标识
            {
                case 0:
                    pbox.Size = new System.Drawing.Size(20, 18);//设置PictureBox控件大小
                    pbox.Image = Image.FromFile("2.gif");//设置PictureBox控件要显示的图像
                    break;
                case 1:
                    pbox.Size = new System.Drawing.Size(30, 31);//设置PictureBox控件大小
                    pbox.Image = Image.FromFile("3.gif");//设置PictureBox控件要显示的图像
                    break;
                case 2:
                    pbox.Size = new System.Drawing.Size(34, 30);//设置PictureBox控件大小
                    pbox.Image = Image.FromFile("1.gif");//设置PictureBox控件要显示的图像
                    break;
            }
            if (e.Button == MouseButtons.Left)//判断是否单击了鼠标左键
            {
                petchPic.Controls.Add(pbox);//将PictureBox控件添加到树枝上
            }
        }
    }
}