/// <summary> /// Shows a detailed view for array values. /// </summary> private void ViewMI_Click(object sender, System.EventArgs e) { if (PropertiesLV.SelectedItems.Count > 0) { object tag = PropertiesLV.SelectedItems[0].Tag; if (tag != null && tag.GetType() == typeof(OpcDa::ItemProperty)) { OpcDa::ItemProperty property = (OpcDa::ItemProperty)tag; if (property.Value != null) { if (property.ID == OpcDa::Property.VALUE) { //ComplexItem complexItem = ComplexTypeCache.GetComplexItem( m_element ); //if ( complexItem != null ) //{ // new EditComplexValueDlg().ShowDialog( complexItem, property.Value, true, true ); //} } else if (property.Value.GetType().IsArray) { new EditArrayDlg().ShowDialog(property.Value, true); } } } } }
private void AddItemProperty(OpcDa::ItemProperty property) { if (property.ResultID.Succeeded()) { new PropertyTreeNode <IBrowse>(property, this); } }
/// <summary> /// Initializes a new instance of the <see cref="PropertyTreeNode<ParentType>"/> class. /// </summary> /// <param name="property">The property.</param> /// <param name="node">The parent node.</param> internal PropertyTreeNode(OpcDa::ItemProperty property, ParentType node) : base(property.ID.ToString(), property, node) { if (property.Value == null) { return; } AddDummyNode(); }
/// <summary> /// Adds an item to the list view. /// </summary> private void AddProperty(OpcDa::ItemProperty property) { // create list view item. ListViewItem listItem = new ListViewItem((string)GetFieldValue(property, ID), (int)ImageListLibrary.Icons.IMAGE_TAG); // add appropriate sub-items. listItem.SubItems.Add(Opc.Convert.ToString(GetFieldValue(property, DESCRIPTION))); listItem.SubItems.Add(Opc.Convert.ToString(GetFieldValue(property, VALUE))); listItem.SubItems.Add(Opc.Convert.ToString(GetFieldValue(property, DATA_TYPE))); listItem.SubItems.Add(Opc.Convert.ToString(GetFieldValue(property, ITEM_PATH))); listItem.SubItems.Add(Opc.Convert.ToString(GetFieldValue(property, ITEM_NAME))); listItem.SubItems.Add(Opc.Convert.ToString(GetFieldValue(property, ERROR))); // save item object as list view item tag. listItem.Tag = property; // add to list view. PropertiesLV.Items.Add(listItem); }
/// <summary> /// Returns the value of the specified field. /// </summary> private object GetFieldValue(OpcDa::ItemProperty property, int fieldID) { switch (fieldID) { case ID: { return(property.ID.ToString()); } case DESCRIPTION: { return(property.Description); } case VALUE: { return(property.Value); } case DATA_TYPE: { return((property.Value != null) ? property.Value.GetType() : null); } case ITEM_PATH: { return(property.ItemPath); } case ITEM_NAME: { return(property.ItemName); } case ERROR: { return(property.ResultID); } } return(null); }