示例#1
0
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            //读取默认设置
            TreeNodeStates currentState     = e.State;
            Font           currentFont      = e.Node.NodeFont ?? e.Node.TreeView.Font;
            Color          currentFontColor = e.Node.ForeColor;
            Color          currentBackColor = e.Node.BackColor;

            if (currentFontColor == Color.Empty)
            {
                currentFontColor = NoFocusNodeFontColor;
            }
            if (currentBackColor == Color.Empty)
            {
                currentBackColor = NoFocusNodeBackColor;
            }

            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                //选中状态
                e.Graphics.FillRectangle(new SolidBrush(SelectedNodeBackColor), e.Bounds);
                ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, currentFontColor, SelectedNodeBackColor);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, currentFont, e.Bounds, SelectedNodeFontColor, SelectedNodeBackColor, TextFormatFlags.GlyphOverhangPadding);
            }
            else
            {
                //非选中状态
                e.Graphics.FillRectangle(new SolidBrush(currentBackColor), e.Bounds);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, currentFont, e.Bounds, currentFontColor, TextFormatFlags.GlyphOverhangPadding);
            }
        }
 public DrawTreeNodeEventArgs(Graphics graphics, TreeNode node, Rectangle bounds, TreeNodeStates state)
 {
     _graphics = graphics;
     _node = node;
     _bounds = bounds;
     _state = state;
 }
示例#3
0
文件: GClass5.cs 项目: zha0/Cerberus
 // Token: 0x0600036D RID: 877 RVA: 0x000096B4 File Offset: 0x000078B4
 protected virtual void OnDrawNode(DrawTreeNodeEventArgs e)
 {
     try
     {
         Rectangle      rect           = new Rectangle(GClass5.smethod_0(e).Location.X, e.Bounds.Location.Y, e.Bounds.Width, e.Bounds.Height);
         TreeNodeStates treeNodeStates = this.treeNodeStates_0;
         if (treeNodeStates != TreeNodeStates.Selected)
         {
             if (treeNodeStates == TreeNodeStates.Checked)
             {
                 e.Graphics.FillRectangle(Brushes.Green, rect);
                 e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8f), Brushes.Black, new Rectangle(rect.X + 2, rect.Y + 2, rect.Width, rect.Height), GClass6.stringFormat_0);
                 base.Invalidate();
             }
             else if (treeNodeStates == TreeNodeStates.Default)
             {
                 e.Graphics.FillRectangle(Brushes.Red, rect);
                 e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8f), Brushes.LimeGreen, new Rectangle(rect.X + 2, rect.Y + 2, rect.Width, rect.Height), GClass6.stringFormat_0);
                 base.Invalidate();
             }
         }
         else
         {
             e.Graphics.FillRectangle(Brushes.Green, rect);
             e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8f), Brushes.Black, new Rectangle(rect.X + 2, rect.Y + 2, rect.Width, rect.Height), GClass6.stringFormat_0);
             base.Invalidate();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     base.OnDrawNode(e);
 }
示例#4
0
		protected Color GetTextColor(TreeNodeStates state, Color c)
		{
			if ((state & SelectedAndFocused) == SelectedAndFocused) {
				return SystemColors.HighlightText;
			}
			return c;
		}
示例#5
0
        private void AtomicTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            // found somewhere online. this allows us to colour the nodes differently.
            TreeNodeStates state = e.State;
            Font           font  = AtomicTreeView.Font;
            Color          foreColor;
            Color          backColor = AtomicTreeView.BackColor; // currently set to blue.

            if (e.Node.Nodes.Count == 0)                         // if the node has no children
            {
                Font regFont = new Font(font, FontStyle.Regular);
                foreColor = Color.Black;
                using (Brush background = new SolidBrush(backColor))
                {
                    e.Graphics.FillRectangle(background, e.Bounds);
                    TextRenderer.DrawText(e.Graphics, e.Node.Text, regFont, e.Bounds, foreColor, TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.SingleLine | TextFormatFlags.EndEllipsis);
                }
            }
            else
            {
                foreColor = AtomicTreeView.ForeColor;
                using (Brush background = new SolidBrush(backColor))
                {
                    e.Graphics.FillRectangle(background, e.Bounds);
                    TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, foreColor, TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.SingleLine | TextFormatFlags.EndEllipsis);
                }
            }
        }
