| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2091 人关注过本帖
标题:[开源]vb.net做图形监控软件开发(MicroDraw二次开发)
只看楼主 加入收藏
asuo888
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-4-11
收藏
 问题点数:0 回复次数:0 
[开源]vb.net做图形监控软件开发(MicroDraw二次开发)

源码:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Windows;

namespace 监控示例
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private AxMICRODRAWOCXLib.AxMicroDrawOcx axMicroDrawOcx1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.ListBox listBox2;
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components;

private bool is_jiankong; //监控标志
private MICRODRAWOCXLib.MdObjectList g_objectlist; //需要监控的文字链表
private long g_jiankong_val; //动态数值

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
is_jiankong = false; //是否监控标志
timer1.Interval = 100; //监控时间间隔
timer1.Stop(); //初始化时停止

g_objectlist = axMicroDrawOcx1.CreateObjectList();
g_jiankong_val = 0;

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.axMicroDrawOcx1 = new AxMICRODRAWOCXLib.AxMicroDrawOcx();
this.button1 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.listBox2 = new System.Windows.Forms.ListBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.axMicroDrawOcx1)).BeginInit();
this.SuspendLayout();
//
// axMicroDrawOcx1
//
this.axMicroDrawOcx1.Enabled = true;
this.axMicroDrawOcx1.Location = new System.Drawing.Point(8, 8);
this.axMicroDrawOcx1.Name = "axMicroDrawOcx1";
this.axMicroDrawOcx1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMicroDrawOcx1.OcxState")));
this.axMicroDrawOcx1.Size = new System.Drawing.Size(624, 400);
this.axMicroDrawOcx1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(648, 336);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(128, 64);
this.button1.TabIndex = 1;
this.button1.Text = "开始监控";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
//
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(632, 8);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(72, 316);
this.listBox1.TabIndex = 2;
//
// listBox2
//
this.listBox2.ItemHeight = 12;
this.listBox2.Location = new System.Drawing.Point(712, 8);
this.listBox2.Name = "listBox2";
this.listBox2.Size = new System.Drawing.Size(72, 316);
this.listBox2.TabIndex = 3;
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(784, 470);
this.Controls.Add(this.listBox2);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.axMicroDrawOcx1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.axMicroDrawOcx1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
//首先找到要监控的文字元素
g_objectlist.AddText("aaa",0);


//打开或关闭监控
if (is_jiankong == true)
{
is_jiankong = false;
button1.Text = "开始监控";
}
else
{
is_jiankong = true;
timer1.Start();
button1.Text = "关闭监控";
}

}

private void Form1_Load(object sender, System.EventArgs e)
{
axMicroDrawOcx1.DisplayControlBar = false;
axMicroDrawOcx1.DisplayCreateBar = false;
axMicroDrawOcx1.DisplayModifyBar = false;
}

private void timer1_Tick(object sender, System.EventArgs e)
{
//要动态显示的文字存放在 g_objetlist链表中,以下代码是在链表中查找文字,得到文字的基点坐标
//然后画一个动态显示效果,如果用户要再提高效率,可以考虑用数组的方式。在初始化程序中用数组来
//存放这些文字的ID,

int count = g_objectlist.count();
g_jiankong_val++;

for(int i=0; i<count; i++)
{
//得到文字基点
double px = axMicroDrawOcx1.GetPointX((MICRODRAWOCXLib.ENTITY_OPTION)g_objectlist.GetObjectID(i),-5);
double py = axMicroDrawOcx1.GetPointY((MICRODRAWOCXLib.ENTITY_OPTION)g_objectlist.GetObjectID(i),-5);

//画文字

axMicroDrawOcx1.DrawTextEx(px,py,0,g_jiankong_val.ToString(),10,0,0,0,0,0xff00ff,0x000000,0,"宋体");
}
}
}
}

效果图:



用MicroDraw图形控件实现行业监控是一个很不错的选择。用户仅利用自己熟悉的语言(vb,vc,delphi,.net)等,就快速的开发出所需要的图形表示效果。

与传统的监控软件相比,利用MicroDraw图形控件做监控软件具有以下优势!

1. MicroDraw图形控件是一个完全自主的CAD/GIS开发平台,可以兼容多种图纸格式(dwg/dxf/dwf/mif/dgn),并能够快速的浏览和查询。在工业、煤矿、电力等行业的设计图纸全部是CAD软件制作,MicroDraw图形控件可以100%的读取和操作这些图纸数据。 这是其他软件无法比拟的。

2.所监控的底图更新后,直接更换底图就OK,无需另外工作量。 用户可以在MicroDraw或AutoCAD中设定好要监控和动态显示的元素。 然后用程序来控制这些元素。


3.如果用户将DWG文件保存为MDF格式,平均压缩率为原文件的30%,打开和保存速度会提高2-3倍。采用MDF格式后控件打包可以不需要 asdwg*.dll模块。控件文件大小不足1M,可以方便的在WEB上进行作业。


4.图形控件仅提供快速动态的显示和操作接口函数,如何显示和更新数据还需要用户按照自己需求来做。我们不提供监控行业自身的相关功能,比如::读取接口数据源,串口,并口,PLC数据,DDE连接等技术则需要用户自己解决。



下载地址: http://www.microdraw.cn

[此贴子已经被作者于2006-5-8 19:59:16编辑过]

搜索更多相关主题的帖子: 图形 MicroDraw 监控软件 开源 开发 
2006-05-08 19:56
快速回复:[开源]vb.net做图形监控软件开发(MicroDraw二次开发)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011572 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved