public void LoadCalibrationPrints() { if (this.ActivePrinter.Make != null && this.ActivePrinter.Model != null) { // Load the calibration file names List<string> calibrationPrintFileNames = LoadCalibrationPartNamesForPrinter(this.ActivePrinter.Make, this.ActivePrinter.Model); var libraryProvider = new LibraryProviderSQLite(null, null, null, "Local Library"); libraryProvider.EnsureSamplePartsExist(calibrationPrintFileNames); var queueItems = QueueData.Instance.GetItemNames(); // Finally, ensure missing calibration parts are added to the queue if missing var filenamesWithoutExtensions = calibrationPrintFileNames.Select(f => Path.GetFileNameWithoutExtension(f)); foreach (string nameOnly in filenamesWithoutExtensions) { if (queueItems.Contains(nameOnly)) { continue; } // Find the first library item with the given name and add it to the queue PrintItem libraryItem = libraryProvider.GetLibraryItems(nameOnly).FirstOrDefault(); if (libraryItem != null) { QueueData.Instance.AddItem(new PrintItemWrapper(libraryItem)); } } libraryProvider.Dispose(); } }
public async Task LoadCalibrationPrints() { if (this.ActivePrinter.Make != null && this.ActivePrinter.Model != null) { // Load the calibration file names List<string> calibrationPrintFileNames = LoadCalibrationPartNamesForPrinter(this.ActivePrinter.Make, this.ActivePrinter.Model); using (LibraryProviderSQLite instance = new LibraryProviderSQLite(null, null, null, "Local Library")) { await instance.EnsureSamplePartsExist(calibrationPrintFileNames); } var queueItems = QueueData.Instance.GetItemNames(); // Finally, ensure missing calibration parts are added to the queue if missing var filenamesWithoutExtensions = calibrationPrintFileNames.Select(f => Path.GetFileNameWithoutExtension(f)); foreach (string nameOnly in filenamesWithoutExtensions) { if (queueItems.Contains(nameOnly)) { continue; } // If the library item does not exist in the queue, add it IEnumerable<PrintItem> libraryItems = null; using (LibraryProviderSQLite instance = new LibraryProviderSQLite(null, null, null, "Local Library")) { libraryItems = instance.GetLibraryItems(nameOnly); } foreach (PrintItem libraryItem in libraryItems) { if (libraryItem != null) { QueueData.Instance.AddItem(new PrintItemWrapper(libraryItem)); } } } } }
public void LoadCalibrationPrints() { // Load the calibration file names string calibrationFiles = ActiveSliceSettings.Instance.GetValue("calibration_files"); if(string.IsNullOrEmpty(calibrationFiles)) { return; } string[] calibrationPrintFileNames = calibrationFiles.Split(';'); if (calibrationPrintFileNames.Length < 1) { return; } var libraryProvider = new LibraryProviderSQLite(null, null, null, "Local Library"); libraryProvider.EnsureSamplePartsExist(calibrationPrintFileNames); var queueItems = QueueData.Instance.GetItemNames(); // Finally, ensure missing calibration parts are added to the queue if missing var filenamesWithoutExtensions = calibrationPrintFileNames.Select(f => Path.GetFileNameWithoutExtension(f)); foreach (string nameOnly in filenamesWithoutExtensions) { if (queueItems.Contains(nameOnly)) { continue; } // Find the first library item with the given name and add it to the queue PrintItem libraryItem = libraryProvider.GetLibraryItems(nameOnly).FirstOrDefault(); if (libraryItem != null) { QueueData.Instance.AddItem(new PrintItemWrapper(libraryItem)); } } libraryProvider.Dispose(); }