⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 additemssampleform.cs

📁 利用OpcNet控件(包含源码)进行OPC通讯的开发样例
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using HaiGrang.Package.OpcNetApiChs.Opc;
using HaiGrang.Package.OpcNetApiChs.Da;
using HaiGrang.Package.OpcNetApiChs.DaNet;

namespace AddItemsSample
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class AddItemsSampleForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label OpcRemoveItemName;
		private System.Windows.Forms.Button RemoveOpcItem;
		private System.Windows.Forms.Label OpcItemName;
		private System.Windows.Forms.Button AddOpcItem;
		private System.Windows.Forms.Label OpcRemoveGroupName;
		private System.Windows.Forms.Button RemoveOpcGroup;
		private System.Windows.Forms.Label OpcGroupName;
		private System.Windows.Forms.Button AddOpcGroup;
		private System.Windows.Forms.Button OpcServerDisConnect;
		private System.Windows.Forms.Label OpcServerRemove;
		private System.Windows.Forms.Label OpcServerName;
		private System.Windows.Forms.Button bOpcServerConnect;

		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		
		private System.ComponentModel.Container components = null;

		public AddItemsSampleForm()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

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

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

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.OpcRemoveItemName = new System.Windows.Forms.Label();
			this.RemoveOpcItem = new System.Windows.Forms.Button();
			this.OpcItemName = new System.Windows.Forms.Label();
			this.AddOpcItem = new System.Windows.Forms.Button();
			this.OpcRemoveGroupName = new System.Windows.Forms.Label();
			this.RemoveOpcGroup = new System.Windows.Forms.Button();
			this.OpcGroupName = new System.Windows.Forms.Label();
			this.AddOpcGroup = new System.Windows.Forms.Button();
			this.OpcServerDisConnect = new System.Windows.Forms.Button();
			this.OpcServerRemove = new System.Windows.Forms.Label();
			this.OpcServerName = new System.Windows.Forms.Label();
			this.bOpcServerConnect = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// OpcRemoveItemName
			// 
			this.OpcRemoveItemName.BackColor = System.Drawing.Color.Yellow;
			this.OpcRemoveItemName.Location = new System.Drawing.Point(72, 256);
			this.OpcRemoveItemName.Name = "OpcRemoveItemName";
			this.OpcRemoveItemName.Size = new System.Drawing.Size(216, 32);
			this.OpcRemoveItemName.TabIndex = 64;
			this.OpcRemoveItemName.Text = "Opc Remove Item Name";
			this.OpcRemoveItemName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// RemoveOpcItem
			// 
			this.RemoveOpcItem.Location = new System.Drawing.Point(328, 256);
			this.RemoveOpcItem.Name = "RemoveOpcItem";
			this.RemoveOpcItem.Size = new System.Drawing.Size(216, 32);
			this.RemoveOpcItem.TabIndex = 63;
			this.RemoveOpcItem.Text = "Remove Opc Item";
			this.RemoveOpcItem.Click += new System.EventHandler(this.RemoveOpcItem_Click);
			// 
			// OpcItemName
			// 
			this.OpcItemName.BackColor = System.Drawing.Color.Yellow;
			this.OpcItemName.Location = new System.Drawing.Point(72, 192);
			this.OpcItemName.Name = "OpcItemName";
			this.OpcItemName.Size = new System.Drawing.Size(216, 32);
			this.OpcItemName.TabIndex = 62;
			this.OpcItemName.Text = "Opc Item Name";
			this.OpcItemName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// AddOpcItem
			// 
			this.AddOpcItem.Location = new System.Drawing.Point(328, 192);
			this.AddOpcItem.Name = "AddOpcItem";
			this.AddOpcItem.Size = new System.Drawing.Size(216, 32);
			this.AddOpcItem.TabIndex = 61;
			this.AddOpcItem.Text = "Add Opc Item";
			this.AddOpcItem.Click += new System.EventHandler(this.AddOpcItem_Click);
			// 
			// OpcRemoveGroupName
			// 
			this.OpcRemoveGroupName.BackColor = System.Drawing.Color.Yellow;
			this.OpcRemoveGroupName.Location = new System.Drawing.Point(72, 320);
			this.OpcRemoveGroupName.Name = "OpcRemoveGroupName";
			this.OpcRemoveGroupName.Size = new System.Drawing.Size(216, 32);
			this.OpcRemoveGroupName.TabIndex = 60;
			this.OpcRemoveGroupName.Text = "Opc Remove Group Name";
			this.OpcRemoveGroupName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// RemoveOpcGroup
			// 
			this.RemoveOpcGroup.Location = new System.Drawing.Point(328, 320);
			this.RemoveOpcGroup.Name = "RemoveOpcGroup";
			this.RemoveOpcGroup.Size = new System.Drawing.Size(216, 32);
			this.RemoveOpcGroup.TabIndex = 59;
			this.RemoveOpcGroup.Text = "Remove Opc Group";
			this.RemoveOpcGroup.Click += new System.EventHandler(this.RemoveOpcGroup_Click);
			// 
			// OpcGroupName
			// 
			this.OpcGroupName.BackColor = System.Drawing.Color.Yellow;
			this.OpcGroupName.Location = new System.Drawing.Point(72, 128);
			this.OpcGroupName.Name = "OpcGroupName";
			this.OpcGroupName.Size = new System.Drawing.Size(216, 32);
			this.OpcGroupName.TabIndex = 58;
			this.OpcGroupName.Text = "Opc Group Name";
			this.OpcGroupName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// AddOpcGroup
			// 
			this.AddOpcGroup.Location = new System.Drawing.Point(328, 128);
			this.AddOpcGroup.Name = "AddOpcGroup";
			this.AddOpcGroup.Size = new System.Drawing.Size(216, 32);
			this.AddOpcGroup.TabIndex = 57;
			this.AddOpcGroup.Text = "Add Opc Group";
			this.AddOpcGroup.Click += new System.EventHandler(this.AddOpcGroup_Click);
			// 
			// OpcServerDisConnect
			// 
			this.OpcServerDisConnect.Location = new System.Drawing.Point(328, 384);
			this.OpcServerDisConnect.Name = "OpcServerDisConnect";
			this.OpcServerDisConnect.Size = new System.Drawing.Size(216, 32);
			this.OpcServerDisConnect.TabIndex = 56;
			this.OpcServerDisConnect.Text = "Opc Server DisConnect";
			this.OpcServerDisConnect.Click += new System.EventHandler(this.OpcServerDisConnect_Click);
			// 
			// OpcServerRemove
			// 
			this.OpcServerRemove.BackColor = System.Drawing.Color.Yellow;
			this.OpcServerRemove.Location = new System.Drawing.Point(72, 384);
			this.OpcServerRemove.Name = "OpcServerRemove";
			this.OpcServerRemove.Size = new System.Drawing.Size(216, 32);
			this.OpcServerRemove.TabIndex = 55;
			this.OpcServerRemove.Text = "Opc Server Remove";
			this.OpcServerRemove.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// OpcServerName
			// 
			this.OpcServerName.BackColor = System.Drawing.Color.Yellow;
			this.OpcServerName.Location = new System.Drawing.Point(72, 64);
			this.OpcServerName.Name = "OpcServerName";
			this.OpcServerName.Size = new System.Drawing.Size(216, 32);
			this.OpcServerName.TabIndex = 54;
			this.OpcServerName.Text = "Opc Server Name";
			this.OpcServerName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// bOpcServerConnect
			// 
			this.bOpcServerConnect.Location = new System.Drawing.Point(328, 64);
			this.bOpcServerConnect.Name = "bOpcServerConnect";
			this.bOpcServerConnect.Size = new System.Drawing.Size(216, 32);
			this.bOpcServerConnect.TabIndex = 53;
			this.bOpcServerConnect.Text = "Opc Server Connect";
			this.bOpcServerConnect.Click += new System.EventHandler(this.bOpcServerConnect_Click);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -