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


C# Tree.DrawContext类代码示例

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


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

示例1: Draw

        public override void Draw(TreeNodeAdv node, DrawContext context)
        {
            Graphics g = context.Graphics;
            Rectangle targetRect = new Rectangle(
                context.Bounds.X + this.LeftMargin,
                context.Bounds.Y,
                context.Bounds.Width - this.LeftMargin,
                context.Bounds.Height);

            // Retrieve item information
            PackageItem item = node.Tag as PackageItem;
            Image typeIcon = null;
            if (item != null)
            {
                switch (item.Type)
                {
                    case PackageItem.PackageType.Core:
                        typeIcon = PackageManagerFrontendResCache.IconCore;
                        break;
                    case PackageItem.PackageType.Editor:
                        typeIcon = PackageManagerFrontendResCache.IconEditor;
                        break;
                    case PackageItem.PackageType.Sample:
                        typeIcon = PackageManagerFrontendResCache.IconSample;
                        break;
                }
            }
            if (typeIcon == null) return;

            // Draw icon centered
            Point iconPos = new Point(
                targetRect.X + targetRect.Width / 2 - typeIcon.Width / 2,
                targetRect.Y + targetRect.Height / 2 - typeIcon.Height / 2);
            g.DrawImageUnscaled(typeIcon, iconPos.X, iconPos.Y);
        }
开发者ID:ninja2003,项目名称:duality,代码行数:35,代码来源:DualityPackageTypeNodeControl.cs

