Remove all remaining ApplicationStaticDataPath dependencies
This commit is contained in:
parent
6feac79ee3
commit
59cf8782a3
9 changed files with 120 additions and 119 deletions
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
|
|
@ -8,6 +10,7 @@ using MatterHackers.MatterControl.DataStorage;
|
|||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrintQueue;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.MatterControl.PrintLibrary;
|
||||
|
||||
|
||||
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||
|
|
@ -48,17 +51,47 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
if (this.ActivePrinter.Make != null && this.ActivePrinter.Model != null)
|
||||
{
|
||||
List<string> calibrationPrints = LoadCalibrationPrintsFromFile(this.ActivePrinter.Make, this.ActivePrinter.Model);
|
||||
foreach (string partFile in calibrationPrints)
|
||||
// Load the calibration file names
|
||||
List<string> calibrationPrintFileNames = LoadCalibrationPartNamesForPrinter(this.ActivePrinter.Make, this.ActivePrinter.Model);
|
||||
|
||||
string[] itemsToAdd = LibraryData.SyncCalibrationFilesToDisk(calibrationPrintFileNames);
|
||||
if (itemsToAdd.Length > 0)
|
||||
{
|
||||
// TODO: Figure out a better way to accomplish this with Assets model
|
||||
string partFullPath = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "SampleParts", partFile);
|
||||
QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(partFullPath), partFullPath)));
|
||||
// Import any files sync'd to disk into the library, then add them to the queue
|
||||
LibraryData.Instance.LoadFilesIntoLibrary(itemsToAdd, null, (sender, e) =>
|
||||
{
|
||||
AddItemsToQueue(calibrationPrintFileNames, QueueData.Instance.GetItemNames());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, just ensure the item gets into the queue
|
||||
AddItemsToQueue(calibrationPrintFileNames, QueueData.Instance.GetItemNames());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> LoadCalibrationPrintsFromFile(string make, string model)
|
||||
private static void AddItemsToQueue(List<string> calibrationPrintFileNames, string[] queueItems)
|
||||
{
|
||||
// After the import has completed, add each of the calibration items into the print queue
|
||||
foreach (string fileName in calibrationPrintFileNames)
|
||||
{
|
||||
string nameOnly = Path.GetFileNameWithoutExtension(fileName);
|
||||
if (queueItems.Contains(nameOnly))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the library item does not exist in the queue, add it
|
||||
var libraryItem = LibraryData.Instance.GetLibraryItems(nameOnly).FirstOrDefault();
|
||||
if (libraryItem != null)
|
||||
{
|
||||
QueueData.Instance.AddItem(new PrintItemWrapper(libraryItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> LoadCalibrationPartNamesForPrinter(string make, string model)
|
||||
{
|
||||
List<string> calibrationFiles = new List<string>();
|
||||
string setupSettingsPathAndFile = Path.Combine("PrinterSettings", make, model, "calibration.ini");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue