Exemplo n.º 1
0
        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);
				}
			}
		}
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
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();
			}
		}
Exemplo n.º 6
0
 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();
         }
     }
 }
        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 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);
        }
Exemplo n.º 10
0
        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();
            }
        }