• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DrawContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Draw

        public override void Draw(TreeNodeAdv node, DrawContext context)
        {
            if (context.CurrentEditorOwner == this && node == Parent.CurrentNode)
                return;

            var label = GetLabel(node);
            var textBounds = GetBounds(node, context);
            var focusRect = new Rectangle(textBounds.X, context.Bounds.Y,
                textBounds.Width - 1, context.Bounds.Height - 1);

            Brush backgroundBrush;
            Color textColor;
            Font font;
            CreateBrushes(node, context, label, out backgroundBrush, out textColor, out font, ref label);

            //if (backgroundBrush != null)
            //    context.Graphics.FillRectangle(backgroundBrush, focusRect);

            var focusPen = new Pen(SystemColors.Highlight);
            focusPen.Color = context.DrawSelection == DrawSelectionMode.None ? 
                SystemColors.ControlText : SystemColors.InactiveCaption;

            //focusPen.Color = SystemColors.Highlight;
            //context.Graphics.DrawRectangle(focusPen, focusRect);
            
            if (UseCompatibleTextRendering)
                TextRenderer.DrawText(context.Graphics, label, font, textBounds, textColor, _formatFlags);
            else
                context.Graphics.DrawString(label, font, GetBrush(textColor), textBounds, _format);
        }
开发者ID:subTee,项目名称:Deviare2,代码行数:30,代码来源:NodeCategoryTitle.cs


示例2: Draw

		public override void Draw(TreeNodeAdv node, DrawContext context)
		{
			if (node.CanExpand)
			{
				Rectangle r = context.Bounds;
				int dy = (int)Math.Round((float)(r.Height - ImageSize) / 2);

                if (_useVisualStyles)
                {
                    VisualStyleRenderer renderer;

                    if (node.IsExpanded)
                        renderer = _openedRenderer;
                    else
                        renderer = _closedRenderer;

                    renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y + dy, ImageSize, ImageSize));
                }
                else
                {
                    Image img;

                    if (node.IsExpanded)
                        img = this.Minus;
                    else
                        img = this.Plus;

                    context.Graphics.DrawImageUnscaled(img, new Point(r.X, r.Y + dy));
                }
			}
		}
开发者ID:andyvand,项目名称:ProcessHacker,代码行数:31,代码来源:NodePlusMinus.cs


示例3: CommentHitTestError

        public void CommentHitTestError()
        {
            string test="<p><!--OddPage--></p>";
            XmlDocument doc=new XmlDocument();
            doc.LoadXml(test);

            Stylesheet s=new Stylesheet();
            s.BindStyles(doc.NameTable);

            Rectangle rc=new Rectangle(0, 0, 500, int.MaxValue);

            using ( IGraphics gr=new DummyGraphics() )
            {
                DrawContext ctx=new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null);
                LayoutEngine layoutEngine=new LayoutEngine(s);

                layoutEngine.Reflow(ctx, doc.DocumentElement);

                Console.WriteLine("Bounds {0}", layoutEngine.BoundingRect);
                for (int x=0; x< layoutEngine.BoundingRect.Width; x+=10)
                {
                    HitTestInfo hti=layoutEngine.GetHitTestInfo(gr, new Point(x,8));
                    SelectionPoint sp=hti.SelectionPoint;
                    Console.WriteLine("Hit test at {0} = {1}", x, sp);
                }
            }
        }
开发者ID:jugglingcats,项目名称:XEditNet,代码行数:27,代码来源:LayoutTests.cs


示例4: Draw

 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     Rectangle bounds = GetBounds(node, context);
     CheckState state = GetCheckState(node);
     if (Application.RenderWithVisualStyles)
     {
         VisualStyleRenderer renderer;
         if (state == CheckState.Indeterminate)
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.MixedNormal);
         else if (state == CheckState.Checked)
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.CheckedNormal);
         else
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.UncheckedNormal);
         renderer.DrawBackground(context.Graphics, new Rectangle(bounds.X, bounds.Y, ImageSize, ImageSize));
     }
     else
     {
         Image img;
         if (state == CheckState.Indeterminate)
             img = _unknown;
         else if (state == CheckState.Checked)
             img = _check;
         else
             img = _uncheck;
         context.Graphics.DrawImage(img, bounds.Location);
     }
 }
开发者ID:zhuangyy,项目名称:Motion,代码行数:27,代码来源:NodeCheckBox.cs


示例5: Draw

 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     if (node.CanExpand)
     {
         Rectangle r = context.Bounds;
         int dy = (int)Math.Round((float)(r.Height - ImageSize) / 2);
         if (Application.RenderWithVisualStyles)
         {
             VisualStyleRenderer renderer;
             if (node.IsExpanded)
                 renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
             else
                 renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
             renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y + dy, ImageSize, ImageSize));
         }
         else
         {
             Image img;
             if (node.IsExpanded)
                 img = _minus;
             else
                 img = _plus;
             context.Graphics.DrawImageUnscaled(img, new Point(r.X, r.Y + dy));
         }
     }
 }
开发者ID:Veggie13,项目名称:Genesis,代码行数:26,代码来源:NodePlusMinus.cs


示例6: Draw

        public override void Draw(DrawContext context, PxRect pxrect, PxRect? pxsampleRect = null, DrawColor? color = null)
        {
            context.Set();
            Rectangle rect = pxrect.Rectangle();
            Rectangle sampleRect;
            if (pxsampleRect == null) sampleRect = texture.Bounds;
            else sampleRect = pxsampleRect.Value.Rectangle();

            // top left
            DrawBatch.Draw(texture, rect.MarginTop(fh).MarginLeft(fw).PxRect(), sampleRect.MarginTop(fh).MarginLeft(fw).PxRect(), color);
            // top
            DrawBatch.Draw(texture, rect.MarginTop(fh).Inflated(-fw, 0).PxRect(), sampleRect.MarginTop(fh).Inflated(-fw, 0).PxRect(), color);
            // top right
            DrawBatch.Draw(texture, rect.MarginTop(fh).MarginRight(fw).PxRect(), sampleRect.MarginTop(fh).MarginRight(fw).PxRect(), color);
            // left
            DrawBatch.Draw(texture, rect.Inflated(0, -fh).MarginLeft(fw).PxRect(), sampleRect.Inflated(0, -fh).MarginLeft(fw).PxRect(), color);
            // center
            DrawBatch.Draw(texture, rect.Inflated(-fw, -fh).PxRect(), sampleRect.Inflated(-fw, -fh).PxRect(), color);
            // right
            DrawBatch.Draw(texture, rect.Inflated(0, -fh).MarginRight(fw).PxRect(), sampleRect.Inflated(0, -fh).MarginRight(fw).PxRect(), color);
            // bottom left
            DrawBatch.Draw(texture, rect.MarginBottom(fh).MarginLeft(fw).PxRect(), sampleRect.MarginBottom(fh).MarginLeft(fw).PxRect(), color);
            // bottom
            DrawBatch.Draw(texture, rect.MarginBottom(fh).Inflated(-fw, 0).PxRect(), sampleRect.MarginBottom(fh).Inflated(-fw, 0).PxRect(), color);
            // bottom right
            DrawBatch.Draw(texture, rect.MarginBottom(fh).MarginRight(fw).PxRect(), sampleRect.MarginBottom(fh).MarginRight(fw).PxRect(), color);
        }
开发者ID:zetaPRIME,项目名称:xybrid,代码行数:27,代码来源:Drawable9Patch.cs


示例7: DrawEventArgs

 public DrawEventArgs(TreeNodeAdv node, EditableControl control, DrawContext context, string text)
     : base(node)
 {
     _control = control;
     _context = context;
     _text = text;
 }
开发者ID:Tokter,项目名称:TokED,代码行数:7,代码来源:DrawEventArgs.cs


示例8: MeasureSize

 public override Size MeasureSize(TreeNodeAdv node, DrawContext context)
 {
     if (GetValue(node).ToString() == "")
         return new Size(0, 0);
     else
         return new Size(_normal.Width,_normal.Height);
 }
开发者ID:zobo,项目名称:xdebugclient,代码行数:7,代码来源:NodeEllipsisButton.cs


