基本信息
源码名称:C# 编程工具箱源码下载
源码大小:1.36M
文件格式:.rar
开发语言:C#
更新时间:2017-12-26
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 10 元×
微信扫码支付:10 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
为编程提供便捷方式,
加入历史剪切板和常用正则!
未完善【自定义安卓库】
打算写一个联网的有兴趣的可以联系我!qq:481869314
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 编程工具箱
{
//猫九先森QQ:481869314可以一起写一个我联网的哦!有兴趣联系我!
public partial class Form1 : Form
{
int tp = 0;
ArrayList jqb = new ArrayList();
string st = Clipboard.GetText();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
FormDock a = new FormDock(this);
}
#region 取色器
[DllImport("user32.dll")]//取设备场景
private static extern IntPtr GetDC(IntPtr hwnd);//返回设备场景句柄
[DllImport("gdi32.dll")]//取指定点颜色
private static extern int GetPixel(IntPtr hdc, Point p);
private void timer1_Tick(object sender, EventArgs e)
{
Point p = new Point(MousePosition.X, MousePosition.Y);//取置顶点坐标
label1.Text ="当前鼠标坐标:" "X:" p.X "Y:" p.Y;//把坐标显示到窗口上
IntPtr hdc = GetDC(new IntPtr(0));//取到设备场景(0就是全屏的设备场景)
int c = GetPixel(hdc, p);//取指定点颜色
int r = (c & 0xFF);//转换R
int g = (c & 0xFF00) / 256;//转换G
int b = (c & 0xFF0000) / 65536;//转换B
textBox1.Text = c.ToString();//输出10进制颜色
textBox2.Text ="#" r.ToString("x").PadLeft(2, '0') g.ToString("x").PadLeft(2, '0') b.ToString("x").PadLeft(2, '0');//输出16进制颜色
textBox3.Text = r.ToString() ',' g.ToString() ',' b.ToString();//输出RGB
pictureBox1.BackColor = Color.FromArgb(r, g, b);//设置颜色框
}
private void button1_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
}
#endregion
#region 快捷按钮
private void button2_Click(object sender, EventArgs e)
{
try
{
//远程桌面
System.Diagnostics.Process.Start("mstsc.exe");
}
catch
{
MessageBox.Show("系统找不到指定的程序文件", "错误提示!");
return;
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
//计算器
System.Diagnostics.Process.Start("calc.exe");
}
catch
{
MessageBox.Show("系统找不到指定的程序文件", "错误提示!");
return;
}
}
private void button4_Click(object sender, EventArgs e)
{
try
{
//记事本
System.Diagnostics.Process.Start("notepad.exe");
}
catch
{
MessageBox.Show("系统找不到指定的程序文件", "错误提示!");
return;
}
}
private void button5_Click(object sender, EventArgs e)
{
try
{
//CMD
System.Diagnostics.Process.Start("cmd.exe");
}
catch
{
MessageBox.Show("系统找不到指定的程序文件", "错误提示!");
return;
}
}
private void button7_Click(object sender, EventArgs e)
{
try
{
string path = null;
OpenFileDialog opf = new OpenFileDialog();
opf.Filter = "JPG|*.jpg|PNG|*.png|GIF|*.gif";
if (opf.ShowDialog() == DialogResult.OK)
path = opf.FileName;
Bitmap pbm = new Bitmap(path);
this.BackgroundImage = pbm;
}
catch
{ }
}
private void button8_Click(object sender, EventArgs e)
{
string character;
character = textASCII.Text;
try
{
if (character.Length == 1)
{
ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
int intAsciiCode = (int)asciiEncoding.GetBytes(character)[0];
textBox4.Text="ASCII:" intAsciiCode.ToString();
}
else
{
throw new Exception("Character is not valid.");
}
}
catch { MessageBox.Show("转换失败请输入一个合法字符!","系统提示:"); }
}
private void button6_Click(object sender, EventArgs e)
{
//创建图象,保存将来截取的图象
Bitmap image = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics imgGraphics = Graphics.FromImage(image);
//设置截屏区域
imgGraphics.CopyFromScreen(0, 0, 0, 0, new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));
//保存
image.Save(tp ".jpg");
}
#endregion
#region 桌面停靠
/// <summary>
/// 窗口停靠隐藏类
/// 使用方法
/// private FormDock formDock = null;
/// formDock = new FormDock(this,300);
/// </summary>
public class FormDock
{
#region 自定义声明
/// <summary>
/// 定义计时器
/// </summary>
private Timer StopRectTimer = new Timer();
/// <summary>
/// 贴边设置
/// </summary>
internal AnchorStyles StopAanhor = AnchorStyles.None;
/// <summary>
/// 父级窗口实例
/// </summary>
private Form parentForm = null;
private Point m_TempPoiont;//临时点位置
private Point m_LastPoint;//窗体最小化前的坐标点位置
#endregion
#region 构造函数
/// <summary>
/// 自动停靠
/// </summary>
/// <param name="frmParent">父窗口对象</param>
public FormDock(Form frmParent)
{
parentForm = frmParent;
parentForm.LocationChanged = new EventHandler(parentForm_LocationChanged);
StopRectTimer.Tick = new EventHandler(timer1_Tick); //注册事件
StopRectTimer.Interval = 500; //计时器执行周期
StopRectTimer.Start(); //计时器开始执行
}
/// <summary>
/// 自动停靠
/// </summary>
/// <param name="frmParent">父窗口对象</param>
/// <param name="_trimInterval">时钟周期</param>
public FormDock(Form frmParent, int _trimInterval)
{
parentForm = frmParent;
parentForm.LocationChanged = new EventHandler(parentForm_LocationChanged);
StopRectTimer.Tick = new EventHandler(timer1_Tick); //注册事件
StopRectTimer.Interval = _trimInterval; //计时器执行周期
StopRectTimer.Start(); //计时器开始执行
}
#endregion
/// <summary>
/// 时钟的开始
/// </summary>
public void TimerStart()
{
StopRectTimer.Start();
}
/// <summary>
/// 时钟的停止
/// </summary>
public void TimerStop()
{
StopRectTimer.Stop();
}
#region 窗口位置改变事件
/// <summary>
/// 窗口位置改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void parentForm_LocationChanged(object sender, EventArgs e)
{
if (parentForm.Location.X == -32000 && parentForm.Location.Y == -32000)
{
m_LastPoint = m_TempPoiont;//最小化了,m_LastPoint就是最小化前的位置。
}
else
{
m_TempPoiont = parentForm.Location;
}
this.mStopAnthor();
}
#endregion
#region 计时器 周期事件
/// <summary>
/// 计时器 周期事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick(object sender, EventArgs e)
{
if (parentForm.Bounds.Contains(Cursor.Position))
{
this.FormShow();
}
else
{
this.FormHide();
}
}
#endregion
#region 窗口停靠位置计算
/// <summary>
/// 窗口停靠位置计算
/// </summary>
private void mStopAnthor()
{
if (parentForm.Top <= 0)
{
StopAanhor = AnchorStyles.Top;
}
else if (parentForm.Left <= 0)
{
StopAanhor = AnchorStyles.Left;
}
else if (parentForm.Left >= Screen.PrimaryScreen.Bounds.Width - parentForm.Width)
{
StopAanhor = AnchorStyles.Right;
}
else
{
StopAanhor = AnchorStyles.None;
}
}
#endregion
#region 窗体不贴边显示
/// <summary>
/// 窗体不贴边显示
/// </summary>
public void FormShow()
{
switch (this.StopAanhor)
{
case AnchorStyles.Top:
parentForm.Location = new Point(parentForm.Location.X, 0);
break;
case AnchorStyles.Left:
parentForm.Location = new Point(0, parentForm.Location.Y);
break;
case AnchorStyles.Right:
parentForm.Location = new Point(Screen.PrimaryScreen.Bounds.Width - parentForm.Width, parentForm.Location.Y);
break;
}
}
#endregion
#region 窗体贴边隐藏
/// <summary>
/// 窗体贴边隐藏
/// </summary>
private void FormHide()
{
switch (this.StopAanhor)
{
case AnchorStyles.Top:
if (parentForm.WindowState == FormWindowState.Minimized)
{
parentForm.Location = this.m_LastPoint;
break;
}
parentForm.Location = new Point(parentForm.Location.X, (parentForm.Height - 2) * (-1));
break;
case AnchorStyles.Left:
parentForm.Location = new Point((-1) * (parentForm.Width - 2), parentForm.Location.Y);
break;
case AnchorStyles.Right:
parentForm.Location = new Point(Screen.PrimaryScreen.Bounds.Width - 2, parentForm.Location.Y);
break;
}
}
#endregion
}
#endregion
#region 常用正则匹配
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int i;
i = comboBox1.SelectedIndex;
switch (i)
{
case 0:
Clipboard.SetDataObject(@"\w[-\w. ]*@([A-Za-z0-9][-A-Za-z0-9] \.) [A-Za-z]{2,14}");
MessageBox.Show(@"内容为:\w[-\w. ]*@([A-Za-z0-9][-A-Za-z0-9] \.) [A-Za-z]{2,14}","已复制到粘贴板");
break;
case 1:
Clipboard.SetDataObject(@"[\u4e00-\u9fa5]");
MessageBox.Show(@"内容为:[\u4e00-\u9fa5]", "已复制到粘贴板");
break;
case 2:
Clipboard.SetDataObject(@"[^\x00-\xff]");
MessageBox.Show(@"内容为:[^\x00-\xff]", "已复制到粘贴板");
break;
case 3:
Clipboard.SetDataObject(@"([01]?\d|2[0-3]):[0-5]?\d:[0-5]?\d");
MessageBox.Show(@"内容为:([01]?\d|2[0-3]):[0-5]?\d:[0-5]?\d", "已复制到粘贴板");
break;
case 4:
Clipboard.SetDataObject(@"(\d )\.(\d )\.(\d )\.(\d )");
MessageBox.Show(@"内容为:(\d )\.(\d )\.(\d )\.(\d )", "已复制到粘贴板");
break;
case 5:
Clipboard.SetDataObject(@"\d{17}[0-9Xx]|\d{15}");
MessageBox.Show(@"内容为:\d{17}[0-9Xx]|\d{15}", "已复制到粘贴板");
break;
case 6:
Clipboard.SetDataObject(@"(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)");
MessageBox.Show(@"内容为:(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)", "已复制到粘贴板");
break;
case 7:
Clipboard.SetDataObject(@"[1-9]\d*");
MessageBox.Show(@"内容为:[1-9]\d*", "已复制到粘贴板");
break;
case 8:
Clipboard.SetDataObject(@"-[1-9]\d*");
MessageBox.Show(@"内容为:-[1-9]\d*", "已复制到粘贴板");
break;
case 9:
Clipboard.SetDataObject(@"(13\d|14[57]|15[^4,\D]|17[13678]|18\d)\d{8}|170[0589]\d{7}");
MessageBox.Show(@"内容为:(13\d|14[57]|15[^4,\D]|17[13678]|18\d)\d{8}|170[0589]\d{7}", "已复制到粘贴板");
break;
default:
break;
}
}
#endregion
#region 历史剪切板
private void button9_Click(object sender, EventArgs e)
{
if (button9.Text == "清除历史剪切板")
{
timer2.Stop();
Clipboard.Clear();
jqb.Clear();
button9.Text = "开启历史剪切板";
}
else if (button9.Text != "开启历史剪切板")
{
button9.Text = "清除历史剪切板";
timer2.Start();
}
}
private void timer2_Tick(object sender, EventArgs e)
{
string temp = Clipboard.GetText();
if (st !=temp )
{
jqb.Add(temp);
comboBox2.Items.Add(temp);
st = temp;
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
int i;
i = comboBox2.SelectedIndex;
switch (i)
{
case 0:
Clipboard.SetDataObject(comboBox2.SelectedItem);
break;
case 1:
Clipboard.SetDataObject(comboBox2.SelectedItem);
break;
case 2:
Clipboard.SetDataObject(comboBox2.SelectedItem);
break;
case 3:
Clipboard.SetDataObject(comboBox2.SelectedItem);
break;
case 4:
Clipboard.SetDataObject(comboBox2.SelectedItem);
break;
default:
MessageBox.Show("当前只能截取前五个剪切板即将清空", "系统提示:");
jqb.Clear();
Clipboard.Clear();
comboBox2.Items.Clear();
break;
}
}
#endregion
private void button10_Click(object sender, EventArgs e)
{
android_kongjianku a = new android_kongjianku();
a.ShowDialog();
}
}
}