private void SetImageIndex(ComTreeNode comTreeNode) { ComPtrTreeNode comPtrTreeNode = comTreeNode as ComPtrTreeNode; ComMethodTreeNode comMethodTreeNode = comTreeNode as ComMethodTreeNode; ComPropertyTreeNode comPropertyTreeNode = comTreeNode as ComPropertyTreeNode; ComPtrItemTreeNode comPtrItemTreeNode = comTreeNode as ComPtrItemTreeNode; if (comPtrTreeNode != null) { comPtrTreeNode.ImageIndex = comPtrTreeNode.ComPtr.IsInvalid ? NullObjectImageIndex : ObjectImageIndex; if (comPtrTreeNode.IsCollection) { comPtrTreeNode.ImageIndex = comPtrTreeNode.IsEmptyCollection ? NullCollectionImageIndex : CollectionImageIndex; } } else if (comMethodTreeNode != null) { comMethodTreeNode.ImageIndex = MethodImageIndex; } else if (comPropertyTreeNode != null) { comPropertyTreeNode.ImageIndex = PropertyImageIndex; } else if (comPtrItemTreeNode != null) { comPtrItemTreeNode.ImageIndex = comPtrTreeNode.ComPtr.IsInvalid ? NullObjectImageIndex : ObjectImageIndex; } comTreeNode.SelectedImageIndex = comTreeNode.ImageIndex; }
private ComTreeNode[] GetChildren(ComPtrTreeNode node) { if (node == null) { return new ComTreeNode[] { } } ; ComTreeNode[] childNodes = new ComTreeNode[] { }; try { childNodes = GetChildren(node.ComPtr); } catch { GlobalExceptionHandler.HandleException(); } List <ComTreeNode> filteredComTreeNodes = new List <ComTreeNode>(); foreach (ComTreeNode childNode in childNodes) { ComPtrTreeNode comPtrTreeNode = childNode as ComPtrTreeNode; ComPropertyTreeNode comPropertyTreeNode = childNode as ComPropertyTreeNode; if (comPtrTreeNode != null) { if ((comPtrTreeNode.ComPtr.IsInvalid) && (_showNullObjects == false)) { continue; } if (comPtrTreeNode.IsCollection) { if ((comPtrTreeNode.IsEmptyCollection) && (_showEmptyCollections == false)) { continue; } } } else if (comPropertyTreeNode != null) { if (_showProperties == false) { continue; } } filteredComTreeNodes.Add(childNode); } SetImageIndex(filteredComTreeNodes.ToArray()); return(filteredComTreeNodes.ToArray()); }
private ComTreeNode GetChild(ComPtr comPtr, ComPropertyInfo comPropertyInfo) { if (comPtr == null) { return(null); } if (comPropertyInfo == null) { return(null); } if (comPtr.IsInvalid) { return(null); } ComFunctionInfo getFunctionInfo = comPropertyInfo.GetFunction; if (getFunctionInfo == null) { return(null); } if (getFunctionInfo.IsRestricted) { return(null); } ComTreeNode comTreeNode = null; object propertyValue = null; if (getFunctionInfo.Parameters.Length == 0) { try { comPtr.TryInvokePropertyGet(getFunctionInfo.DispId, out propertyValue); } catch { GlobalExceptionHandler.HandleException(); } if (propertyValue == null) { switch (getFunctionInfo.ReturnParameter.VariantType) { case VarEnum.VT_DISPATCH: case VarEnum.VT_PTR: case VarEnum.VT_ARRAY: case VarEnum.VT_UNKNOWN: propertyValue = new ComPtr(IntPtr.Zero); break; } } if (propertyValue is ComPtr) { comTreeNode = new ComPtrTreeNode(comPropertyInfo, (ComPtr)propertyValue); if (((ComPtr)propertyValue).IsInvalid == false) { comTreeNode.Nodes.Add(String.Empty); } } else { comTreeNode = new ComPropertyTreeNode(comPropertyInfo, propertyValue); } } else { switch (getFunctionInfo.ReturnParameter.VariantType) { case VarEnum.VT_DISPATCH: case VarEnum.VT_PTR: case VarEnum.VT_ARRAY: case VarEnum.VT_UNKNOWN: comTreeNode = new ComPtrTreeNode(comPropertyInfo, new ComPtr()); break; default: comTreeNode = new ComPropertyTreeNode(comPropertyInfo, null); break; } } return(comTreeNode); }