示例9: Draw

 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     Rectangle r = context.Bounds;
     int dy = (int)Math.Round((float)(r.Height - ImageSize) / 2);
     CheckState state = GetCheckState(node);
     if (Application.RenderWithVisualStyles)
     {
         VisualStyleRenderer renderer;
         if (state == CheckState.Indeterminate)
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.MixedNormal);
         else if (state == CheckState.Checked)
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.CheckedNormal);
         else
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.UncheckedNormal);
         renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y + dy, ImageSize, ImageSize));
     }
     else
     {
         Image img;
         if (state == CheckState.Indeterminate)
             img = _unknown;
         else if (state == CheckState.Checked)
             img = _check;
         else
             img = _uncheck;
         context.Graphics.DrawImage(img, new Point(r.X, r.Y + dy));
         //ControlPaint.DrawCheckBox(context.Graphics, r, state2);
     }
 }
开发者ID:KillerGoldFisch,项目名称:GCharp,代码行数:29,代码来源:NodeCheckBox.cs


示例10: MeasureSize

		public override Size MeasureSize(TreeNodeAdv node, DrawContext context, int rightBoundLastControl)
		{
			Image image=GetIcon(node);
			if(image!=null)
				return image.Size;
			else
				return Size.Empty;
		}
开发者ID:shintadono,项目名称:Free.Controls.TreeView,代码行数:8,代码来源:NodeIcon.cs


示例11: MeasureSize

		public override Size MeasureSize(TreeNodeAdv node, DrawContext context)
		{
			Image image = GetIcon(node);
			
            if (image != null)
				return image.Size;
			
            return Size.Empty;
		}
开发者ID:john-peterson,项目名称:processhacker,代码行数:9,代码来源:NodeIcon.cs


示例12: Draw

 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     Image image = GetIcon(node);
     if (image != null)
     {
         Rectangle r = GetBounds(node, context);
         context.Graphics.DrawImage(image, r.Location);
     }
 }
开发者ID:zhuangyy,项目名称:Motion,代码行数:9,代码来源:NodeIcon.cs


示例13: Draw

 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     Image image = GetIcon(node);
     if (image != null)
     {
         Point point = new Point(context.Bounds.X,
             context.Bounds.Y + (context.Bounds.Height - image.Height) / 2);
         context.Graphics.DrawImage(image, point);
     }
 }
开发者ID:Veggie13,项目名称:Genesis,代码行数:10,代码来源:NodeIcon.cs


示例14: Draw

		public override void Draw(TreeNodeAdv node, DrawContext context)
		{
			Image image=GetIcon(node);
			if(image!=null)
			{
				Rectangle r=GetBounds(node, context);
				if(image.Width>0&&image.Height>0)
				{
					switch(_scaleMode)
					{
						case ImageScaleMode.Fit:
							context.Graphics.DrawImage(image, r);
							break;
						case ImageScaleMode.ScaleDown:
							{
								float factor=Math.Min((float)r.Width/(float)image.Width, (float)r.Height/(float)image.Height);
								if(factor<1)
									context.Graphics.DrawImage(image, r.X, r.Y, image.Width*factor, image.Height*factor);
								else
									context.Graphics.DrawImage(image, r.X, r.Y, image.Width, image.Height);
							} break;
						case ImageScaleMode.ScaleUp:
							{
								float factor=Math.Max((float)r.Width/(float)image.Width, (float)r.Height/(float)image.Height);
								if(factor>1)
									context.Graphics.DrawImage(image, r.X, r.Y, image.Width*factor, image.Height*factor);
								else
									context.Graphics.DrawImage(image, r.X, r.Y, image.Width, image.Height);
							} break;
						case ImageScaleMode.AlwaysScale:
							{
								float fx=(float)r.Width/(float)image.Width;
								float fy=(float)r.Height/(float)image.Height;
								if(Math.Min(fx, fy)<1)
								{ //scale down
									float factor=Math.Min(fx, fy);
									context.Graphics.DrawImage(image, r.X, r.Y, image.Width*factor, image.Height*factor);
								}
								else if(Math.Max(fx, fy)>1)
								{
									float factor=Math.Max(fx, fy);
									context.Graphics.DrawImage(image, r.X, r.Y, image.Width*factor, image.Height*factor);
								}
								else
									context.Graphics.DrawImage(image, r.X, r.Y, image.Width, image.Height);
							} break;
						case ImageScaleMode.Clip:
						default:
							context.Graphics.DrawImage(image, r.X, r.Y, image.Width, image.Height);
							break;
					}
				}

			}
		}
