随笔分类 -  C#

摘要:c#中禁止跨线程直接访问控件,InvokeRequired是为了解决这个问题而产生的当一个控件的InvokeRequired属性值为真时,说明有一个创建它以外的线程想访问它,此时它将会在内部调用new MethodInvoker(LoadGlobalImage)来完成下面的步骤,这个做法保证了控件的安全,你可以这样理解,有人想找你借钱,他可以直接在你的钱包中拿,这样太不安全,因此必须让别人先要告诉你,你再从自己的钱包把钱拿出来借给别人,这样就安全了在设计中为了让界面与逻辑分离,我的做法是使用事件,界面只要响应事件来处理界面的显示就行了。而事件在逻辑处理中可能由不同的线程引发,这些事件的响应方法 阅读全文
posted @ 2013-01-28 18:37 louiskoo 阅读(400) 评论(0) 推荐(0)
摘要:private delegate void AddstudyDescriptionNodeDelegate(string studyDescription, string studyUID); private void AddstudyDescriptionNode(string studyDescription, string studyUID) { if (InvokeRequired) { BeginInvoke(new AddstudyDescriptionNodeDelegate(... 阅读全文
posted @ 2013-01-28 17:02 louiskoo 阅读(186) 评论(0) 推荐(0)
摘要:public static System.Drawing.Image ByteArrayToImage(byte[] b) { ImageConverter imgconv = new ImageConverter(); System.Drawing.Image img = (System.Drawing.Image)imgconv.ConvertFrom(b); return img; } public static byte[] ImageToByteArray(System.Dra... 阅读全文
posted @ 2013-01-28 17:01 louiskoo 阅读(912) 评论(0) 推荐(0)
摘要:private void DSApictureBox_MouseDown(object sender, MouseEventArgs e) { if (drawLine) { start = new PointF(e.X,e.Y); start = LineAlgorithm.Control2Image(matrix,start); if (list1.Count == 0) { ... 阅读全文
posted @ 2013-01-28 15:34 louiskoo 阅读(13449) 评论(0) 推荐(1)
摘要://定义委托,它定义了可以代表的方法的类型 public delegate void GreetingDelegate(string name); private static void EnglishGreeting(string name) { Console.WriteLine("Morning, " + name); } private static void ChineseGreeting(string name) { Console.WriteLine("... 阅读全文
posted @ 2013-01-28 15:12 louiskoo 阅读(1609) 评论(1) 推荐(0)
摘要:Stopwatch 和Timer 阅读全文
posted @ 2013-01-23 15:59 louiskoo 阅读(151) 评论(0) 推荐(0)
摘要:/// <summary> /// 获取视频采集设备列表 /// </summary> private void GetCameraList() { try { videoDeviceCoolection = new FilterInfoCollection(FilterCategory.VideoInputDevice); if (videoDeviceCoolection.Count == 0) { ... 阅读全文
posted @ 2013-01-22 12:42 louiskoo 阅读(2049) 评论(1) 推荐(0)
摘要:http://www.albahari.com/threading/ 阅读全文
posted @ 2013-01-22 10:32 louiskoo 阅读(129) 评论(0) 推荐(0)
摘要://第一种方法 DataClasses3DataContext con = new DataClasses3DataContext(); var qu = from c in con.FeeMain select c; if (textBox1.Text != "") qu = qu.Where(c => c.wtdw == textBox1.Text); if (textBox2.Text != "") ... 阅读全文
posted @ 2013-01-22 10:31 louiskoo 阅读(403) 评论(0) 推荐(0)
摘要:var query = from f in db.TField join fw in db.TFieldWel on f.emp_no equals fw.emp_no where f.fy_no == fy_no && fw.fy_no == fy_no && (string.IsNullOrEmpty(brd_no) ? true : f.brd_no.Equals(brd_no)) && (string.IsNullOrEmpty(area_no) ? true : f.area_no.Equals(area_no)) && 阅读全文
posted @ 2013-01-22 10:29 louiskoo 阅读(211) 评论(0) 推荐(0)
摘要:public bool DeleteFiles(string path) { if (Directory.Exists(path)==false) { MessageBox.Show("Path is not Existed!"); return false; } DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] files = dir.GetFile... 阅读全文
posted @ 2013-01-21 22:44 louiskoo 阅读(16664) 评论(0) 推荐(0)
摘要:Image image = Image.FromFile(item.FullName); Image bt = new Bitmap(image); listImages.Add(bt); image.Dispose(); 阅读全文
posted @ 2013-01-21 20:13 louiskoo 阅读(280) 评论(0) 推荐(0)
摘要:public static Bitmap CropBitmap(Bitmap bitmap, int cropX, int cropY, int cropWidth, int cropHeight) { Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight); Bitmap cropped = bitmap.Clone(rect, bitmap.PixelFormat); return cropped; } static void Main(string[] args) { string path = ... 阅读全文
posted @ 2013-01-21 19:21 louiskoo 阅读(687) 评论(0) 推荐(0)