public FrmChangeId(Node target) { InitializeComponent(); this.lblNodeID.Text = target.id.ToString(); this.lblNodeName.Text = target.name; toChange = target; }
private void BtnOK_Click(object sender, EventArgs e) { Contract.Requires(txtId.Text != null); this.newNode = new Node((Int16)Int32.Parse(txtId.Text)); this.cancelled = false; this.Close(); }
public void loadNode(Node newtarget) { childForms = new List<sensorFrm>(); target = newtarget; int n = 0; int formHeight = this.Height; int formWidth = this.Width; foreach (sensor thisSensor in target.sensors.Values) { sensorFrm newSensorForm; try { newSensorForm = new sensorFrm(thisSensor); newSensorForm.Visible = false; newSensorForm.Show(); newSensorForm.MdiParent = this; newSensorForm.Left = (newSensorForm.Width * n); newSensorForm.Top = 0; formWidth = newSensorForm.Width + newSensorForm.Left + SystemInformation.Border3DSize.Width; formHeight = newSensorForm.Height + SystemInformation.Border3DSize.Height; newSensorForm.Visible = true; newSensorForm.OnSetIcon += setIcon; childForms.Add(newSensorForm); } catch (commsException) { MessageBox.Show("An exception occurred interrogating the node. Please retry."); } catch (Exception) { MessageBox.Show("A serious, unhandled exception occurred interrogating the node. This is bad."); } n++; } int borderX = (this.Width - this.ClientRectangle.Width) + SystemInformation.Border3DSize.Height; int borderY = (this.Height - this.ClientRectangle.Height) + SystemInformation.Border3DSize.Width; this.Width = formWidth + borderX ; this.Height = formHeight + borderY ; }
public FrmChangeP(Node target) { InitializeComponent(); this.lblNodeName.Text = target.name; toChange = target; }
private void loadNodeInfoPanel(Node loadThis) { Contract.Requires(loadThis != null); gpNodeInfo.Visible = true; lstNodes.Width = 317; lblNodeId.Text = loadThis.id.ToString(); lblNodeName.Text = loadThis.name; lblSensorCount.Text = loadThis.sensors.Count.ToString(); }
private void addNewNode(Node newNode) { Contract.Requires(newNode != null); newNode.addRequiredWaitWhen(nodeActivityStarted,nodeActivityFinished); // Connect to node and fill fields try { newNode.Mydriver = getMyDriver(); newNode.fillProperties(); } catch (badPortException) { MessageBox.Show("Bad port name"); return; } catch (cantOpenPortException) { MessageBox.Show("Can't open port, please make sure it is valid and unused"); return; } catch (commsCryptoException) { MessageBox.Show("Crypto failure talking to node. Please retry, and ensure network keys are set correctly."); return; } catch (commsTimeoutException ) { MessageBox.Show("Timeout attempting to talk to node. Check node power and operation, and network keys."); return; } catch (InternalErrorException ) { MessageBox.Show("An internal error occurred when attempting to talk to the node. Please retry."); return; } // Add node to node list String id = newNode.id.ToString(); String caption = newNode.name + " (id " + id + ")"; String name = newNode.name; String sensorCount = newNode.sensors.Count.ToString(); ListViewItem listItem = new ListViewItem(new[] { caption, id, name, sensorCount }, 0); listItem.ImageIndex = 0; listItem.Tag = newNode; lstNodes.Items.Add(listItem); _nodes.Add(newNode); }
public void ReadXml(XmlReader reader) { short parentNodeId = 0; string port = null; bool encrypt = false; byte[] key = new byte[16]; bool readElement = false; while (!readElement) { switch (reader.Name) { case "ID": id = (short)reader.ReadElementContentAsInt(); break; case "nodeType": _cachedType = new sensorType((sensorTypeEnum)reader.ReadElementContentAsInt()); break; case "parentNodeID": parentNodeId = (short)reader.ReadElementContentAsInt(); break; case "driverPort": port = reader.ReadElementContentAsString(); break; case "driverEncrypt": encrypt = reader.ReadElementContentAsBoolean(); break; case "key": reader.ReadElementContentAsBinHex(key, 0, 16); break; case "selectedSensor": if (reader.NodeType == XmlNodeType.EndElement) readElement = true; else reader.Read(); break; default: reader.Read(); break; } } _parentNode = new Node(parentNodeId); }
public sensor(Node newParentNode) { _parentNode = newParentNode; }