X3

RedSky

导航

随笔分类 -  C#

1 2 下一页

C#城市最短路径
摘要:123 public class City { public int Id { get; set; } public string Name { get; set; } public List<City> Cities { get; set; } = new List<City>(); public 阅读全文

posted @ 2025-05-09 17:58 HotSky 阅读(16) 评论(0) 推荐(0)

C#Animation
摘要:Animation using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Security.Cryptography; using Syste 阅读全文

posted @ 2025-04-02 18:04 HotSky 阅读(25) 评论(0) 推荐(0)

WPF FPS类
摘要:public class FPSBase { public static void Run() { CompositionTarget.Rendering += CompositionTarget_Rendering; } public static TimeSpan RunTime { get; 阅读全文

posted @ 2024-11-13 10:39 HotSky 阅读(20) 评论(0) 推荐(0)

生命模拟
摘要:界面: <DockPanel Background="#EEEEEE"> <WrapPanel DockPanel.Dock="Top"> <Border Background="Green" Width="20" Height="20" VerticalAlignment="Center"/> < 阅读全文

posted @ 2024-10-21 17:32 HotSky 阅读(9) 评论(0) 推荐(0)

C# Sql帮助类,可扩展
摘要:查看代码 [System.AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)] public class DbTableAttribute 阅读全文

posted @ 2024-08-13 15:33 HotSky 阅读(27) 评论(0) 推荐(1)

Bmp读写二值图
摘要:public class Bmp : IDisposable { /* * 每行像素数据必须是4的倍数 * 黑白二值图0表示黑,1表示白 */ public int Width { get => _width; } public int Height { get => Math.Abs(_heigh 阅读全文

posted @ 2024-07-08 09:21 HotSky 阅读(42) 评论(0) 推荐(0)

C#访问或修改私有类、函数、变量、属性
摘要:.NET: public static class TypeUtil { public static Type? GetType(string assemblyName, string typePath) { var assembly = Assembly.Load(assemblyName); i 阅读全文

posted @ 2024-05-27 10:57 HotSky 阅读(253) 评论(1) 推荐(0)

C#Sqlite插入/更新并返回数据
摘要:关键词:returning 返回所有列:returning *; 返回指定列:returning columnname; 删除命令不支持returning 参考代码: string path = @"Data Source=D:\Data\data.sqlite;Version=3"; using 阅读全文

posted @ 2024-02-20 15:32 HotSky 阅读(364) 评论(0) 推荐(0)

C#矩形分割矩形,使用任意个矩形来占据一个大的矩形,并求得未占用区域的所有不重叠矩形块
摘要:public enum TanglecySide { None = 1, LeftToRight = 1 >> 1, RightToLeft = 1 >> 2, TopBottom = 1 >> 3, BottomToTop = 1 >> 4, LeftToLeft = 1 >> 5, RightT 阅读全文

posted @ 2023-12-05 15:00 HotSky 阅读(81) 评论(0) 推荐(0)

C# Bitmap操作
摘要:1.透明图片“瘦身” public Bitmap Slim(Bitmap bitmap) { int x = bitmap.Width, y = bitmap.Height, m = -1, n = -1; for (int i = 0; i < bitmap.Width; i++) { for ( 阅读全文

posted @ 2022-10-07 15:59 HotSky 阅读(233) 评论(0) 推荐(0)

WPF 限制或释放鼠标在窗体内移动
摘要:123 public class User32 { public struct RECT { public int LeftTopX; public int LeftTopY; public int RightBottomX; public int RightBottomY; public RECT 阅读全文

posted @ 2022-08-12 13:58 HotSky 阅读(156) 评论(0) 推荐(0)

C#解决XML反序列化空格值被忽略的问题
摘要:解决办法:将XmlReaderSettings的值CheckCharacters = false 如下: using (StreamReader sr = new StreamReader(xmlfilePath)) { var setting = new XmlReaderSettings { C 阅读全文

posted @ 2022-06-22 18:00 HotSky 阅读(443) 评论(0) 推荐(0)

c#跨线程等待
摘要:1. ManualResetEvent,AutoResetEvent WaitOne() 当前线程进入等待状态; Reset() 表示需要等待; Set() 表示等待结束,执行WaitOne()后面代码; 区别: 当有多个线程调用WaitOne()时, AutoResetEvent 执行Set()后 阅读全文

posted @ 2022-05-26 11:45 HotSky 阅读(621) 评论(0) 推荐(0)

Xml序列化和反序列化
摘要:public class XMLHelper { public static string Serialize<T>(T entity, Encoding encoding = null) { StringBuilder sb = new StringBuilder(); XmlSerializer 阅读全文

posted @ 2022-04-07 15:49 HotSky 阅读(43) 评论(0) 推荐(0)

Bitmap透明图片描边
摘要:1 public static byte[] ToArray(this Bitmap bitmap) 2 { 3 var lockbits = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMod 阅读全文

posted @ 2022-04-01 16:53 HotSky 阅读(186) 评论(0) 推荐(0)

WPF 可缩放ScrollView(方式二)
摘要:方式一 增加了缩放Maximun、Minimun和Value值,以及可供监听缩放变化的ValueChanged事件。 public class ScaleScrollView : ScrollViewer { readonly List<object> ValueChangedEvents = ne 阅读全文

posted @ 2022-03-22 15:47 HotSky 阅读(442) 评论(0) 推荐(0)

WPF 可缩放ScrollView(方式一)
摘要:点击查看方式二 public class ScaleScrollView : ScrollViewer { List<object> MouseWheelEvents = new List<object>(); /// <summary> /// 通过监听此事件对内容进行缩放 /// </summa 阅读全文

posted @ 2022-03-22 10:04 HotSky 阅读(557) 评论(0) 推荐(0)

c#datatable序列化xml
摘要:public static List<T> ToListModel<T>(this DataTable dt) { if (dt.Rows.Count <= 0) return null; string typeName = typeof(T).Name; using (MemoryStream m 阅读全文

posted @ 2021-09-14 15:29 HotSky 阅读(384) 评论(0) 推荐(0)

C#获取文件MD5
摘要:public static string GetFileMD5(string filePath) { using (FileStream fs = new FileStream(filePath, FileMode.Open)) { System.Security.Cryptography.MD5C 阅读全文

posted @ 2021-03-02 09:25 HotSky 阅读(311) 评论(0) 推荐(0)

WPF点连成曲线,贝塞尔曲线两种画法
摘要:先看效果图: 黑色是需要经过的点; 黄色为控制点; 绿色为两点之间的中点。 方式一: 方式二: <Canvas x:Name="canvas2"/> 方法一代码,【这是别人的代码,时间久了忘记原出处了】: Path path; public void UpdateRoad(List<Point> l 阅读全文

posted @ 2020-09-02 10:49 HotSky 阅读(2295) 评论(0) 推荐(0)

1 2 下一页