Made any save of a file unsure that we put it in the library.
Took out dead CreateCopyInQueue code Made it possible to update the FileLocation of a PrintItem.
This commit is contained in:
parent
398bb55c22
commit
3386bba281
4 changed files with 23 additions and 74 deletions
|
|
@ -149,6 +149,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
public string FileLocation
|
||||
{
|
||||
get { return this.PrintItem.FileLocation; }
|
||||
set { this.PrintItem.FileLocation = value; }
|
||||
}
|
||||
|
||||
public int StlFileHashCode
|
||||
|
|
|
|||
|
|
@ -305,16 +305,6 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
layoutLeftToRight.AddChild(viewLink);
|
||||
}
|
||||
|
||||
// copy button
|
||||
{
|
||||
Button copyLink = linkButtonFactory.Generate(LocalizedString.Get("Copy"));
|
||||
copyLink.Click += (sender, e) =>
|
||||
{
|
||||
CreateCopyInQueue();
|
||||
};
|
||||
layoutLeftToRight.AddChild(copyLink);
|
||||
}
|
||||
|
||||
// add to library button
|
||||
{
|
||||
if (this.PrintItemWrapper.PrintItem.PrintItemCollectionID == LibraryData.Instance.LibraryCollection.Id)
|
||||
|
|
@ -454,63 +444,6 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
QueueData.Instance.AddItem(new PrintItemWrapper( new PrintItem(partToAddToQueue.Name, partToAddToQueue.FileLocation)), partToAddToQueue.insertAfterIndex);
|
||||
}
|
||||
|
||||
public void CreateCopyInQueue()
|
||||
{
|
||||
int thisIndexInQueue = QueueData.Instance.GetIndex(PrintItemWrapper);
|
||||
if (thisIndexInQueue != -1 && File.Exists(PrintItemWrapper.FileLocation))
|
||||
{
|
||||
string applicationDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath;
|
||||
string stagingFolder = Path.Combine(applicationDataPath, "data", "temp", "design");
|
||||
if (!Directory.Exists(stagingFolder))
|
||||
{
|
||||
Directory.CreateDirectory(stagingFolder);
|
||||
}
|
||||
|
||||
string newCopyFilename;
|
||||
int infiniteBlocker = 0;
|
||||
do
|
||||
{
|
||||
newCopyFilename = Path.Combine(stagingFolder, Path.ChangeExtension(Path.GetRandomFileName(), "stl"));
|
||||
newCopyFilename = Path.GetFullPath(newCopyFilename);
|
||||
infiniteBlocker++;
|
||||
} while (File.Exists(newCopyFilename) && infiniteBlocker < 100);
|
||||
|
||||
File.Copy(PrintItemWrapper.FileLocation, newCopyFilename);
|
||||
|
||||
string newName = PrintItemWrapper.Name;
|
||||
|
||||
if (!newName.Contains(" - copy"))
|
||||
{
|
||||
newName += " - copy";
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = newName.LastIndexOf(" - copy");
|
||||
newName = newName.Substring(0, index) + " - copy";
|
||||
}
|
||||
|
||||
int copyNumber = 2;
|
||||
string testName = newName;
|
||||
string[] itemNames = QueueData.Instance.GetItemNames();
|
||||
// figure out if we have a copy already and increment the number if we do
|
||||
while (true)
|
||||
{
|
||||
if (itemNames.Contains(testName))
|
||||
{
|
||||
testName = "{0} {1}".FormatWith(newName, copyNumber);
|
||||
copyNumber++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
newName = testName;
|
||||
|
||||
UiThread.RunOnIdle(AddPartToQueue, new PartToAddToQueue(newName, newCopyFilename, thisIndexInQueue + 1));
|
||||
}
|
||||
}
|
||||
|
||||
string alsoRemoveFromSdCardMessage = "Would you also like to remove this file from the Printer's SD Card?".Localize();
|
||||
string alsoRemoveFromSdCardTitle = "Remove From Printer's SD Card?";
|
||||
void DeletePartFromQueue(object state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue