当前位置: 首页>>代码示例>>C#>>正文


C# Forms.DrawTreeNodeEventArgs类代码示例

本文整理汇总了C#中System.Windows.Forms.DrawTreeNodeEventArgs的典型用法代码示例。如果您正苦于以下问题:C# DrawTreeNodeEventArgs类的具体用法?C# DrawTreeNodeEventArgs怎么用?C# DrawTreeNodeEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DrawTreeNodeEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DrawTreeNodeEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnDrawNode

        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            if (e.Node.IsVisible && null != e.Node.Tag)
            {
                if (e.Node.Tag is AttributeData)
                {
                    e.DrawDefault = false;
                    var data = (AttributeData) e.Node.Tag;

                    e.Graphics.DrawString(data.Name, Font, _grayBrush, e.Bounds.X, e.Bounds.Y);
                    var nameSize = e.Graphics.MeasureString(data.Name, Font);

                    e.Graphics.DrawString(data.Value, Font, _blackPen.Brush, e.Bounds.X + nameSize.Width + 5, e.Bounds.Y);
                }

                else if (e.Node.Tag is PluginElementData)
                {
                    e.DrawDefault = false;
                    var data = (PluginElementData) e.Node.Tag;

                    Bitmap icon;

                    if ((icon = GetIcon(data.IconPath)) != null)
                        e.Graphics.DrawImage(icon, e.Bounds.X, e.Bounds.Y, 16, 16);

                    e.Graphics.DrawString(data.Name, Font, _blackPen.Brush, e.Bounds.X + 20, e.Bounds.Y);
                }
            }
            else e.DrawDefault = true;

            base.OnDrawNode(e);
        }
开发者ID:beyastard,项目名称:XTools,代码行数:32,代码来源:PluginStoreViewer.cs

示例2: OnDrawNode

        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);
        }
开发者ID:devfinity-fx,项目名称:cpms_z,代码行数:25,代码来源:SwxTreeView.cs

示例3: State_DrawNode

        void State_DrawNode (object sender, DrawTreeNodeEventArgs e) {
            if (!(e.Node.Tag is TreeNode_StateTag)) {
                return;
            }
            e.DrawDefault = false;
            TreeNode_StateTag state_tag = (TreeNode_StateTag)e.Node.Tag;
            State state = state_tag.state;
            string[] texts = e.Node.Text.Split();
            using (Brush black = new SolidBrush(Color.Black)) {
                using (Brush blue = new SolidBrush(Color.Blue)) {
                    using (Brush red = new SolidBrush(Color.Red)) {
                        using (Brush yellow = new SolidBrush(Color.DarkOrange)) {
                            Brush[] brushes = new Brush[] { 
                                    blue, red, yellow, red, blue,
                                    blue, red, yellow, red, blue
                                };
                            SizeF offset = new SizeF();

                            string panels = texts[0];
                            for (int i = 0; i < panels.Length; ++i) {
                                String p = "" + panels[i];
                                e.Graphics.DrawString(p, tree.Font, brushes[i], e.Bounds.Left + (int)offset.Width, e.Bounds.Top);
                                offset += e.Graphics.MeasureString(p, tree.Font);
                            }
                            for (int i = 1; i < texts.Length; ++i) {
                                string txt = texts[i];
                                e.Graphics.DrawString(txt, tree.Font, black, e.Bounds.Left + (int)offset.Width, e.Bounds.Top);
                                offset += e.Graphics.MeasureString(txt, tree.Font);
                            }
                        }
                    }
                }
            }
        }
开发者ID:baguio,项目名称:SSC-AI,代码行数:34,代码来源:MainForm_OnSolved_TreeUpdater.cs

示例4: OnDrawNode

        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            base.OnDrawNode(e);

            //节点背景绘制
            if (e.Node.IsSelected)
            {
                e.Graphics.DrawImage(Resources.tree_Selected, e.Bounds);
            }
            else if ((e.State & TreeNodeStates.Hot) != 0)//|| currentMouseMoveNode == e.Node)
            {
                e.Graphics.DrawImage(Resources.tree_Hover, e.Bounds);
            }
            else
            {
                e.Graphics.FillRectangle(Brushes.White, e.Bounds);
            }

            //节点头图标绘制
            if (e.Node.IsExpanded)
            {
                e.Graphics.DrawImage(Resources.tree_NodeExpend, e.Node.Bounds.X - 12, e.Node.Bounds.Y + 9);
            }
            else if (e.Node.IsExpanded == false && e.Node.Nodes.Count > 0)
            {
                e.Graphics.DrawImage(Resources.tree_NodeCollaps, e.Node.Bounds.X - 12, e.Node.Bounds.Y + 9);
            }

            //文本绘制
            using (Font foreFont = new Font(this.Font, FontStyle.Regular))
            using (Brush drawTextBrush = new SolidBrush(drawTextColor))
            {
                e.Graphics.DrawString(e.Node.Text, foreFont, drawTextBrush, e.Node.Bounds.Left + 5, e.Node.Bounds.Top + 1);
            }
        }
开发者ID:Bobwjy,项目名称:SignPressClient,代码行数:35,代码来源:BaseTreeView.cs

示例5: OnDrawNode

		protected override void OnDrawNode(DrawTreeNodeEventArgs e)
		{
			try
			{
				Rectangle Bounds = new Rectangle(e.Bounds.Location.X, e.Bounds.Location.Y, e.Bounds.Width, e.Bounds.Height);
				//e.Node.Nodes.Item.
				switch (State)
				{
					case TreeNodeStates.Default:
						e.Graphics.FillRectangle(Brushes.Red, Bounds);
						e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.LimeGreen, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), Helpers.NearSF);
						Invalidate();
						break;
					case TreeNodeStates.Checked:
						e.Graphics.FillRectangle(Brushes.Green, Bounds);
						e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.Black, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), Helpers.NearSF);
						Invalidate();
						break;
					case TreeNodeStates.Selected:
						e.Graphics.FillRectangle(Brushes.Green, Bounds);
						e.Graphics.DrawString(e.Node.Text, new Font("Segoe UI", 8), Brushes.Black, new Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), Helpers.NearSF);
						Invalidate();
						break;
				}

			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}

			base.OnDrawNode(e);
		}
开发者ID:CookieYT,项目名称:FlatUI,代码行数:33,代码来源:FlatTreeView.cs

