pictureboxc#如何在picturebox上显示图片
picturebox 时间:2021-06-17 阅读:(
)
(c#)操作picturebox
当然是通过定义边界了,Rectangle类,在mousemove事件中判断是否移到边界,下面给你一些简单的代码,具体实现还要看你自己,当然要实现扭曲旋转这种效果,要用到GDI+
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
Point postion = new Point(100,100); //显示图片的左上角位置
Size size = new Size(100,100); //图片显示大小
//定义四个区域
Rectangle LeftTop; //左上
Rectangle RightTop; //右上
Rectangle LeftBottom; //左下
Rectangle RightBottom; //右下
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
LeftTop = new Rectangle(postion.X, postion.Y, 5, 5);
RightTop = new Rectangle(postion.X + size.Width - 5, postion.Y, 5, 5);
LeftBottom = new Rectangle(postion.X, postion.Y + size.Height - 5, 5, 5);
RightBottom = new Rectangle(postion.X + size.Width - 5, postion.Y + size.Height - 5, 5, 5);
}
//在Paint事件中,画出图形
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Brush brush = new SolidBrush(Color.Blue);
g.FillRectangle(brush, postion.X, postion.Y, size.Width, size.Height);
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (LeftTop.Contains(e.Location) ||
RightTop.Contains(e.Location) ||
LeftBottom.Contains(e.Location) ||
RightBottom.Contains(e.Location))
{
Cursor.Current = Cursors.Hand;
}
}
}
}picturebox 怎样显示文字
利用c#的GDI+技术,PictureBox.CreateGraphics()绘图,利用g.DrawString写文字。
利用this.Invalidate()刷新Form窗体,或者利用PictureBox.Invalidate()刷新PictureBox.。
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CCDTest
{
public partial class Form1 : Form
{
string filename;
//Label lblResult;
public Form1()
{
InitializeComponent();
filename = Application.StartupPath + "";
}
private void Form1_Load(object sender, EventArgs e)
{
pbCCD.Load(filename);
}
private void pbCCD_MouseDown(object sender, MouseEventArgs e)
{
PointF pf = e.Location;
using (Graphics g = pbCCD.CreateGraphics())
{
Console.WriteLine("Beg MyDraw....");
Font f = new Font("Arial", 12);
g.DrawString("Hello!", f, Brushes.Violet, pf);
Console.WriteLine("End MyDraw.....");
}
}
private void pbCCD_MouseUp(object sender, MouseEventArgs e)
{
pbCCD.Invalidate();
}
}
}c#如何在picturebox上显示图片
看你在哪个窗口里执行了,要是就在当前窗口,那就把别的窗口那个picturebox的modifier属性设置成public,然后直接设置就行了,要是在别的窗口,就定义一个public的变量,保存图片的路径,到那个窗口直接用就行了
搬瓦工今天正式对外开卖荷兰阿姆斯特丹机房走联通AS9929高端线路的VPS,官方标注为“NL - China Unicom Amsterdam(ENUL_9)”,三网都走联通高端网络,即使是在欧洲,国内访问也就是飞快。搬瓦工的依旧是10Gbps带宽,可以在美国cn2 gia、日本软银与荷兰AS9929之间免费切换。官方网站:https://bwh81.net优惠码:BWH3HYATVBJW,节约6...
目前,我们都在用哪个FTP软件?喜欢用的是WinSCP,是一款免费的FTP/SFTP软件。今天在帮助一个网友远程解决问题的时候看到他用的是FlashFXP FTP工具,这个工具以前我也用过,不过正版是需要付费的,但是网上有很多的绿色版本和破解版本。考虑到安全的问题,个人不建议选择破解版。但是这款软件还是比较好用的。今天主要是遇到他的虚拟主机无法通过FTP连接主机,这里我就帮忙看看到底是什么问题。一...
mineserver怎么样?mineserver是一家国人商家,主要提供香港CN2 KVM VPS、香港CMI KVM VPS、日本CN2 KVM VPS、洛杉矶cn2 gia端口转发等服务,云服务器网(yuntue.com)介绍过几次,最近比较活跃。现在新推出了3款特价KVM VPS,性价比高,香港CMI/洛杉矶GIA VPS,2核/2GB内存/20GB NVME/3.5TB流量/200Mbps...
picturebox为你推荐
贸易配额出口配额是什么意思?implement_dynamic(VC++)DECLARE_DYNAMIC(CDrawToolDlg)这个是什么意思?公众号付费阅读目前公众号有没有的付费问答平台可以提供的?sdfsdfsdfsdf世界上最大的一块金砖有多重?pat是什么格式怎么将自己做的PS图片保存为PAT格式?上行宽带上行宽带是什么?java程序员招聘java工程师待遇如何网络安全密钥一般路由器是网络安全密钥是多少腾讯合作伙伴大会腾讯的合作伙伴都有za是哪个国家的奥洛菲是哪个国家的
域名到期查询 网站虚拟主机空间 免费注册网站域名 谷歌域名邮箱 idc评测 企业主机 westhost 国外空间服务商 抢票工具 html空间 dd444 idc是什么 绍兴电信 paypal注册教程 常州联通宽带 石家庄服务器托管 德隆中文网 中国linux 稳定空间 阿里dns 更多