随笔分类 - WPF
摘要:public static int ushorts2int(ushort[] res) { int high = res[0]; int low = res[1]; int value = (high << 16) + low; return value; } public static ushor
阅读全文
摘要:<Image.RenderTransform> </Image.RenderTransform> <Image.Triggers> </Image.Triggers> <Image.Source> <DrawingImage> <DrawingImage.Drawing> <DrawingGroup
阅读全文
摘要:下载Nuget包:EMGU.CV(测试用版本:4.0.1.3373) ; public void InitVideo() { VideoCapture _capture = new VideoCapture("rtsp://admin:123456@192.168.1.237:554"); Thre
阅读全文
摘要:long time=(now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; //时间戳 bt[x++] = (byte)(time >> 24); bt[x++] = (byte)((time >> 16) & 0xFF); bt
阅读全文
摘要:private string hexStrToStr(string str) { //去除字符串中的空格 string[] strT = str.Split(' '); string strA = ""; foreach (string strB in strT) { strA += strB; }
阅读全文
摘要:WPF 窗口大小自适应 在设置桌面不同分辨率以及较大DPI下,窗口如何显示的问题。 方案一 设置窗口最大值和最小值显示 通过对比当前屏幕的可显示区域,将窗口高宽最大值和最小值,设置为窗口的实际高宽(此例中仅设置高度) 界面设置 设置窗口内容自适应SizeToContent="WidthAndHeig
阅读全文
摘要:<Window.Resources> </Window.Resources>
阅读全文
摘要:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.
阅读全文
摘要:public void TestA() { int time = 1658310821; string str = time.ToString("X4"); byte[] testb = strToHexByte(str); } /// <summary> /// 16进制字符串转换成16进制byt
阅读全文
摘要:public void Test() { byte[] results = new byte[1]; results[0] = 0xff; int temp = results[0]; byte b = SetBit(results[0], 7, 0); Console.WriteLine(b);
阅读全文
摘要:/// /// 获取字节中的指定Bit的值 /// /// 字节 /// Bit的索引值(0-7) /// public int GetBit(byte test, int index) { byte x = 1; switch (index) { case 0: { x = 0x01; } bre
阅读全文
摘要:using System.Web; 引用system.web。 textBox2.Text = System.Web.HttpUtility.UrlDecode(textBox1.Text, System.Text.Encoding.GetEncoding("GB2312"));//将Url中的编码
阅读全文
摘要:WPF程序最大化被任务栏遮挡的解决办法 this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; this.MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth; WINF
阅读全文
摘要:不支持非公共的无参构造函数: public abstract class BaseInstance where T : class,new() { private readonly static object lockObj = new object(); private static T inst
阅读全文
摘要:string postString = "arg1=a&arg2=b";//这里即为传递的参数,可以用工具抓包分析,也可以自己分析,主要是form里面每一个name都要加进来 byte[] postData = Encoding.UTF8.GetBytes(postString);//编码,尤其是汉
阅读全文
摘要:private void findRsmFile(string file) { DirectoryInfo drInfo = new DirectoryInfo(file); //获取当前目录下所有以*.RSM结尾的文件,并添加至fileList FileInfo[] fi = drInfo.Get
阅读全文
摘要:SimpleIoc 是一个简单依赖注入容器; 例:Mainviewmodel需要使用一个服务或类,假设我需要的person类 首先将实现的服务注册到SimpleIOC, SimpleIoc.Default.Register(()=>new Person()); 然后把Mainviewmodel也注册
阅读全文
摘要:C# 依赖注入 依赖注入是一个过程,就是当一个类需要调用另一个类来完成某项任务的时候,在调用类里面不要去new被调用的类的对象,而是通过注入的方式来获取这样一个对象。具体的实现就是在调用类里面有一个被调用类的接口,然后通过调用接口的函数来完成任务; 依赖注入最常用的两种方式是setter注入和构造函
阅读全文
摘要:public List ReadeCFGNameFromExcel(string ExcelName) { List ColumnDB = new List(); //创建 Excel对象 Microsoft.Office.Interop.Excel.Application App = new Mi
阅读全文