随笔分类 - C#
摘要:List 或 Dictionary值如果是类对象,那么要在类中实现IEquatable相关接口 public class Seat : IEquatable<Seat> { #region Field #endregion #region Property /// <summary> /// 名称
阅读全文
posted @ 2020-05-22 17:23
孤獨龍
摘要:1、List List<string> temp = new List<string>(); foreach (PlayAgentItem arg in PlayAgentConfigSection.values.Cast<PlayAgentItem>()) { temp.Add(arg.IpAdd
阅读全文
posted @ 2020-05-22 13:56
孤獨龍
摘要://把图片设置为Border的背景<Grid Width="973" Height="688"> <Border Name="Image_Game" Width="973" Height="688" BorderBrush="#FF2B9EC5" BorderThickness="4" Corner
阅读全文
posted @ 2020-05-20 16:01
孤獨龍
摘要:被这个问题困扰了2天,最后发现原因竟然是编译器设置问题,着实令人郁闷不已啊。 解决方法就是设置项目属性的平台目标为x86就行了,默认为(Any CPU).
阅读全文
posted @ 2020-05-12 21:44
孤獨龍
摘要:从字符串到画刷: var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFFFFF90"); Fill = brush;(Color)C
阅读全文
posted @ 2019-12-05 09:01
孤獨龍
摘要:MouseButtonEventArgs args = new MouseButtonEventArgs(Mouse.PrimaryDevice,0, MouseButton.Left); args.RoutedEvent = UIElement.MouseLeftButtonDownEvent; btn.RaiseEvent(args);
阅读全文
posted @ 2019-11-18 16:50
孤獨龍
摘要:1.System.Windows.Forms.SendKeys 组合键:Ctrl = ^ 、Shift = + 、Alt = % 模拟按键:A private void button1_Click(object sender, EventArgs e) { textBox1.Focus(); Sen
阅读全文
posted @ 2019-10-17 18:16
孤獨龍
摘要:说明: msdn中 ObservableCollection<T> 类 表示一个动态数据集合,在添加项、移除项或刷新整个列表时,此集合将提供通知。 在许多情况下,所使用的数据是对象的集合。 例如,数据绑定中的一个常见方案是使用 ItemsControl(如 ListBox、ListView 或 Tr
阅读全文
posted @ 2019-03-25 01:37
孤獨龍
摘要:报如下错误, 解决方法:打开项目文件,修改 打开项目文件修改:<Deterministic>true</Deterministic> 为:<Deterministic>false</Deterministic>
阅读全文
posted @ 2019-03-06 20:11
孤獨龍
摘要:ObservableCollection<类> 用于同步更新集合,删除集合内的元素,界面也会同步删除, 前台代码 后台代码:
阅读全文
posted @ 2018-10-26 11:47
孤獨龍
摘要:using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; using System.Web; using System.Xml.Linq; namesp...
阅读全文
posted @ 2018-01-17 20:43
孤獨龍
摘要:C#如何获取本机网络ip有几种方法获取本机局域网地址和网络地址。1. 获取本机局域网地址:使用IPHostEntry2. 获取本机网络ip地址通过向网站http://www.ip138.com/ip2city.asp发送webrequest,分析返回的数据流 try { string strUrl = "http://www.ip138.com/ip2city.asp"; //获得IP的网址 Uri uri = new Uri(strUrl); WebRequest webreq = WebRequest.Create(uri); Stream s = webreq .Ge
阅读全文
posted @ 2012-07-20 23:00
孤獨龍
摘要:Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e){ if (e.Reason == Microsoft.Win32.SessionSwitchReason.SessionLock) { // 屏幕锁定 } else ...
阅读全文
posted @ 2012-07-01 21:45
孤獨龍
摘要:在程序中加入MANIFEST资源打开Vs2005或vs2008工程,看在Properties下是否有app.manifest这个文件;如没有,右击工程在菜单中选择“属性”。 选中"Security",在界面中勾选"Enable ClickOnce Security Settings"后,在Properties下就有自动生成app.manifest文件。 打开app.manifest文件,将Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighl
阅读全文
posted @ 2012-02-26 16:58
孤獨龍
摘要:1:NetworkInterface 类: 该类位于 System.Net.NetworkInformation 命名空间 该类可以方便的检测本机有多少个网卡(网络适配器),网卡信息,哪些网络连接可用等。 2:常用方法和属性: view sourceprint? NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); Console.WriteLine("适配器个数:" + adapters.Length); Console.WriteLine(); foreach (Network
阅读全文
posted @ 2012-02-25 15:45
孤獨龍
摘要:FilePatch = Path.Combine(movie.SaveFolderPatch, "电影资料.txt"); FileInfo fi = new FileInfo(FilePatch); if (fi.Exists) fi.Delete(); FileStream fs = File.Open(FilePatch, FileMode.OpenOrCreate, FileAccess.Write); ...
阅读全文
posted @ 2012-01-15 22:29
孤獨龍
摘要:字符字符编号实体名字说明—�—未使用Unused——未使用Unused——未使用Unused——未使用Unused——未使用Unused——未使用Unused——未使用Unused——未使用Unused——未使用Unused—	—制表符Horizontal tab— —换行Line feed——未使用Unused——未使用Unused— —回车Carri
阅读全文
posted @ 2012-01-01 22:18
孤獨龍
摘要:1.this.Close(); 只是关闭当前窗口,若不是主窗体的话,是无法退出程序的,另外若有托管线程(非主线程),也无法干净地退出;2.Application.Exit(); 强制所有消息中止,退出所有的窗体,但是若有托管线程(非主线程),也无法干净地退出;3.Application.ExitThread(); 强制中止调用线程上的所有消息,同样面临其它线程无法正确退出的问题;4.System.Environment.Exit(0); 这是最彻底的退出方式,不管什么线程都被强制退出,把程序结束的很干净。
阅读全文
posted @ 2011-12-08 17:33
孤獨龍
摘要:using System.Runtime.InteropServices;[DllImportAttribute ("gdi32.dll")] public static extern IntPtr CreateRoundRectRgn(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,int nWidthEllipse,int nHeightEllipse); [DllImportAttribute ("user32.dll")] public static extern int Set
阅读全文
posted @ 2011-07-05 16:28
孤獨龍
摘要:在窗口程序的开发中,我们经常会需要当用户鼠标点击窗口的任何地方时,能够让窗口随鼠标一起移动。特别是当你的WinForms窗口没有窗口栏(Form.FormBorderStyle = None),用户无法通过点击窗口栏移动窗口时,这种实现就很必要了。应该有很多方法可以实现,我自己发现了两种方法:一种方法就是自己编程实现窗口的位置随鼠标改变;另一种就是直接利用Windows的API。废话不多说了,看代码,so easy :)设计一个窗体时,把以下代码加入到窗口中,就可以实现这个功能: private bool IsMouseDownInForm = false; private Point p;
阅读全文
posted @ 2011-07-04 15:52
孤獨龍

浙公网安备 33010602011771号