private void devicesTreeView_AfterSelect(object sender, TreeViewEventArgs e) { try { if (e.Node.Tag is EthCATDevice) { SoemInterrop.RefreshSlavesState(); EthCATDevice slave = (EthCATDevice)e.Node.Tag; slave.Refresh(); e.Node.SelectedImageIndex = e.Node.ImageIndex = SlaveStatetoIco(slave.State); propertyGrid.SelectedObject = slave; propertyGrid.ExpandAllGridItems(); propertyInput.SelectedObjects = new object[] { slave.InputData }; propertyInput.ExpandAllGridItems(); propertyOutput.SelectedObjects = new object[] { slave.OutputData }; propertyOutput.ExpandAllGridItems(); PDOToolStripMenuItem.Enabled = slave.MailboxProtocol.Contains(MailBoxProto.CoE.ToString()); } else { propertyGrid.SelectedObject = null; } } catch { } }
private void tmrRefreshState_Tick(object sender, EventArgs e) { tmrStart.Enabled = false; SoemInterrop.RefreshSlavesState(); foreach (TreeNode tn in devicesTreeView.Nodes) { EthCATDevice slave = tn.Tag as EthCATDevice; SlaveState s = slave.State; slave.Refresh(); if (s != slave.State) { int img = SlaveStatetoIco(slave.State); tn.ImageIndex = tn.SelectedImageIndex = img; devicesTreeView.Refresh(); } if (tn == devicesTreeView.SelectedNode) { propertyGrid.Refresh(); propertyInput.Refresh(); } } }