示例#6
0
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            TreeNodeStates state = e.State;
            Font           font  = e.Node.NodeFont ?? e.Node.TreeView.Font;
            Color          fore  = e.Node.ForeColor;
            Rectangle      rect  = new Rectangle();

            if (fore == Color.Empty)
            {
                fore = e.Node.TreeView.ForeColor;
            }


            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                fore = SystemColors.HighlightText;
                rect = new Rectangle(0, e.Bounds.Y, e.Node.TreeView.Width, e.Node.Bounds.Height);
                e.Graphics.FillRectangle(new SolidBrush(e.Node.BackColor), rect);
                //ControlPaint.DrawFocusRectangle(e.Graphics, rect, fore, Color.Red);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, e.Node.BackColor, TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.VerticalCenter);
            }
            else
            {
                rect = new Rectangle(0, e.Bounds.Y, e.Node.TreeView.Width, e.Node.Bounds.Height);
                e.Graphics.FillRectangle(new SolidBrush(Parent.BackColor), rect);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.VerticalCenter);
            }
            base.OnDrawNode(e);
        }
示例#7
0
 /// <devdoc>
 /// Creates a new DrawTreeNodeEventArgs with the given parameters.
 /// </devdoc>
 public DrawTreeNodeEventArgs(Graphics graphics, TreeNode node, Rectangle bounds, TreeNodeStates state)
 {
     Graphics = graphics;
     Node     = node;
     Bounds   = bounds;
     State    = state;
 }
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            TreeNodeStates state = e.State;
            Font           font  = e.Node.NodeFont ?? e.Node.TreeView.Font;
            Color          fore  = e.Node.ForeColor;

            if (fore == Color.Empty)
            {
                fore = e.Node.TreeView.ForeColor;
            }
            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                var color = Color.Blue;

                if ((state & TreeNodeStates.Focused) != TreeNodeStates.Focused)
                {
                    color = Color.FromArgb(30, 30, 255);
                }

                fore = SystemColors.HighlightText;
                e.Graphics.FillRectangle(new SolidBrush(color), e.Bounds);
                ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, fore, color);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, color, TextFormatFlags.GlyphOverhangPadding);
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding);
            }
        }
示例#9
0
    protected override void OnDrawNode(DrawTreeNodeEventArgs e)
    {
        TreeNodeStates state = e.State;
        Font           font  = e.Node.NodeFont ?? e.Node.TreeView.Font;
        Color          fore  = e.Node.ForeColor;

        if (fore == Color.Empty)
        {
            fore = e.Node.TreeView.ForeColor;
        }
        if (e.Node == e.Node.TreeView.SelectedNode)
        {
            fore = SystemColors.HighlightText;
            Rectangle r = e.Bounds;

            e.Graphics.FillRectangle(SystemBrushes.Highlight, r);
            r.Width  -= 1;
            r.Height -= 1;

            GraphicsPath p = GetRoundedRect(r, 2);

            e.Graphics.DrawPath(SystemPens.HotTrack, p);
            //e.Graphics.DrawRectangle(SystemPens.HotTrack, r);
            //ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, fore, SystemColors.Highlight);

            TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding);
        }
        else
        {
            e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
            TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding);
        }
    }
 public DrawTreeNodeEventArgs(System.Drawing.Graphics graphics, TreeNode node, Rectangle bounds, TreeNodeStates state)
 {
     this.graphics = graphics;
     this.node = node;
     this.bounds = bounds;
     this.state = state;
     this.drawDefault = false;
 }
示例#11
0
 public DrawTreeNodeEventArgs(System.Drawing.Graphics graphics, TreeNode node, Rectangle bounds, TreeNodeStates state)
 {
     this.graphics    = graphics;
     this.node        = node;
     this.bounds      = bounds;
     this.state       = state;
     this.drawDefault = false;
 }
        //From https://stackoverflow.com/questions/10034714/c-sharp-winforms-highlight-treenode-when-treeview-doesnt-have-focus
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            TreeNodeStates treeState = e.State;
            Font           treeFont  = e.Node.NodeFont ?? e.Node.TreeView.Font;

            // Colors.
            Color  foreColor = e.Node.ForeColor;
            string strDeselectedColor = @"#6B6E77", strSelectedColor = @"#94C7FC";
            Color  selectedColor   = System.Drawing.ColorTranslator.FromHtml(strSelectedColor);
            Color  deselectedColor = System.Drawing.ColorTranslator.FromHtml(strDeselectedColor);

            // New brush.
            SolidBrush selectedTreeBrush   = new SolidBrush(selectedColor);
            SolidBrush deselectedTreeBrush = new SolidBrush(deselectedColor);

            // Set default font color.
            if (foreColor == Color.Empty)
            {
                foreColor = e.Node.TreeView.ForeColor;
            }

            // Draw bounding box and fill.
            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                // Use appropriate brush depending on if the tree has focus.
                if (this.Focused)
                {
                    foreColor = SystemColors.HighlightText;
                    e.Graphics.FillRectangle(selectedTreeBrush, e.Bounds);
                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, foreColor, SystemColors.Highlight);
                    TextRenderer.DrawText(e.Graphics, e.Node.Text, treeFont, e.Bounds,
                                          foreColor, TextFormatFlags.GlyphOverhangPadding);
                }
                else
                {
                    foreColor = SystemColors.HighlightText;
                    e.Graphics.FillRectangle(deselectedTreeBrush, e.Bounds);
                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, foreColor, SystemColors.Highlight);
                    TextRenderer.DrawText(e.Graphics, e.Node.Text, treeFont, e.Bounds,
                                          foreColor, TextFormatFlags.GlyphOverhangPadding);
                }
            }
            else
            {
                if ((e.State & TreeNodeStates.Hot) == TreeNodeStates.Hot)
                {
                    e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                    TextRenderer.DrawText(e.Graphics, e.Node.Text, treeFont, e.Bounds,
                                          System.Drawing.Color.Black, TextFormatFlags.GlyphOverhangPadding);
                }
                else
                {
                    e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                    TextRenderer.DrawText(e.Graphics, e.Node.Text, treeFont, e.Bounds,
                                          foreColor, TextFormatFlags.GlyphOverhangPadding);
                }
            }
        }
示例#13
0
 public DrawTreeNodeEventArgs(Graphics graphics, TreeNode node,
                              Rectangle_ bounds, TreeNodeStates state)
 {
     this.bounds       = bounds;
     this.draw_default = false;
     this.graphics     = graphics;
     this.node         = node;
     this.state        = state;
 }
 //=====================================================================
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="g">The graphics object to use</param>
 /// <param name="treeNode">The tree node to draw</param>
 /// <param name="nodeState">The current node state</param>
 /// <param name="bounds">The node's bounds</param>
 /// <example>
 /// <code language="cs" source="..\Demos\ListControlDemoCS\ExtendedTreeViewTestForm.cs"
 ///   region="TreeNodeDrawing Example" title="C# - TreeNodeDrawing Event Handler Example" />
 /// <code language="cs" source="..\Demos\ListControlDemoCS\ExtendedTreeViewTestForm.cs"
 ///   region="TreeNodeDrawn Example" title="C# - TreeNodeDrawn Event Handler Example" />
 /// <code language="vbnet" source="..\Demos\ListControlDemoVB\ExtendedTreeViewTestForm.vb"
 ///   region="TreeNodeDrawing Example" title="VB.NET - TreeNodeDrawing Event Handler Example" />
 /// <code language="vbnet" source="..\Demos\ListControlDemoVB\ExtendedTreeViewTestForm.vb"
 ///   region="TreeNodeDrawn Example" title="VB.NET - TreeNodeDrawn Event Handler Example" />
 /// </example>
 public DrawTreeNodeExtendedEventArgs(Graphics g, TreeNode treeNode, TreeNodeStates nodeState,
   Rectangle bounds)
 {
     graphics = g;
     node = treeNode;
     state = nodeState;
     nodeBounds = bounds;
     nodeParts = NodeParts.Background;
     imageIndex = stateImageIndex = -1;
 }
示例#15
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="g">The graphics object to use</param>
        /// <param name="treeNode">The tree node to draw</param>
        /// <param name="nodeState">The current node state</param>
        /// <param name="bounds">The node's bounds</param>
        /// <example>
        /// <code language="cs" source="..\Demos\ListControlDemoCS\ExtendedTreeViewTestForm.cs"
        ///   region="TreeNodeDrawing Example" title="C# - TreeNodeDrawing Event Handler Example" />
        /// <code language="cs" source="..\Demos\ListControlDemoCS\ExtendedTreeViewTestForm.cs"
        ///   region="TreeNodeDrawn Example" title="C# - TreeNodeDrawn Event Handler Example" />
        /// <code language="vbnet" source="..\Demos\ListControlDemoVB\ExtendedTreeViewTestForm.vb"
        ///   region="TreeNodeDrawing Example" title="VB.NET - TreeNodeDrawing Event Handler Example" />
        /// <code language="vbnet" source="..\Demos\ListControlDemoVB\ExtendedTreeViewTestForm.vb"
        ///   region="TreeNodeDrawn Example" title="VB.NET - TreeNodeDrawn Event Handler Example" />
        /// </example>
        public DrawTreeNodeExtendedEventArgs(Graphics g, TreeNode treeNode, TreeNodeStates nodeState,
                                             Rectangle bounds)
        {
            graphics   = g;
            node       = treeNode;
            state      = nodeState;
            nodeBounds = bounds;
            nodeParts  = NodeParts.Background;
            imageIndex = stateImageIndex = -1;
        }
 /// <summary>
 ///  Creates a new DrawTreeNodeEventArgs with the given parameters.
 /// </summary>
 public DrawTreeNodeEventArgs(
     Graphics graphics,
     TreeNode?node,
     Rectangle bounds,
     TreeNodeStates state)
 {
     Graphics = graphics.OrThrowIfNull();
     Node     = node;
     Bounds   = bounds;
     State    = state;
 }
示例#17
0
 /// <summary>
 ///  Creates a new DrawTreeNodeEventArgs with the given parameters.
 /// </summary>
 public DrawTreeNodeEventArgs(
     Graphics graphics,
     TreeNode?node,
     Rectangle bounds,
     TreeNodeStates state)
 {
     Graphics = graphics ?? throw new ArgumentNullException(nameof(graphics));
     Node     = node;
     Bounds   = bounds;
     State    = state;
 }
示例#18
0
 public FlatTreeView(TreeNodeStates state)
 {
     _state = state;
     SetStyle(
         ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw |
         ControlStyles.OptimizedDoubleBuffer, true);
     DoubleBuffered = true;
     BackColor      = _baseColor;
     ForeColor      = Color.White;
     LineColor      = _lineColor;
     DrawMode       = TreeViewDrawMode.OwnerDrawAll;
 }
示例#19
0
        protected void OnDrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            Rectangle nodeRect = e.Node.Bounds;

            e.Node.BackColor = Color.White;
            e.Node.ForeColor = Color.Black;

            Font nodeFont = new Font(new FontFamily("Arial"), 16, FontStyle.Regular, GraphicsUnit.Pixel);

            StringFormat stringFormat = new StringFormat();

            stringFormat.LineAlignment = StringAlignment.Center;

            if (e.Node.Nodes.Count != 0)
            {
                Point ptExpand  = new Point(nodeRect.Location.X - 20, nodeRect.Location.Y + 10);
                Image expandImg = null;
                if (e.Node.IsExpanded || e.Node.Nodes.Count < 1)
                {
                    expandImg = new Bitmap(Resources.TreeViewSetaBaixo1);
                }
                else
                {
                    expandImg = new Bitmap(Resources.TreeViewSetaDireita);
                }
                e.Graphics.DrawImage(expandImg, ptExpand);
            }

            Color foreColor = e.Node.ForeColor;
            Color backColor = e.Node.BackColor;

            nodeRect.Width = +200;

            TreeNodeStates state = e.State;

            if ((state & TreeNodeStates.Selected) == TreeNodeStates.Selected)
            {
                backColor = Color.FromArgb(232, 247, 255);
            }

            using (Brush background = new SolidBrush(backColor))
            {
                int tamanhoImagemNode = 12;
                e.Graphics.FillRectangle(background, nodeRect);
                using (Brush textBrush = new SolidBrush(foreColor))
                {
                    e.Graphics.DrawString(e.Node.Text, nodeFont, textBrush,
                                          Rectangle.Inflate(nodeRect, -tamanhoImagemNode, 0), stringFormat);
                }
            }
        }