示例2: AutoSizeColumn

        public void AutoSizeColumn(TreeColumn column)
        {
            if (!Columns.Contains(column))
                throw new ArgumentException("column");

            DrawContext context = new DrawContext();
            context.Graphics = Graphics.FromImage(new Bitmap(1, 1));
            context.Font = this.Font;
            int res = 0;
            for (int row = 0; row < RowCount; row++)
            {
                if (row < RowMap.Count)
                {
                    int w = 0;
                    TreeNodeAdv node = RowMap[row];
                    foreach (NodeControl nc in NodeControls)
                    {
                        if (nc.ParentColumn == column)
                            w += nc.GetActualSize(node, _measureContext).Width;
                    }
                    res = Math.Max(res, w);
                }
            }

            if (res > 0)
                column.Width = res;
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:27,代码来源:TreeViewAdv.Draw.cs

示例3: AutoHeaderHeightLayout

		public AutoHeaderHeightLayout(TreeViewAdv treeView, int headerHeight)
		{
			_treeView = treeView;
			PreferredHeaderHeight = headerHeight;
			_measureContext = new DrawContext();
			_measureContext.Graphics = Graphics.FromImage(new Bitmap(1, 1));
		}
开发者ID:montague247,项目名称:treeviewadv,代码行数:7,代码来源:AutoHeaderHeightLayout.cs

示例4: DrawNode

        public void DrawNode(TreeNodeAdv node, DrawContext context)
        {
            foreach (NodeControlInfo item in GetNodeControls(node))
            {
                if (item.Bounds.X >= OffsetX && item.Bounds.X - OffsetX < this.Bounds.Width)// skip invisible nodes
                {
                    if (!DragMode)
                    {
                        if (ColumnSelectionMode == ColumnSelectionMode.All)
                        {
                            if (node.IsSelected && Focused)
                                context.DrawSelection = DrawSelectionMode.Active;
                            else if (node.IsSelected && !Focused && !HideSelection)
                                context.DrawSelection = DrawSelectionMode.Inactive;
                        }
                        else
                        {
                            bool selectedColumn = ((item.Control != null) && (item.Control.ParentColumn != null) && (this.SelectedColumnIndex == item.Control.ParentColumn.Index));
                            if (node.IsSelected && Focused && selectedColumn)
                                context.DrawSelection = DrawSelectionMode.Active;
                            else if (node.IsSelected && !Focused && !HideSelection && selectedColumn)
                                context.DrawSelection = DrawSelectionMode.Inactive;
                            else
                                context.DrawSelection = DrawSelectionMode.None;
                        }
                    }

                    context.Bounds = item.Bounds;
                    context.Graphics.SetClip(context.Bounds);
                    item.Control.Draw(node, context);
                    context.Graphics.ResetClip();
                }
            }
        }
开发者ID:redoz,项目名称:bitdiffer,代码行数:34,代码来源:TreeViewAdv.Draw.cs

示例5: AutoRowHeightLayout

		public AutoRowHeightLayout(TreeViewAdv treeView, int rowHeight)
		{
			_rowCache = new List<Rectangle>();
			_treeView = treeView;
			PreferredRowHeight = rowHeight;
			_measureContext = new DrawContext();
			_measureContext.Graphics = Graphics.FromImage(new Bitmap(1, 1));
		}
开发者ID:john-peterson,项目名称:processhacker,代码行数:8,代码来源:AutoRowHeightLayout.cs

示例6: TreeViewRowDrawEventArgs

		public TreeViewRowDrawEventArgs(Graphics graphics, Rectangle clipRectangle, TreeNodeAdv node, DrawContext context, int row, Rectangle rowRect)
			: base(graphics, clipRectangle)
		{
			_node = node;
			_context = context;
			_row = row;
			_rowRect = rowRect;
		}
开发者ID:ASK-sa,项目名称:ASK.ServEasy,代码行数:8,代码来源:TreeViewRowDrawEventArgs.cs

示例7: DrawNode

 public void DrawNode(TreeNodeAdv node, DrawContext context)
 {
     foreach (NodeControlInfo item in GetNodeControls(node))
     {
         context.Bounds = item.Bounds;
         context.Graphics.SetClip(context.Bounds);
         item.Control.Draw(node, context);
         context.Graphics.ResetClip();
     }
 }
开发者ID:segafan,项目名称:wme1_jankavan_tlc_edition-repo,代码行数:10,代码来源:TreeViewAdv.Draw.cs

示例8: Draw

		public override void Draw(TreeNodeAdv node, DrawContext context)
		{
			Graphics g = context.Graphics;
			Rectangle targetRect = new Rectangle(
				context.Bounds.X + this.LeftMargin,
				context.Bounds.Y,
				context.Bounds.Width - this.LeftMargin,
				context.Bounds.Height);

			// Retrieve item information
			PackageItem item = node.Tag as PackageItem;
			if (item == null) return;

			string headline = null;
			string summary = null;
			if (item != null)
			{
				headline = item.Title;
				if (item.ItemPackageInfo != null)
				{
					summary = item.ItemPackageInfo.Summary;
				}
			}

			// Calculate drawing layout and data
			StringFormat headlineFormat = new StringFormat { Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap };
			StringFormat summaryFormat = new StringFormat { Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.LineLimit };
			Rectangle headlineRect;
			Rectangle summaryRect;
			{
				SizeF headlineSize;
				SizeF summarySize;
				// Base info
				{
					headlineSize = g.MeasureString(headline, context.Font, targetRect.Width, headlineFormat);
					headlineRect = new Rectangle(targetRect.X, targetRect.Y, targetRect.Width, (int)headlineSize.Height + 2);
					summaryRect = new Rectangle(targetRect.X, targetRect.Y + headlineRect.Height, targetRect.Width, targetRect.Height - headlineRect.Height);
					summarySize = g.MeasureString(summary, context.Font, summaryRect.Size, summaryFormat);
				}
				// Alignment info
				{
					Size totelContentSize = new Size(Math.Max(headlineRect.Width, summaryRect.Width), headlineRect.Height + (int)summarySize.Height);
					Point alignAdjust = new Point(0, Math.Max((targetRect.Height - totelContentSize.Height) / 2, 0));
					headlineRect.X += alignAdjust.X;
					headlineRect.Y += alignAdjust.Y;
					summaryRect.X += alignAdjust.X;
					summaryRect.Y += alignAdjust.Y;
				}
			}

			Color textColor = this.Parent.ForeColor;

			g.DrawString(headline, context.Font, new SolidBrush(Color.FromArgb(context.Enabled ? 255 : 128, textColor)), headlineRect, headlineFormat);
			g.DrawString(summary, context.Font, new SolidBrush(Color.FromArgb(context.Enabled ? 128 : 64, textColor)), summaryRect, summaryFormat);
		}
开发者ID:Scottyaim,项目名称:duality,代码行数:55,代码来源:DualityPackageSummaryNodeControl.cs

示例9: DrawRow

	    private void DrawRow(PaintEventArgs e, ref DrawContext context, int row, Rectangle rowRect)
		{
		    TreeNodeAdv node = this.RowMap[row];

		    context.DrawSelection = DrawSelectionMode.None;
		    context.CurrentEditorOwner = _currentEditorOwner;

		    bool focused = this.Focused;

		    if (node.IsSelected && focused)
		    {
		        context.DrawSelection = DrawSelectionMode.Active;
		    }
		    else if (node.IsSelected && !focused && !this.HideSelection)
		    {
		        context.DrawSelection = DrawSelectionMode.Inactive;
		    }

            Rectangle focusRect = new Rectangle(OffsetX, rowRect.Y, this.Width - (this._vScrollBar.Visible ? this._vScrollBar.Width : 0), rowRect.Height);

		    context.DrawFocus = false;

		    if (context.DrawSelection != DrawSelectionMode.Active)
		    {
                using (SolidBrush b = new SolidBrush(node.BackColor))
                {
                    e.Graphics.FillRectangle(b, focusRect);
                }
		    }

		    if (context.DrawSelection == DrawSelectionMode.Active || context.DrawSelection == DrawSelectionMode.Inactive)
		    {
		        if (context.DrawSelection == DrawSelectionMode.Active)
		        {
		            context.DrawSelection = DrawSelectionMode.FullRowSelect;

                    if (ExplorerVisualStyle.VisualStylesEnabled)
                    {
                        ExplorerVisualStyle.TvItemSelectedRenderer.DrawBackground(context.Graphics, focusRect);
                    }
                    else
                    {
		                e.Graphics.FillRectangle(SystemBrushes.Highlight, focusRect);
		            }
		        }
		        else
		        {
		            context.DrawSelection = DrawSelectionMode.None;
		        }
		    }

		    this.DrawNode(node, context);
		}
开发者ID:john-peterson,项目名称:processhacker,代码行数:53,代码来源:TreeViewAdv.Draw.cs

示例10: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            // BeginPerformanceCount();
            // PerformanceAnalyzer.Start("OnPaint");

            DrawContext context = new DrawContext();
            context.Graphics = e.Graphics;
            context.Font = this.Font;
            context.Enabled = Enabled;

            int y = 0;
            int gridHeight = 0;

            if (UseColumns)
            {
                DrawColumnHeaders(e.Graphics);
                y += ColumnHeaderHeight;
                if (Columns.Count == 0 || e.ClipRectangle.Height <= y)
                    return;
            }

            int firstRowY = _rowLayout.GetRowBounds(FirstVisibleRow).Y;
            y -= firstRowY;

            e.Graphics.ResetTransform();
            e.Graphics.TranslateTransform(-OffsetX, y);
            Rectangle displayRect = DisplayRectangle;
            for (int row = FirstVisibleRow; row < RowCount; row++)
            {
                Rectangle rowRect = _rowLayout.GetRowBounds(row);
                gridHeight += rowRect.Height;
                if (rowRect.Y + y > displayRect.Bottom)
                    break;
                else
                    DrawRow(e, ref context, row, rowRect);
            }

            if ((GridLineStyle & GridLineStyle.Vertical) == GridLineStyle.Vertical && UseColumns)
                DrawVerticalGridLines(e.Graphics, firstRowY);

            if (_dropPosition.Node != null && DragMode && HighlightDropPosition)
                DrawDropMark(e.Graphics);

            e.Graphics.ResetTransform();
            DrawScrollBarsBox(e.Graphics);

            if (DragMode && _dragBitmap != null)
                e.Graphics.DrawImage(_dragBitmap, PointToClient(MousePosition));

            // PerformanceAnalyzer.Finish("OnPaint");
            // EndPerformanceCount(e);
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:52,代码来源:TreeViewAdv.Draw.cs

示例11: DrawNode

 public void DrawNode(TreeNodeAdv node, DrawContext context)
 {
     foreach (NodeControlInfo item in GetNodeControls(node))
     {
         if (item.Bounds.Right >= OffsetX && item.Bounds.X - OffsetX < this.Bounds.Width)// skip invisible nodes
         {
             context.Bounds = item.Bounds;
             context.Graphics.SetClip(context.Bounds);
             item.Control.Draw(node, context);
             context.Graphics.ResetClip();
         }
     }
 }
开发者ID:ldh9451,项目名称:XLE,代码行数:13,代码来源:TreeViewAdv.Draw.cs

示例12: TreeViewAdv

        public TreeViewAdv()
        {
            InitializeComponent();
               SetStyle(ControlStyles.AllPaintingInWmPaint
            | ControlStyles.UserPaint
            | ControlStyles.OptimizedDoubleBuffer
            | ControlStyles.ResizeRedraw
            | ControlStyles.Selectable
            , true);

            if (Environment.OSVersion.Version.Major < 6)
            {
                if (Application.RenderWithVisualStyles)
                    _columnHeaderHeight = 20;
                else
                    _columnHeaderHeight = 17;
            }
            else
            {
                if (Application.RenderWithVisualStyles)
                    _columnHeaderHeight = 25;
                else
                    _columnHeaderHeight = 17;
            }

               _hScrollBar.Height = SystemInformation.HorizontalScrollBarHeight;
               _vScrollBar.Width = SystemInformation.VerticalScrollBarWidth;
               _rowLayout = new FixedRowHeightLayout(this, RowHeight);
               _rowMap = new List<TreeNodeAdv>();
               _selection = new List<TreeNodeAdv>();
               _readonlySelection = new ReadOnlyCollection<TreeNodeAdv>(_selection);
               _columns = new TreeColumnCollection(this);
               _toolTip = new ToolTip();

               _measureContext = new DrawContext();
               _measureContext.Font = Font;
               _measureContext.Graphics = Graphics.FromImage(new Bitmap(1, 1));

               Input = new NormalInputState(this);
               _search = new IncrementalSearch(this);
               CreateNodes();
               CreatePens();

               ArrangeControls();

               _plusMinus = new NodePlusMinus(this);
               _controls = new NodeControlsCollection(this);

            Font = _font;
               ExpandingIcon.IconChanged += ExpandingIconChanged;
        }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:51,代码来源:TreeViewAdv.cs

示例13: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
#if DEBUG
            this.BeginPerformanceCount();
#endif
            DrawContext context = new DrawContext
            {
                Graphics = e.Graphics, 
                Font = this.Font, 
                Enabled = Enabled
            };

            this.DrawColumnHeaders(e.Graphics);

            int y = this.ColumnHeaderHeight;

            if (this.Columns.Count == 0 || e.ClipRectangle.Height <= y)
                return;

            int firstRowY = _rowLayout.GetRowBounds(this.FirstVisibleRow).Y;

            y -= firstRowY;

            e.Graphics.ResetTransform();
            e.Graphics.TranslateTransform(-OffsetX, y);

            Rectangle displayRect = e.ClipRectangle;

            for (int row = this.FirstVisibleRow; row < this.RowCount; row++)
            {
                Rectangle rowRect = _rowLayout.GetRowBounds(row);

                if (rowRect.Y + y > displayRect.Bottom)
                    break;

                this.DrawRow(e, ref context, row, rowRect);
            }

            e.Graphics.ResetTransform();

            this.DrawScrollBarsBox(e.Graphics);

#if DEBUG
            this.EndPerformanceCount(e);
#endif
        }
