public bool TryStart(Drawing drawing, Vector offset, MachineProfiles.IProfile machineProfile) { if (drawing == null) { return(false); } if (thread != null) { return(false); } paths = new List <Path>(); foreach (Path path in drawing.Paths) { paths.Add(Path.Offset(path, offset)); } paths = Clipper.ClipPaths(paths, new Rect(new Point(0.0, 0.0), CornerMath.FarExtent(machineProfile.TableSize, machineProfile.Origin))); maxFeed = machineProfile.MaxFeedRate; stop = false; thread = new Thread(threadStart); thread.Start(); return(true); }
private void updateProfile(MachineProfiles.IProfile profile) { NotifyPropertyChanged(nameof(MachineSize)); NotifyPropertyChanged(nameof(MachineOrigin)); Point extent = CornerMath.FarExtent(profile.TableSize, profile.Origin); ViewCenter = new Point(extent.X / 2.0, extent.Y / 2.0); }
private void _openCommand_Execute(object parameter) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Scalable Vector Graphics (*.svg)|*.svg"; if (dialog.ShowDialog() ?? false) { AppCore.Document.LoadSVG(dialog.FileName); Point tableTopLeft = CornerMath.AtCorner(Corner.TopLeft, AppCore.MachineProfiles.Active.TableSize, AppCore.MachineProfiles.Active.Origin); AppCore.Document.Offset = new Vector(tableTopLeft.X, tableTopLeft.Y); } }
private void CompositionTarget_Rendering(object sender, EventArgs e) { if (graphicsStale) { using (writeableBitmap.GetBitmapContext()) { writeableBitmap.Clear(); Point minExtent = CornerMath.MinExtent(TableSize, TableOrigin); Point maxExtent = CornerMath.MaxExtent(TableSize, TableOrigin); fillRectMM(minExtent.X, minExtent.Y, maxExtent.X, maxExtent.Y, Colors.White); int gridXMin = 50 * ((int)Math.Round(minExtent.X / 50.0) - 2); int gridYMin = 50 * ((int)Math.Round(minExtent.Y / 50.0) - 2); int gridXMax = 50 * ((int)Math.Round(maxExtent.X / 50.0) + 2); int gridYMax = 50 * ((int)Math.Round(maxExtent.Y / 50.0) + 2); for (int x = gridXMin + 10; x < gridXMax; x += 10) { drawLineMM(x, gridYMin, x, gridYMax, Color.FromRgb(0xF0, 0xF0, 0xF0)); } for (int y = gridYMin + 10; y < gridYMax; y += 10) { drawLineMM(gridXMin, y, gridXMax, y, Color.FromRgb(0xF0, 0xF0, 0xF0)); } for (int x = gridXMin + 50; x < gridXMax; x += 50) { drawLineMM(x, gridYMin, x, gridYMax, Color.FromRgb(0xE0, 0xE0, 0xE0)); } for (int y = gridYMin + 50; y < gridYMax; y += 50) { drawLineMM(gridXMin, y, gridXMax, y, Color.FromRgb(0xE0, 0xE0, 0xE0)); } drawRectMM(minExtent.X, minExtent.Y, maxExtent.X, maxExtent.Y, Color.FromRgb(0x80, 0x80, 0x80)); drawLineMM(gridXMin, 0.0, gridXMax, 0.0, Color.FromRgb(0x80, 0x80, 0x80)); drawLineMM(0.0, gridYMin, 0.0, gridYMax, Color.FromRgb(0x80, 0x80, 0x80)); drawPointerMM(MachinePosition.X, MachinePosition.Y, Colors.Red); if (Document != null && Document.Drawing != null) { Vector offset = Document.Offset; foreach (Path path in Document.Drawing.Paths) { if (path.Points.Count >= 2) { Point prev = path.Points[0] + offset; for (int i = 1; i < path.Points.Count + 1; i++) { if (i == path.Points.Count && !path.Closed) { break; } Point point = path.Points[i % path.Points.Count] + offset; drawLineMM(prev.X, prev.Y, point.X, point.Y, path.Closed ? Colors.Blue : Colors.Green); prev = point; } } } } if (MachinePath != null) { Point prev = new Point(0.0, 0.0); int indexCap = Math.Min(MachinePathFrame, MachinePath.Travels.Count); for (int i = 0; i < indexCap; i++) { MachinePath.Travel travel = MachinePath.Travels[i]; drawLineMM(prev.X, prev.Y, travel.Destination.X, travel.Destination.Y, !travel.Rapid ? Colors.Red : Colors.Purple); prev = travel.Destination; } } } graphicsStale = false; } }