示例#20
0
        private MenuState GetMenuState(TreeNodeStates state)
        {
            MenuState ret = MenuState.Normal;

            if (((int)state & (int)TreeNodeStates.Hot) == (int)TreeNodeStates.Hot)
            {
                ret = MenuState.Hover;
            }
            else if (((int)state & (int)TreeNodeStates.Selected) == (int)TreeNodeStates.Selected)
            {
                ret = MenuState.Selected;
            }

            return(ret);
        }
示例#21
0
        void DrawLine(Graphics g, LineSegment line, float yPos, float xPos, TreeNodeStates state)
        {
            int logicalX = 0;

            if (line.Words != null)
            {
                foreach (TextWord word in line.Words)
                {
                    switch (word.Type)
                    {
                    case TextWordType.Space:
                        xPos += spaceSize.Width;
                        logicalX++;
                        break;

                    case TextWordType.Tab:
                        xPos += spaceSize.Width * 4;
                        logicalX++;
                        break;

                    case TextWordType.Word:
                        xPos += DrawDocumentWord(g,
                                                 word.Word,
                                                 new PointF(xPos, yPos),
                                                 word.Bold ? BoldMonospacedFont : RegularMonospacedFont,
                                                 GetTextColor(state, word.Color)
                                                 );
                        logicalX += word.Word.Length;
                        break;
                    }
                }
            }
            else
            {
                DrawDocumentWord(g,
                                 bookmark.Document.GetText(line),
                                 new PointF(xPos, yPos),
                                 RegularMonospacedFont,
                                 GetTextColor(state, Color.Black)
                                 );
            }
        }
示例#22
0
        void treeWiewSettings_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            TreeNodeStates state = e.State;
            Font           font  = e.Node.NodeFont ?? e.Node.TreeView.Font;
            Color          fore  = Color.DimGray;

            //if (fore == Color.Empty) fore = e.Node.TreeView.ForeColor;
            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                fore = Color.DimGray;
                e.Graphics.FillRectangle(new SolidBrush(Color.WhiteSmoke), e.Bounds);
                //e.Graphics.FillEllipse(new SolidBrush(Color.AliceBlue), e.Bounds);
                //ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, fore, Color.Red);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, Color.WhiteSmoke, TextFormatFlags.PathEllipsis);
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding);
            }
        }
示例#23
0
    protected override void OnDrawNode(DrawTreeNodeEventArgs e)
    {
        TreeNodeStates state = e.State;
        Font           font  = e.Node.NodeFont ?? e.Node.TreeView.Font;
        Color          fore  = e.Node.ForeColor;

        if (fore == Color.Empty)
        {
            fore = e.Node.TreeView.ForeColor;
        }
        if (e.Node == e.Node.TreeView.SelectedNode)
        {
            fore = SystemColors.HighlightText;
            e.Graphics.FillRectangle(new SolidBrush(highlight), e.Bounds);
            ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, fore, highlight);
            TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, highlight, TextFormatFlags.GlyphOverhangPadding);
        }
        else
        {
            e.Graphics.FillRectangle(new SolidBrush(this.BackColor), e.Bounds);
            TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding);
        }
    }
示例#24
0
        private void _bookmarks_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            TreeNodeStates state = e.State;
            Font           font  = e.Node.NodeFont ?? e.Node.TreeView.Font;
            Color          fore  = e.Node.ForeColor;

            if (fore == Color.Empty)
            {
                fore = e.Node.TreeView.ForeColor;
            }
            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                fore = SystemColors.HighlightText;
                e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, fore, SystemColors.Highlight);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding);
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding);
            }
        }
示例#25
0
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            TreeNodeStates state = e.State;
            Font           font  = e.Node.NodeFont ?? e.Node.TreeView.Font;
            Color          fore  = e.Node.ForeColor;

            if (fore == Color.Empty)
            {
                fore = e.Node.TreeView.ForeColor;
            }
            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                fore = System.Drawing.Color.White;
                e.Graphics.FillRectangle(new SolidBrush(Color.DarkOrange), e.Bounds);
                ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds, fore, Color.Red);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, Color.Red, TextFormatFlags.GlyphOverhangPadding);
            }
            else
            {
                // e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, font, e.Bounds, fore, TextFormatFlags.GlyphOverhangPadding);
            }
            base.OnDrawNode(e);
        }