开发者ID:shintadono,项目名称:Free.Controls.TreeView,代码行数:55,代码来源:NodeIcon.cs


示例15: Draw

 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     Image image = GetIcon(node);
     if (image != null)
     {
         Rectangle r = GetBounds(node, context);
     // ml: center icon vertically.
     r.Y += (context.Bounds.Height - r.Height) / 2;
         context.Graphics.DrawImage(image, r.Location);
     }
 }
开发者ID:abibell,项目名称:mysql-workbench,代码行数:11,代码来源:NodeIcon.cs


示例16: MeasureSize

        public override Size MeasureSize(TreeNodeAdv node, DrawContext context)
        {
            if (!(node.Tag is Node)) return new Size(0, 0);

            var properNode = (Node) node.Tag;

            if (!_nodeTypesThatShouldBeSized.Contains(properNode.GetType())) return new Size(0, 0);

            if (node.Row == 0 && _firstRowSize != default(Size)) return _firstRowSize;

            return _fixedSize;
        }
开发者ID:subTee,项目名称:Deviare2,代码行数:12,代码来源:NodeSizeControl.cs


示例17: Draw

 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     if (GetValue(node).ToString() != "")
     {
         Image img;
         if (_pstate)
             img = _pressed;
         else
             img = _normal;
         Rectangle bounds = GetBounds(node, context);
         context.Graphics.DrawImage(img, bounds.Location);
     }
 }
开发者ID:zobo,项目名称:xdebugclient,代码行数:13,代码来源:NodeEllipsisButton.cs


示例18: Draw

        public override void Draw(DrawContext context, PxRect rect, PxRect? sampleRect = null, DrawColor? color = null)
        {
            if (dirty) { BuildTexture(); dirty = false; }
            context.Set();

            int hoff = 0;
            int voff = (rect.H / 2) - (texture.Bounds.Height / 2);
            if (align == TextAlign.Right) hoff = rect.W - texture.Bounds.Width;
            else if (align == TextAlign.Center) hoff = (rect.W / 2) - (texture.Bounds.Width / 2);

            DrawBatch.Draw(texture, new PxRect(rect.Position + new PxVector(hoff, voff), texture.Bounds.Size.PxVector()), sampleRect, color);
            //DrawBatch.Draw(texture, rect, sampleRect, color);
        }
开发者ID:zetaPRIME,项目名称:xybrid,代码行数:13,代码来源:TextDrawableFreetype.cs


示例19: UIManager

        /// <summary>
        /// インスタンスを生成します。
        /// </summary>
        /// <param name="game">Game。</param>
        public UIManager(Game game)
            : base(game)
        {
            // サービスとして登録します。
            Game.Services.AddService(typeof(IUIService), this);

            scissorTestRasterizerState = new RasterizerState()
            {
                ScissorTestEnable = true
            };

            drawContext = new DrawContext(this);
        }
开发者ID:willcraftia,项目名称:Blocks,代码行数:17,代码来源:UIManager.cs


示例20: Draw

		public override void Draw(TreeNodeAdv node, DrawContext context)
		{
			Rectangle bounds=GetBounds(node, context);
			CheckState state=GetCheckState(node);

			//Bild zeichnen
			Image img;

			if(state==CheckState.Indeterminate) img=_unknown;
			else if(state==CheckState.Checked) img=_check;
			else img=_uncheck;

			context.Graphics.DrawImage(img, bounds.Location);
		}
开发者ID:shintadono,项目名称:Free.Controls.TreeView,代码行数:14,代码来源:NodeCheckBox.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DrawMode类代码示例发布时间:2022-05-24
下一篇:
C# DrawArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap