private RecentPrintsHistory.PrintHistory GatherData() { PrintJobDetails printJobDetails = printerview.CreatePrintJobDetails(out var modelZTooSmall); printJobDetails.GenerateSlicerSettings(null, printerview); var splitFileName = new SplitFileName(printJobDetails.objectDetailsList[0].filename); var printerJob = new JobParams("", splitFileName.name + "." + splitFileName.ext, printJobDetails.preview_image, FilamentSpool.TypeEnum.NoFilament, 0.0f, 0.0f) { options = printJobDetails.jobOptions, preprocessor = null, filament_temperature = 0, autoprint = printJobDetails.autoPrint }; List <Slicer.General.KeyValuePair <string, string> > keyValuePairList = slicer_connection.SlicerSettings.GenerateUserKeyValuePairList(); foreach (PrintDetails.ObjectDetails objectDetails in printJobDetails.objectDetailsList) { if (printJobDetails.autoPrint) { objectDetails.hidecontrols = true; } } RecentPrintsHistory.CreatePrintHistoryFolder(printerJob, null, slicer_connection.SlicerSettings.ProfileName, keyValuePairList, printJobDetails.objectDetailsList, out RecentPrintsHistory.PrintHistory cph); return(cph); }
public bool AddModelToRecent(string fileName, string icon) { var splitFileName = new SplitFileName(fileName); var recentRecord = new RecentModelHistory.RecentRecord(fileName, splitFileName.name + "." + splitFileName.ext, icon); for (var index = 0; index < m_thedatabaseRecent.Count; ++index) { if (m_thedatabaseRecent[index].cachefilename != null && m_thedatabaseRecent[index].cachefilename.Equals(recentRecord.cachefilename, StringComparison.OrdinalIgnoreCase)) { if (string.IsNullOrEmpty(icon) && !string.IsNullOrEmpty(m_thedatabaseRecent[index].iconfilename)) { recentRecord.iconfilename = m_thedatabaseRecent[index].iconfilename; } else if (!string.IsNullOrEmpty(m_thedatabaseRecent[index].iconfilename) && !m_thedatabaseRecent[index].iconfilename.Equals(recentRecord.iconfilename)) { if (File.Exists(m_thedatabaseRecent[index].iconfilename)) { try { File.Delete(m_thedatabaseRecent[index].iconfilename); } catch (IOException ex) { } } } m_thedatabaseRecent.RemoveAt(index); break; } } m_thedatabaseRecent.Insert(0, recentRecord); SaveRecentData(); return(true); }
private string GenerateCacheFileName(string filename) { var splitFileName = new SplitFileName(filename); var guid = Guid.NewGuid(); return(splitFileName.name + guid.ToString().Substring(0, 18) + splitFileName.ext); }
private string GenerateIconFileName(string modelname) { var splitFileName = new SplitFileName(modelname); var str = Path.Combine(Paths.PublicDataFolder, "MyLibrary", "Icons"); if (!Directory.Exists(str)) { Directory.CreateDirectory(str); } var num = DateTime.Now.Ticks / 10000L; return(Path.Combine(str, splitFileName.name + num.ToString() + ".png")); }
public void PrintSlicedModel(PrintJobDetails currentJobDetails, RecentPrintsTab recentPrints, AsyncCallback OnPrintJobStarted) { var gcodefile = Path.Combine(Paths.WorkingFolder, "m3doutput.gcode"); var filepath = "M3D.M3D"; foreach (PrintDetails.ObjectDetails objectDetails in currentJobDetails.objectDetailsList) { if (currentJobDetails.autoPrint) { objectDetails.hidecontrols = true; } filepath = objectDetails.filename; } var splitFileName = new SplitFileName(filepath); var jobParams = new JobParams(gcodefile, splitFileName.name + "." + splitFileName.ext, currentJobDetails.preview_image, FilamentSpool.TypeEnum.OtherOrUnknown, (int)currentJobDetails.Estimated_Print_Time, currentJobDetails.Estimated_Filament) { options = currentJobDetails.jobOptions, preprocessor = currentJobDetails.printer.MyFilamentProfile.preprocessor, filament_temperature = currentJobDetails.printer.MyFilamentProfile.Temperature, autoprint = currentJobDetails.autoPrint }; List <Slicer.General.KeyValuePair <string, string> > keyValuePairList = SlicerSettings.GenerateUserKeyValuePairList(); SettingsManager.SavePrintingObjectsDetails(jobParams, currentJobDetails.objectDetailsList); SettingsManager.SavePrintJobInfo(jobParams, currentJobDetails.printer, SlicerSettings.ProfileName, SlicerSettings.GenerateUserKeyValuePairList()); recentPrints?.AddRecentPrintHistory(jobParams, currentJobDetails.printer, SlicerSettings.ProfileName, keyValuePairList, currentJobDetails.objectDetailsList); if (currentJobDetails.print_to_file) { jobParams.outputfile = currentJobDetails.printToFileOutputFile; jobParams.jobMode = JobParams.Mode.SaveToBinaryGCodeFile; } else if (currentJobDetails.auto_untethered_print) { jobParams.jobMode = !currentJobDetails.sdSaveOnly_print ? JobParams.Mode.SavingToSDCardAutoStartPrint : JobParams.Mode.SavingToSDCard; } var num = (int)currentJobDetails.printer.PrintModel(OnPrintJobStarted, currentJobDetails.printer, jobParams); }
private static ModelImporterInterface GetModelLoader(string fileName) { var lowerInvariant = new SplitFileName(fileName).ext.ToLowerInvariant(); var importerInterface = (ModelImporterInterface)null; if (lowerInvariant == "stl") { importerInterface = new ModelSTLImporter(); } else if (lowerInvariant == "obj") { importerInterface = new ModelOBJImporter(); } else if (lowerInvariant == "m3d") { importerInterface = new ModelM3DImporter(); } else if (lowerInvariant == "smf") { importerInterface = new ModelSMFImporter(); } return(importerInterface); }