示例#1
0
        private void treeViewDrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            if ((e.State & TreeNodeStates.Selected) != 0)
            {
                e.Graphics.FillRectangle(Brushes.DodgerBlue, e.Node.Bounds);

                Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width + 2, e.Bounds.Height); //字体显示不全
                e.Graphics.DrawString(e.Node.Text, ((TreeView)sender).Font, Brushes.White, rect);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
示例#2
0
        private void tvLocalPath_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            bool hasUpdate = false;

            e.DrawDefault = false;
            if (e.Node.Tag != null)
            {
                MulticoreCoreZipFile core = (MulticoreCoreZipFile)e.Node.Tag;
                hasUpdate = core.WasUpdated;
            }
            Font font = new Font(tvLocalPath.Font, hasUpdate ? FontStyle.Bold : FontStyle.Regular);

            TextRenderer.DrawText(e.Graphics, e.Node.Text, font, new Point(e.Bounds.Left, e.Bounds.Top), tvLocalPath.ForeColor);
        }
        private void FolderTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            var  node     = e.Node;
            var  treeView = e.Node.TreeView;
            Font treeFont = node.NodeFont ?? treeView.Font;
            var  color    = treeView.SelectedNode == node ? SystemColors.HighlightText : treeView.ForeColor;

            if (treeView.SelectedNode == node)
            {
                e.Graphics.FillRectangle(treeView.Focused ? SystemBrushes.Highlight: Brushes.Gray, e.Bounds);
            }
            TextRenderer.DrawText(e.Graphics, node.Text, treeFont, e.Bounds, color,
                                  TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.VerticalCenter);
        }
        void RuleTreeViewDrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            if (e.Bounds.X < 5)
            {
                return;
            }
            int state;

            if (e.Node is CategoryTreeNode)
            {
                state = (e.Node as CategoryTreeNode).ErrorState;
            }
            else if (e.Node is RuleTreeNode)
            {
                state = (e.Node as RuleTreeNode).isError ? 1 : 0;
            }
            else
            {
                e.DrawDefault = true;
                return;
            }
            e.DrawDefault = false;
            if ((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected)
            {
                e.Graphics.DrawString(e.Node.Text, ruleTreeView.Font, SystemBrushes.HighlightText, e.Bounds.Location);
            }
            else
            {
                e.Graphics.DrawString(e.Node.Text, ruleTreeView.Font, SystemBrushes.WindowText, e.Bounds.Location);
            }
            e.Graphics.DrawLine(SystemPens.WindowFrame, ruleLabel.Width, e.Bounds.Top, ruleLabel.Width, e.Bounds.Bottom);
            if (state == 0)
            {
                // Warning
                e.Graphics.DrawIcon(SystemIcons.Warning, new Rectangle(ruleLabel.Width + 4, e.Bounds.Y, 16, 16));
                e.Graphics.DrawString(ResourceService.GetString("Global.WarningText"), ruleTreeView.Font, SystemBrushes.WindowText, ruleLabel.Width + 24, e.Bounds.Y);
            }
            else if (state == 1)
            {
                // Error
                e.Graphics.DrawIcon(SystemIcons.Error, new Rectangle(ruleLabel.Width + 4, e.Bounds.Y, 16, 16));
                e.Graphics.DrawString(ResourceService.GetString("Global.ErrorText"), ruleTreeView.Font, SystemBrushes.WindowText, ruleLabel.Width + 24, e.Bounds.Y);
            }
            else
            {
                // Mixed
                e.Graphics.DrawString(StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.WarningErrorMixed}"),
                                      ruleTreeView.Font, SystemBrushes.WindowText, ruleLabel.Width + 24, e.Bounds.Y);
            }
        }
示例#5
0
 private static void DrawRedefines(DrawTreeNodeEventArgs e, Variable variable, Font font, int nameWidth)
 {
     if (variable.Redefines != null)
     {
         TextRenderer.DrawText(e.Graphics,
                               "↺ " + variable.Redefines.VariableName,
                               font,
                               new Rectangle(e.Bounds.X + LevelWidth + nameWidth - RedefinesWidth, e.Bounds.Y, RedefinesWidth + PicWidth,
                                             e.Bounds.Height),
                               Color.DarkBlue,
                               Color.Empty,
                               TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
     }
 }
示例#6
0
        protected override void DrawForeground(DrawTreeNodeEventArgs e)
        {
            Graphics g = e.Graphics;
            float    x = e.Bounds.X;

            DrawText(e, positionText, SystemBrushes.WindowText, RegularBigFont, ref x);

            spaceSize = g.MeasureString("-", RegularBigFont, new PointF(0, 0), StringFormat.GenericTypographic);

            if (line != null && !line.IsDeleted)
            {
                DrawLine(g, line, e.Bounds.Y, x, e.State);
            }
        }
示例#7
0
        void TreeViewDrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            AbstractProjectBrowserTreeNode node = e.Node as AbstractProjectBrowserTreeNode;

            if (node != null)
            {
                Image img = node.Overlay;
                if (img != null)
                {
                    Graphics g = e.Graphics;
                    g.DrawImageUnscaled(img, e.Bounds.X - img.Width, e.Bounds.Bottom - img.Height);
                }
            }
        }
 private void tvProcessCard_DrawNode(object sender, DrawTreeNodeEventArgs e)
 {
     e.Graphics.FillRectangle(Brushes.White, e.Node.Bounds);
     if (e.State == TreeNodeStates.Selected)//选中的失去焦点的节点
     {
         Brush brush = new SolidBrush(Color.FromArgb(51, 153, 255));
         e.Graphics.FillRectangle(brush, new Rectangle(e.Node.Bounds.Left - 1, e.Node.Bounds.Top, e.Node.Bounds.Width + 4, e.Node.Bounds.Height));
         e.Graphics.DrawString(e.Node.Text, tvProcessCard.Font, Brushes.White, e.Bounds);//白字
     }
     else
     {
         e.DrawDefault = true;
     }
 }
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            int    iconOffset = e.Node.ImageIndex == e.Node.TreeView.ImageList?.Images.Count ? e.Node.TreeView.ImageList.ImageSize.Width + 3: 0;
            string nodeText = this.HtmlDecode ? e.Node.Text.HtmlDecode() : e.Node.Text;
            Font   nodeFont = e.Node.NodeFont ?? this.Font;
            SizeF  nodeTextSize = TextRenderer.MeasureText(nodeText, nodeFont);
            Color  backColor = GetItemBackColor(e), foreColor = GetItemForeColor(e);

            //Calculate the text rectangle.
            Rectangle nodeTextRect = new Rectangle(
                e.Node.Bounds.X,
                e.Node.Bounds.Y,
                (int)nodeTextSize.Width,
                e.Node.Bounds.Height);

            if (FullRowSelect)
            {
                using (SolidBrush brush = new SolidBrush(backColor))
                {
                    nodeTextRect.Offset(-iconOffset, 0);
                    e.Graphics.FillRectangle(brush, e.Bounds);
                }
            }
            else
            {
                using (SolidBrush brushClear = new SolidBrush(this.BackColor))
                    using (SolidBrush brush = new SolidBrush(backColor))
                    {
                        e.Graphics.FillRectangle(brushClear, nodeTextRect);
                        nodeTextRect.Offset(-iconOffset, 0);
                        e.Graphics.FillRectangle(brush, nodeTextRect);
                    }
            }

            // Draw the text.
            TextRenderer.DrawText(
                e.Graphics,
                nodeText,
                nodeFont,
                nodeTextRect,
                foreColor,
                backColor,
                (FullRowSelect ? TextFormatFlags.Left : TextFormatFlags.HorizontalCenter) | TextFormatFlags.NoPrefix);

            //Draw the focused rectangle.
            if ((e.State & TreeNodeStates.Focused) == TreeNodeStates.Focused && !FullRowSelect)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, nodeTextRect, foreColor, backColor);
            }
        }
示例#10
0
        internal override void DrawNode(DrawTreeNodeEventArgs e)
        {
            var optNode = (OptionNode)e.Node;

            CheckBoxRenderer.DrawCheckBox(
                e.Graphics,
                optNode.IconBounds.Location,
                _state != null ?
                _state.Value ?
                CheckBoxState.CheckedNormal :
                CheckBoxState.UncheckedNormal :
                CheckBoxState.MixedNormal
                );
        }
