毕业设计 动态标注公式的实现
2007-05-21 14:22
375 查看
6.2生产通知单界面及代码
//在图片上创建文本框
private void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
//确定点
Point pt=new Point(e.X,e.Y);
//生成文本
GenTextBox(pt, mark);
mark++;//标记值
}
//保存数据
private void btn_Save_Click(object sender, EventArgs e)
{
string sImage = img_path; //得到图片存储位置
string Formula_id = TB_Formual.Text.Trim();//得到公式编号;
DrawLabel DL = new DrawLabel(); //标注点业务处理类
DL.DelPoint(Formula_id); //删除原始结点
foreach (Control tr in Pic_Image.Controls) //查询图片控件中所有控件
{
if (tr.GetType() == typeof(TextBox)) //得到控件类型为文本框
{
TextBox cutb = (TextBox)tr; //创建文本框类
Point pt = cutb.Location; //得到文本框位置
int value =Convert.ToInt32(cutb.Text.ToString());//得到文本框值
DL.SavePoint(pt.X, pt.Y, value, Formula_id);//保存值
}
}
FrmProduct FP = new FrmProduct(odt_id,Formula_id,sImage);//显示生产通知单窗体
FP.Show();
}
//移除控件
private void RemoveAllText()
{
int length=Pic_Image.Controls.Count;//得到控件数目
for (int i = 0; i <length;i++ )
{
this.Pic_Image.Controls.Remove(Pic_Image.Controls[0]);//移除
}
}
//加载图片
private void btn_LoadImg_Click(object sender, EventArgs e)
{
RemoveAllText();//移除已有控件
OPF_Image.Filter = "Image Files(*.jgp)|*.jpg";//过滤图片类型
OPF_Image.Multiselect = false;
OPF_Image.FileName = "";
if (OPF_Image.ShowDialog() == DialogResult.OK)
{
Pic_Image.Image = Image.FromFile(OPF_Image.FileName);//加载图片
img_path = OPF_Image.FileName;//保存图片路径
}
btn_Save.Enabled = true;//保存按钮可用
}
//自动生成文本框及样式
private void GenTextBox(Point pt, int mark)
{
this.tb = new System.Windows.Forms.TextBox();//创建文本框
Point dot = pt; //文本框位置
this.tb.Location = new System.Drawing.Point(dot.X, dot.Y);
this.tb.Name = "textBox" + mark.ToString();//文本框名称
this.tb.Size = new System.Drawing.Size(30, 20);//文本框大小
this.tb.TabIndex = mark;//序号
this.tb.BorderStyle = BorderStyle.None;//无边框
this.tb.BackColor = Color.White;//背景为白色
this.tb.MouseLeave += new System.EventHandler(this.TBMouseLeave);//文本框不可编辑
this.tb.MouseEnter += new System.EventHandler(this.TBMouseEnter);//文本框可编辑
this.tb.DoubleClick += new System.EventHandler(this.TBRemove);//删除控件
this.Pic_Image.Controls.Add(tb); //在图片中增加文本框
}
//当鼠标离开时使文本不可编辑
private void TBMouseLeave(object sender, EventArgs e)
{
TextBox cuTB = (TextBox)sender;
cuTB.ReadOnly = true;
}
//当鼠标进入时使文本可编辑
private void TBMouseEnter(object sender, EventArgs e)
{
TextBox cuTB = (TextBox)sender;
cuTB.ReadOnly = false;
}
//删除文本控件
private void TBRemove(object sender, EventArgs e)
{
TextBox cuTB = (TextBox)sender;
if (MessageBox.Show("确定要删除!") == DialogResult.OK)
{
this.Pic_Image.Controls.Remove(cuTB);
}
}
相关文章推荐
- (设计模式)简单工厂模式之通过配置文件动态创建实现类
- 动态语言和虚拟机实现, 暨介绍一下我设计的一个新型的动态语言(2)
- php动态内容文件缓存的设计和高效实现
- 设计模式--CGLib动态代理的实现与解析
- 系统架构设计——设计模式之代理模式(二)CGLIB动态代理实现
- Oracle 函数实现动态解析公式字符串
- linux&Windows动态链接库技术实现和设计程序常用的技术
- 策略设计模式:父类持有接口成员变量,动态设定接口成员实现类,动态改变方法
- 嵌入式操作系统的实现(几年前的毕业设计之四)
- 【原创】我的毕业设计论文——利用HOOK技术实现应用层网络抓包
- 动态规划分析总结——怎样设计和实现动态规划算法
- 设计模式之 动态代理 - ThreadLocal实现事务管理
- Java毕业设计------基于JSP技术的健身房管理系统的设计与实现
- 高德地图实现多点标注marker和动态信息窗体
- 嵌入式防火墙的实现(几年前的毕业设计之五)
- 我的毕业设计论文:基于局域网的通信工具的设计与实现(一)
- 设计模式学习(十四)————抽象工厂模式(使用Qt框架的反射技术——根据字符串动态创建类来实现)
- android应用开发-从设计到实现 3-9 Origami动态原型设计
- Java代理设计模式(Proxy)的四种具体实现:静态代理和动态代理
- 用公式实现动态设置图表的轴数据项