事件
public delegate void NumManipulationHandler(NumEventArgs e); // 基于上面的委托定义事件 public event NumManipulationHandler ChangeNum; public class Program { public static void Main() { NumEvent even = new NumEvent(0); even.ChangeNum += EventAction.Action; even.SetValue(7); even.SetValue(11); System.Console.ReadKey(); } } public class NumEvent { private int value; public delegate void NumManipulationHandler(NumEventArgs e); public event NumManipulationHandler ChangeNum; public virtual void OnChangeNum(NumEventArgs e) { ChangeNum?.Invoke(e); } public NumEvent(int n) { SetValue(n); } public void SetValue(int n) { if (value != n) { NumEventArgs e = new NumEventArgs(n); value = n; OnChangeNum(e); } } } public class EventAction { public static void Action(NumEventArgs e) { System.Console.WriteLine("value : " + e.value); } } public class NumEventArgs : EventArgs { public int value; public NumEventArgs(int _value) { this.value = _value; } }ini读写
using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Linq; using System.Text; namespace DEMOBus { public class IniFile { private string m_FileName; public string FileName { get { return m_FileName; } set { m_FileName = value; } } [DllImport("kernel32.dll")] private static extern int GetPrivateProfileInt( string lpAppName, string lpKeyName, int nDefault, string lpFileName ); [DllImport("kernel32.dll")] private static extern int GetPrivateProfileString( string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName ); [DllImport("kernel32.dll")] private static extern int WritePrivateProfileString( string lpAppName, string lpKeyName, string lpString, string lpFileName ); /// <summary> /// 构造函数 /// </summary> /// <param name="aFileName">Ini文件路径</param> public IniFile(string aFileName) { this.m_FileName = aFileName; } /// <summary> /// 构造函数 /// </summary> public IniFile() { } /// <summary> /// [扩展]读Int数值 /// </summary> /// <param name="section">节</param> /// <param name="name">键</param> /// <param name="def">默认值</param> /// <returns></returns> public int ReadInt(string section, string name, int def) { return GetPrivateProfileInt(section, name, def, this.m_FileName); } /// <summary> /// [扩展]读取string字符串 /// </summary> /// <param name="section">节</param> /// <param name="name">键</param> /// <param name="def">默认值</param> /// <returns></returns> public string ReadString(string section, string name, string def) { StringBuilder vRetSb = new StringBuilder(2048); GetPrivateProfileString(section, name, def, vRetSb, 2048, this.m_FileName); return vRetSb.ToString(); } /// <summary> /// [扩展]写入Int数值,如果不存在 节-键,则会自动创建 /// </summary> /// <param name="section">节</param> /// <param name="name">键</param> /// <param name="Ival">写入值</param> public void WriteInt(string section, string name, int Ival) { WritePrivateProfileString(section, name, Ival.ToString(), this.m_FileName); } /// <summary> /// [扩展]写入String字符串,如果不存在 节-键,则会自动创建 /// </summary> /// <param name="section">节</param> /// <param name="name">键</param> /// <param name="strVal">写入值</param> public void WriteString(string section, string name, string strVal) { WritePrivateProfileString(section, name, strVal, this.m_FileName); } /// <summary> /// 删除指定的 节 /// </summary> /// <param name="section"></param> public void DeleteSection(string section) { WritePrivateProfileString(section, null, null, this.m_FileName); } /// <summary> /// 删除全部 节 /// </summary> public void DeleteAllSection() { WritePrivateProfileString(null, null, null, this.m_FileName); } /// <summary> /// 读取指定 节-键 的值 /// </summary> /// <param name="section"></param> /// <param name="name"></param> /// <returns></returns> public string IniReadValue(string section, string name) { StringBuilder strSb = new StringBuilder(256); GetPrivateProfileString(section, name, "", strSb, 256, this.m_FileName); return strSb.ToString(); } /// <summary> /// 写入指定值,如果不存在 节-键,则会自动创建 /// </summary> /// <param name="section"></param> /// <param name="name"></param> /// <param name="value"></param> public void IniWriteValue(string section, string name, string value) { WritePrivateProfileString(section, name, value, this.m_FileName); } } }绘图
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Windows.Forms; namespace _949CS//实时曲线绘制 { class draw { public List<Point> ptlist = new List<Point> { new Point(0, 0)}; public PictureBox picbox = new PictureBox(); public Bitmap mybitmap;//用于双缓冲的位图,和画布等大 public Int32 xMoveToUp = 0, yMoveToRight = 0; //X上移距离与Y右移距离 public Int32 xToLeft = 5, xToRight = 10, yToUp = 5, yToDown = 5; //XY图像边距,x轴起点离左边距,终点右边距,y轴起点下边距,上边距,Y轴坐标为从上往下递增值 public void DrawLineS(Color color, float Xmax, float Ymax) { if (ptlist.Count < 2) {//空返回 return; } mybitmap = new Bitmap(picbox.Width, picbox.Height);//设定位图大小 Graphics doublebufferg = Graphics.FromImage(mybitmap);//从位图上获取“画布” doublebufferg.Clear(Color.Black);//用背景色刷新 //picbox填充为白色,便于显示图像 500*300 Rectangle rect = new Rectangle(0, 0, picbox.Width, picbox.Height); doublebufferg.FillRectangle(new SolidBrush(Color.Black), rect); //画X和Y轴 DrawXY(ref doublebufferg, picbox); //X轴上的刻度 SetYAxis(ref doublebufferg, picbox, Ymax); //Y轴上的刻度 SetXAxis(ref doublebufferg, picbox, Xmax); Point[] pt = ptlist.ToArray(); Int32 i = 0; for (i = 0; i < pt.Length; i++) { pt[i].X += xToLeft + yMoveToRight;//自定义坐标转换 pt[i].Y = picbox.Height - yToDown - xMoveToUp - pt[i].Y; if (i > 0) { //要显示的实时曲线部分 doublebufferg.DrawLine(new Pen(color, 1), pt[i - 1], pt[i]); } } //将缓冲中的位图绘制到我们的窗体上 if (!picbox.IsDisposed) { //是够释放 picbox.BackColor = Color.Black; //背景色直接设置 (picbox.CreateGraphics()).DrawImage(mybitmap, 0, 0); } } //X上移 public void SetMoveX(Int32 x) { xMoveToUp = x; } //Y右移 public void SetMoveY(Int32 y) { yMoveToRight = y; } //完成X轴和Y轴的基本部分 public void DrawXY(ref Graphics g,PictureBox picbox) { Pen pen = new Pen(Color.White, 2);//画笔 SolidBrush sb = new SolidBrush(Color.White);//话刷 //X轴的箭头,实际上是绘制了一个三角形 Int32 arrorWidth = 5, arrorHeight = 2; //箭头的三角形中位线长与底边长一半 Point[] xpts = new Point[3] { //自定义坐标转换 new Point(picbox.Width - (xToRight + arrorWidth), picbox.Height - (arrorHeight + yToDown + xMoveToUp)), new Point(picbox.Width - xToRight, picbox.Height - yToDown - xMoveToUp), new Point(picbox.Width - (xToRight + arrorWidth), picbox.Height + arrorHeight - yToDown - xMoveToUp) }; g.DrawLine(pen, xToLeft, picbox.Height - yToDown - xMoveToUp, picbox.Width - xToRight, picbox.Height - yToDown - xMoveToUp); g.DrawPolygon(pen, xpts);//自定义坐标转换 g.DrawString("X", new Font("宋体", 11), sb, picbox.Width - (xToRight), picbox.Height - (yToDown + xMoveToUp)); //Y轴的箭头,实际上是绘制了一个三角形 Point[] ypts = new Point[3] { //自定义坐标转换 new Point(xToLeft + yMoveToRight - arrorHeight, yToUp + arrorHeight), new Point(xToLeft + yMoveToRight, yToUp), new Point(xToLeft + yMoveToRight + arrorHeight, yToUp + arrorHeight) }; g.DrawLine(pen, xToLeft + yMoveToRight, picbox.Height - yToDown, xToLeft + yMoveToRight, yToUp); g.DrawPolygon(pen, ypts);//自定义坐标转换 g.DrawString("Y", new Font("宋体", 11), sb, yMoveToRight + xToLeft + arrorHeight, 0); } //绘制Y轴上的刻度 public void SetYAxis(ref Graphics g,PictureBox picbox, float YMAX) { Pen p1 = new Pen(Color.Goldenrod, 1); Pen p2 = new Pen(Color.White, 2); SolidBrush sb = new SolidBrush(Color.White); float ykedu = YMAX / 200;//给定的最大刻度与实际像素的比例关系=,未优化,目前为1:1 //第一个刻度的两个端点 float xl = xToLeft - 3 + yMoveToRight, yl = picbox.Height - yToUp, xr = xToLeft + 3 + yMoveToRight, yr = picbox.Height - yToDown;//自定义坐标转换 for (int j = 0; j < picbox.Height - (yToDown + yToUp); j += 10) { if (j % 50 == 0)//一个大的刻度,黑色,每隔50像素一个 { g.DrawLine(p2, xl, yl - j, xr, yl - j);//刻度线 string tempy = ((j - xMoveToUp - yToDown) * ykedu).ToString();//自定义坐标转换 g.DrawString(tempy, new Font("宋体", 8), sb, xl - 20, yl - j - 5); } else//小刻度,金黄色,10像素一个 { g.DrawLine(p1, xl, yl - j, xr, yl - j); } } } //绘制x轴上的刻度 public void SetXAxis(ref Graphics g,PictureBox picbox, float XMAX) { Pen p1 = new Pen(Color.Goldenrod, 1); Pen p2 = new Pen(Color.White, 2); SolidBrush sb = new SolidBrush(Color.White); float xkedu = XMAX / 400; //比例关系未优化,目前为1:1 float xt = xToLeft, yt = picbox.Height - yToDown - 3 - xMoveToUp, xb = xToLeft, yb = picbox.Height - yToDown + 3 - xMoveToUp; //自定义坐标转换 for (int i = 0; i < picbox.Width - (xToLeft + xToRight); i += 10) { if (i % 50 == 0) { g.DrawLine(p2, xt + i, yt, xb + i, yb); string tempx = ((i - yMoveToRight - xToLeft) * xkedu).ToString();//自定义坐标转换 g.DrawString(tempx, new Font("宋体", 8), sb, xt + i - 7, picbox.Height - 25 - xMoveToUp); } else { g.DrawLine(p1, xt + i, yt, xb + i, yb); } } } } }CListCtrlEx重载
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Windows.Forms; namespace ADT_LISTVIEW { enum LIST_TYPE { NO_TYPE = -1, EDIT_TYPE = 0, CBO_TYPE = 1, } class ListViewEx : ListView { private TextBox m_tb; private ComboBox m_cb; private bool m_bCheckBox; private Int32[ ] m_lst = new Int32[20]; //支持最大列数20 private string[] m_str = new string[20]; //最大列字符串20 public void SetChekBox(bool bCheck) { m_bCheckBox = bCheck; } public void AddCboString(String str) { string[] param = str.Split(':'); m_cb.Items.Clear(); foreach (string i in param) { m_cb.Items.Add(i); } m_cb.SelectedIndex = 0; } public void SetListType(int nIndex, int type) { m_lst[nIndex] = type; } public int FindStringInCbo(int nCol, string str) { if (m_lst[nCol] != 1) { return -1; } else { AddCboString(m_str[nCol]); return m_cb.FindString(str, -1); } } public ListViewEx() { m_tb = new TextBox(); m_cb = new ComboBox(); m_tb.Multiline = false; m_tb.Visible = false; m_cb.Visible = false; m_cb.DropDownStyle = ComboBoxStyle.DropDownList; m_cb.IntegralHeight = true; this.GridLines = true; this.CheckBoxes = true; this.FullRowSelect = false; SetChekBox(this.CheckBoxes); this.Controls.Add(m_tb); this.Controls.Add(m_cb); for (int i = 0; i < 20; i++) { SetListType(i, 0); } SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); //解决ListView闪烁问题 } public void Insert(int nIndex, ListViewItem item) { for (int i = 0; i < item.SubItems.Count; i++ ) { //保存所有列字符——最多20 m_str[i] = item.SubItems[i].Text; if (m_str[i].IndexOf(':') > 0) { SetListType(i, 1); AddCboString(m_str[i]); item.SubItems[i].Text = m_cb.Text; } else { SetListType(i, 0); } } this.Items.Insert(nIndex, item); } private void EditItem(ListViewItem.ListViewSubItem subItem) { if (this.SelectedItems.Count <= 0) { return; } Rectangle _rect = subItem.Bounds; m_tb.Bounds = _rect; ListViewItem lvi = this.SelectedItems[0]; //选中的多行第0行 if (subItem == lvi.SubItems[0] || 0 == subItem.Bounds.X) { //第一列为复选框 if (m_bCheckBox) { return; } else { //修复宽度 m_tb.Width = this.Columns[0].Width; } } m_tb.BringToFront(); m_tb.Text = subItem.Text; m_tb.Leave += new EventHandler(tb_Leave); m_tb.TextChanged += new EventHandler(m_tb_TextChanged); m_tb.Visible = true; m_tb.Tag = subItem; m_tb.Select(); } private void EditItem(ListViewItem.ListViewSubItem subItem, Rectangle rt) { if (this.SelectedItems.Count <= 0) { return; } Rectangle _rect = rt; m_cb.Bounds = _rect; m_cb.BringToFront(); // m_cb.Items.Add(subItem.Text); m_cb.Text = subItem.Text; m_cb.Leave += new EventHandler(lstb_Leave); m_cb.TextChanged += new EventHandler(m_lstb_TextChanged); m_cb.DropDownClosed += new EventHandler(m_lstb_TextChanged); m_cb.DropDown += new EventHandler(m_lstb_DropDown); m_cb.LostFocus += new EventHandler(lstb_Lost); m_cb.Visible = true; m_cb.Tag = subItem; m_cb.Select(); } protected override void OnKeyDown(KeyEventArgs e) { // if (e.KeyCode == Keys.F2) // { // // if (this.SelectedItems.Count > 0) // { // this.SelectedItems[1].BeginEdit(); // ListViewItem lvi = this.SelectedItems[0]; // EditItem(lvi.SubItems[0], new Rectangle(lvi.Bounds.Left, lvi.Bounds.Top, this.Columns[0].Width, lvi.Bounds.Height - 2)); // } // } base.OnKeyDown(e); } protected override void OnSelectedIndexChanged(EventArgs e) { this.m_tb.Visible = false; this.m_cb.Visible = false; base.OnSelectedIndexChanged(e); } protected override void OnDoubleClick(EventArgs e) { Point tmpPoint = this.PointToClient(Cursor.Position); ListViewItem.ListViewSubItem subitem = this.HitTest(tmpPoint).SubItem; ListViewItem item = this.HitTest(tmpPoint).Item; if (subitem != null) { int nIndex = 0; item.Checked = !item.Checked; //修复双击时反选功能 if (0 == subitem.Bounds.X) {//修复第一列 nIndex = 0; } else { nIndex = this.SelectedItems[0].SubItems.IndexOf(subitem); if (nIndex > this.Columns.Count) { //修复频繁点击时索引不更新bug base.OnDoubleClick(e); return; } } if (0 == m_lst[nIndex]) { //类型选择,编辑框 EditItem(subitem); } else if (1 == m_lst[nIndex]) { //组合框 AddCboString(m_str[nIndex]); EditItem(subitem, new Rectangle(subitem.Bounds.Left, subitem.Bounds.Top, this.Columns[nIndex].Width, subitem.Bounds.Height - 2)); } else { ; } //item.Checked = !item.Checked; } base.OnDoubleClick(e); } // protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) // { // m_cb.Hide(); // base.OnDrawColumnHeader(e); // } protected override void WndProc(ref Message m) { if (m.Msg == 0x115 || m.Msg == 0x114) { this.m_tb.Visible = false; this.m_cb.Visible = false; } base.WndProc(ref m); } private void tb_Leave(object sender, EventArgs e) { m_tb.TextChanged -= new EventHandler(m_tb_TextChanged); (sender as TextBox).Visible = false; } private void m_tb_TextChanged(object sender, EventArgs e) { if ((sender as TextBox).Tag is ListViewItem.ListViewSubItem) { (this.m_tb.Tag as ListViewItem.ListViewSubItem).Text = this.m_tb.Text; } } private void lstb_Leave(object sender, EventArgs e) { m_cb.TextChanged -= new EventHandler(m_lstb_TextChanged); m_cb.DropDownClosed -= new EventHandler(m_lstb_TextChanged); m_cb.DropDownClosed -= new EventHandler(m_lstb_DropDown); m_cb.DropDown -= new EventHandler(m_lstb_DropDown); m_cb.LostFocus -= new EventHandler(lstb_Lost); } private void m_lstb_TextChanged(object sender, EventArgs e) { if ((sender as ComboBox).Tag is ListViewItem.ListViewSubItem) { (this.m_cb.Tag as ListViewItem.ListViewSubItem).Text = this.m_cb.Text; } } private void m_lstb_DropDown(object sender, EventArgs e) { if ((sender as ComboBox).Tag is ListViewItem.ListViewSubItem) { this.m_cb.Text = (this.m_cb.Tag as ListViewItem.ListViewSubItem).Text; } } private void lstb_Lost(object sender, EventArgs e) { m_cb.Hide(); //隐藏 lstb_Leave(sender, e); } } }参考
FastTunnel: 开源免费跨平台 内网穿透 远程内网电脑 自定义域名访问内网站点 反向代理内网服务 http代理 类花生壳 端口转发 微信 小程序 frp NAT ssh proxy tunnel ngork
GitHub - HandyOrg/HandyControl: Contains some simple and commonly used WPF controls
https://github.com/OfficeDev/Image-FileHandler
https://github.com/probot/no-response
https://github.com/dotnet/Open-XML-SDK
https://github.com/OfficeDev/PnP-WOPI
https://github.com/OfficeDev/Open-XML-SDK
https://github.com/OfficeDev/Excel-IO
GitHub - cnxy/files-uwp: A modern file explorer that pushes the boundaries of the platform.
GitHub - OfficeDev/office-fluent-ui-command-identifiers: Office Fluent User Interface Control Identifiers
Code of Conduct | Microsoft Open Source
https://github.com/CollaboratingPlatypus/PetaPoco
https://www.cnblogs.com/zhangweizhong/p/3718549.html
NuGet Gallery | PetaPoco 5.1.304
https://www.cnblogs.com/zhangweizhong/category/855479.html
https://www.cnblogs.com/zhangweizhong/category/771056.html
https://github.com/LonelyCodelang?tab=repositories
https://worktile.com/share/files/64a3b9c8ec0a4d3d81b89a630177c880
https://github.com/statianzo/PostLog
https://www.cnblogs.com/zhangweizhong/category/771055.html
https://github.com/statianzo/Fleck
https://github.com/EasyHttp/EasyHttp
GitHub - Tencent/xLua: xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.
QJ_FileCenter: 企捷Lotus文件管理平台是开源文档管理平台/企业网盘,支持企业文件、个人文件等文件分库管理,平台能够满足统一存储、文件共享功能。并提供文件上传、目录维护、重命名、移动、复制、删除、预览、等功能。
需ngnix反向代理,账号admin,密码abc123.搭建个人云盘
企捷科技 - 企捷科技
https://gitee.com/dotnetchina/BootstrapAdmin
dotNET China: 让 .NET 开发更简单,更通用,更流行。
GitHub - files-community/Files: Building the best file manager for Windows
GitHub - MMmmmoko/Bongo-Cat-Mver: An Bongo Cat overlay written in C++