示例#11
0
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            if (e.Node == null)
            {
                return;
            }

            if (e.DrawDefault || e.Node.TreeView.DrawMode != TreeViewDrawMode.OwnerDrawText)
            {
                return;
            }

            var bounds = e.Bounds;

            bounds.Y += 1;
            var foreColour = e.Node.TreeView.ForeColor;
            var backColour = Brushes.Transparent;

            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                backColour = SystemBrushes.Highlight;
                foreColour = SystemColors.HighlightText;
            }

            if (e.Node is HighlightableTreeNode)
            {
                var node = e.Node as HighlightableTreeNode;

                if (e.Node == e.Node.TreeView.SelectedNode)
                {
                    if (node.Highlighted)
                    {
                        backColour = Brushes.Red;
                    }
                }
                else
                {
                    if (node.Highlighted)
                    {
                        foreColour = Color.Red;
                    }
                }
            }

            e.Graphics.FillRectangle(backColour, e.Bounds);

            var font = e.Node.NodeFont ?? e.Node.TreeView.Font;

            TextRenderer.DrawText(e.Graphics, e.Node.Text, font, bounds, foreColour, TextFormatFlags.GlyphOverhangPadding);
        }
示例#12
0
 /// <summary>
 /// 绘制颜色
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void treeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
 {
     //or  自定义颜色
     if ((e.State & TreeNodeStates.Selected) != 0)
     {
         ///刷新背景色防止字体图标重绘叠加
         e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(227, 251, 244)), e.Node.Bounds);
         //重绘字体
         Font nodeFont = e.Node.NodeFont;
         if (nodeFont == null)
         {
             nodeFont = ((TreeView)sender).Font;
         }
         e.Graphics.DrawString(e.Node.Text, nodeFont, new SolidBrush(Color.FromArgb(0, 0, 0)), Rectangle.Inflate(e.Bounds, 0, -7));
     }
     else
     {
         ///刷新背景色防止字体图标重绘叠加
         e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0, Color.Gray)), e.Node.Bounds);
         //重绘字体
         Font nodeFont = e.Node.NodeFont;
         if (nodeFont == null)
         {
             nodeFont = ((TreeView)sender).Font;
         }
         e.Graphics.DrawString(e.Node.Text, nodeFont, new SolidBrush(Color.FromArgb(0, 0, 0)), Rectangle.Inflate(e.Bounds, 0, -7));
     }
     //节点头图标绘制
     if (e.Node.IsExpanded)
     {
         e.Graphics.DrawImage(Resources.open, e.Node.Bounds.X - 46, e.Node.Bounds.Y + 7);
     }
     else if (e.Node.IsExpanded == false && e.Node.Nodes.Count > 0)
     {
         e.Graphics.DrawImage(Resources.close, e.Node.Bounds.X - 46, e.Node.Bounds.Y + 7);
     }
     //失焦之后选中状态不消失
     if ((e.State & TreeNodeStates.Focused) != 0)
     {
         using (Pen focusPen = new Pen(Color.Black))
         {
             focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
             Rectangle focusBounds = e.Node.Bounds;
             focusBounds.Size = new Size(focusBounds.Width - 1,
                                         focusBounds.Height - 1);
             e.Graphics.DrawRectangle(focusPen, focusBounds);
         }
     }
 }
