如何使用GDI +使用不同的颜色绘制线条? [英] How to draw lines using different Color using GDI+?
本文介绍了如何使用GDI +使用不同的颜色绘制线条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个动态的点列表,可以随时添加新的点.我想画线以使用不同的颜色将它们连接起来.颜色基于这些点的ID,将从数据库中检索这些ID.
I need to create a dynamic List of Points, new Point ,can be added at any time. I want to draw lines to connect them using different color. Color is based on the ID''s of those points, which will be retrieved from the database.
推荐答案
创建一个 ^ ],并使用 ^ ]进行绘制使用该笔的线.请确保正确放置您的物品,例如
Create a Pen[^] of the appropriate color and use Graphics.DrawLine()[^] to draw a line using that Pen. Be sure to properly dispose your objects, e.g.
PaintEventArgs pea = ...
using (Pen p = new Pen (...)) {
pea.Graphics.DrawLine (...)
}
/ravi
/ravi
这不是用于控制台的东西.请查看我过去的答案:
在mdi子表单之间画线 [在面板上捕获图形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [连接不同的控件 [矢量图形软件,例如C#或VB.NET中的CorelDraw或Inkscape [ ^ ].
基本上,您需要使用类System.Windows.Controls.Canvas
并在其上放置一些UI元素:
http://msdn.microsoft.com/en-us/library/system. windows.controls.canvas.aspx [ ^ ].
—SA
This thing is not for console. Please see my past answers:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].
That was forSystem.Drawing
, which is usually used withSystem.Windows.Forms
or with bitmaps.
Alternative type of application is WPF. I don''t have answer to your particular problem (for WPF, it is extremely simple), but you can get some ideas:
Connect different controls[^],
Vector graphics software like CorelDraw or Inkscape in C# or VB.NET[^].
Basically, you need to use the classSystem.Windows.Controls.Canvas
and put some UI elements on it:
http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.aspx[^].
—SA
这篇关于如何使用GDI +使用不同的颜色绘制线条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文