|
using System;
using System.Drawing;
using CsGL.OpenGL;
using System.Collections;
using System.Diagnostics;
namespace _2D_draw
{
/// <summary>
/// Summary description for DrawingObjectLine.
/// </summary>
public class DrawingObjectLine : DrawingObject
{
Point start = new Point();
Point end = new Point();
public DrawingObjectLine()
{
this.strType = "Line";
comment = "line between two points";
}
public void Draw()
{
Draw( GL.GL_RENDER , 0);
}
// ******************************************************************
// draw the line
public override void Draw( uint mode , uint highlight)
{
if ( highlight == ID )
{
GL.glColor3ub( 100 , 0 , 200);
}
else
{
GL.glColor3ub( 0 , 0 , 0);
}
GL.glLoadName( ID ); // used to select an object
//System.Console.WriteLine("Draw: " + ID.ToString() + " " + this.strType);
DrawLine( start , end );
GL.glFlush();
}
public override void HandleMouseDown(System.Windows.Forms.MouseEventArgs e)
{
start = transform( e.X , e.Y );
}
public override void HandleMouseUp(System.Windows.Forms.MouseEventArgs e)
{
end = transform( e.X , e.Y );
Draw();
}
public override void HandleMouseMove(System.Windows.Forms.MouseEventArgs e)
{
end = transform( e.X , e.Y );
Draw();
}
// ideas - what if the start point matches the end point? then don't add the line?
// draw dotted line for when we havent' selected the end point yet?
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.