Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to use GdiGraphics.DrawLine() method? (Read 1599 times)
lyudmil
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Jan 9th, 2009
How to use GdiGraphics.DrawLine() method?
Jan 9th, 2009 at 10:21pm
Print Post  
I am trying to draw some static lines on screen. The folowing code is not working. What am I doing wrong?

Diagram diagram = diagramView.Diagram;
GdiGraphics gdi = diagram.CreateMeasureGraphics();
System.Drawing.Pen pen = new System.Drawing.Pen(Color.Red, 10);
gdi.DrawLine(pen, 0, 0, 300, 300);

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use GdiGraphics.DrawLine() method?
Reply #1 - Jan 10th, 2009 at 9:42am
Print Post  
Hi Lyudmil,

The Graphics object returned by CreateMeasureGraphics() is meant to help you only for some font and image measurements; calling its Draw methods won't reflect upon what's rendered in the browser. If all you need is some decoration lines, you could create locked link object in the diagram background instead of using the Graphics API. If you need some more complex graphics, handle the DrawBackground event as shown below.

Code
Select All
protected void Page_Load(object sender, EventArgs e)
{
	if (!IsPostBack)
	{
		Diagram diagram = view.Diagram;

		DiagramLink decorationLine = diagram.Factory.CreateDiagramLink(
			new PointF(0, 0), new PointF(300, 300));
		decorationLine.HeadShape = ArrowHead.None;
		decorationLine.ZIndex = 0;
		decorationLine.Locked = true;
		decorationLine.Pen = new MindFusion.Drawing.Pen(Color.Blue, 10);

		diagram.DrawBackground += new DiagramEventHandler(diagram_DrawBackground);
	}
}

void diagram_DrawBackground(object sender, DiagramEventArgs e)
{
	IGraphics gdi = e.Graphics;
	System.Drawing.Pen pen = new System.Drawing.Pen(Color.Red, 10);
	gdi.DrawLine(pen, 300, 0, 0, 300);
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint