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的变量,保存图片的路径,到那个窗口直接用就行了
atcloud怎么样?atcloud刚刚发布了最新的8折优惠码,该商家主要提供常规cloud(VPS)和storage(大硬盘存储)系列VPS,其数据中心分布在美国(俄勒冈、弗吉尼亚)、加拿大、英国、法国、德国、新加坡,所有VPS默认提供480Gbps的超高DDoS防御。Atcloud高防VPS。atcloud.net,2020年成立,主要提供基于KVM虚拟架构的VPS、只能DNS解析、域名、SS...
香港服务器租用多少钱一个月?香港服务器受到很多朋友的青睐,其中免备案成为其特色之一。很多用户想了解香港云服务器价格多少钱,也有同行询问香港服务器的租赁价格,一些实际用户想要了解香港服务器的市场。虽然价格是关注的焦点,但价格并不是香港服务器的全部选择。今天小编介绍了一些影响香港服务器租赁价格的因素,以及在香港租一个月的服务器要花多少钱。影响香港服务器租赁价格的因素:1.香港机房选择香港机房相当于选择...
Hostodo在九月份又发布了两款特别套餐,开设在美国拉斯维加斯、迈阿密和斯波坎机房,基于KVM架构,采用NVMe SSD高性能磁盘,最低1.5GB内存8TB月流量套餐年付34.99美元起。Hostodo是一家成立于2014年的国外VPS主机商,主打低价VPS套餐且年付为主,基于OpenVZ和KVM架构,美国三个地区机房,支持支付宝或者PayPal、加密货币等付款。下面列出这两款主机配置信息。CP...
picturebox为你推荐
阶乘符号数学中的阶乘符号与那个标点符号的写法相同?flash实例Flash元件和实例的概念及关系?webservice框架什么是webservice,什么情况下使用,如何使用java程序员招聘为什么Java程序员工资都很高cursorlocationsession("rs").cursorlocation=3是什么意思?特斯拉model3降价小鹏P7和特斯拉Model 3,买哪个更加划算?彩信平台请问彩信平台升级怎么改参数能告诉我具体步骤吗?validdatevalid use date 什么意思idataparameterweighting parameter是什么意思pass是什么在英语里pass是什么意思
购买域名和空间 注册cn域名 大硬盘 diahosting kdata 新站长网 绍兴高防 好看qq空间 元旦促销 全站静态化 天互数据 nerds 国外代理服务器软件 四核服务器 优酷黄金会员账号共享 华为云盘 台湾google 视频服务器是什么 带宽租赁 监控服务器 更多