using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using OpcClientFormTest.PLCServiceTest; using System.ServiceModel; using System.Threading; namespace OpcClientFormTest { public partial class Form1 : Form, IPLCServiceTestCallback { private PLCServiceTestClient proxy; public Form1() { InitializeComponent(); InstanceContext site = new InstanceContext(this); proxy = new PLCServiceTestClient(site); string flag = System.DateTime.Now.ToString("HHmmss"); this.textBox2.Text = flag; this.Text = flag; proxy.Register(flag); } #region IPLCServiceTestCallback 成员 public void ReturnProductCode(string name) { this.textBox1.Text = name; Random r = new Random(); this.BackColor = Color.FromArgb(255, r.Next(256), r.Next(256), r.Next(256)); } #endregion } }