示例#13
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.TreeView.DrawNode"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.DrawTreeNodeEventArgs"></see> that contains the event data.</param>
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            base.OnDrawNode(e);

            ExtendedTreeNode customTreeNode = e.Node as ExtendedTreeNode;
            Font             nodeFont       = (e.Node.NodeFont != null) ? e.Node.NodeFont : this.Font;
            Color            nodeColor      = (((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected) && e.Node.TreeView.Focused) ? SystemColors.HighlightText : ((e.Node.ForeColor != Color.Empty) ? e.Node.ForeColor : e.Node.TreeView.ForeColor);

            bool  showAsLink = (customTreeNode != null && customTreeNode.ShowAsLink);
            Brush textBrush  = SystemBrushes.MenuText;

            if (showAsLink)
            {
                nodeFont  = new Font(nodeFont, FontStyle.Underline);
                textBrush = Brushes.Navy;
                nodeColor = Color.Navy;
            }

            // Draw the background and node text for a selected node.
            if ((e.State & TreeNodeStates.Selected) != 0 || (e.State & TreeNodeStates.Focused) != 0)
            {
                Rectangle hoverRectangle = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                e.Graphics.FillRectangle(SystemBrushes.Highlight, hoverRectangle);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, nodeFont, e.Bounds, SystemColors.HighlightText, TextFormatFlags.VerticalCenter);
            }
            // Use the default background and node text.
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, NodeBounds(e.Node));
                TextRenderer.DrawText(e.Graphics, e.Node.Text, nodeFont, e.Bounds, nodeColor, TextFormatFlags.VerticalCenter);
            }

            Rectangle closeButtonRectangle = new Rectangle(e.Bounds.X + e.Bounds.Width, e.Bounds.Y, this.Bounds.Width - (e.Bounds.X + e.Bounds.Width) - verticalScrollPadding, e.Bounds.Height);

            e.Graphics.FillRectangle(SystemBrushes.Window, closeButtonRectangle);

            if (customTreeNode != null && customTreeNode.ShowCloseButton)
            {
                // Fix for more than 96dpi screen resolutions.
                if (SystemFonts.IconTitleFont.Size > closeButtonFont.Size)
                {
                    closeButtonFont = SystemFonts.IconTitleFont;
                }

                TextRenderer.DrawText(e.Graphics, "x", closeButtonFont, closeButtonRectangle, SystemColors.WindowText, TextFormatFlags.Right);
            }

            this.ResumeLayout();
        }
示例#14
0
        private void treeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            if (!e.Node.IsVisible)
            {
                return;
            }

            Brush bg, fg;

            if (e.Node.IsSelected ||
                e.State == TreeNodeStates.Focused ||
                e.State == TreeNodeStates.Hot ||
                e.State == TreeNodeStates.Marked ||
                e.State == TreeNodeStates.Selected ||
                e.State == TreeNodeStates.Checked ||
                e.State == TreeNodeStates.Indeterminate ||
                e.State == TreeNodeStates.ShowKeyboardCues)
            {
                bg = SystemBrushes.Highlight;
                fg = Brushes.White;
            }
            else
            {
                bg = Brushes.White;
                fg = Brushes.Black;
            }
            var newBounds = e.Bounds;

            newBounds.Width = e.Node.TreeView.ClientRectangle.Width;
            e.Graphics.FillRectangle(bg, newBounds);

            var   texts    = e.Node.Text.Split(TreeListViewControl.ColumnSeperator);
            int   column   = 0;
            float colX     = 0;
            float colWidth = 0;

            foreach (var text in texts)
            {
                try
                {
                    float extraSpacing = ((column == 0) ? (float)(e.Bounds.X - e.Node.TreeView.Location.X) : 0f);
                    colWidth = (column == texts.Length - 1 ? e.Node.TreeView.Width : ColumnProvider.Columns[column].Width);
                    e.Graphics.DrawString(text, e.Node.TreeView.Font, fg, new RectangleF(colX + extraSpacing, e.Bounds.Y + 1, colWidth - extraSpacing, e.Bounds.Height - 2));
                    colX += ColumnProvider.Columns[column].Width;
                    column++;
                }
                catch { }
            }
        }
        private void tvMapEntries_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            var model = e.Node.Tag as DocumentEntry;

            if (model == null)
            {
                e.DrawDefault = true;
                return;
            }

            Brush color;

            switch (model.Type)
            {
            case DocumentMapType.TimeGAPStart:
            case DocumentMapType.TimeGAPEnd:
                color = Brushes.White;
                break;

            case DocumentMapType.Network:
                color = Brushes.Yellow;
                break;

            case DocumentMapType.Value:
                color = Brushes.Red;
                break;

            case DocumentMapType.Event:
                color = Brushes.Blue;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            int width = 9;

            e.Graphics.FillRectangle(Brushes.Black, Rectangle.Inflate(new Rectangle(0, e.Node.Bounds.Y, width, e.Node.Bounds.Height), -2, -2));
            e.Graphics.FillRectangle(color, Rectangle.Inflate(new Rectangle(0, e.Node.Bounds.Y, width, e.Node.Bounds.Height), -3, -3));

            if (model.HighlightColor != "" && model.HighlightColor != "Transparent")
            {
                width = Width;
                e.Graphics.FillRectangle(Brushes.Black, Rectangle.Inflate(new Rectangle(100, e.Node.Bounds.Y, width, e.Node.Bounds.Height), -2, -2));
                e.Graphics.FillRectangle(new SolidBrush(Color.FromName(model.HighlightColor)), Rectangle.Inflate(new Rectangle(100, e.Node.Bounds.Y, width, e.Node.Bounds.Height), -3, -3));
            }


            e.DrawDefault = true;
        }
 void m_HostTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
 {
     if (this.Nodes == null || this.Nodes.Count <= 0)
     {
         return;
     }
     //
     WFNew.BaseItemState eBaseItemState = GISShare.Controls.WinForm.WFNew.BaseItemState.eNormal;
     if (this.AutoMouseMoveSeleced && e.Node == this.GetNodeAt(this.PointToClient(Form.MousePosition)))
     {
         eBaseItemState = this.m_IsMouseDown || e.Node.IsEditing ? WFNew.BaseItemState.ePressed : GISShare.Controls.WinForm.WFNew.BaseItemState.eHot;
     }
     //
     this.DrawItem_TreeNodeItem(e, eBaseItemState);
 }