示例#26
0
        private void RecursiveDrawCheck(PaintEventArgs args, TreeNode node, ref int currentIndex)
        {
            TreeNodeStates state = 0;

            if (_hoverNode == node)
            {
                state |= TreeNodeStates.Hot;
            }
            else if (node == SelectedNode)
            {
                state |= TreeNodeStates.Selected;
            }

            OnDrawNode(new DrawTreeNodeEventArgs(args.Graphics, node, new Rectangle(0, node.Bounds.Y, Width, ItemHeight), state));
            currentIndex++;

            if (node.IsExpanded)
            {
                foreach (TreeNode child in node.Nodes)
                {
                    RecursiveDrawCheck(args, child, ref currentIndex);
                }
            }
        }
示例#27
0
 protected Color GetTextColor(TreeNodeStates state, Color c)
 {
     if ((state & SelectedAndFocused) == SelectedAndFocused) {
         return SystemColors.HighlightText;
     }
     return c;
 }
示例#28
0
 protected override void OnDrawNode(DrawTreeNodeEventArgs e)
 {
     checked
     {
         try
         {
             int            arg_50_1 = e.Bounds.Location.X;
             int            arg_50_2 = e.Bounds.Location.Y;
             int            arg_50_3 = e.Bounds.Width;
             rectangle      bounds   = e.Bounds;
             rectangle      Bounds   = new rectangle(arg_50_1, arg_50_2, arg_50_3, bounds.Height);
             TreeNodeStates state    = this.State;
             bool           flag     = state == TreeNodeStates.Default;
             if (flag)
             {
                 e.Graphics.FillRectangle(Brushes.Red, Bounds);
                 Graphics arg_D7_0 = e.Graphics;
                 string   arg_D7_1 = e.Node.Text;
                 Font     arg_D7_2 = new Font("Segoe UI", 8f);
                 Brush    arg_D7_3 = Brushes.LimeGreen;
                 bounds = new rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height);
                 arg_D7_0.DrawString(arg_D7_1, arg_D7_2, arg_D7_3, bounds, Helpers.NearSF);
                 this.Invalidate();
             }
             else
             {
                 flag = (state == TreeNodeStates.Checked);
                 if (flag)
                 {
                     e.Graphics.FillRectangle(Brushes.Green, Bounds);
                     Graphics arg_160_0 = e.Graphics;
                     string   arg_160_1 = e.Node.Text;
                     Font     arg_160_2 = new Font("Segoe UI", 8f);
                     Brush    arg_160_3 = Brushes.Black;
                     bounds = new rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height);
                     arg_160_0.DrawString(arg_160_1, arg_160_2, arg_160_3, bounds, Helpers.NearSF);
                     this.Invalidate();
                 }
                 else
                 {
                     flag = (state == TreeNodeStates.Selected);
                     if (flag)
                     {
                         e.Graphics.FillRectangle(Brushes.Green, Bounds);
                         Graphics arg_1E9_0 = e.Graphics;
                         string   arg_1E9_1 = e.Node.Text;
                         Font     arg_1E9_2 = new Font("Segoe UI", 8f);
                         Brush    arg_1E9_3 = Brushes.Black;
                         bounds = new rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height);
                         arg_1E9_0.DrawString(arg_1E9_1, arg_1E9_2, arg_1E9_3, bounds, Helpers.NearSF);
                         this.Invalidate();
                     }
                 }
             }
         }
         catch (Exception expr_1F9)
         {
             ProjectData.SetProjectError(expr_1F9);
             Exception ex = expr_1F9;
             Interaction.MsgBox(ex.Message, MsgBoxStyle.OkOnly, null);
             ProjectData.ClearProjectError();
         }
         base.OnDrawNode(e);
     }
 }
        private Color GetTreeNodeForeColor(TreeNode node, TreeNodeStates nodeState)
        {
            Color nodeForeColor = Color.Empty;

            if ((nodeState & TreeNodeStates.Selected) == TreeNodeStates.Selected)
            {
                nodeForeColor = Color.FromKnownColor(KnownColor.HighlightText);
            }
            else
            {
                nodeForeColor = node.ForeColor;
                if (nodeForeColor == Color.Empty)
                {
                    nodeForeColor = this.ForeColor;
                }
            }

            return nodeForeColor;
        }
