public TreeViewItemWrapper( TSource dataItem, ITreeviewSourceDecoder <TSource> decoder, ITreeViewItemWrapper <TSource> parent, bool isLastSibling, ITreeview <TSource> treeview) { if (dataItem == null) { throw new ArgumentNullException("dataItem"); } if (decoder == null) { throw new ArgumentNullException("decoder"); } if (treeview == null) { throw new ArgumentNullException("treeview"); } this._dataItem = dataItem; this._decoder = decoder; this._parent = parent; this._isLastSibling = isLastSibling; this.treeview = treeview; }
private void RenderChildren(ITreeViewItemWrapper <TSource> parent, ITreeviewSourceDecoder <TSource> treeviewSourceDecoder, EventType currentEventType) { foreach (var child in parent.Children) { treeviewRowRenderer.RenderRow(child, treeviewSourceDecoder, currentEventType); if (child.IsExpanded) { RenderChildren(child, treeviewSourceDecoder, currentEventType); } } }
public void RenderRow(ITreeViewItemWrapper <TSource> item, ITreeviewSourceDecoder <TSource> treeviewSourceDecoder, EventType currentEventType) { if (item == null) { throw new ArgumentNullException("item"); } if (treeviewSourceDecoder == null) { throw new ArgumentNullException("treeviewSourceDecoder"); } var gridRect = new Rect(0, 0, 0, 0); guiLayout.BeginHorizontal(); guiLayout.Space(1); // In order to use the GUI.DrawTexture which takes absolute position on the page // we have to get the relative location of the space we just drew. if (currentEventType == EventType.repaint) { gridRect = guiLayout.GetLastRect(); } var structureX = RenderTreeviewIcons(item, gridRect, currentEventType); var iconTopLeft = new Vector2(gridRect.x + structureX, gridRect.y); guiLayout.Space(gridRect.x + structureX); var itemIconDimensions = iconRenderer.RenderItemIcon(item, iconTopLeft); if (itemIconDimensions.x > 0) { rowClickableLocations.RegisterRowIcon(new Rect(iconTopLeft.x, iconTopLeft.y, itemIconDimensions.x, itemIconDimensions.y), item); } guiLayout.Space(itemIconDimensions.x); var renderContext = new RenderDisplayContext(item.IsSelected, item.IsExpanded, item.IsActive); treeviewSourceDecoder.RenderDisplay(item.Value, renderContext); if (currentEventType == EventType.repaint) { gridRect = guiLayout.GetLastRect(); rowClickableLocations.RegisterRowContent(gridRect, item); } guiLayout.EndHorizontal(); }
public ITreeViewItemWrapper <TSource> Root(ITreeview <TSource> treeview, ITreeviewSourceDecoder <TSource> sourceDecoder) { if (treeview == null) { throw new ArgumentNullException("treeview"); } if (sourceDecoder == null) { throw new ArgumentNullException("sourceDecoder"); } var itemSourceCopy = treeview.ItemsSource; if (itemSourceCopy == null) { return(null); } if (itemSourceCopy != this._decodedSource) { // Itemsource on treeview has changed since last cached. this._cachedRoot = null; } if (this._cachedRoot != null) { return(this._cachedRoot); } var stronglyTypedSource = itemSourceCopy as TSource; if (stronglyTypedSource == null) { this._log.LogError("Source is of type {0}, expected type {1}", treeview.ItemsSource.GetType().Name, typeof(TSource).Name); return(null); } this._cachedRoot = new TreeViewItemWrapper <TSource>(stronglyTypedSource, sourceDecoder, null, true, treeview); this._decodedSource = itemSourceCopy; return(this._cachedRoot); }
protected virtual void Init() { TreeviewIcons = new CustomItemTreeviewIcons(); TreeviewSourceDecoder = new Treeview_DataRecorder(this.guiLayout); }