System.Drawing.Toolkit.ToolkitGraphicsImageBase.DrawLine C# (CSharp) Method

DrawLine() public method

public DrawLine ( int x1, int y1, int x2, int y2 ) : void
x1 int
y1 int
x2 int
y2 int
return void
		public override void DrawLine(int x1, int y1, int x2, int y2)
				{
					IToolkitPen pen = Pen;
					ToolkitPenBase penBase;

					if (pen == null)
						return;
					penBase = pen as ToolkitPenBase;

					int color = penBase.Color.ToArgb();
					Frame frame = image.image.GetFrame(0);
					// TODO: Finish off
					int dy = y2 - y1;
					int dx = x2 - x1;
					int stepx, stepy;

					if (dy < 0)
					{
						dy = -dy;
						stepy = -frame.Stride;
					} 
					else
						stepy = frame.Stride;
					if (dx < 0)
					{
						dx = -dx;
						stepx = -1;
					} 
					else
					{
						stepx = 1;
					}
					dy <<= 1;
					dx <<= 1;

					y1 *= frame.Stride;
					y2 *= frame.Stride;
					SetPixelLine(frame, x1,y1, color);
					if (dx > dy) 
					{
						int fraction = dy - (dx >> 1);
						while (x1 != x2) 
						{
							if (fraction >= 0) 
							{
								y1 += stepy;
								fraction -= dx;
							}
							x1 += stepx;
							fraction += dy;
							SetPixelLine(frame, x1,y1, color);
						}
					} 
					else 
					{
						int fraction = dx - (dy >> 1);
						while (y1 != y2) 
						{
							if (fraction >= 0) 
							{
								x1 += stepx;
								fraction -= dy;
							}
							y1 += stepy;
							fraction += dx;
							SetPixelLine(frame, x1,y1, color);
						}
					}
					this.image.ImageChanged();
				}