示例#30
0
 /// <summary>
 /// Removes the supplied State flag
 /// </summary>
 public void RemoveStateFlag(TreeNodeStates stateFlag) 
 {
    this.State &= ~stateFlag;
 }
示例#31
0
		void DrawLine(Graphics g, LineSegment line, float yPos, float xPos, TreeNodeStates state)
		{
			int logicalX = 0;
			if (line.Words != null) {
				foreach (TextWord word in line.Words) {
					switch (word.Type) {
						case TextWordType.Space:
							xPos += spaceSize.Width;
							logicalX++;
							break;
						case TextWordType.Tab:
							xPos += spaceSize.Width * 4;
							logicalX++;
							break;
						case TextWordType.Word:
							xPos += DrawDocumentWord(g,
							                         word.Word,
							                         new PointF(xPos, yPos),
							                         word.Bold ? BoldMonospacedFont : RegularMonospacedFont,
							                         GetTextColor(state, word.Color)
							                        );
							logicalX += word.Word.Length;
							break;
					}
				}
			} else {
				DrawDocumentWord(g,
				                 bookmark.Document.GetText(line),
				                 new PointF(xPos, yPos),
				                 RegularMonospacedFont,
				                 GetTextColor(state, Color.Black)
				                );
			}
		}
示例#32
0
 /// <summary>
 /// Tests if this TreeNode has the supplied flag set.
 /// </summary>
 public Boolean HasStateFlag(TreeNodeStates stateFlag) 
 {
    return (this.State & stateFlag) == stateFlag;
 }
示例#33
0
        public void Ctor_Graphics_TreeNode_Rectangle_TreeNodeStates(Graphics graphics, TreeNode node, Rectangle bounds, TreeNodeStates state)
        {
            var e = new DrawTreeNodeEventArgs(graphics, node, bounds, state);

            Assert.Equal(graphics, e.Graphics);
            Assert.Equal(node, e.Node);
            Assert.Equal(bounds, e.Bounds);
            Assert.Equal(state, e.State);
        }
示例#34
0
 private MenuState GetMenuState(TreeNodeStates state)
 {
     MenuState ret = MenuState.Normal;
     if (((int)state & (int)TreeNodeStates.Hot) == (int)TreeNodeStates.Hot)
     {
         ret = MenuState.Hover;
     }
     else if (((int)state & (int)TreeNodeStates.Selected) == (int)TreeNodeStates.Selected)
     {
         ret = MenuState.Selected;
     }
     
     return ret;
 }
示例#35
0
 public DrawTreeNodeEventArgs(Graphics graphics, TreeNode node, Rectangle bounds, TreeNodeStates state)
 {
     throw null;
 }
	// Constructors
	public DrawTreeNodeEventArgs(System.Drawing.Graphics graphics, TreeNode node, System.Drawing.Rectangle bounds, TreeNodeStates state) {}
示例#37
0
 /// <summary>
 /// Sets the supplied State flag.
 /// </summary>
 public void SetStateFlag(TreeNodeStates stateFlag) 
 {
    this.State |= stateFlag;
 }
 internal GetNodeColorsEventArgs(TreeNode node, TreeNodeStates state, Color backColor, Color foreColor) : base(node, state)
 {
     this.BackColor = backColor;
     this.ForeColor = foreColor;
 }
 public void Ctor_Graphics_TreeNode_Rectangle_TreeNodeStates(TreeNode node, Rectangle bounds, TreeNodeStates state)
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var e = new DrawTreeNodeEventArgs(graphics, node, bounds, state);
             Assert.Equal(graphics, e.Graphics);
             Assert.Equal(node, e.Node);
             Assert.Equal(bounds, e.Bounds);
             Assert.Equal(state, e.State);
         }
 }
 public PostDrawTreeNodeEventArgs(System.Drawing.Graphics g, TreeNode node, Rectangle bounds, TreeNodeStates state) : base(node, state)
 {
     this.FGraphics = g;
     this.FBounds = bounds;
 }
 internal NodeStateEventArgs(TreeNode node, TreeNodeStates state)
 {
     this.FNode = node;
     this.FState = state;
 }