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的变量,保存图片的路径,到那个窗口直接用就行了
Hostodo发布了几款采用NVMe磁盘的促销套餐,从512MB内存起,最低年付14.99美元,基于KVM架构,开设在拉斯维加斯机房。这是一家成立于2014年的国外VPS主机商,主打低价VPS套餐且年付为主,基于OpenVZ和KVM架构,产品性能一般,数据中心目前在拉斯维加斯和迈阿密,支持使用PayPal或者支付宝等付款方式。下面列出几款NVMe硬盘套餐配置信息。CPU:1core内存:512MB...
最近很多网站都遭受到了伪墙/假墙攻击,导致网站流量大跌,间歇性打不开网站。这是一种新型的攻击方式,攻击者利用GWF规则漏洞,使用国内服务器绑定host的方式来触发GWF的自动过滤机制,造成GWF暂时性屏蔽你的网站和服务器IP(大概15分钟左右),使你的网站在国内无法打开,如果攻击请求不断,那么你的网站就会是一个一直无法正常访问的状态。常规解决办法:1,快速备案后使用国内服务器,2,使用国内免备案服...
reliablesite怎么样?reliablesite是一家于2006年成立的老牌美国主机商,主要提供独服,数据中心有迈阿密、纽约、洛杉矶等,均免费提供20Gbps DDoS防护,150TB月流量,1Gbps带宽。月付19美金可升级为10Gbps带宽。洛杉矶/纽约/迈阿密等机房,E3-1240V6/64GB内存/1TB SSD硬盘/DDOS/150TB流量/1Gbps带宽/DDOS,$95/月,...
picturebox为你推荐
订房系统求酒店开房系统英文名网站介绍几个好的英语学习网站存储区域网络网络存储技术的SAN(存储区域网络)的优点scriptmanagerajax ToolkitScriptManager与ScriptManager的区别youtube创始人卜秋静 有关生平介绍avc是什么格式电厂AVC啥意思?刷ip流量如何刷自己网站的IP流量shoujiao手机电池突然充不上电,是怎么回事?该怎么办?java程序员招聘java工程师待遇如何腾讯合作伙伴大会腾讯位置服务是什么?
解析域名 域名查询系统 hostigation qq云存储 秒解服务器 线路工具 英文站群 java虚拟主机 100m免费空间 中国智能物流骨干网 可外链网盘 世界测速 免费全能主机 cn3 空间技术网 idc查询 免费的域名 免费asp空间申请 789电视剧网 qq空间打开很慢 更多