public bool AddUnintersectingLine(Point p1, Point p2) { UnintersectingLine newLine = new UnintersectingLine(p1, p2, this.AllUnintersectingLines); return(false); }
private void Canvas_MouseUp_1(object sender, System.Windows.Input.MouseEventArgs e) { // TODO: Remove Console.Out.WriteLine("UP " + (ActivePoint ? "t" : "f")); if (lines.ActivePoint) { // Finnish the line! // Remove temporary line. MyCanvas.Children.Remove(lines.CurrentLine); // Add the final line. Dot.paintDot(MyCanvas, e.GetPosition(this)); UnintersectingLine line = new UnintersectingLine(lines.CurrentPoint, e.GetPosition(this), lines.AllUnintersectingLines); if (line.HasErrors) { // Hittade ingen giltig path. } else { lines.AllUnintersectingLines.Add(line); line.Stroke = SystemColors.WindowFrameBrush; line.Stroke = new SolidColorBrush(Color.FromRgb((byte)rand.Next(0, 200), (byte)rand.Next(0, 200), (byte)rand.Next(0, 200))); /* * Line line = new Line(); * * line.Stroke = SystemColors.WindowFrameBrush; * line.X1 = lines.CurrentPoint.X; * line.Y1 = lines.CurrentPoint.Y; * line.X2 = e.GetPosition(this).X; * line.Y2 = e.GetPosition(this).Y; */ MyCanvas.Children.Add(line); // Test Point extendedPoint = line.FirstSegment.ExtendFrom(10); Dot.paintDot(MyCanvas, line.LastSegment.ExtendTo(10)); Console.Out.WriteLine("Extended Point: " + extendedPoint); Dot.paintDot(MyCanvas, extendedPoint); } lines.ActivePoint = false; } else { //Start a new line. lines.CurrentPoint = e.GetPosition(this); // Paint a point Dot.paintDot(MyCanvas, lines.CurrentPoint); lines.ActivePoint = true; } }