private void CreateTreeItem(IFCTreeItem ifcParent, IFCTreeItem ifcItem) { IntPtr ifcType = IFCEngine.GetInstanceType(ifcItem.instance); string strIfcType = Marshal.PtrToStringAnsi(ifcType); IFCEngine.GetAttribute(ifcItem.instance, "Name", IfcEngine.SdaiType.Unicode, out IntPtr name); string strName = Marshal.PtrToStringUni(name); IFCEngine.GetAttribute(ifcItem.instance, "Description", IfcEngine.SdaiType.Unicode, out IntPtr description); string strDescription = Marshal.PtrToStringUni(description); string strItemText = "'" + (string.IsNullOrEmpty(strName) ? "<name>" : strName) + "', '" + (string.IsNullOrEmpty(strDescription) ? "<description>" : strDescription) + "' (" + strIfcType + ")"; if ((ifcParent != null) && (ifcParent.treeNode != null)) { ifcItem.treeNode = new TreeViewItem() { Header = strItemText }; ifcParent.treeNode.Items.Add(ifcItem.treeNode); } else { ifcItem.treeNode = new TreeViewItem() { Header = strItemText }; treeControl.Items.Add(ifcItem.treeNode); } if (ifcItem.ifcItem == null) { // item without visual representation Random rand = new Random(); byte[] colorValue = new byte[4]; rand.NextBytes(colorValue); var color = System.Windows.Media.Color.FromArgb( (byte)(255 - colorValue[0] * 255), (byte)(colorValue[1] * 255), (byte)(colorValue[2] * 255), (byte)(colorValue[3] * 255)); ifcItem.treeNode.Foreground = new SolidColorBrush(color);//Colors.Gray } ifcItem.treeNode.Tag = ifcItem; }
/// <summary> /// Helper /// </summary> /// <param name="ifcParent"></param> /// <param name="ifcItem"></param> private void CreateTreeItem(IFCTreeItem ifcParent, IFCTreeItem ifcItem) { IntPtr ifcType = _ifcEngine.GetInstanceType(ifcItem.instance); string strIfcType = Marshal.PtrToStringAnsi(ifcType); IntPtr name; _ifcEngine.GetAttribute(ifcItem.instance, "Name", IfcEngine.SdaiType.Unicode, out name); string strName = Marshal.PtrToStringUni(name); IntPtr description; _ifcEngine.GetAttribute(ifcItem.instance, "Description", IfcEngine.SdaiType.Unicode, out description); string strDescription = Marshal.PtrToStringUni(description); string strItemText = "'" + (string.IsNullOrEmpty(strName) ? "<name>" : strName) + "', '" + (string.IsNullOrEmpty(strDescription) ? "<description>" : strDescription) + "' (" + strIfcType + ")"; if ((ifcParent != null) && (ifcParent.treeNode != null)) { TreeViewItem tvi = new TreeViewItem() { Header = strItemText }; ifcParent.treeNode.Items.Add(tvi); ifcItem.treeNode = tvi; } else { TreeViewItem tvi = new TreeViewItem() { Header = strItemText }; _treeControl.Items.Add(tvi); ifcItem.treeNode = tvi; } if (ifcItem.ifcItem == null) { // item without visual representation ifcItem.treeNode.Foreground = new SolidColorBrush(Colors.Gray); } ifcItem.treeNode.Tag = ifcItem; }
private string getInstanceType(IntPtr instance) { IntPtr ifcTypeIns = _ifcEngine.GetInstanceType(instance); IntPtr name = IntPtr.Zero; _ifcEngine.GetEntityName(ifcTypeIns, IfcEngine.SdaiType.String, out name); return(Marshal.PtrToStringAnsi(name)); }