コード例 #1
0
 protected virtual void OnGetNodeColors(GetNodeColorsEventArgs e)
 {
     EventHandler<GetNodeColorsEventArgs> handler = base.Events[EventGetNodeColors] as EventHandler<GetNodeColorsEventArgs>;
     if (handler != null)
     {
         handler(this, e);
     }
 }
コード例 #2
0
        private void WmCustomDraw(ref Message m)
        {
            TreeNode node;
            TreeNodeStates itemState;
            switch (Microsoft.Win32.NMCUSTOMDRAW.GetDrawStage(m.LParam))
            {
                case CDDS.CDDS_ITEMPREPAINT:
                    node = this.NodeFromHandle(Microsoft.Win32.NMCUSTOMDRAW.GetItemSpec(m.LParam));
                    if (node != null)
                    {
                        if (!base.ClientRectangle.IntersectsWith(Microsoft.Win32.NMCUSTOMDRAW.GetRect(m.LParam)))
                        {
                            m.Result = (IntPtr) 4L;
                        }
                        else
                        {
                            System.Drawing.Color backColor = Microsoft.Win32.NMTVCUSTOMDRAW.GetBackColor(m.LParam);
                            System.Drawing.Color foreColor = Microsoft.Win32.NMTVCUSTOMDRAW.GetForeColor(m.LParam);
                            itemState = (TreeNodeStates) Microsoft.Win32.NMCUSTOMDRAW.GetItemState(m.LParam);
                            IntPtr ptr = Windows.SendMessage(base.Handle, 0x110a, (IntPtr) 8L, IntPtr.Zero);
                            if ((ptr != IntPtr.Zero) && (node.Handle == ptr))
                            {
                                itemState |= TreeNodeStates.Marked;
                            }
                            GetNodeColorsEventArgs e = new GetNodeColorsEventArgs(node, itemState, backColor, foreColor);
                            this.OnGetNodeColors(e);
                            if (e.BackColor != backColor)
                            {
                                Microsoft.Win32.NMTVCUSTOMDRAW.SetBackColor(m.LParam, e.BackColor);
                            }
                            if (e.ForeColor != foreColor)
                            {
                                Microsoft.Win32.NMTVCUSTOMDRAW.SetForeColor(m.LParam, e.ForeColor);
                            }
                            if (base.DrawMode != TreeViewDrawMode.Normal)
                            {
                                m.Result = (IntPtr) (((int) m.Result) | 0x10);
                            }
                        }
                        break;
                    }
                    break;

                case CDDS.CDDS_ITEMPOSTPAINT:
                    node = this.NodeFromHandle(Microsoft.Win32.NMCUSTOMDRAW.GetItemSpec(m.LParam));
                    if (node != null)
                    {
                        Rectangle bounds = node.Bounds;
                        if (base.ClientRectangle.IntersectsWith(bounds))
                        {
                            itemState = (TreeNodeStates) Microsoft.Win32.NMCUSTOMDRAW.GetItemState(m.LParam);
                            using (Graphics graphics = Graphics.FromHdcInternal(Microsoft.Win32.NMCUSTOMDRAW.GetHdc(m.LParam)))
                            {
                                PostDrawTreeNodeEventArgs args2 = new PostDrawTreeNodeEventArgs(graphics, node, bounds, itemState);
                                this.OnPostDrawNode(args2);
                            }
                        }
                    }
                    break;
            }
        }
コード例 #3
0
 protected override void OnGetNodeColors(GetNodeColorsEventArgs e)
 {
     bool flag = (e.State & TreeNodeStates.Selected) == 0;
     if (base.ExplorerTheme || (base.HotTracking && ((e.State & (TreeNodeStates.Hot | TreeNodeStates.Selected)) == TreeNodeStates.Hot)))
     {
         e.ForeColor = e.Node.ForeColor;
         flag = flag && !base.ExplorerTheme;
     }
     else if ((e.State & TreeNodeStates.Marked) > 0)
     {
         e.ForeColor = SystemColors.HighlightText;
         flag = false;
     }
     if (flag && ImageHelper.IsCloseColors(e.ForeColor, e.BackColor))
     {
         e.ForeColor = this.ForeColor;
     }
     base.OnGetNodeColors(e);
 }