private void RenderJob() { this.Enabled = false; var t = new BackgroundWorker(); _waitWindowManager = new WaitWindowManager(); _waitWindowManager.Start(this, t); if (t != null) { t.ReportProgress(0, new WaitWindowUserState(0.01d, "Loading calibration model")); } Application.DoEvents(); t.DoWork += new DoWorkEventHandler(RenderJobAsync); //load calibration model ObjectView.Objects3D.Clear(); SceneView.UpdateGroundPane(); //ZIE ONDER //SavePrinter = PrinterManager.DefaultPrinter; this._selectedPrinter.Selected = true; PrinterManager.Append((AtumPrinter)(this._selectedPrinter)); PrinterManager.SetDefaultPrinter((AtumPrinter)this._selectedPrinter); BasicCorrectionModel basicCorrection = new BasicCorrectionModel(); basicCorrection.Open((string)null, false, printerConnectionMaterialTabPanel1.SelectedMaterial.ModelColor, ObjectView.NextObjectIndex, basicCorrection.Triangles); basicCorrection.UpdateBoundries(); basicCorrection.UpdateSelectionboxText(); if (ObjectView.BindingSupported) { basicCorrection.BindModel(); } ObjectView.AddModel((object)basicCorrection); Application.DoEvents(); // System.Threading.Thread.Sleep(250); //let op hier nog op null printer (initieel) checken t.RunWorkerAsync(); }
private void RenderJob(Material selectedMaterial, AtumPrinter selectedPrinter, DriveInfo selectedDrive) { //load calibration model for (var objectViewModelIndex = ObjectView.Objects3D.Count - 1; objectViewModelIndex > 1; objectViewModelIndex--) { ObjectView.Objects3D.RemoveAt(objectViewModelIndex); } RenderEngine.PrintJob = new DAL.Print.PrintJob(); RenderEngine.PrintJob.Name = "Calibration"; RenderEngine.PrintJob.Material = selectedMaterial; RenderEngine.PrintJob.SelectedPrinter = this.AtumPrinter; var basicCorrection = new BasicCorrectionModel(); basicCorrection.Open((string)null, false, selectedMaterial.ModelColor, ObjectView.NextObjectIndex, basicCorrection.Triangles, enableProgressStatus: false); basicCorrection.UpdateBoundries(); for (var modelIndex = ObjectView.Objects3D.Count - 1; modelIndex > 0; modelIndex--) { ObjectView.Objects3D.RemoveAt(modelIndex); } ObjectView.AddModel(basicCorrection, false, false, false); RenderEngine.RenderAsync(); try { while (RenderEngine.TotalAmountSlices != RenderEngine.TotalProcessedSlices && !RenderEngine.PrintJob.PostRenderCompleted) { var progress = (((decimal)RenderEngine.TotalProcessedSlices / (decimal)RenderEngine.TotalAmountSlices) * 100); Thread.Sleep(250); } } catch (Exception exc) { Atum.DAL.Managers.LoggingManager.WriteToLog("GeneratePrintJobAsync", "Exc", exc); new frmMessageBox("GeneratePrintJobAsync", exc.Message, MessageBoxButtons.OK, MessageBoxDefaultButton.Button2).ShowDialog(); } try { var usbPrintjobPath = string.Format(@"{0}{1}", selectedDrive.Name, RenderEngine.PrintJob.Name); var pathPrinterJobXml = Path.Combine(Path.GetTempPath(), "printjob.xml"); //serialize first to temp var serializer = new System.Xml.Serialization.XmlSerializer(typeof(DAL.Print.PrintJob)); using (var streamWriter = new StreamWriter(pathPrinterJobXml, false)) { serializer.Serialize(streamWriter, RenderEngine.PrintJob); } var pathPrinterJobChecksumXml = Path.Combine(System.IO.Path.GetTempPath(), "checksum.crc"); using (var checksumWriter = new StreamWriter(pathPrinterJobChecksumXml, false)) { checksumWriter.WriteLine(DateTime.Now.Ticks.ToString()); } var osPathSeparator = "\\"; if (!Directory.Exists(usbPrintjobPath)) { Directory.CreateDirectory(usbPrintjobPath); } var zipCopied = false; while (!zipCopied) { try { File.Copy(RenderEngine.PrintJob.SlicesPath, usbPrintjobPath + osPathSeparator + "slices.zip", true); File.Copy(pathPrinterJobXml, usbPrintjobPath + osPathSeparator + "printjob.apj", true); File.Copy(pathPrinterJobChecksumXml, usbPrintjobPath + osPathSeparator + "checksum.crc", true); zipCopied = true; } catch { Thread.Sleep(250); } } } catch (Exception exc) { new frmMessageBox("Failed to save printjob", "Failed to save printjob", MessageBoxButtons.OK, MessageBoxDefaultButton.Button2).ShowDialog(); } }