示例#17
0
 public static void fillRectangleBackColor(DrawTreeNodeEventArgs e)
 {
     if (e.Node.Level == 0)
     {
         fillRectangle(e, 4, 282, Constantes.blue);
     }
     else if (e.Node.Level == 1)
     {
         fillRectangle(e, 22, 282, Constantes.blue);
     }
     else if (e.Node.Level == 2)
     {
         fillRectangle(e, 41, 282, Constantes.blue);
     }
 }
示例#18
0
        private void TreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            var treeview = sender as TreeView;
            var brush    = Brushes.Black;

            if (e.Node.ForeColor == Color.Blue)
            {
                var location = e.Node.Bounds.Location;
                location.Offset(-11, 2);
                var size = new Size(9, 9);
                brush = Brushes.Black;
                e.Graphics.FillRectangle(brush, new Rectangle(location, size));
            }
            e.Graphics.DrawString(e.Node.Text, treeview.Font, brush, e.Bounds.Left, e.Bounds.Top);
        }
示例#19
0
 private void RosterTree_DrawNode(object sender, DrawTreeNodeEventArgs e)
 {
     if (e.Node is GroupNode)
     {
         DrawGroup(e);
     }
     else if (e.Node is ItemNode)
     {
         DrawItem(e);
     }
     else
     {
         e.DrawDefault = true; // or assert(false)
     }
 }
示例#20
0
        private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            if (e.Bounds.Y < 0 || e.Bounds.X == -1)
            {
                return;
            }

            var tv = sender as TreeView;

            new SolidBrush(Color.FromArgb(e.Bounds.Y % 200, e.Bounds.Y % 200, e.Bounds.Y % 200));

            e.Graphics.DrawString(e.Node.Text, tv.Font, new SolidBrush(this.ForeColor)
                                  , e.Bounds.X,
                                  e.Bounds.Y);
        }
示例#21
0
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            // here nothing is drawn. Only collect Indeterminated Nodes, to draw them later (in WndProc())
            // because drawing Treenodes properly (Text, Icon(s) Focus, Selection...) is very complicated
            if (CheckBoxes && e.Node.StateImageIndex == 1)
            {
                indeterminateds.Add(e.Node);
            }
            e.DrawDefault = true;
            //e.Node.NodeFont = DrawBoldSelectedNode && e.Node.IsSelected
            //                      ? new Font(Font, FontStyle.Bold)
            //                      : new Font(Font, FontStyle.Regular);

            base.OnDrawNode(e);
        }
