public Form1() { InitializeComponent(); InterfaceUpdate = new HandleInterfaceUpdateDelegate(UpdateRTUData); UpdateCurPage = new UpdateEveryPage(UpdateCurrentPage); xmlUpdate = new GetXMLData(GetFormWebXml); }
public Form1() { InitializeComponent(); this.tabMain.Region = new Region(new RectangleF(this.tabPage1.Left, this.tabPage1.Top, this.tabPage1.Width, this.tabPage1.Height)); CloseProject(); InterfaceUpdate = new HandleInterfaceUpdateDelegate(UpdateRTUData); }
public void InitClient() //窗体控件已在初始化 { interfaceUpdateHandle = new HandleInterfaceUpdateDelegate(UpdateTextBox); //实例化委托对象 //spSend.Open(); //SerialPort对象在程序结束前必须关闭,在此说明 //spReceive.DataReceived += Ports.SerialDataReceivedEventHandler(spReceive_DataReceived); //spReceive.ReceivedBytesThreshold = 1; //spReceive.Open(); }
HandleInterfaceUpdateDelegate interfaceUpdateHandle; //定义一个委托实例,此位置是尝试后的最佳位置 //delegate void HandleSerialPortStatus(object sender, System.EventArgs e); //event HandleSerialPortStatus HandleStatus; public 清除发送区显示() { InitializeComponent(); fasong.Text = "发送:" + writeFlag.ToString(); jieshou.Text = "接收:" + readFlag.ToString(); interfaceUpdateHandle = new HandleInterfaceUpdateDelegate(UpdateReceiveTextBox);//实例化委托,此位置是尝试后的最佳位置 //HandleStatus(this.sp.IsOpen,new System.EventArgs()); }
public void RegControl(Control winControl, HandleInterfaceUpdateDelegate updateHandle, byte CommID) { RemoveControl(winControl); Win_Control win = new Win_Control(); win.WinCon = winControl; win.UpdateHandle = updateHandle; win.CommID = CommID; Win_Controls.Add(win); }
private void UpdateReceiveTextBox(string text) { //不在同一线程 if (txtCard.InvokeRequired) { HandleInterfaceUpdateDelegate InterfaceUpdate = new HandleInterfaceUpdateDelegate(UpdateReceiveTextBox); Invoke(InterfaceUpdate, new object[] { text }); } //在同一线程 else { txtCard.Text = text; } }
private void 串口设置ToolStripMenuItem_Click(object sender, EventArgs e) { SerialSetting FSerialSetting = new SerialSetting(); FSerialSetting.ShowDialog(); if (FSerialSetting.DialogResult == DialogResult.OK) { this.serialPort1.BaudRate = FSerialSetting.Baud; this.serialPort1.PortName = FSerialSetting.Port; interfaceUpdateHandle = new HandleInterfaceUpdateDelegate(UpdateLabel); //实例化委托对象 FSerialSetting.Close(); this.serialPort1.Open(); } }
private void UpdateReceiveTextBox(string text) { //不在同一线程 if (lbl_sno.InvokeRequired) { HandleInterfaceUpdateDelegate InterfaceUpdate = new HandleInterfaceUpdateDelegate(UpdateReceiveTextBox); Invoke(InterfaceUpdate, text); } //在同一线程 else { AddToLog(text); //lbl_sno.Invoke(AddToLog, new object[] { text }); } }
public Form1() { InitializeComponent(); interfaceUpdateHandle = new HandleInterfaceUpdateDelegate(UpdateTextBox); //实例化委托对象 }
public FormMain() //类的构造器 { InitializeComponent(); interfaceUpdateHandle = new HandleInterfaceUpdateDelegate(UpdateTextBox); //实例化委托对象 serialPort1.ReceivedBytesThreshold = 3; }