开发者ID:john-peterson,项目名称:processhacker,代码行数:46,代码来源:TreeViewAdv.Draw.cs

示例14: Draw

        public override void Draw(TreeNodeAdv node, DrawContext context)
        {
            PlotterInfo info = GetValue(node) as PlotterInfo;

            if (_plotter == null)
            {
                _plotter = new Plotter
                {
                    BackColor = Color.Black, 
                    ShowGrid = false, 
                    OverlaySecondLine = false
                };
            }

            if (info.UseLongData)
            {
                _plotter.UseLongData = true;
                _plotter.LongData1 = info.LongData1;
                _plotter.LongData2 = info.LongData2;
            }
            else
            {
                _plotter.UseLongData = false;
                _plotter.Data1 = info.Data1;
                _plotter.Data2 = info.Data2;
            }

            _plotter.UseSecondLine = info.UseSecondLine;
            _plotter.OverlaySecondLine = info.OverlaySecondLine;
            _plotter.LineColor1 = info.LineColor1;
            _plotter.LineColor2 = info.LineColor2;

            if ((_plotter.Width != context.Bounds.Width - 1 || 
                _plotter.Height != context.Bounds.Height - 1) &&
                context.Bounds.Width > 1 && context.Bounds.Height > 1)
                _plotter.Size = new Size(context.Bounds.Width - 1, context.Bounds.Height - 1);

            _plotter.Draw();

            using (Bitmap b = new Bitmap(_plotter.Width, _plotter.Height))
            {
                _plotter.DrawToBitmap(b, new Rectangle(0, 0, b.Width, b.Height));

                context.Graphics.DrawImage(b, context.Bounds.Location);
            }
        }