示例#22
0
 void tree_DrawNode(object sender, DrawTreeNodeEventArgs e)
 {
     if (e.Node.Level == 0)
     {
         HideCheckBox(e.Node);
         e.DrawDefault = true;
     }
     else
     {
         e.Graphics.FillRectangle(new SolidBrush(Color.White),
                                  new Rectangle(e.Bounds.Left + 1, e.Bounds.Top, this.ClientSize.Width - e.Bounds.Left, e.Bounds.Height));
         e.Graphics.DrawString(e.Node.Text, e.Node.TreeView.Font,
                               Brushes.Black, e.Node.Bounds.X, e.Node.Bounds.Y);
     }
 }
示例#23
0
        // Create a Font object for the node tags.
        //TODO: Have code that isn't copied from MSDN...
        private static void myTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            // Draw the background and node text for a selected node.
            if ((e.State & TreeNodeStates.Selected) != 0)
            {
                Rectangle rect = NodeBounds(e.Node);
                rect.Width += 5;
                e.Graphics.FillRectangle(Brushes.Gray, rect);

                Font nodeFont = e.Node.TreeView.Font;
                //if (nodeFont == null) nodeFont = ((TreeView)sender).Font;

                Rectangle bounds = NodeBounds(e.Node);
                bounds.Width += 10;
                e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, bounds);

                e.DrawDefault = false;
            }

            // Use the default background and node text.
            else
            {
                e.DrawDefault = true;
            }

            /*
             * // If a node tag is present, draw its string representation
             * // to the right of the label text.
             * if (e.Node.Tag != null)
             * {
             *  e.Graphics.DrawString(e.Node.Tag.ToString(), e.Node.TreeView.Font,
             *      Brushes.Yellow, e.Bounds.Right + 2, e.Bounds.Top);
             * }
             *
             * // If the node has focus, draw the focus rectangle large, making
             * // it large enough to include the text of the node tag, if present.
             * if ((e.State & TreeNodeStates.Focused) != 0)
             * {
             *  using (Pen focusPen = new Pen(Color.Black))
             *  {
             *      focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
             *      Rectangle focusBounds = NodeBounds(e.Node);
             *      focusBounds.Size = new Size(focusBounds.Width - 1,
             *      focusBounds.Height - 1);
             *      e.Graphics.DrawRectangle(focusPen, focusBounds);
             *  }
             * }*/
        }
        void OnTreeDrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            var fillBrush   = PluginBase.MainForm.GetThemeColor("TreeView.BackColor", SystemColors.Window);
            var textBrush   = PluginBase.MainForm.GetThemeColor("TreeView.ForeColor", SystemColors.WindowText);
            var moduleBrush = Brushes.DimGray;

            if ((e.State & TreeNodeStates.Selected) > 0)
            {
                fillBrush   = PluginBase.MainForm.GetThemeColor("TreeView.Highlight", SystemColors.Highlight);
                textBrush   = PluginBase.MainForm.GetThemeColor("TreeView.HighlightText", SystemColors.HighlightText);
                moduleBrush = Brushes.LightGray;
            }
            var   bounds    = e.Bounds;
            var   text      = e.Node.Text;
            float x         = text == Settings.ItemSpacer ? 0 : bounds.X;
            var   itemWidth = tree.Width - x;
            var   graphics  = e.Graphics;

            graphics.FillRectangle(new SolidBrush(fillBrush), x, bounds.Y, itemWidth, tree.ItemHeight);
            var font = tree.Font;

            graphics.DrawString(text, font, new SolidBrush(textBrush), x, bounds.Top, StringFormat.GenericDefault);
            var node = e.Node as ClassNode;

            if (node == null)
            {
                return;
            }
            if (!string.IsNullOrEmpty(node.In))
            {
                x += graphics.MeasureString(text, font).Width;
                graphics.DrawString($"({node.In})", font, moduleBrush, x, bounds.Top, StringFormat.GenericDefault);
            }
            x = itemWidth;
            var module = node.Module;

            if (!string.IsNullOrEmpty(module))
            {
                x -= graphics.MeasureString(module, font).Width;
                graphics.DrawString(module, font, moduleBrush, x, bounds.Y, StringFormat.GenericDefault);
            }
            if (node.IsPrivate)
            {
                font = new Font(font, FontStyle.Underline);
                x   -= graphics.MeasureString("(private)", font).Width;
                graphics.DrawString("(private)", font, moduleBrush, x, bounds.Y, StringFormat.GenericTypographic);
            }
        }
