bool CheckIfPointBelongToLine(Line line, PointF point) { Line check1 = new Line(); check1.X1 = line.X1; check1.Y1 = line.Y1; check1.X2 = point.X; check1.Y2 = point.Y; Line check2 = new Line(); check2.X1 = line.X2; check2.Y1 = line.Y2; check2.X2 = point.X; check2.Y2 = point.Y; double summ = tool.GetLength(check1) + tool.GetLength(check2); double length = tool.GetLength(line); double tolerance = 0.00001; if (Math.Abs(length - summ) < tolerance) { return(true); } return(false); }
private void AddAnnotation(Line wall, GridSetup grid) { Label wallSize = new Label { Width = 100, Height = 25, VerticalContentAlignment = VerticalAlignment.Bottom, HorizontalContentAlignment = allign, FontSize = 14, Foreground = lineColor, Effect = null, Content = Math.Round((tool.GetLength(wall) * grid.Scale) + 0.05).ToString() }; wallSize.RenderTransform = new RotateTransform(270 - SetTextAngle(wall), wallSize.Width / 2, wallSize.Height); PointF textPosition = tool.GetCenter(dimensionLine); Canvas.SetLeft(wallSize, textPosition.X - wallSize.Width / 2); Canvas.SetTop(wallSize, textPosition.Y - wallSize.Height); wallSize.Uid = "Dimension"; interfaceElements.Add(wallSize); }