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的变量,保存图片的路径,到那个窗口直接用就行了
RAKsmart怎么样?RAKsmart香港机房新增了付费的DDoS高防保护服务,香港服务器默认接入20Mbps的大陆优化带宽(电信走CN2、联通和移动走BGP)。高防服务器需要在下单页面的IP Addresses Option里面选择购买,分:40Gbps大陆优化高防IP-$461/月、100Gbps国际BGP高防IP-$692/月,有兴趣的可以根据自己的需求来选择!点击进入:RAKsmart官...
俄罗斯vps云服务器商家推荐!俄罗斯VPS,也叫毛子主机(毛子vps),因为俄罗斯离中国大陆比较近,所以俄罗斯VPS的延迟会比较低,国内用户也不少,例如新西伯利亚机房和莫斯科机房都是比较热门的俄罗斯机房。这里为大家整理推荐一些好用的俄罗斯VPS云服务器,这里主要推荐这三家:justhost、ruvds、justg等俄罗斯vps主机,方便大家对比购买适合自己的俄罗斯VPS。一、俄罗斯VPS介绍俄罗斯...
georgedatacenter这次其实是两个促销,一是促销一款特价洛杉矶E3-1220 V5独服,性价比其实最高;另外还促销三款特价vps,georgedatacenter是一家成立于2019年的美国VPS商家,主营美国洛杉矶、芝加哥、达拉斯、新泽西、西雅图机房的VPS、邮件服务器和托管独立服务器业务。georgedatacenter的VPS采用KVM和VMware虚拟化,可以选择windows...
picturebox为你推荐
贸易配额出口配额是什么意思?小明发布首页永久网站小明看看手机首页链接旺旺群发淘宝怎样旺旺群群发存储区域网络什么是存储局域网?组建它需要哪些内容?4k超高清视频下载为新手推荐几个获取4K片源的途径snake模型急求 设计贪吃蛇实验报告excel大写金额EXCEL如何显示出汉字大写金额公众号付费阅读怎么利用公众号做知识付费?netbios协议NetBIOS协议起什么作用?音乐代码网页中怎么写自动播放mp3音乐的代码
什么是域名 子域名查询 cn域名备案 cybermonday ion vultr美国与日本 搬瓦工官网 视频存储服务器 mach 国外bt 监控宝 双12活动 嘉洲服务器 可外链相册 isp服务商 国外ip加速器 优酷黄金会员账号共享 环聊 net空间 空间申请 更多