示例#25
0
        /// <summary>
        /// Draws a group header
        /// </summary>
        private void drawRootItem(DrawTreeNodeEventArgs e)
        {
            Rectangle nodeTextRect = e.Bounds;

            nodeTextRect.Y      += 1;
            nodeTextRect.Width  -= 1;
            nodeTextRect.Height -= 3;

            if ((e.State & TreeNodeStates.Marked) == TreeNodeStates.Marked ||
                (e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected)
            {
                using (Brush selBrush = new SolidBrush(Color.FromArgb(225, 230, 232)))
                {
                    e.Graphics.FillRectangle(selBrush, nodeTextRect);
                }

                using (Pen outerPen = new Pen(Color.FromArgb(49, 106, 197)))
                {
                    e.Graphics.DrawRectangle(outerPen, nodeTextRect);
                }
            }
            else
            {
                using (LinearGradientBrush lgBrush = new LinearGradientBrush(
                           e.Bounds, Color.FromArgb(221, 220, 203), Color.FromArgb(196, 193, 176), LinearGradientMode.Vertical))
                {
                    e.Graphics.FillRectangle(lgBrush, nodeTextRect);
                }

                using (Pen linePen = new Pen(this.BackColor))
                {
                    e.Graphics.DrawLine(linePen, 0, nodeTextRect.Bottom - 2, nodeTextRect.Width, nodeTextRect.Bottom - 2);
                }
            }

            if (e.Node.IsExpanded == true)
            {
                e.Graphics.DrawImage(Properties.Resources.expanded, new Point(nodeTextRect.Left + 3, nodeTextRect.Top + 4));
            }
            else
            {
                e.Graphics.DrawImage(Properties.Resources.collapsed, new Point(nodeTextRect.Left + 3, nodeTextRect.Top + 4));
            }

            nodeTextRect.Offset(16, 2);

            e.Graphics.DrawString(e.Node.Text, this.mGroupHeaderFont, SystemBrushes.ControlText, nodeTextRect.Location);
        }
示例#26
0
        private void ModelsTree_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            Brush brush = null;

            foreach (TreeNode tn in ModelsTree.Nodes)
            {
                DisableButtonTreeNode(tn);
            }
            if (e.Node is ButtonTreeNode)
            {
                ButtonTreeNode btn  = e.Node as ButtonTreeNode;
                Rectangle      rect = new Rectangle(
                    ModelsTree.ClientRectangle.Width - 210,
                    e.Bounds.Y,
                    200,
                    ModelsTree.ItemHeight - 1);
                btn.ButtonControl.Bounds = rect;
                //color
            }
            if (e.Node is IValidable)
            {
                if (!((IValidable)e.Node).IsValid)
                {
                    brush = Brushes.Red;
                }
                else
                {
                    brush = Brushes.Green;
                }
            }
            else
            {
                if ((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected)
                {
                    brush = Brushes.White;
                }
                else
                {
                    brush = Brushes.Black;
                }
            }
            int x = (ModelsTree.ItemHeight - (int)e.Graphics.MeasureString(e.Node.Text, ModelsTree.Font).Height) / 2;

            e.Graphics.DrawString(e.Node.Text, ModelsTree.Font,
                                  brush, e.Bounds.Left, e.Bounds.Top + x);
            e.DrawDefault = false;
            ValidateProject();
        }
示例#27
0
        private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            SEItem item = (SEItem)e.Node.Tag;

            Brush b = Brushes.Black;

            if (item.isConsole)
            {
                b = Brushes.Blue;
            }

            if (!item.Enabled)
            {
                b = Brushes.Gray;
            }
            else
            {
                TreeNode parent = e.Node.Parent;
                while (parent != null)
                {
                    if (!parent.Checked)
                    {
                        b = Brushes.Gray;
                        break;
                    }
                    parent = parent.Parent;
                }
            }

            Rectangle frame = e.Bounds;

            if ((e.State & TreeNodeStates.Selected) != 0)
            {
                frame.Width = (int)e.Graphics.MeasureString(item.ToString(), treeView1.Font).Width;
                e.Graphics.FillRectangle(TreeViewBackBrush, frame);
                frame.Inflate(-1, -1);
                e.Graphics.DrawRectangle(Pens.Red, frame);
            }

            if (item.isSeparator)
            {
                e.Graphics.DrawLine(Pens.Black, frame.Left + 4, frame.Top + frame.Height / 2, frame.Right - 4, frame.Top + frame.Height / 2);
            }
            else
            {
                e.Graphics.DrawString(item.ToString(), treeView1.Font, b, e.Bounds.Left, e.Bounds.Top + 2);
            }
        }
        private void DrawPlusMinus(DrawTreeNodeEventArgs e)
        {
            if (e.Node.Nodes.Count == 0)
            {
                return;
            }
            int   indent   = (e.Node.Level * this.Indent) + this.Margin.Size.Width;
            int   iconLeft = indent + this.Indent;
            Image img      = Properties.Resources.plus;

            if (e.Node.IsExpanded)
            {
                img = Properties.Resources.minus;
            }
            e.Graphics.DrawImage(img, iconLeft - img.Width - 2, (e.Bounds.Y + e.Bounds.Height / 2) - (img.Height / 2) - 1);
        }
        private void DrawNodeLineHorizontal(DrawTreeNodeEventArgs e)
        {
            if (IsRootNode(e.Node))
            {
                return;
            }
            if (!ShowLines)
            {
                return;
            }
            Pen linePen = new Pen(Color.Black);
            int xLoc    = (e.Node.Level * this.Indent) + (Properties.Resources.minus.Width / 2);
            int midY    = (e.Bounds.Top + e.Bounds.Bottom) / 2 - 1;

            e.Graphics.DrawLine(linePen, xLoc, midY, xLoc + 7, midY);
        }
