private void previewButtonInfo_Click(object sender, RoutedEventArgs e) { ToolPath path = previewPath; StringBuilder info = new StringBuilder(); Bounds b = path.GetDimensions(); info.AppendLine($"Dimensions (XY): {b.SizeX:0.###}x{b.SizeY:0.###} mm"); info.AppendLine($"Lower left corner (XY): {b.MinX:0.###},{b.MinY:0.###} mm"); info.AppendLine($"Travel Distance: {path.GetTravelDistance():0} mm"); info.Append($"Total Lines: {path.Count}"); MessageBox.Show(info.ToString()); }
private void editor_UpdatePreview() { previewPathStraight.Points.Clear(); previewPathArc.Points.Clear(); previewPathRapid.Points.Clear(); foreach (GCodeCommand c in previewPath) { var s = c as Straight; if (s != null) { if (s.Rapid) { previewPathRapid.Points.Add(s.Start.ToPoint3D()); previewPathRapid.Points.Add(s.End.ToPoint3D()); } else { previewPathStraight.Points.Add(s.Start.ToPoint3D()); previewPathStraight.Points.Add(s.End.ToPoint3D()); } continue; } var a = c as Arc; if (a != null) { foreach (Movement m in a.Split(Properties.Settings.Default.EditorArcSplitDistance)) { previewPathArc.Points.Add(m.Start.ToPoint3D()); previewPathArc.Points.Add(m.End.ToPoint3D()); } } } Bounds b = previewPath.GetDimensions(); editorGrid.Center = new Point3D(Math.Round((b.MinX + b.MaxX) / 20) * 10, Math.Round((b.MinY + b.MaxY) / 20) * 10, 0); editorGrid.Length = Math.Ceiling((b.SizeX + 20) / 20) * 20; editorGrid.Width = Math.Ceiling((b.SizeY + 20) / 20) * 20; editor_Preview.ZoomExtents(400); editor_imgTextChanged.Visibility = Visibility.Hidden; }