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的变量,保存图片的路径,到那个窗口直接用就行了
tmhhost怎么样?tmhhost正在搞暑假大促销活动,全部是高端线路VPS,现在直接季付8折优惠,活动截止时间是8月31日。可选机房及线路有美国洛杉矶cn2 gia+200G高防、洛杉矶三网CN2 GIA、洛杉矶CERA机房CN2 GIA,日本软银(100M带宽)、香港BGP直连200M带宽、香港三网CN2 GIA、韩国双向CN2。点击进入:tmhhost官方网站地址tmhhost优惠码:Tm...
华纳云(HNCloud Limited)是一家专业的全球数据中心基础服务提供商,总部在香港,隶属于香港联合通讯国际有限公司,拥有香港政府颁发的商业登记证明,保证用户的安全性和合规性。 华纳云是APNIC 和 ARIN 会员单位。主要提供数据中心基础服务、互联网业务解决方案, 以及香港服务器租用、香港服务器托管、香港云服务器、美国云服务器,云计算、云安全技术研发等产品和服务。其中云服务器基于成熟的 ...
公司成立于2007年,是国内领先的互联网业务平台服务提供商。公司专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前,旅途云公司研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的国内BGP、双线高防、香港等优质的IDC资源。点击进入:旅途云官方网商家LOGO优惠方案:CPU内存硬盘带宽/流量/防御...
picturebox为你推荐
短信营销方案短信营销怎么才能更有效果呢?scriptmanager怎么解决ScriptManager和Jqery冲突renderpartialYii中render和renderPartial的区别公众号付费阅读如何申请微信付费阅读功能pat是什么格式怎么能把常用格式的图片转换成PAT格式的呀~云输入法QQ云输入法怎样进行中英文切换?特斯拉model3降价特斯拉model 3中国有补贴吗东兴证券网站东兴证券超强版下载怎么查微信注册时间怎么知道微信上次登录时间空间导航QQ空间中如何自定义导航?
域名升级访问 备案未注册域名 出租服务器 免费域名解析 新加坡主机 免费ftp空间 网页背景图片 搜狗12306抢票助手 免费全能空间 湖南服务器托管 e蜗牛 免费网站申请 vip购优汇 idc是什么 免费防火墙 免费智能解析 电信主机 江苏双线服务器 四川电信商城 空间登入 更多