示例#30
0
        private void tvReports_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            SolidBrush selectedTreeBrush = new SolidBrush(e.Node.TreeView.BackColor);

            if (e.Node == e.Node.TreeView.SelectedNode)
            {
                e.Graphics.FillRectangle(selectedTreeBrush, e.Bounds);
                ControlPaint.DrawBorder(e.Graphics, e.Bounds, Color.Black, ButtonBorderStyle.Dashed);
                //DrawFocusRectangle(e.Graphics, e.Bounds, e.Node.ForeColor, SystemColors.Highlight);
                TextRenderer.DrawText(e.Graphics, e.Node.Text, e.Node.TreeView.Font, e.Bounds, e.Node.ForeColor, TextFormatFlags.GlyphOverhangPadding);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
    private void OnProjectTree_DrawNode(object sender, DrawTreeNodeEventArgs e)
    {
        if (e.Node == SelectedNode)
        {
            e.DrawDefault = true;
        }
        else
        {
            foreach (CustomNode item in customNodes)
            {
                if (Regex.IsMatch(e.Node.Text, item.pattern, RegexOptions.IgnoreCase))
                {
                    Match match = Regex.Match(e.Node.Text, item.pattern, RegexOptions.IgnoreCase);

                    int left = 0;
                    for (int i = 1; i < match.Groups.Count; i++)
                    {

                        int width = TextRenderer.MeasureText(match.Groups[i].Value, Font).Width;
                        Rectangle bounds = new Rectangle();
                        bounds = e.Bounds;
                        bounds.X += left;
                        bounds.Width = width;
                        left += width - 5;
                        TextRenderer.DrawText(e.Graphics, match.Groups[i].Value, Font, bounds, item.color[i - 1]);
                    }
                }
            }

            Brush brush = new SolidBrush(Color.Crimson);
        }
    }
 protected override void OnDrawNode(DrawTreeNodeEventArgs e)
 {
     e.Graphics.DrawString (e.Node.Text.Split (';') [0], new Font (Font.SystemFontName, 13),
         new SolidBrush (Color.Black), e.Bounds.X, e.Bounds.Y);
     e.Graphics.DrawString (e.Node.Text.Split (';') [1], new Font (Font.SystemFontName, 9),
         new SolidBrush (Color.Black), e.Bounds.X + 10, e.Bounds.Y + 15);
 }