随笔分类 - C#
改变图片的对比度
摘要:private void button1_Click(object sender, EventArgs e) { UpdatePicBoxEventHandle UpdatePicBox = new UpdatePicBoxEventHandle(...
阅读全文
设置/取消桌面背景
摘要:private void Set_Click(object sender, EventArgs e) { //设置壁纸 SystemParametersInfo(SystemParametersInfoAction.SPI_SETDESKW...
阅读全文
放大镜
摘要:using (Graphics g = pictureBox1.CreateGraphics()) {//画板 Rectangle sourceRec = new Rectangle(e.X - 10, e.Y - 10, 10, ...
阅读全文
图片缩放/旋转/平移/设置分辨率
摘要:#region 设置分辨率 using (Graphics g = pictureBox2.CreateGraphics()) { g.Clear(pictureBox2.BackColor);//清空 ...
阅读全文
贝塞尔样条
摘要:/*贝塞尔样条是由四个点指定的曲线:两个端点(p1 和 p2)和两个控制点(c1 和 c2)。曲线开始于 p1,结束于 p2。 * 该曲线不经过控制点,但是控制点的作用像磁铁一样,在某些方向上拉拽曲线并影响曲线弯曲的方式。 该曲线始于 p1 并向控制点...
阅读全文
线性梯度画刷
摘要:using (Graphics graphics = this.CreateGraphics()) {// graphics.Clear(Color.White); Pen pen = new Pen(Color.Red, 2); ...
阅读全文
画七彩五角星
摘要:using (Graphics graphics = this.CreateGraphics()) { graphics.Clear(Color.White); Point[] points = {//顺时针点坐标...
阅读全文
画花纹图案
摘要:using (Graphics g = this.CreateGraphics()) {//画板 g.FillRectangle(Brushes.White, this.ClientRectangle);//画板颜色 ...
阅读全文
画箭头
摘要:using (Pen mypen = new Pen(Color.Black, 6)) { mypen.StartCap = LineCap.DiamondAnchor;//设置起始箭头 mypen.EndCap = ...
阅读全文
图片填充线条
摘要:Bitmap bitmap = new Bitmap("1.jpg"); TextureBrush b = new TextureBrush(bitmap);//指定纹理图片 Pen p = new Pen(b, 30);//创建画笔 ...
阅读全文
创建快捷方式
摘要:WshShell shell = new WshShell();//建立对象 //生成快捷方式文件,指定路径及文件名 IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut( Environme...
阅读全文
接收按键消息
摘要:public const int WM_KEYDOWN = 0x0100;//按键消息 public const int WM_SYSKEYDOWN = 0x0104;//快捷键或系统命令键的消息 protected override bool ProcessCmdKe...
阅读全文
获取剪贴板中的数据
摘要:/// /// Adds the specified window to the chain of clipboard viewers. Clipboard viewer windows receive a WM_DRAWCLIPBOARD message whenever the...
阅读全文
获取鼠标位置的颜色值
摘要:Color c = new Color();//创建颜色对象 Bitmap bitmap = new Bitmap(this.BackgroundImage);//创建BITMAP对象 int x = Cursor.Position.X;//鼠标x坐标 ...
阅读全文
接触/限制鼠标活动区域
摘要:this.Cursor = new Cursor(Cursor.Current.Handle); Cursor.Position = new Point(Cursor.Position.X,Cursor.Position.Y);//鼠标位置 Cursor....
阅读全文
鼠标左右键互换
摘要:/// /// Reverses or restores the meaning of the left and right mouse buttons. /// /// If this parameter is TRUE, the left button generates right-button messages and the righ...
阅读全文
c# 隐藏 控制台应用程序
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Diagnostics;using System.Runtime.InteropServices;namesp...
阅读全文
Ping
摘要:const int SOCKET_ERROR = -1; const int ICMP_ECHO = 8; public string PingHost(string host) { IPHostEntry server...
阅读全文