Blame mono/Assistance/GuidelineLine.cs

Ivan Mahonin cfceb0
using System;
Ivan Mahonin cfceb0
using System.Drawing;
Ivan Mahonin cfceb0
using System.Drawing.Imaging;
Ivan Mahonin cfceb0
using System.Collections.Generic;
Ivan Mahonin cfceb0
Ivan Mahonin cfceb0
namespace Assistance {
Ivan Mahonin cfceb0
	public class GuidelineLine: Guideline {
Ivan Mahonin cfceb0
		protected Point p0, p1;
Ivan Mahonin cfceb0
		protected Point direction;
Ivan Mahonin cfceb0
		
Ivan Mahonin cfceb0
		public GuidelineLine(Point p0, Point p1) {
Ivan Mahonin cfceb0
			this.p0 = p0;
Ivan Mahonin cfceb0
			this.p1 = p1;
Ivan Mahonin cfceb0
			direction = (p1 - p0).normalize();
Ivan Mahonin cfceb0
		}
Ivan Mahonin cfceb0
		
Ivan Mahonin cfceb0
		public override void draw(Graphics g, bool active) {
Ivan Mahonin cfceb0
			Point pp0 = p0;
Ivan Mahonin cfceb0
			Point pp1 = p1;
Ivan Mahonin cfceb0
			Geometry.truncateInfiniteLine(new Rectangle(g.VisibleClipBounds), ref pp0, ref pp1);
Ivan Mahonin cfceb0
			g.DrawLine(active ? penActive : pen , pp0.toFloat(), pp1.toFloat());
Ivan Mahonin cfceb0
		}
Ivan Mahonin cfceb0
		
Ivan Mahonin cfceb0
		public override Point transformPoint(Point p) {
Ivan Mahonin cfceb0
			return Point.dot(p - p0, direction)*direction + p0;
Ivan Mahonin cfceb0
		}
Ivan Mahonin cfceb0
	}
Ivan Mahonin cfceb0
}
Ivan Mahonin cfceb0