示例#1
0
        /// <summary>
        /// Draws the data of a tree node at the specified location.</summary>
        /// <param name="node">The tree control's node whose data is to be drawn</param>
        /// <param name="g">The current GDI+ graphics object</param>
        /// <param name="x">The x-coordinate of the upper-left corner of the node label</param>
        /// <param name="y">The y-coordinate of the upper-left corner of the node label</param>
        public override void DrawData(TreeControl.Node node, Graphics g, int x, int y)
        {
            var treeListControl = node.TreeControl as TreeListControl;

            ItemInfo info = new WinFormsItemInfo();

            m_itemView.GetInfo(node.Tag, info);
            if (info.Properties.Length == 0)
            {
                return;
            }

            Region oldClip = g.Clip;

            //UpdateColumnWidths(node, info, g);
            int xOffset = treeListControl.TreeWidth;

            for (int i = 0; i < info.Properties.Length; ++i)
            {
                var dataEditor = info.Properties[i] as DataEditor;
                if (dataEditor != null) // show object data details in columns
                {
                    if (TrackingEditor != null && (TrackingEditor.Owner == node.Tag) &&
                        (TrackingEditor.Name == dataEditor.Name))
                    {
                        dataEditor = TrackingEditor;
                    }
                    var clip = new Rectangle(xOffset, y, treeListControl.Columns[i].ActualWidth, treeListControl.GetRowHeight(node));
                    if (i == info.Properties.Length - 1) // extends last column
                    {
                        clip.Width = node.TreeControl.ActualClientSize.Width - xOffset;
                    }
                    g.SetClip(clip);
                    dataEditor.PaintValue(g, clip);
                }
                xOffset += treeListControl.Columns[i].ActualWidth;
            }

            if (node.Selected)
            {
                g.SetClip(new Rectangle(0, y, treeListControl.Width + 1, node.LabelHeight + 1));
                g.DrawRectangle(s_BorderPen, 0, y, treeListControl.Width, node.LabelHeight);
            }

            g.Clip = oldClip;
        }
示例#2
0
        /// <summary>
        /// Get the data editor hit by point p; also set edit mode if the editor supports multiple controls.</summary>
        /// <param name="node">The node</param>
        /// <param name="p">The point</param>
        /// <returns>Data editor hit by point</returns>
        internal DataEditor GetDataEditor(TreeControl.Node node, Point p)
        {
            var treeListControl = node.TreeControl as TreeListControl;

            ItemInfo info = new WinFormsItemInfo();

            treeListControl.TreeListItemRenderer.ItemView.GetInfo(node.Tag, info);
            if (info.Properties.Length != treeListControl.Columns.Count)
            {
                return(null);
            }

            int left = treeListControl.TreeWidth;

            for (int i = 0; i < treeListControl.Columns.Count; ++i)
            {
                var column = treeListControl.Columns[i];
                if (p.X >= left && p.X <= left + column.ActualWidth)
                {
                    var dataEditor = info.Properties[i] as DataEditor;
                    if (dataEditor != null)
                    {
                        foreach (NodeLayoutInfo nodeLayout in NodeLayout)
                        {
                            if (nodeLayout.Node == node)
                            {
                                dataEditor.TextBox = m_editTextBox;
                                dataEditor.Bounds  = GetEditArea(nodeLayout, dataEditor);
                                dataEditor.SetEditingMode(p);
                                break;
                            }
                        }
                    }
                    return(dataEditor);
                }

                left += column.ActualWidth;
            }

            return(null);
        }