摘要: private void pictureBox1_MouseMove(object sender, MouseEventArgs e){ int originalWidth = this.pictureBox1.Image.Width; int originalHeight = this.pictureBox1.Image.Height; PropertyInfo rectangleProperty = this.pictureBox1.GetType().GetProperty("ImageRectangle", BindingFlags.Instance | Bindi 阅读全文
posted @ 2011-06-23 12:45 biubiubiu 阅读(227) 评论(0) 推荐(0) 编辑
摘要: /// <summary> /// 获取字符串中数字 /// </summary> /// <param name="str"></param> /// <returns></returns> public int GetNumberInt(string str) { int result = 0; if (str != null && str != string.Empty) { // 正则表达式剔除非数字字符(不包含小数点.) str = Regex.Replace(str, @&q 阅读全文
posted @ 2011-06-14 12:06 biubiubiu 阅读(302) 评论(0) 推荐(1) 编辑
摘要: 以下代码是我的项目中拷贝出来的,已通过测试成功,代码如下://首先建立一个抽象类,做为基类,试过用接口,但没有成功,所以放弃//抽象类: public abstract class IMCU05SConfig { public abstract bool AddMcu(HJEquipType equiptype, ZHNode node); public abstract bool EditMcu(HJMCU mcu); }因为项目需要,是利用动态加载DLL的方式,需要自定义配置窗体,所以新建一个类库,将窗体写在当中,然后实现抽象类用于调用,代码如下: public class McuConf 阅读全文
posted @ 2011-06-01 16:11 biubiubiu 阅读(249) 评论(0) 推荐(0) 编辑
摘要: this.PictureBoxNodeBackImage.AllowDrop = true; //这个也要加上 //最后我们判断完成后怎样向PictureBox中添加数据,并从datagridview中删除选中数据所在的行,我们在PictureBox的DragDrop事件中执行操作 private void PictureBoxNodeBackImage_DragDrop(object sender, DragEventArgs e) { Point pos = new Point(e.X, e.Y); //拖動數據后 所記錄的坐標 pos = this.PictureBoxNodeBack. 阅读全文
posted @ 2011-05-26 17:22 biubiubiu 阅读(779) 评论(0) 推荐(0) 编辑
摘要: 反射是种机制,通过这种机制我们可以知道一个未知类型的类型信息,比如,有一个对象a,这个对象不是我们定义的,也许是通过网络捕捉到的,也许是使用泛型定义的,但我们想知道这个对象的类型信息,想知道这个对象有哪些方法或者属性什么的.甚至我们想进一步调用这个对象的方法.关键是现在我们只知道它是一个对象,不知道它的类型,自然不会知道它有哪些方法等信息.这时我们该怎么办?反射机制就是解决这么一个问题的.通过反射机制我们可以知道未知类型对象的类型信息.再比如,我们有一个dll文件 ,我们想调用里面的类.现在假设这个dll文件 的类的定义,数量等不是固定的,是经常变化的.也许某一天你要在这个dll里面增加一个类 阅读全文
posted @ 2011-05-25 11:18 biubiubiu 阅读(273) 评论(0) 推荐(1) 编辑
摘要: public class Document { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual DocumentFile DocumentFile { get; set; } } public class DocumentFile { public virtual int Id { get; set; } public virtual Document Document { get; set; } public virtual byte[] Data { ge 阅读全文
posted @ 2011-05-11 20:00 biubiubiu 阅读(246) 评论(0) 推荐(1) 编辑
摘要: using System;using Microsoft.Win32;namespace TunEc.ZHJF.Common{ public class OperateReg { /// <summary> /// 读取指定名称的注册表的值 /// </summary> /// <param name="name">注册表值</param> /// <returns></returns> public static string GetRegData(string strItemName) { try 阅读全文
posted @ 2011-05-09 17:13 biubiubiu 阅读(339) 评论(0) 推荐(0) 编辑
摘要: //TreeView的AfterCheck事件 private void TvNodeInfo_AfterCheck(object sender, TreeViewEventArgs e) { CheckControl(e); } public void CheckControl(TreeViewEventArgs e) { if (e.Action != TreeViewAction.Unknown) { if (e.Node != null && !Convert.IsDBNull(e.Node)) { CheckParentNode(e.Node); if (e.Node 阅读全文
posted @ 2011-05-03 13:19 biubiubiu 阅读(405) 评论(0) 推荐(0) 编辑
摘要: 由于项目需要,hibernate.cfg.xml里的链接字符串需要动态加载,在网上找好久,无满足答案。自己摸索2个方法1、修改xml文件 string FileName = "hibernate.cfg.xml"; XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(FileName); XmlNodeList nodeList = xmldoc.DocumentElement.ChildNodes[0].ChildNodes; foreach (XmlNode nl in nodeList) { if (nl.Name 阅读全文
posted @ 2011-04-19 14:45 biubiubiu 阅读(666) 评论(0) 推荐(0) 编辑
摘要: 1 private bool canMove = false; 2 private Point mousePos; 3 4 private void pictureBox1_MouseMove(object sender, MouseEventArgs e) 5 { 6 if (this.canMove) 7 { 8 pictureBox1.Location = new Point(pictureBox1.Location.X 9 - mousePos.X + e.X, pictureBox1.Location.Y10 - mousePos.Y + e.Y);11 }12 }13 14 pr. 阅读全文
posted @ 2011-03-29 14:35 biubiubiu 阅读(474) 评论(0) 推荐(0) 编辑