示例6: DrawDocTreeNodeText

		// This method is here because by default TreeView try to display icon in every case
		// i.e. even when we have no icon to show it's going to put a blank space. So here we 
		// detect when that happen and "shift" the text back in the right position 16px to the left
		internal static void DrawDocTreeNodeText (object sender, DrawTreeNodeEventArgs e)
		{
			if (!string.IsNullOrEmpty (e.Node.ImageKey)) {
				e.DrawDefault = true;
				return;
			}
			// Retrieve the node font. If the node font has not been set,
            // use the TreeView font.
            Font nodeFont = e.Node.NodeFont;
            if (nodeFont == null)
				nodeFont = ((TreeView)sender).Font;

            // Draw the node text.
			var clip = new Rectangle (e.Bounds.X - 16, e.Bounds.Y, e.Bounds.Width + 16, e.Bounds.Height);
			e.Graphics.SetClip (clip);
			if ((e.State & TreeNodeStates.Selected) != 0) {
				e.Graphics.Clear (SystemColors.Highlight);
				using (var pen = new Pen (Color.Black)) {
					pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
					e.Graphics.DrawRectangle (pen, new Rectangle (clip.Location, new Size (clip.Width - 1, clip.Height - 1)));
				}
				e.Graphics.DrawString (e.Node.Text, nodeFont, SystemBrushes.HighlightText, clip);
			} else {
				e.Graphics.Clear (Color.White);
				e.Graphics.DrawString (e.Node.Text, nodeFont, Brushes.Black, clip);
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:30,代码来源:CustomDrawing.cs

示例7: DrawSearchResultNodeText

		internal static void DrawSearchResultNodeText (object sender, DrawTreeNodeEventArgs e)
		{
            Font nodeFont = e.Node.NodeFont;
            if (nodeFont == null)
				nodeFont = ((TreeView)sender).Font;
			var clip = new Rectangle (0, e.Bounds.Y, e.Node.TreeView.Width, e.Bounds.Height);
			e.Graphics.SetClip (clip);
			var selectedStates = TreeNodeStates.Marked | TreeNodeStates.Selected | TreeNodeStates.Focused;

			if (e.Node.Tag == null) {
				nodeFont = new Font (nodeFont.FontFamily, nodeFont.Size - 2);
				// We use a TabRenderer to get the nice system gradient
				e.Graphics.Clear (Color.White);
				clip = new Rectangle (1, e.Bounds.Y + 1, e.Node.TreeView.ClientRectangle.Width - 3, e.Bounds.Height - 3);
				// If we're using the classic theme, then we can't use TabRender. Fall back to a simpler view.
				if (TabRenderer.IsSupported) {
					TabRenderer.DrawTabItem(e.Graphics, clip, e.Node.Text, nodeFont, System.Windows.Forms.VisualStyles.TabItemState.Normal);
				} else {
					e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, clip);
					// The fallback rendering has more empty space than the tab rendering. Take advantage of it.
					var fallbackNodeFont = new Font(nodeFont.FontFamily, nodeFont.Size + 2);
					e.Graphics.DrawString(e.Node.Text, fallbackNodeFont, SystemBrushes.ActiveCaptionText, clip.X, clip.Y);
				}
				using (var pen = new Pen (Color.Black, 1.0f))
					e.Graphics.DrawLine (pen, new Point (clip.Left, clip.Bottom), new Point (clip.Right - 1, clip.Bottom));
			} else {
				e.Graphics.Clear ((e.State & selectedStates) != 0 ? SystemColors.Highlight : SystemColors.ControlLightLight);
				e.Graphics.DrawString (e.Node.Text, nodeFont, (e.State & selectedStates) != 0 ? SystemBrushes.HighlightText : SystemBrushes.ControlText, new PointF (e.Bounds.X, e.Bounds.Y + 2));
			}
		}
开发者ID:mono,项目名称:mono-tools,代码行数:30,代码来源:CustomDrawing.cs

示例8: OnDrawNode

		private void OnDrawNode(object sender, DrawTreeNodeEventArgs e)
		{
			if ((e.State & TreeNodeStates.Selected) != 0)
			{

				var backColor = ((e.State & TreeNodeStates.Focused) != 0) ? Configuration.DefaultFocusedColor : BackColor ;

				e.Graphics.FillRectangle(new SolidBrush(backColor), NodeBounds(e.Node));

				// Retrieve the node font. If the node font has not been set,
				// use the TreeView font.
				var nodeFont = e.Node.NodeFont ?? ((TreeView) sender).Font;

				// Draw the node text.
				e.Graphics.DrawString(e.Node.Text, nodeFont, new SolidBrush(ForeColor),
					Rectangle.Inflate(e.Bounds, 2, 0));
			}
			else
			{
				e.DrawDefault = true;
			}

//			if ((e.State & TreeNodeStates.Focused) == 0) return;
//
//			using(var focusBrush = new SolidBrush(Configuration.DefaultFocusedColor))
//			{
//				focusBrush.Color = Color.FromArgb(100, focusBrush.Color.R, focusBrush.Color.G, focusBrush.Color.B);
//				var focusBounds = NodeBounds(e.Node);
//				focusBounds.Size = new Size(focusBounds.Width - 1,
//					focusBounds.Height - 1);
////				e.Graphics.DrawRectangle(focusPen, focusBounds);
//				e.Graphics.FillRectangle(focusBrush,focusBounds);
//			}
		}
开发者ID:rokn,项目名称:REAL-Editor,代码行数:34,代码来源:ProjectExplorer.cs

示例9: OnDrawNode

 /// <summary>
 /// DrawNodeイベントを発生させます。
 /// </summary>
 /// <param name="e">イベントデータを格納している<see cref="System.Windows.Forms.DrawTreeNodeEventArgs"/>。</param>
 protected override void OnDrawNode(DrawTreeNodeEventArgs e)
 {
     if (!MultiLineLabel)
         base.OnDrawNode(e);
     else
         TextRenderer.DrawText(e.Graphics, e.Node.Text, this.Font, e.Bounds, this.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
 }
开发者ID:Ricordanza,项目名称:Ricordanza.kernel,代码行数:11,代码来源:CoreTreeView.cs

示例10: OnDrawNode

 protected override void OnDrawNode(DrawTreeNodeEventArgs e)
 {
     e.Graphics.DrawString (e.Node.Text.Split (';') [0], new Font ("Microsoft Sans Serif", 13),
         new SolidBrush (Color.Black), e.Bounds.X, e.Bounds.Y);
     e.Graphics.DrawString (e.Node.Text.Split (';') [1], new Font ("Microsoft Sans Serif", 9),
         new SolidBrush (Color.Black), e.Bounds.X + 10, e.Bounds.Y+15);
     base.OnDrawNode (e);
 }
开发者ID:kozze89,项目名称:SparkleShare-GUI-Experiments,代码行数:8,代码来源:TreeView.cs

示例11: OnDrawNode

 protected override void OnDrawNode(DrawTreeNodeEventArgs e)
 {
     if ((OnDrawNodeField != null) && (OnDrawNodeField.GetValue(this) == null))
     {
         e.DrawDefault = true;
     }
     base.OnDrawNode(e);
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:8,代码来源:TreeViewEx.cs

示例12: OnDrawNode

        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            TreeNodeStates treeState = e.State;
            Font treeFont = e.Node.NodeFont ?? e.Node.TreeView.Font;
            Font hotFont = 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, hotFont, 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);
                }
            }
        }