开发者ID:john-peterson,项目名称:processhacker,代码行数:46,代码来源:NodePlotter.cs

示例15: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            BeginPerformanceCount();

            DrawContext context = new DrawContext();
            context.Graphics = e.Graphics;
            context.Font = this.Font;
            context.Enabled = Enabled;

            int y = 0;
            if (HeaderStyle != ColumnHeaderStyle.None)
            {
                DrawColumnHeaders(e.Graphics);
                y += ColumnHeaderHeight;
                if (Columns.Count == 0 /*|| e.ClipRectangle.Height <= y*/)
                    return;
            }
            y -= _rowLayout.GetRowBounds(FirstVisibleRow).Y;

            e.Graphics.ResetTransform();
            e.Graphics.TranslateTransform(-OffsetX, y);
            Rectangle displayRect = DisplayRectangle;
            for (int row = FirstVisibleRow; row < RowCount; row++)
            {
                Rectangle rowRect = _rowLayout.GetRowBounds(row);
                if (rowRect.Y + y > displayRect.Bottom)
                    break;
                else
                    DrawRow(e, ref context, row, rowRect);
            }

            if (Search.IsActive)
                Search.Draw(context);

            if (_dropPosition.Node != null && DragMode)
                DrawDropMark(e.Graphics);

            e.Graphics.ResetTransform();
            DrawScrollBarsBox(e.Graphics);

            if (DragMode && _dragBitmap != null)
                e.Graphics.DrawImage(_dragBitmap, PointToClient(MousePosition));

            EndPerformanceCount(e);
        }
开发者ID:segafan,项目名称:wme1_jankavan_tlc_edition-repo,代码行数:45,代码来源:TreeViewAdv.Draw.cs


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