public PrintQueueItem(string displayName, string fileLocation)
 {
     PrintItem printItem = new PrintItem();
     printItem.Name = displayName;
     printItem.FileLocation = fileLocation;
     this.PrintItemWrapper = new PrintItemWrapper(printItem);
     ConstructPrintQueueItem();
 }
		private PrintItemWrapper MakeCopyForQueue()
		{
			PrintItem printItemToCopy = PrintItemWrapper.PrintItem;
			string fileName = Path.ChangeExtension(Path.GetRandomFileName(), Path.GetExtension(printItemToCopy.FileLocation));
			string newFileLocation = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, fileName);
			File.Copy(printItemToCopy.FileLocation, newFileLocation);
			PrintItem printItemForQueue = new PrintItem(printItemToCopy.Name, newFileLocation);
			printItemForQueue.Protected = printItemToCopy.Protected;
			return new PrintItemWrapper(printItemForQueue);
		}
		public PrintItemWrapper(PrintItem printItem, List<ProviderLocatorNode> sourceLibraryProviderLocator = null)
		{
			this.PrintItem = printItem;

			if (FileLocation != null)
			{
				this.fileType = Path.GetExtension(FileLocation).ToUpper();
			}

			SourceLibraryProviderLocator = sourceLibraryProviderLocator;
		}
		private async void MergeAndSavePartsToStl()
		{
			if (MeshGroups.Count > 0)
			{
				partSelectButtonWasClicked = viewControls3D.partSelectButton.Checked;

				processingProgressControl.ProcessType = "Saving Parts:".Localize();
				processingProgressControl.Visible = true;
				processingProgressControl.PercentComplete = 0;
				LockEditControls();

				// we sent the data to the asynch lists but we will not pull it back out (only use it as a temp holder).
				PushMeshGroupDataToAsynchLists(true);

				string fileName = "TextCreator_{0}".FormatWith(Path.ChangeExtension(Path.GetRandomFileName(), ".amf"));
				string filePath = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, fileName);

				processingProgressControl.RatioComplete = 0;
				await Task.Run(() => mergeAndSavePartsBackgroundWorker_DoWork(filePath));

				PrintItem printItem = new PrintItem();

				printItem.Name = string.Format("{0}", word);
				printItem.FileLocation = Path.GetFullPath(filePath);

				PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem);

				// and save to the queue
				QueueData.Instance.AddItem(printItemWrapper);

				//Exit after save
				UiThread.RunOnIdle(CloseOnIdle);
			}
		}
		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;

		}
        public override void OnDragDrop(FileDropEventArgs fileDropEventArgs)
        {
            foreach (string droppedFileName in fileDropEventArgs.DroppedFiles)
            {
                string extension = Path.GetExtension(droppedFileName).ToUpper();
                if (extension == ".STL" || extension == ".GCODE")
                {
                    PrintItem printItem = new PrintItem();
                    printItem.Name = Path.GetFileNameWithoutExtension(droppedFileName);
                    printItem.FileLocation = Path.GetFullPath(droppedFileName);
                    printItem.PrintItemCollectionID = LibraryData.Instance.LibraryCollection.Id;
                    printItem.Commit();

                    LibraryData.Instance.AddItem(new PrintItemWrapper(printItem));
                }
            }

            base.OnDragDrop(fileDropEventArgs);
        }
        void loadFile_Click(object sender, MouseEventArgs mouseEvent)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);
            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
                    PrintItem printItem = new PrintItem();
                    printItem.Name = System.IO.Path.GetFileNameWithoutExtension(loadedFileName);
                    printItem.FileLocation = System.IO.Path.GetFullPath(loadedFileName);
                    printItem.PrintItemCollectionID = PrintLibraryListControl.Instance.LibraryCollection.Id;
                    printItem.Commit();

                    PrintLibraryListItem queueItem = new PrintLibraryListItem(new PrintItemWrapper(printItem));
                    PrintLibraryListControl.Instance.AddChild(queueItem);
                }
                PrintLibraryListControl.Instance.Invalidate();
            }
            PrintLibraryListControl.Instance.SaveLibraryItems();
        }
		private static void AddStlOrGcode(LibraryProviderQueue libraryToAddTo, string loadedFileName, string extension)
		{
			PrintItem printItem = new PrintItem();
			printItem.Name = Path.GetFileNameWithoutExtension(loadedFileName);
			printItem.FileLocation = Path.GetFullPath(loadedFileName);
			printItem.PrintItemCollectionID = libraryToAddTo.baseLibraryCollection.Id;
			printItem.Commit();

			if ((extension != "" && MeshFileIo.ValidFileExtensions().Contains(extension)))
			{
				List<MeshGroup> meshToConvertAndSave = MeshFileIo.Load(loadedFileName);

				try
				{
					PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem, libraryToAddTo);
					SaveToLibraryFolder(printItemWrapper, meshToConvertAndSave, false);
					libraryToAddTo.AddItem(printItemWrapper);
				}
				catch (System.UnauthorizedAccessException)
				{
					UiThread.RunOnIdle(() =>
					{
						//Do something special when unauthorized?
						StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes, unauthorized access", "Unable to save");
					});
				}
				catch
				{
					UiThread.RunOnIdle(() =>
					{
						StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes.", "Unable to save");
					});
				}
			}
			else // it is not a mesh so just add it
			{
				PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem, libraryToAddTo);
				if (false)
				{
					libraryToAddTo.AddItem(printItemWrapper);
				}
				else // save a copy to the library and update this to point at it
				{
					string sourceFileName = printItem.FileLocation;
					string newFileName = Path.ChangeExtension(Path.GetRandomFileName(), Path.GetExtension(printItem.FileLocation));
					string destFileName = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, newFileName);

					File.Copy(sourceFileName, destFileName, true);

					printItemWrapper.FileLocation = destFileName;
					printItemWrapper.PrintItem.Commit();

					// let the queue know that the item has changed so it load the correct part
					libraryToAddTo.AddItem(printItemWrapper);
				}
			}
		}
		private void MergeAndSavePartsDoWork(SaveAsWindow.SaveAsReturnInfo returnInfo)
		{
			if (returnInfo != null)
			{
				PrintItem printItem = new PrintItem();
				printItem.Name = returnInfo.newName;
				printItem.FileLocation = Path.GetFullPath(returnInfo.fileNameAndPath);
				printItemWrapper = new PrintItemWrapper(printItem, returnInfo.destinationLibraryProvider.GetProviderLocator());
			}

			// we sent the data to the async lists but we will not pull it back out (only use it as a temp holder).
			PushMeshGroupDataToAsynchLists(TraceInfoOpperation.DO_COPY);

			Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
			try
			{
				// push all the transforms into the meshes
				for (int i = 0; i < asyncMeshGroups.Count; i++)
				{
					asyncMeshGroups[i].Transform(asyncMeshGroupTransforms[i]);

					bool continueProcessing;
					ReportProgressChanged((i + 1) * .4 / asyncMeshGroups.Count, "", out continueProcessing);
				}

				string[] metaData = { "Created By", "MatterControl", "BedPosition", "Absolute" };

				MeshOutputSettings outputInfo = new MeshOutputSettings(MeshOutputSettings.OutputType.Binary, metaData);

				// If null we are replacing a file from the current print item wrapper
				if (returnInfo == null)
				{
					var fileInfo = new FileInfo(printItemWrapper.FileLocation);

					bool requiresTypeChange = !fileInfo.Extension.Equals(".amf", StringComparison.OrdinalIgnoreCase);
					if (requiresTypeChange && !printItemWrapper.UseIncrementedNameDuringTypeChange)
					{
						// Not using incremented file name, simply change to AMF
						printItemWrapper.FileLocation = Path.ChangeExtension(printItemWrapper.FileLocation, ".amf");
					}
					else if (requiresTypeChange)
					{
						string newFileName;
						string incrementedFileName;

						// Switching from .stl, .obj or similar to AMF. Save the file and update the
						// the filename with an incremented (n) value to reflect the extension change in the UI 
						string fileName = Path.GetFileNameWithoutExtension(fileInfo.Name);

						// Drop bracketed number sections from our source filename to ensure we don't generate something like "file (1) (1).amf"
						if (fileName.Contains("("))
						{
							fileName = fileNameNumberMatch.Replace(fileName, "").Trim();
						}

						// Generate and search for an incremented file name until no match is found at the target directory
						int foundCount = 0;
						do
						{
							newFileName = string.Format("{0} ({1})", fileName, ++foundCount);
							incrementedFileName = Path.Combine(fileInfo.DirectoryName, newFileName + ".amf");

							// Continue incrementing while any matching file exists
						} while (Directory.GetFiles(fileInfo.DirectoryName, newFileName + ".*").Any());

						// Change the FileLocation to the new AMF file
						printItemWrapper.FileLocation = incrementedFileName;
					}

					try
					{
						// get a new location to save to
						string tempFileNameToSaveTo = ApplicationDataStorage.Instance.GetTempFileName("amf");

						// save to the new temp location
						bool savedSuccessfully = MeshFileIo.Save(asyncMeshGroups, tempFileNameToSaveTo, outputInfo, ReportProgressChanged);

						// Swap out the files if the save operation completed successfully 
						if (savedSuccessfully && File.Exists(tempFileNameToSaveTo))
						{
							// Ensure the target path is clear
							if(File.Exists(printItemWrapper.FileLocation))
							{
								File.Delete(printItemWrapper.FileLocation);
							}

							// Move the newly saved file back into place
							File.Move(tempFileNameToSaveTo, printItemWrapper.FileLocation);

							// Once the file is swapped back into place, update the PrintItem to account for extension change
							printItemWrapper.PrintItem.Commit();
						}
					}
					catch(Exception ex)
					{
						Trace.WriteLine("Error saving file: ", ex.Message);
					}
				}
				else // we are saving a new file and it will not exist until we are done
				{
					MeshFileIo.Save(asyncMeshGroups, printItemWrapper.FileLocation, outputInfo, ReportProgressChanged);
				}

				// Wait for a second to report the file changed to give the OS a chance to finish closing it.
				UiThread.RunOnIdle(printItemWrapper.ReportFileChange, 3);

				if (returnInfo != null
					&& returnInfo.destinationLibraryProvider != null)
				{
					// save this part to correct library provider
					LibraryProvider libraryToSaveTo = returnInfo.destinationLibraryProvider;
					if (libraryToSaveTo != null)
					{
						libraryToSaveTo.AddItem(printItemWrapper);
						libraryToSaveTo.Dispose();
					}
				}
				else // we have already saved it and the library should pick it up
				{
				}

				saveSucceded = true;
			}
			catch (System.UnauthorizedAccessException e2)
			{
				Debug.Print(e2.Message);
				GuiWidget.BreakInDebugger();
				saveSucceded = false;
				UiThread.RunOnIdle(() =>
				{
					//Do something special when unauthorized?
					StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes.", "Unable to save");
				});
			}
			catch (Exception e)
			{
				Debug.Print(e.Message);
				GuiWidget.BreakInDebugger();
				saveSucceded = false;
				UiThread.RunOnIdle(() =>
				{
					StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes.", "Unable to save");
				});
			}
		}
 void PreloadLibrary()
 {
     foreach (string partFile in OemSettings.Instance.PreloadedLibraryFiles)
     {
         string partFullPath = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "SampleParts", partFile);
         if (System.IO.File.Exists(partFullPath))
         {
             PrintItem printItem = new PrintItem();
             printItem.Name = Path.GetFileNameWithoutExtension(partFullPath);
             printItem.FileLocation = Path.GetFullPath(partFullPath);
             printItem.PrintItemCollectionID = LibraryCollection.Id;
             printItem.Commit();
         }
     }
 }
		public void MoveSelectedToBottom()
		{
			if (SelectedIndex >= 0 && SelectedIndex < Count)
			{
				int currentIndex = SelectedIndex;
				PrintItem replacementItem = new PrintItem(SelectedPrintItem.Name, SelectedPrintItem.FileLocation);
				QueueData.Instance.RemoveAt(SelectedIndex);
				this.SelectedIndex = currentIndex;
			}
		}
		private void MergeAndSavePartsDoWork(SaveAsWindow.SaveAsReturnInfo returnInfo)
		{
			if (returnInfo != null)
			{
				PrintItem printItem = new PrintItem();
				printItem.Name = returnInfo.newName;
				printItem.FileLocation = Path.GetFullPath(returnInfo.fileNameAndPath);
				printItemWrapper = new PrintItemWrapper(printItem, returnInfo.destinationLibraryProvider.GetProviderLocator());
			}

			// we sent the data to the asynch lists but we will not pull it back out (only use it as a temp holder).
			PushMeshGroupDataToAsynchLists(TraceInfoOpperation.DO_COPY);

			Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
			try
			{
				// push all the transforms into the meshes
				for (int i = 0; i < asynchMeshGroups.Count; i++)
				{
					asynchMeshGroups[i].Transform(asynchMeshGroupTransforms[i].TotalTransform);

					bool continueProcessing;
					ReportProgressChanged((i + 1) * .4 / asynchMeshGroups.Count, "", out continueProcessing);
				}

				saveSucceded = true;

				string[] metaData = { "Created By", "MatterControl", "BedPosition", "Absolute" };

				MeshOutputSettings outputInfo = new MeshOutputSettings(MeshOutputSettings.OutputType.Binary, metaData);
				if (Path.GetExtension(printItemWrapper.FileLocation).ToUpper() == ".STL")
				{
					printItemWrapper.FileLocation = Path.ChangeExtension(printItemWrapper.FileLocation, ".AMF");
				}

				MeshFileIo.Save(asynchMeshGroups, printItemWrapper.FileLocation, outputInfo);

				printItemWrapper.ReportFileChange();

				if (returnInfo != null
					&& returnInfo.destinationLibraryProvider != null)
				{
					// save this part to correct library provider
					LibraryProvider libraryToSaveTo = returnInfo.destinationLibraryProvider;
					if (libraryToSaveTo != null)
					{
						libraryToSaveTo.AddItem(printItemWrapper);
						libraryToSaveTo.Dispose();
					}
				}
				else // we have already save it and the library should pick it up
				{

				}
			}
			catch (System.UnauthorizedAccessException e2)
			{
				Debug.Print(e2.Message);
				GuiWidget.BreakInDebugger();
				saveSucceded = false;
				UiThread.RunOnIdle(() =>
				{
					//Do something special when unauthorized?
					StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes.", "Unable to save");
				});
			}
			catch(Exception e)
			{
				Debug.Print(e.Message);
				GuiWidget.BreakInDebugger();
				saveSucceded = false;
				UiThread.RunOnIdle(() =>
				{
					StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes.", "Unable to save");
				});
			}
		}
        void mergeAndSavePartsBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            string filePath = e.Result as string;
            if (filePath != null)
            {
                PrintItem printItem = new PrintItem();
                printItem.Commit();

                printItem.Name = string.Format("{0}", word);
                printItem.FileLocation = Path.GetFullPath(filePath);
                printItem.PrintItemCollectionID = LibraryData.Instance.LibraryCollection.Id;
                printItem.Commit();

                PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem);

                LibraryData.Instance.AddItem(printItemWrapper);

                // and save to the queue
                {
                    QueueData.Instance.AddItem(printItemWrapper);
                }
            }

            //Exit after save
            Close();
        }
        void loadFile_ClickOnIdle(object state)
        {
            OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file, Select a GCODE file|*.stl;*.gcode", multiSelect: true);
            FileDialog.OpenFileDialog(ref openParams);
            if (openParams.FileNames != null)
            {
                foreach (string loadedFileName in openParams.FileNames)
                {
                    PrintItem printItem = new PrintItem();
                    printItem.Name = Path.GetFileNameWithoutExtension(loadedFileName);
                    printItem.FileLocation = Path.GetFullPath(loadedFileName);
                    printItem.PrintItemCollectionID = LibraryData.Instance.LibraryCollection.Id;
                    printItem.Commit();

                    LibraryData.Instance.AddItem(new PrintItemWrapper(printItem));
                }
            }
        }
			public SaveAsReturnInfo(string newName, string fileNameAndPath, LibraryProvider destinationLibraryProvider)
			{
				this.newName = newName;
				this.fileNameAndPath = fileNameAndPath;

				PrintItem printItem = new PrintItem();
				printItem.Name = newName;
				printItem.FileLocation = Path.GetFullPath(fileNameAndPath);

				printItemWrapper = new PrintItemWrapper(printItem, destinationLibraryProvider);
			}
		public void CreateCopyInQueue()
		{
			// Guard for single item selection
			if (this.queueDataView.SelectedItems.Count != 1) return;

			var queueRowItem = this.queueDataView.SelectedItems[0];

			var printItemWrapper = queueRowItem.PrintItemWrapper;

			int thisIndexInQueue = QueueData.Instance.GetIndex(printItemWrapper);
			if (thisIndexInQueue != -1 && File.Exists(printItemWrapper.FileLocation))
			{
				string libraryDataPath = ApplicationDataStorage.Instance.ApplicationLibraryDataPath;
				if (!Directory.Exists(libraryDataPath))
				{
					Directory.CreateDirectory(libraryDataPath);
				}

				string newCopyFilename;
				int infiniteBlocker = 0;
				do
				{
					newCopyFilename = Path.Combine(libraryDataPath, Path.ChangeExtension(Path.GetRandomFileName(), Path.GetExtension(printItemWrapper.FileLocation)));
					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;

				PrintItem newPrintItem = new PrintItem();
				newPrintItem.Name = newName;
				newPrintItem.FileLocation = newCopyFilename;
				newPrintItem.ReadOnly = printItemWrapper.PrintItem.ReadOnly;
				newPrintItem.Protected = printItemWrapper.PrintItem.Protected;
				UiThread.RunOnIdle(AddPartCopyToQueue, new PartToAddToQueue()
				{
					PrintItem = newPrintItem,
					InsertAfterIndex = thisIndexInQueue + 1
				});
			}
		}
Exemple #17
0
			public SaveAsReturnInfo(string newName, string fileNameAndPath, bool placeInLibrary)
			{
				this.newName = newName;
				this.fileNameAndPath = fileNameAndPath;
				this.placeInLibrary = placeInLibrary;

				PrintItem printItem = new PrintItem();
				printItem.Name = newName;
				printItem.FileLocation = Path.GetFullPath(fileNameAndPath);
				printItem.PrintItemCollectionID = LibraryData.Instance.LibraryCollection.Id;
				printItem.Commit();

				printItemWrapper = new PrintItemWrapper(printItem);
			}
		protected virtual void AddStlOrGcode(string loadedFileName, string displayName)
		{
			string extension = Path.GetExtension(loadedFileName).ToUpper();

			PrintItem printItem = new PrintItem();
			printItem.Name = displayName;
			printItem.FileLocation = Path.GetFullPath(loadedFileName);
			printItem.PrintItemCollectionID = this.baseLibraryCollection.Id;
			printItem.Commit();

			if ((extension != "" && MeshFileIo.ValidFileExtensions().Contains(extension)))
			{
				List<MeshGroup> meshToConvertAndSave = MeshFileIo.Load(loadedFileName);

				try
				{
					PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem, this);
					SaveToLibraryFolder(printItemWrapper, meshToConvertAndSave, false);
				}
				catch (System.UnauthorizedAccessException)
				{
					UiThread.RunOnIdle(() =>
					{
						//Do something special when unauthorized?
						StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes, unauthorized access", "Unable to save");
					});
				}
				catch
				{
					UiThread.RunOnIdle(() =>
					{
						StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes.", "Unable to save");
					});
				}
			}
			else // it is not a mesh so just add it
			{
				PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem, this);
				string sourceFileName = printItem.FileLocation;
				string newFileName = Path.ChangeExtension(Path.GetRandomFileName(), Path.GetExtension(printItem.FileLocation));
				string destFileName = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, newFileName);

				File.Copy(sourceFileName, destFileName, true);

				printItemWrapper.FileLocation = destFileName;
				printItemWrapper.PrintItem.Commit();
			}
		}
		private void OpenPartPreviewWindow(PrintItem printItem, View3DWidget.AutoRotate autoRotate)
		{
			PrintItemWrapper itemWrapper = new PrintItemWrapper(printItem.Id);
			if (partPreviewWindow == null)
			{
				partPreviewWindow = new PartPreviewMainWindow(itemWrapper, autoRotate);
				partPreviewWindow.Closed += new EventHandler(PartPreviewWindow_Closed);
			}
			else
			{
				partPreviewWindow.BringToFront();
			}
		}
        public override void OnDragDrop(FileDropEventArgs fileDropEventArgs)
        {
            foreach (string droppedFileName in fileDropEventArgs.DroppedFiles)
            {
                string extension = Path.GetExtension(droppedFileName).ToUpper();
                if (extension == ".STL" || extension == ".GCODE")
                {
                    PrintItem printItem = new PrintItem();
                    printItem.Name = System.IO.Path.GetFileNameWithoutExtension(droppedFileName);
                    printItem.FileLocation = System.IO.Path.GetFullPath(droppedFileName);
                    printItem.PrintItemCollectionID = PrintLibraryListControl.Instance.LibraryCollection.Id;
                    printItem.Commit();

                    PrintLibraryListItem queueItem = new PrintLibraryListItem(new PrintItemWrapper(printItem));
                    PrintLibraryListControl.Instance.AddChild(queueItem);
                }
                PrintLibraryListControl.Instance.Invalidate();
            }
            PrintLibraryListControl.Instance.SaveLibraryItems();

            base.OnDragDrop(fileDropEventArgs);
        }
		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;

		}
		private PrintItem GetPrintItemFromFile(string fileName, string displayName)
		{
			PrintItem item = new PrintItem();
			item.FileLocation = fileName;
			item.Name = displayName;
			return item;
		}
        private void SubmitForm()
        {
            string newName = textToAddWidget.ActualTextEditWidget.Text;
            if (newName != "")
            {
                string fileName = "{0}.stl".FormatWith(Path.GetRandomFileName());
                string fileNameAndPath = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, fileName);

                PrintItem printItem = new PrintItem();
                printItem.Name = newName;
                printItem.FileLocation = Path.GetFullPath(fileNameAndPath);
                printItem.PrintItemCollectionID = LibraryData.Instance.LibraryCollection.Id;
                printItem.Commit();

                PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem);
                QueueData.Instance.AddItem(printItemWrapper);

                if (addToLibraryOption.Checked)
                {
                    LibraryData.Instance.AddItem(printItemWrapper);
                }

                functionToCallOnSaveAs(printItemWrapper);
                CloseOnIdle();
            }
        }