开发者ID:nathanlea,项目名称:SecureCameraCaptureClient,代码行数:57,代码来源:CustomTreeView.cs

示例13: treeView1_DrawNode

        private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            e.DrawDefault = true;

            Rectangle rect = e.Bounds;

            if ((e.State & TreeNodeStates.Selected) != 0)
            {
                if ((e.State & TreeNodeStates.Focused) != 0)
                    e.Graphics.FillRectangle(SystemBrushes.Highlight, rect);
                else
                    e.Graphics.FillRectangle(SystemBrushes.Control, rect);
            }
            else
                e.Graphics.FillRectangle(Brushes.White, rect);

            e.Graphics.DrawRectangle(SystemPens.Control, rect);

            for (int intColumn = 1; intColumn < this.listView1.Columns.Count; intColumn++)
            {
                rect.Offset(this.listView1.Columns[intColumn - 1].Width, 0);
                rect.Width = this.listView1.Columns[intColumn].Width;

                e.Graphics.DrawRectangle(SystemPens.Control, rect);

                string strColumnText;
                string[] list = e.Node.Tag as string[];
                if (list != null && intColumn<=list.Length)
                    strColumnText = list[intColumn - 1];
                else
                    strColumnText = e.Node.Text; // dummy

                TextFormatFlags flags = TextFormatFlags.EndEllipsis;
                switch(this.listView1.Columns[intColumn].TextAlign)
                {
                    case HorizontalAlignment.Center:
                        flags |= TextFormatFlags.HorizontalCenter;
                        break;
                    case HorizontalAlignment.Left:
                        flags |= TextFormatFlags.Left;
                        break;
                    case HorizontalAlignment.Right:
                        flags |= TextFormatFlags.Right;
                        break;
                    default:
                        break;
                }

                rect.Y++;
                if ((e.State & TreeNodeStates.Selected) != 0 &&
                    (e.State & TreeNodeStates.Focused) != 0)
                    TextRenderer.DrawText(e.Graphics, strColumnText, e.Node.NodeFont, rect, SystemColors.HighlightText, flags);
                else
                    TextRenderer.DrawText(e.Graphics, strColumnText, e.Node.NodeFont, rect, e.Node.ForeColor, e.Node.BackColor, flags);
                rect.Y--;
            }
        }
开发者ID:rrajaguk,项目名称:ApduParser,代码行数:57,代码来源:TreeViewColumns.cs

示例14: MeasureItemWidth

		protected override int MeasureItemWidth(DrawTreeNodeEventArgs e)
		{
			Graphics g = e.Graphics;
			int x = MeasureTextWidth(g, positionText, BoldMonospacedFont);
//			if (line != null && !line.IsDeleted) {
//				x += MeasureTextWidth(g, bookmark.Document.GetText(line).Replace("\t", "    "), BoldMonospacedFont);
//			}
			return x;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:9,代码来源:BookmarkNode.cs

示例15: OnDrawNode

 /// <summary>
 /// Override draw event to draw appended Control text to RegisterTreeNode.
 /// </summary>
 protected override void OnDrawNode(DrawTreeNodeEventArgs e)
 {
     if (e.Node is RegisterTreeNode)
     {
         e.Graphics.DrawString((e.Node as RegisterTreeNode).Control.Text, Font, new SolidBrush((e.Node as RegisterTreeNode).CreateTextColor()), e.Bounds.Right, e.Bounds.Top);
     }
     e.DrawDefault = true;
     base.OnDrawNode(e);
 }
开发者ID:kaviarasankk,项目名称:x-IMU-GUI,代码行数:12,代码来源:RegisterTreeView.cs


注:本文中的System.Windows.Forms.DrawTreeNodeEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。