private void Form1_Load(object sender, EventArgs e) { PrinterSettingsModel model = new PrinterSettingsModel() { NumberOfCopies = 10, SelectedPrinter = "Printer 1" }; new PrinterSettingsPresenter(model, PrintPreviewView); new PrinterSettingsPresenter(model, PrinterSettingsView); }
private void Form1_Load(object sender, EventArgs e) { PrinterSettingsModel model = new PrinterSettingsModel() { NumberOfCopies = 10, SelectedPrinter = "Printer 1" }; new PrinterSettingsPresenter(model, PrintPreviewView); new PrinterSettingsPresenter(model, PrinterSettingsView); }
public void updateSTLState(PrintModel stl2) { bool dataChanged = false; PrinterSettingsModel ps = SettingsProvider.Instance.Printer_Settings; stl2.UpdateBoundingBox(); //LinkedList<PrintModel> testList = models;//ListObjects(false); foreach (PrintModel pm in PreView.models) { pm.oldOutside = pm.outside; pm.outside = false; } foreach (PrintModel pm in PreView.models) { foreach (PrintModel pm2 in PreView.models) { if (pm == pm2) { continue; } if (pm2.bbox.IntersectsBox(pm.bbox)) { pm.outside = true; pm2.outside = true; } } } foreach (PrintModel stl in PreView.models) { if (!ps.PointInside(stl.xMin, stl.yMin, stl.zMin) || !ps.PointInside(stl.xMax, stl.yMin, stl.zMin) || !ps.PointInside(stl.xMin, stl.yMax, stl.zMin) || !ps.PointInside(stl.xMax, stl.yMax, stl.zMin) || !ps.PointInside(stl.xMin, stl.yMin, stl.zMax) || !ps.PointInside(stl.xMax, stl.yMin, stl.zMax) || !ps.PointInside(stl.xMin, stl.yMax, stl.zMax) || !ps.PointInside(stl.xMax, stl.yMax, stl.zMax)) { stl.outside = true; } } foreach (PrintModel pm in PreView.models) { if (pm.oldOutside != pm.outside) { dataChanged = true; pm.ForceViewRegeneration(); if (SettingsProvider.Instance.ThreeDSettings.pulseOutside) { if (!pm.hasAnimationWithName("pulse") && pm.outside) { pm.addAnimation(new PulseAnimation("pulse", 0.03, 0.03, 0.03, 0.3)); } if (pm.hasAnimationWithName("pulse") && !pm.outside) { pm.removeAnimationWithName("pulse"); } } } } if (dataChanged) { // listObjects.Refresh(); } }
public void Autoposition() { if (PreView.models.Count == 1) { PrintModel stl = (PrintModel)PreView.models.First(x => true); stl.Center(SettingsProvider.Instance.Printer_Settings.BedLeft + SettingsProvider.Instance.Printer_Settings.PrintAreaWidth / 2, SettingsProvider.Instance.Printer_Settings.BedFront + SettingsProvider.Instance.Printer_Settings.PrintAreaDepth / 2); return; } if (autosizeFailed) { return; } RectPacker packer = new RectPacker(1, 1); int border = 3; PrinterSettingsModel ps = SettingsProvider.Instance.Printer_Settings; float maxW = ps.PrintAreaWidth; float maxH = ps.PrintAreaDepth; float xOff = ps.BedLeft, yOff = ps.BedFront; if (ps.printerType == 1) { if (ps.DumpAreaFront <= 0) { yOff = ps.BedFront + ps.DumpAreaDepth - ps.DumpAreaFront; maxH -= yOff; } else if (ps.DumpAreaDepth + ps.DumpAreaFront >= maxH) { yOff = ps.BedFront + -(maxH - ps.DumpAreaFront); maxH += yOff; } else if (ps.DumpAreaLeft <= 0) { xOff = ps.BedLeft + ps.DumpAreaWidth - ps.DumpAreaLeft; maxW -= xOff; } else if (ps.DumpAreaWidth + ps.DumpAreaLeft >= maxW) { xOff = ps.BedLeft + maxW - ps.DumpAreaLeft; maxW += xOff; } } foreach (PrintModel stl in PreView.models) { int w = 2 * border + (int)Math.Ceiling(stl.xMax - stl.xMin); int h = 2 * border + (int)Math.Ceiling(stl.yMax - stl.yMin); if (!packer.addAtEmptySpotAutoGrow(new PackerRect(0, 0, w, h, stl), (int)maxW, (int)maxH)) { autosizeFailed = true; } } if (autosizeFailed) { System.Windows.MessageBox.Show("Too many objects on printer bed for automatic packing.\r\nPacking disabled until elements are removed.", "Printer bed full"); return; } float xAdd = (maxW - packer.w) / 2.0f; float yAdd = (maxH - packer.h) / 2.0f; foreach (PackerRect rect in packer.vRects) { PrintModel s = (PrintModel)rect.obj; float xPos = xOff + xAdd + rect.x + border; float yPos = yOff + yAdd + rect.y + border; s.Position.X += xPos - s.xMin; s.Position.Y += yPos - s.yMin; s.UpdateBoundingBox(); } }