
C#
Thomas会写字
艰苦朴素
展开
-
C# AutoResetEvent ManualResetEvent Mutex 对比
三个函数功能类似,都是线程同步的主要函数。但在使用上有一些差别。关于代码的使用,帖子很多。形象的用图来描述一下。原创 2024-09-16 15:46:11 · 570 阅读 · 0 评论 -
C# 中泛型类型的判断方法
【代码】C# 中泛型类型的判断方法。原创 2024-09-13 16:26:15 · 232 阅读 · 0 评论 -
一种多态的实现方法
通过 Activator.CreateInstance 以及 继承关系实现。原创 2024-09-12 16:44:50 · 212 阅读 · 0 评论 -
C# 获取System.Color 中所有颜色
中的全部颜色提取出来,经过简单筛选后打乱顺序,做成随机颜色数组。转载 2023-08-03 09:45:46 · 816 阅读 · 0 评论 -
C# 函数指针
【代码】C# 函数指针。原创 2023-03-05 07:09:29 · 297 阅读 · 0 评论 -
C# MDI 简单实现
【代码】C# MDI 简单实现。原创 2023-03-02 08:17:43 · 221 阅读 · 0 评论 -
C# PropertyGrid 简单使用
2. 通过Enum.ToString()实现,将String[] 变为 Enum,通过 Enum 实现下拉框。常用属性 PropertyGrid 中已经封装了下拉框属性。1. 通过继承重写 StringConverter 函数。2. 根据字段封装顺序。原创 2023-03-01 23:26:55 · 6696 阅读 · 0 评论 -
C# Spliter使用方法
需要对应Panel容器使用,依次添加Panel、Spliter在。原创 2023-03-01 20:00:44 · 1003 阅读 · 0 评论 -
C# 中结构体的复制
【代码】C# 中 结构体的复制。原创 2022-11-29 09:56:39 · 1125 阅读 · 0 评论 -
C# 控件截图 屏幕截图
【代码】C# 控件截图 屏幕截图。转载 2022-10-17 10:03:25 · 552 阅读 · 0 评论 -
[C#]TreeView单选模式的实现
一、需求使TreeView实现单选模式二、实现1、TreeView控件属性CheckBoxes设置为True2、为TreeView添加AfterCheck事件,并在事件中调用如下方法/// <summary>/// 树形框-单选模式的实现,放在事件 _AfterCheck下/// </summary>/// <param name="tv"></param>/// <param name="e"></param&转载 2022-02-07 17:05:10 · 1234 阅读 · 0 评论 -
ZedGraph控件常用方法和属性总结
最近在WPF使用ZedGraph控件,发现这个控件的功能很强大,据说采用了双缓冲机制来绘制图,只要控制好显示的帧速,能够显示速度较快的动态图。参考:https://blog.youkuaiyun.com/qq_26093511/article/details/513290591、常用属性设置 zedGraphControl2.IsShowPointValues = true; //鼠标经过图表上的点时是否气泡显示该点所对应的值 zedGraphControl转载 2021-11-04 16:48:15 · 1622 阅读 · 0 评论 -
ZedGraph的常用属性
前面有一篇文章介绍ZedGraph的官网,以及控件的使用文档。https://blog.youkuaiyun.com/weixin_40314351/article/details/114273114现在,通过一个案例了解ZedGraph的常用属性。话不多数,直接上图。这个是官网的一个案例,实现了多个Y轴同时在使用。public partial class Form1 : Form { GraphPane myPane ; PointPairList v.转载 2021-11-04 16:46:35 · 608 阅读 · 0 评论 -
ZedGraph 官网下载和帮助文档ZedGraph.chm
ZedGraph介绍ZedGraph是用C#编写的.NET的类库控件,可用于绘制曲线图、饼图、柱状图、股票K线图等,功能非常强大。1、ZedGraph的官网是: https://sourceforge.net/projects/zedgraph/2、ZedGraph.CHM帮助文档官网的链接: https://sourceforge.net/projects/zedgraph/files/gigithub链接: https://github.com/wSweetMei/ZedGp.转载 2021-11-04 16:44:49 · 571 阅读 · 0 评论 -
C# 拖拽实现
1. 属性设置为True2. 实现两个方法 private void Form1_DragDrop(object sender, DragEventArgs e) { string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); if (s == null || s.Length <= 0) retu.原创 2021-11-02 16:31:54 · 1066 阅读 · 0 评论 -
将BitMap转成Icon
System.IntPtr iconHandle = pbitmap.GetHicon();this.Icon = Icon.FromHandle(iconHandle);转载 2021-10-30 15:27:12 · 720 阅读 · 0 评论 -
C# 设置图片背景色透明
C# 将图片的背景色设置透明需要将透明部分设置为纯白色,图片格式pngImage image = Resources.Green.ResizeImage(nw+2, nw+2); Bitmap pbitmap = new Bitmap(image);pbitmap.MakeTransparent(Color.White);uiLabel2.Image = pbitmap;原创 2021-10-23 22:57:22 · 5594 阅读 · 0 评论 -
C#矩阵运算类库 -- 一些补充
重点补充,发现原类中没有深度复制(也许是我没找到。。。)于是修改如下MatrixAlgebra -->Matrix.cs -->Initialize函数 private void Initialize(double[,] Elements) { elements = Elements.CopyMatrix(); SubMat = new MatrixSubset(elements); ...原创 2021-10-13 16:19:51 · 1157 阅读 · 0 评论 -
C#矩阵运算类库
这个类库是本人参考许多相关资料之后做出的C#矩阵运算类库,因为C#的数值计算库相对比较少,所以希望这个类库能够给大家带来一些帮助。源码github网址:https://github.com/JoshuaHe2015/MatrixLibrary功能介绍:(持续更新中)1、矩阵的基本运算: 矩阵的加、减、乘、除、求逆、求幂、求秩、求行列式、转置。运算包括矩阵与矩阵的运算,矩阵与向量的运算和矩阵与标量的运算。using System;using LinearAlgebra;namesp转载 2021-10-13 16:14:27 · 1702 阅读 · 1 评论 -
C# ListView 排序
重载Cpomare函数using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Collections;namespace LiLe.MV.Process{ class ListViewItemComparer : IComparer原创 2021-04-30 17:35:07 · 1637 阅读 · 1 评论 -
OPC DAAuto.dll的C#使用方法浅析
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.Collections;using OPCAutomation;using System.Threading;namespace OPCDAAutoTest{ class Tester { static void Main(strin.转载 2021-02-04 14:35:05 · 790 阅读 · 0 评论 -
C# 托管
项目有一个需求,在线程中给控件赋值报错了百度后需要托管delegate void RichTextBoxItem(string sRes);public void AddItemRichTB(String sRes){ if (this.richTextBox1.InvokeRequired) { RichTextBoxItem r = new RichTextBoxItem(AddItemRichTB); this.Invoke(r, new原创 2020-10-21 08:43:11 · 173 阅读 · 0 评论 -
C# 窗口程序控制台输出
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;using System.Runtime.InteropServices;namespace Form1{ static class Program { [DllImport("kernel32.dll")] .原创 2020-10-11 20:37:17 · 1338 阅读 · 0 评论 -
C# 简单的日志类
非常简单的日志类提供两种记录方法基于内存映射文件的无缓冲方式基于文件流的缓冲方式内存映射的方式效率低,但是事实写入文件的方式效率高些,但是突然崩溃有可能丢日志总的来说,两个日志的效率和速度都很一般链接:https://pan.baidu.com/s/1R4FUPjGa2pQFTkDkSdlHhA提取码:g5dv...原创 2020-09-18 07:37:13 · 216 阅读 · 0 评论 -
C# 通过内存映射 进程间通信
参考 文章链接一对一写的C#版本代码,200万次差不多2.7秒的样子1. 为了提速,没用序列化,改自己写映射。2. 为了方便改动变量类型,都是分配8字节。3. 我这里的Body结构体一半是A端写B端都,另一半是B端写A端读,看起来比较乱。代码 chartsusing System;using System.IO;using System.Collections.Generic;using System.Collections.Concurrent;using System.L.原创 2020-08-11 17:05:58 · 301 阅读 · 0 评论 -
C# Task Parallel Library,TPL
System.Threading.Tasks前言:我们之前介绍了两种构建多线程软件的编程技术(使用异步委托或通过System.Threading的成员)。这两个可以在任何版本的.NET平台工作。关于System.Threading 的介绍关于System.Threading.Tasks的介绍 从.NET4.0开始,微软引入了一种全新的多线程应用程序开发方法,即使用TPL并行编程库。使用System.Threading.Tasks中的类型,可以构建可扩展的并行代码,而不必直接与线程和线..转载 2020-08-08 13:21:34 · 765 阅读 · 0 评论 -
C# Panel Graphic 绘图闪烁解决办法
用双缓冲的办法1. 重载Panel类using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication1{ class Panel2 : Panel { public Panel原创 2020-06-30 21:58:25 · 3300 阅读 · 2 评论 -
C# Log4net配置记录使用
AssemblyInfo.cs 添加下面。Config文件属性,始终复制。3. 多进程共享文件读写。1. 安日期生成文件夹。2. 按大小滚动文件。原创 2020-06-16 22:54:13 · 1229 阅读 · 0 评论 -
C# 串口简单实现
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO.Ports;namespace Tool{ class Comm { SerialPort sp = null; public Comm() { sp .原创 2020-05-17 13:56:51 · 299 阅读 · 0 评论 -
C# 通过指针读写窗体成员变量
Class1{ Form1 form = null; public Class1(IntPtr FormHandle) { form = (Form1)Form.FromHandle(FormHandle); }}Form1:Form{ void Func() { Class1 class1 = new Class1(this.Handle); }}原创 2020-05-17 13:53:41 · 403 阅读 · 0 评论 -
C# 字符串切割与拼接
string str = “a,b,c,d,e”;string[] strArray = str.Split(’,’); //字符串转数组str = string.Empty;str = string.Join(",", strArray);//数组转成字符串转载 2020-05-07 11:37:50 · 827 阅读 · 0 评论 -
C# 通过窗口 handle 读写窗体变量
using System.Runtime.InteropServices;class Formpublic int a = 0;void test(){ Test tt = new Test(); tt.handle = this.Handle; tt.Do(); int nNewVal = a;}using System.Run...原创 2020-05-06 17:36:41 · 1342 阅读 · 0 评论 -
C# 读写INI文件
namespace APIMethod{ /* * 姓名:谭义 * 时间:2008.5.28 * Q Q:260511433 * MSN :luoye0732@hotmail.com * 邮箱:luoye0732@163.com * 备注:如果大家对此模块还需要补充或完善修改的,请和我联系,大家一起努力。 * 注意...转载 2020-04-30 10:52:47 · 348 阅读 · 0 评论 -
相机采集的图片原始 buffer 转 C# BitmapImage
/// <summary>/// 原始图像buf转C#图像,转出格式均为彩色/// </summary>/// <param name="nWidth">图像宽</param>/// <param name="nHeight">图像高</param>/// <param name="nBpp">原始图像...原创 2020-04-27 10:52:23 · 2056 阅读 · 1 评论 -
C# 文件加密解密代码
using System;using System.Collections.Generic;using System.Text;using System.Security.Cryptography;using System.IO;namespace DESFile{ /// <summary> /// 异常处理类 /// </summary...转载 2020-04-24 00:02:05 · 633 阅读 · 0 评论 -
C# 子窗口与父窗口之间传值
父窗口传值给子窗口//Form1中代码: public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 lForm = new Form2();//实例化一个Form2窗口...转载 2020-04-23 15:17:46 · 2322 阅读 · 0 评论 -
C# 捕获系统闪退BUG
在程序入口添加代码namespace MainForm{ static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void CurrentDomain_U...原创 2020-04-23 15:09:16 · 2342 阅读 · 0 评论