Added code to ensure that the Queue has unique copies of items
This commit is contained in:
parent
81d9518fcd
commit
ababc041ec
4 changed files with 107 additions and 0 deletions
|
|
@ -349,11 +349,13 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
else
|
||||
{
|
||||
DoAddItem(item, indexToInsert);
|
||||
copyQueueItemToQueueItemFolder(item.FileLocation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DoAddItem(item, indexToInsert);
|
||||
copyQueueItemToQueueItemFolder(item.FileLocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -365,6 +367,26 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
}
|
||||
}
|
||||
|
||||
private void copyQueueItemToQueueItemFolder(string fileNameToLoad)
|
||||
{
|
||||
string pathToQueueItemsFolder = Path.Combine(MatterHackers.MatterControl.DataStorage.ApplicationDataStorage.ApplicationUserDataPath, "data", "QueueItems");
|
||||
string partName = Path.GetFileName(fileNameToLoad);
|
||||
string locationToSaveTo = Path.Combine(pathToQueueItemsFolder, partName);
|
||||
|
||||
if (!Directory.Exists(pathToQueueItemsFolder))
|
||||
{
|
||||
|
||||
Directory.CreateDirectory(pathToQueueItemsFolder);
|
||||
|
||||
}
|
||||
|
||||
if (!File.Exists(locationToSaveTo))
|
||||
{
|
||||
File.Copy(fileNameToLoad, locationToSaveTo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DoAddItem(PrintItemWrapper item, int indexToInsert)
|
||||
{
|
||||
if (indexToInsert == -1)
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
itemOperationButtons.AddChild(exportItemButton);
|
||||
|
||||
Button copyItemButton = editButtonFactory.Generate("Copy".Localize());
|
||||
copyItemButton.Name = "Queue Copy Button";
|
||||
copyItemButton.Margin = new BorderDouble(3, 0);
|
||||
copyItemButton.Click += new EventHandler(copyButton_Click);
|
||||
editButtonsEnableData.Add(new ButtonEnableData(false, true));
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
{
|
||||
this.queueDataView = queueDataView;
|
||||
this.PrintItemWrapper = printItemWrapper;
|
||||
this.Name = "Queue Row Item";
|
||||
ConstructPrintQueueItem();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
savedFileName = defaultPathAndFileName;
|
||||
}
|
||||
|
||||
//Modify PrintItem list for export
|
||||
project.ProjectFiles = NewPrintItemListToExport(project.ProjectFiles);
|
||||
|
||||
|
||||
string jsonString = JsonConvert.SerializeObject(this.project, Newtonsoft.Json.Formatting.Indented);
|
||||
if (!Directory.Exists(applicationDataPath + "/data/"))
|
||||
{
|
||||
|
|
@ -137,7 +142,85 @@ namespace MatterHackers.MatterControl
|
|||
return new List<PrintItem>();
|
||||
}
|
||||
|
||||
newProject.ProjectFiles = NewPrintItemListForImport(newProject.ProjectFiles);
|
||||
|
||||
return newProject.ProjectFiles;
|
||||
}
|
||||
|
||||
public List<PrintItem> NewPrintItemListToExport(List<PrintItem> printItemList)
|
||||
{
|
||||
|
||||
List<PrintItem> newPrintItemList = new List<PrintItem>();
|
||||
|
||||
foreach (var printItem in printItemList)
|
||||
{
|
||||
|
||||
string pathToRenameForExport = printItem.FileLocation;
|
||||
string partName = Path.GetFileName(pathToRenameForExport);
|
||||
string exportedFilePath = "[QueueItems]\\" + partName;
|
||||
|
||||
PrintItem newPrintItem = new PrintItem();
|
||||
newPrintItem.DateAdded = printItem.DateAdded;
|
||||
newPrintItem.Name = printItem.Name;
|
||||
newPrintItem.PrintCount = printItem.PrintCount;
|
||||
newPrintItem.PrintItemCollectionID = printItem.PrintItemCollectionID;
|
||||
newPrintItem.ReadOnly = printItem.ReadOnly;
|
||||
newPrintItem.Protected = printItem.Protected;
|
||||
|
||||
if(pathToRenameForExport.Contains("C:\\"))
|
||||
{
|
||||
|
||||
newPrintItem.FileLocation = exportedFilePath;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
newPrintItem.FileLocation = printItem.FileLocation;
|
||||
|
||||
}
|
||||
newPrintItemList.Add(newPrintItem);
|
||||
}
|
||||
|
||||
return newPrintItemList;
|
||||
|
||||
}
|
||||
|
||||
public List<PrintItem> NewPrintItemListForImport(List<PrintItem> printItemList)
|
||||
{
|
||||
|
||||
List<PrintItem> newPrintItemList = new List<PrintItem>();
|
||||
|
||||
foreach (var printItem in printItemList)
|
||||
{
|
||||
|
||||
string userDataPath = MatterHackers.MatterControl.DataStorage.ApplicationDataStorage.ApplicationUserDataPath;
|
||||
string partName = Path.GetFileName(printItem.FileLocation);
|
||||
string pathToRenameForImport = Path.Combine(userDataPath, "data", "QueueItems");
|
||||
|
||||
PrintItem newPrintItem = new PrintItem();
|
||||
newPrintItem.DateAdded = printItem.DateAdded;
|
||||
newPrintItem.Name = printItem.Name;
|
||||
newPrintItem.PrintCount = printItem.PrintCount;
|
||||
newPrintItem.PrintItemCollectionID = printItem.PrintItemCollectionID;
|
||||
newPrintItem.ReadOnly = printItem.ReadOnly;
|
||||
newPrintItem.Protected = printItem.Protected;
|
||||
|
||||
if(printItem.FileLocation.Contains("[QueueItems]"))
|
||||
{
|
||||
newPrintItem.FileLocation = Path.Combine(pathToRenameForImport, partName);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
newPrintItem.FileLocation = printItem.FileLocation;
|
||||
}
|
||||
|
||||
newPrintItemList.Add(newPrintItem);
|
||||
}
|
||||
|
||||
return newPrintItemList;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue