public PartPreviewMainWindow(PrintItemWrapper printItem, View3DWidget.AutoRotate autoRotate3DView, View3DWidget.OpenMode openMode = View3DWidget.OpenMode.Viewing) : base(750, 550) { UseOpenGL = true; string partPreviewTitle = LocalizedString.Get("MatterControl"); Title = string.Format("{0}: ", partPreviewTitle) + Path.GetFileName(printItem.Name); this.Name = "Part Preview Window"; partPreviewWidget = new PartPreviewContent(printItem, View3DWidget.WindowMode.StandAlone, autoRotate3DView, openMode); partPreviewWidget.Closed += (sender, e) => { Close(); }; this.AddChild(partPreviewWidget); AddHandlers(); Width = 750; Height = 550; MinimumSize = new Vector2(400, 300); ShowAsSystemWindow(); }
public void Start() { if (PrintQueueControl.Instance.Count > 0) { if (StartingNextPart != null) { StartingNextPart(this, new StringEventArgs(ItemNameBeingWorkedOn)); } savedGCodeFileNames = new List<string>(); allFilesToExport = PrintQueueControl.Instance.CreateReadOnlyPartList(); foreach (PrintItem part in allFilesToExport) { PrintItemWrapper printItemWrapper = new PrintItemWrapper(part); if (System.IO.Path.GetExtension(part.FileLocation).ToUpper() == ".STL") { SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper); printItemWrapper.Done += new EventHandler(sliceItem_Done); printItemWrapper.SlicingOutputMessage += printItemWrapper_SlicingOutputMessage; } else if (System.IO.Path.GetExtension(part.FileLocation).ToUpper() == ".GCODE") { sliceItem_Done(printItemWrapper, null); } } } }
static public void SaveToLibraryFolder2(PrintItemWrapper printItemWrapper, List<MeshGroup> meshGroups, bool AbsolutePositioned) { string[] metaData = { "Created By", "MatterControl" }; if (AbsolutePositioned) { metaData = new string[] { "Created By", "MatterControl", "BedPosition", "Absolute" }; } if (printItemWrapper.FileLocation.Contains(ApplicationDataStorage.Instance.ApplicationLibraryDataPath)) { MeshOutputSettings outputInfo = new MeshOutputSettings(MeshOutputSettings.OutputType.Binary, metaData); MeshFileIo.Save(meshGroups, printItemWrapper.FileLocation, outputInfo); } else // save a copy to the library and update this to point at it { string fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".amf"); printItemWrapper.FileLocation = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, fileName); MeshOutputSettings outputInfo = new MeshOutputSettings(MeshOutputSettings.OutputType.Binary, metaData); MeshFileIo.Save(meshGroups, printItemWrapper.FileLocation, outputInfo); printItemWrapper.PrintItem.Commit(); // let the queue know that the item has changed so it load the correct part QueueData.Instance.SaveDefaultQueue(); } printItemWrapper.OnFileHasChanged(); }
public LibraryThumbnailWidget(PrintItemWrapper item, string noThumbnailFileName, string buildingThumbnailFileName, Vector2 size) { this.PrintItem = item; // Set Display Attributes this.Margin = new BorderDouble(0); this.Padding = new BorderDouble(5); this.Width = size.x; this.Height = size.y; this.MinimumSize = size; this.BackgroundColor = normalBackgroundColor; this.Cursor = Cursors.Hand; // set background images if (noThumbnailImage.Width == 0) { ImageBMPIO.LoadImageData(this.GetImageLocation(noThumbnailFileName), noThumbnailImage); ImageBMPIO.LoadImageData(this.GetImageLocation(buildingThumbnailFileName), buildingThumbnailImage); } this.image = new ImageBuffer(buildingThumbnailImage); // Add Handlers this.Click += new ButtonEventHandler(onMouseClick); this.MouseEnterBounds += new EventHandler(onEnter); this.MouseLeaveBounds += new EventHandler(onExit); ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents); CreateThumNailThreadIfNeeded(); }
public PartPreviewMainWindow(PrintItemWrapper printItem, View3DWidget.AutoRotate autoRotate3DView, View3DWidget.OpenMode openMode = View3DWidget.OpenMode.Viewing) : base(690, 340) { UseOpenGL = true; string partPreviewTitle = LocalizedString.Get("MatterControl"); Title = string.Format("{0}: ", partPreviewTitle) + Path.GetFileName(printItem.Name); partPreviewWidget = new PartPreviewContent(printItem, View3DWidget.WindowMode.StandAlone, autoRotate3DView, openMode); partPreviewWidget.Closed += (sender, e) => { Close(); }; #if __ANDROID__ TerminalWidget terminalWidget = new TerminalWidget(true); this.AddChild(new SoftKeyboardContentOffset(partPreviewWidget, SoftKeyboardContentOffset.AndroidKeyboardOffset)); //mainContainer.Closed += (sender, e) => { Close(); }; #else this.AddChild(partPreviewWidget); #endif AddHandlers(); Width = 640; Height = 480; MinimumSize = new Vector2(400, 300); ShowAsSystemWindow(); }
public PrintQueueItem(string displayName, string fileLocation) { PrintItem printItem = new PrintItem(); printItem.Name = displayName; printItem.FileLocation = fileLocation; this.PrintItemWrapper = new PrintItemWrapper(printItem); ConstructPrintQueueItem(); }
public GcodeViewBasic(PrintItemWrapper printItem, GetSizeFunction bedSizeFunction, GetSizeFunction bedCenterFunction) { this.printItem = printItem; this.bedSizeFunction = bedSizeFunction; this.bedCenterFunction = bedCenterFunction; CreateAndAddChildren(null); }
public void QueuePartForSlicing(PrintItemWrapper itemToQueue) { itemToQueue.DoneSlicing = false; string preparingToSliceModelTxt = new LocalizedString("Preparing to slice model").Translated; string peparingToSliceModelFull = string.Format ("{0}...", preparingToSliceModelTxt); itemToQueue.OnSlicingOutputMessage(new StringEventArgs(peparingToSliceModelFull)); using (TimedLock.Lock(listOfSlicingItems, "QueuePartForSlicing")) { //Add to thumbnail generation queue listOfSlicingItems.Add(itemToQueue); } }
//PartPreview3DGcode part3DGcodeView; public PartPreviewMainWindow(PrintItemWrapper printItem) : base(690, 340) { string partPreviewTitle = new LocalizedString ("MatterControl").Translated; Title = string.Format("{0}: ", partPreviewTitle) + Path.GetFileName(printItem.Name); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; TabControl tabControl = new TabControl(); tabControl.TabBar.BorderColor = new RGBA_Bytes(0, 0, 0, 0); tabControl.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; double buildHeight = ActiveSliceSettings.Instance.BuildHeight; string part3DViewLblBeg = ("3D"); string part3DViewLblEnd = new LocalizedString ("View").Translated; string part3DViewLblFull = string.Format("{0} {1} ", part3DViewLblBeg, part3DViewLblEnd); part3DView = new View3DTransformPart(printItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedShape); TabPage partPreview3DView = new TabPage(part3DView, part3DViewLblFull); partGcodeView = new GcodeViewBasic(printItem, ActiveSliceSettings.Instance.GetBedSize, ActiveSliceSettings.Instance.GetBedCenter); TabPage layerView = new TabPage(partGcodeView, new LocalizedString("Layer View").Translated); //part3DGcodeView = new PartPreview3DGcode(printItem.FileLocation, bedXSize, bedYSize); tabControl.AddTab(new SimpleTextTabWidget(partPreview3DView , 16, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes())); tabControl.AddTab(new SimpleTextTabWidget(layerView, 16, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes())); this.AddChild(tabControl); this.AnchorAll(); AddHandlers(); Width = 640; Height = 480; ShowAsSystemWindow(); MinimumSize = new Vector2(400, 300); // We do this after showing the system window so that when we try and take fucus the parent window (the system window) // exists and can give the fucus to its child the gecode window. if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") { tabControl.TabBar.SwitchToPage(layerView); partGcodeView.Focus(); } }
public PartThumbnailWidget(PrintItemWrapper item, string noThumbnailFileName, string buildingThumbnailFileName, ImageSizes size) { ToolTipText = "Click to show in 3D View".Localize(); this.ItemWrapper = item; // Set Display Attributes this.Margin = new BorderDouble(0); this.Padding = new BorderDouble(5); Size = size; switch (size) { case ImageSizes.Size50x50: this.Width = 50 * GuiWidget.DeviceScale; this.Height = 50 * GuiWidget.DeviceScale; break; case ImageSizes.Size115x115: this.Width = 115 * GuiWidget.DeviceScale; this.Height = 115 * GuiWidget.DeviceScale; break; default: throw new NotImplementedException(); } this.MinimumSize = new Vector2(this.Width, this.Height); this.BackgroundColor = normalBackgroundColor; this.Cursor = Cursors.Hand; this.ToolTipText = "Click to show in 3D View".Localize(); // set background images if (noThumbnailImage.Width == 0) { StaticData.Instance.LoadIcon(noThumbnailFileName, noThumbnailImage); noThumbnailImage.InvertLightness(); StaticData.Instance.LoadIcon(buildingThumbnailFileName, buildingThumbnailImage); buildingThumbnailImage.InvertLightness(); } this.thumbnailImage = new ImageBuffer(buildingThumbnailImage); // Add Handlers this.Click += DoOnMouseClick; this.MouseEnterBounds += onEnter; this.MouseLeaveBounds += onExit; ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); }
public PartPreviewContent(PrintItemWrapper printItem, View3DWidget.WindowMode windowMode, View3DWidget.AutoRotate autoRotate3DView, View3DWidget.OpenMode openMode = View3DWidget.OpenMode.Viewing) { this.openMode = openMode; this.autoRotate3DView = autoRotate3DView; this.windowMode = windowMode; BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.AnchorAll(); this.Load(printItem); // We do this after showing the system window so that when we try and take focus of the parent window (the system window) // it exists and can give the focus to its child the gcode window. if (printItem != null && Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") { SwitchToGcodeView(); } }
public ExportPrintItemWindow(PrintItemWrapper printItemWrapper) : base(400, 300) { this.printItemWrapper = printItemWrapper; if (Path.GetExtension(printItemWrapper.FileLocation).ToUpper() == ".GCODE") { partIsGCode = true; } string McExportFileTitleBeg = LocalizedString.Get("MatterControl"); string McExportFileTitleEnd = LocalizedString.Get("Export File"); string McExportFileTitleFull = string.Format("{0}: {1}", McExportFileTitleBeg, McExportFileTitleEnd); this.Title = McExportFileTitleFull; this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; CreateWindowContent(); ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents); ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents); }
private MatterControlApplication(double width, double height, out bool showWindow) : base(width, height) { Name = "MatterControl"; showWindow = false; // set this at startup so that we can tell next time if it got set to true in close UserSettings.Instance.Fields.StartCount = UserSettings.Instance.Fields.StartCount + 1; this.commandLineArgs = Environment.GetCommandLineArgs(); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; bool forceSofwareRendering = false; for (int currentCommandIndex = 0; currentCommandIndex < commandLineArgs.Length; currentCommandIndex++) { string command = commandLineArgs[currentCommandIndex]; string commandUpper = command.ToUpper(); switch (commandUpper) { case "TEST": CheckKnownAssemblyConditionalCompSymbols(); return; case "FORCE_SOFTWARE_RENDERING": forceSofwareRendering = true; GL.ForceSoftwareRendering(); break; case "MHSERIAL_TO_ANDROID": { Dictionary<string, string> vidPid_NameDictionary = new Dictionary<string, string>(); string[] MHSerialLines = File.ReadAllLines(Path.Combine("..", "..", "StaticData", "Drivers", "MHSerial", "MHSerial.inf")); foreach (string line in MHSerialLines) { if (line.Contains("=DriverInstall,")) { string name = Regex.Match(line, "%(.*).name").Groups[1].Value; string vid = Regex.Match(line, "VID_(.*)&PID").Groups[1].Value; string pid = Regex.Match(line, "PID_([0-9a-fA-F]+)").Groups[1].Value; string vidPid = "{0},{1}".FormatWith(vid, pid); if (!vidPid_NameDictionary.ContainsKey(vidPid)) { vidPid_NameDictionary.Add(vidPid, name); } } } using (StreamWriter deviceFilter = new StreamWriter("deviceFilter.txt")) { using (StreamWriter serialPort = new StreamWriter("serialPort.txt")) { foreach (KeyValuePair<string, string> vidPid_Name in vidPid_NameDictionary) { string[] vidPid = vidPid_Name.Key.Split(','); int vid = Int32.Parse(vidPid[0], System.Globalization.NumberStyles.HexNumber); int pid = Int32.Parse(vidPid[1], System.Globalization.NumberStyles.HexNumber); serialPort.WriteLine("customTable.AddProduct(0x{0:X4}, 0x{1:X4}, cdcDriverType); // {2}".FormatWith(vid, pid, vidPid_Name.Value)); deviceFilter.WriteLine("<!-- {2} -->\n<usb-device vendor-id=\"{0}\" product-id=\"{1}\" />".FormatWith(vid, pid, vidPid_Name.Value)); } } } } return; case "CLEAR_CACHE": AboutWidget.DeleteCacheData(); break; case "SHOW_MEMORY": ShowMemoryUsed = true; break; case "DO_GC_COLLECT_EVERY_DRAW": ShowMemoryUsed = true; DoCGCollectEveryDraw = true; break; case "CREATE_AND_SELECT_PRINTER": if (currentCommandIndex + 1 <= commandLineArgs.Length) { currentCommandIndex++; string argument = commandLineArgs[currentCommandIndex]; string[] printerData = argument.Split(','); if (printerData.Length >= 2) { Printer ActivePrinter = new Printer(); ActivePrinter.Name = "Auto: {0} {1}".FormatWith(printerData[0], printerData[1]); ActivePrinter.Make = printerData[0]; ActivePrinter.Model = printerData[1]; if (printerData.Length == 3) { ActivePrinter.ComPort = printerData[2]; } PrinterSetupStatus test = new PrinterSetupStatus(ActivePrinter); test.LoadDefaultSliceSettings(ActivePrinter.Make, ActivePrinter.Model); ActivePrinterProfile.Instance.ActivePrinter = ActivePrinter; } } break; case "CONNECT_TO_PRINTER": if (currentCommandIndex + 1 <= commandLineArgs.Length) { PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(); } break; case "START_PRINT": if (currentCommandIndex + 1 <= commandLineArgs.Length) { bool hasBeenRun = false; currentCommandIndex++; string fullPath = commandLineArgs[currentCommandIndex]; QueueData.Instance.RemoveAll(); if (!string.IsNullOrEmpty(fullPath)) { string fileName = Path.GetFileNameWithoutExtension(fullPath); QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(fileName, fullPath))); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent((sender, e) => { if (!hasBeenRun && PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Connected) { hasBeenRun = true; PrinterConnectionAndCommunication.Instance.PrintActivePartIfPossible(); } }, ref unregisterEvent); } } break; case "SLICE_AND_EXPORT_GCODE": if (currentCommandIndex + 1 <= commandLineArgs.Length) { currentCommandIndex++; string fullPath = commandLineArgs[currentCommandIndex]; QueueData.Instance.RemoveAll(); if (!string.IsNullOrEmpty(fullPath)) { string fileName = Path.GetFileNameWithoutExtension(fullPath); PrintItemWrapper printItemWrapper = new PrintItemWrapper(new PrintItem(fileName, fullPath)); QueueData.Instance.AddItem(printItemWrapper); SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper); ExportPrintItemWindow exportForTest = new ExportPrintItemWindow(printItemWrapper); exportForTest.ExportGcodeCommandLineUtility(fileName); } } break; } if (MeshFileIo.ValidFileExtensions().Contains(Path.GetExtension(command).ToUpper())) { // If we are the only instance running then do nothing. // Else send these to the running instance so it can load them. } } //WriteTestGCodeFile(); #if !DEBUG if (File.Exists("RunUnitTests.txt")) #endif { #if IS_WINDOWS_FORMS if (!Clipboard.IsInitialized) { Clipboard.SetSystemClipboard(new WindowsFormsClipboard()); } #endif // you can turn this on to debug some bounds issues //GuiWidget.DebugBoundsUnderMouse = true; } GuiWidget.DefaultEnforceIntegerBounds = true; if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen) { TextWidget.GlobalPointSizeScaleRatio = 1.3; } using (new PerformanceTimer("Startup", "MainView")) { this.AddChild(ApplicationController.Instance.MainView); } this.MinimumSize = minSize; this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off #if false // this is to test freeing gcodefile memory Button test = new Button("test"); test.Click += (sender, e) => { //MatterHackers.GCodeVisualizer.GCodeFile gcode = new GCodeVisualizer.GCodeFile(); //gcode.Load(@"C:\Users\lbrubaker\Downloads\drive assy.gcode"); SystemWindow window = new SystemWindow(100, 100); window.ShowAsSystemWindow(); }; allControls.AddChild(test); #endif this.AnchorAll(); if (!forceSofwareRendering) { UseOpenGL = true; } string version = "1.4"; Title = "MatterControl {0}".FormatWith(version); if (OemSettings.Instance.WindowTitleExtra != null && OemSettings.Instance.WindowTitleExtra.Trim().Length > 0) { Title = Title + " - {1}".FormatWith(version, OemSettings.Instance.WindowTitleExtra); } UiThread.RunOnIdle(CheckOnPrinter); string desktopPosition = ApplicationSettings.Instance.get("DesktopPosition"); if (desktopPosition != null && desktopPosition != "") { string[] sizes = desktopPosition.Split(','); //If the desktop position is less than -10,-10, override int xpos = Math.Max(int.Parse(sizes[0]), -10); int ypos = Math.Max(int.Parse(sizes[1]), -10); DesktopPosition = new Point2D(xpos, ypos); } showWindow = true; }
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); } } }
public void AddItem(PrintItemWrapper item, int indexToInsert = -1) { QueueData.Instance.AddItem(item, indexToInsert); }
public override void AddItem(PrintItemWrapper itemToAdd) { QueueData.Instance.AddItem(itemToAdd); }
void sliceItem_Done(object sender, EventArgs e) { PrintItemWrapper sliceItem = (PrintItemWrapper)sender; sliceItem.SlicingDone.UnregisterEvent(sliceItem_Done, ref unregisterEvents); sliceItem.SlicingOutputMessage.UnregisterEvent(printItemWrapper_SlicingOutputMessage, ref unregisterEvents); if (File.Exists(sliceItem.FileLocation)) { savedGCodeFileNames.Add(sliceItem.GetGCodePathAndFileName()); } itemCountBeingWorkedOn++; if (itemCountBeingWorkedOn < allFilesToExport.Count) { if (StartingNextPart != null) { StartingNextPart(this, new StringEventArgs(ItemNameBeingWorkedOn)); } } else { if (UpdatePartStatus != null) { UpdatePartStatus(this, new StringEventArgs("Calculating Total cm3...")); } if (savedGCodeFileNames.Count > 0) { double total = 0; foreach (string gcodeFileName in savedGCodeFileNames) { string[] lines = File.ReadAllLines(gcodeFileName); if (lines.Length > 0) { string filamentAmountLine = lines[lines.Length - 1]; bool foundAmountInGCode = false; int startPos = filamentAmountLine.IndexOf("("); if (startPos > 0) { int endPos = filamentAmountLine.IndexOf("cm3)", startPos); if (endPos > 0) { string value = filamentAmountLine.Substring(startPos + 1, endPos - (startPos + 1)); double amountForThisFile; if (double.TryParse(value, out amountForThisFile)) { foundAmountInGCode = true; total += amountForThisFile; } } } } } // now copy all the gcode to the path given for (int i = 0; i < savedGCodeFileNames.Count; i++) { string savedGcodeFileName = savedGCodeFileNames[i]; string originalFileName = Path.GetFileName(allFilesToExport[i].Name); string outputFileName = Path.ChangeExtension(originalFileName, ".gcode"); string outputPathAndName = Path.Combine(exportPath, outputFileName); if (ActivePrinterProfile.Instance.DoPrintLeveling) { GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(savedGcodeFileName); PrintLevelingPlane.Instance.ApplyLeveling(unleveledGCode); unleveledGCode.Save(outputPathAndName); } else { File.Copy(savedGcodeFileName, outputPathAndName, true); } } if (DoneSaving != null) { DoneSaving(this, new StringEventArgs(string.Format("{0:0.0}", total))); } } } }
private void sliceItem_Done(object sender, EventArgs e) { PrintItemWrapper sliceItem = (PrintItemWrapper)sender; sliceItem.SlicingDone -= sliceItem_Done; sliceItem.SlicingOutputMessage -= printItemWrapper_SlicingOutputMessage; if (File.Exists(sliceItem.FileLocation)) { savedGCodeFileNames.Add(sliceItem.GetGCodePathAndFileName()); } itemCountBeingWorkedOn++; if (itemCountBeingWorkedOn < allFilesToExport.Count) { if (StartingNextPart != null) { StartingNextPart(this, new StringEventArgs(ItemNameBeingWorkedOn)); } } else { if (UpdatePartStatus != null) { UpdatePartStatus(this, new StringEventArgs("Calculating Total cm3...")); } if (savedGCodeFileNames.Count > 0) { double total = 0; foreach (string gcodeFileName in savedGCodeFileNames) { string[] lines = File.ReadAllLines(gcodeFileName); if (lines.Length > 0) { string filamentAmountLine = lines[lines.Length - 1]; bool foundAmountInGCode = false; int startPos = filamentAmountLine.IndexOf("("); if (startPos > 0) { int endPos = filamentAmountLine.IndexOf("cm3)", startPos); if (endPos > 0) { string value = filamentAmountLine.Substring(startPos + 1, endPos - (startPos + 1)); double amountForThisFile; if (double.TryParse(value, out amountForThisFile)) { foundAmountInGCode = true; total += amountForThisFile; } } } } } PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter); // now copy all the gcode to the path given for (int i = 0; i < savedGCodeFileNames.Count; i++) { string savedGcodeFileName = savedGCodeFileNames[i]; string originalFileName = Path.GetFileName(allFilesToExport[i].Name); string outputFileName = Path.ChangeExtension(originalFileName, ".gcode"); string outputPathAndName = Path.Combine(exportPath, outputFileName); if (ActivePrinterProfile.Instance.DoPrintLeveling) { GCodeFileLoaded unleveledGCode = new GCodeFileLoaded(savedGcodeFileName); for (int j = 0; j < unleveledGCode.LineCount; j++) { PrinterMachineInstruction instruction = unleveledGCode.Instruction(j); Vector3 currentDestination = instruction.Position; switch (levelingData.CurrentPrinterLevelingSystem) { case PrintLevelingData.LevelingSystem.Probe2Points: instruction.Line = LevelWizard2Point.ApplyLeveling(instruction.Line, currentDestination, instruction.movementType); break; case PrintLevelingData.LevelingSystem.Probe3Points: instruction.Line = LevelWizard3Point.ApplyLeveling(instruction.Line, currentDestination, instruction.movementType); break; case PrintLevelingData.LevelingSystem.Probe7PointRadial: instruction.Line = LevelWizard7PointRadial.ApplyLeveling(instruction.Line, currentDestination, instruction.movementType); break; case PrintLevelingData.LevelingSystem.Probe13PointRadial: instruction.Line = LevelWizard13PointRadial.ApplyLeveling(instruction.Line, currentDestination, instruction.movementType); break; default: throw new NotImplementedException(); } } unleveledGCode.Save(outputPathAndName); } else { File.Copy(savedGcodeFileName, outputPathAndName, true); } } if (DoneSaving != null) { DoneSaving(this, new StringEventArgs(string.Format("{0:0.0}", total))); } } } }
public PrintQueueItem(PrintItemWrapper printItem) { this.PrintItemWrapper = printItem; ConstructPrintQueueItem(); }
public QueueRowItem(PrintItemWrapper printItemWrapper, QueueDataView queueDataView) { this.queueDataView = queueDataView; this.PrintItemWrapper = printItemWrapper; ConstructPrintQueueItem(); }
public static void DeleteCacheData() { if(LibraryProviderSQLite.Instance.PreloadingCalibrationFiles) { return; } // delete everything in the GCodeOutputPath // AppData\Local\MatterControl\data\gcode // delete everything in the temp data that is not in use // AppData\Local\MatterControl\data\temp // plateImages // project-assembly // project-extract // stl // delete all unreference models in Library // AppData\Local\MatterControl\Library // delete all old update downloads // AppData\updates // start cleaning out unused data // MatterControl\data\gcode RemoveDirectory(DataStorage.ApplicationDataStorage.Instance.GCodeOutputPath); string userDataPath = DataStorage.ApplicationDataStorage.Instance.ApplicationUserDataPath; RemoveDirectory(Path.Combine(userDataPath, "updates")); HashSet<string> referencedPrintItemsFilePaths = new HashSet<string>(); HashSet<string> referencedThumbnailFiles = new HashSet<string>(); // Get a list of all the stl and amf files referenced in the queue. foreach (PrintItemWrapper printItem in QueueData.Instance.PrintItems) { string fileLocation = printItem.FileLocation; if (!referencedPrintItemsFilePaths.Contains(fileLocation)) { referencedPrintItemsFilePaths.Add(fileLocation); referencedThumbnailFiles.Add(PartThumbnailWidget.GetImageFileName(printItem)); } } // Add in all the stl and amf files referenced in the library. foreach (PrintItem printItem in LibraryProviderSQLite.GetAllPrintItemsRecursive()) { PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem); string fileLocation = printItem.FileLocation; if (!referencedPrintItemsFilePaths.Contains(fileLocation)) { referencedPrintItemsFilePaths.Add(fileLocation); referencedThumbnailFiles.Add(PartThumbnailWidget.GetImageFileName(printItemWrapper)); } } // If the count is less than 0 then we have never run and we need to populate the library and queue still. So don't delete anything yet. if (referencedPrintItemsFilePaths.Count > 0) { CleanDirectory(userDataPath, referencedPrintItemsFilePaths, referencedThumbnailFiles); } }
private void ClearBedAndLoadPrintItemWrapper(PrintItemWrapper printItemWrapper) { SwitchStateToNotEditing(); MeshGroups.Clear(); MeshGroupExtraData.Clear(); MeshGroupTransforms.Clear(); if (printItemWrapper != null) { // remove it first to make sure we don't double add it printItemWrapper.FileHasChanged -= ReloadMeshIfChangeExternaly; printItemWrapper.FileHasChanged += ReloadMeshIfChangeExternaly; // don't load the mesh until we get all the rest of the interface built meshViewerWidget.LoadDone += new EventHandler(meshViewerWidget_LoadDone); Vector2 bedCenter = new Vector2(); MeshViewerWidget.CenterPartAfterLoad doCentering = MeshViewerWidget.CenterPartAfterLoad.DONT; if(ActiveSliceSettings.Instance != null && ActiveSliceSettings.Instance.CenterOnBed()) { doCentering = MeshViewerWidget.CenterPartAfterLoad.DO; bedCenter = ActiveSliceSettings.Instance.BedCenter; } meshViewerWidget.LoadMesh(printItemWrapper.FileLocation, doCentering, bedCenter); } partHasBeenEdited = false; }
public ViewGcodeBasic(PrintItemWrapper printItem, Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape, WindowMode windowMode) { this.viewerVolume = viewerVolume; this.bedShape = bedShape; this.bedCenter = bedCenter; this.windowMode = windowMode; this.printItem = printItem; if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen) { sliderWidth = 20; } else { sliderWidth = 10; } CreateAndAddChildren(); SliceSettingsWidget.RegisterForSettingsChange("bed_size", RecreateBedAndPartPosition, ref unregisterEvents); SliceSettingsWidget.RegisterForSettingsChange("print_center", RecreateBedAndPartPosition, ref unregisterEvents); SliceSettingsWidget.RegisterForSettingsChange("build_height", RecreateBedAndPartPosition, ref unregisterEvents); SliceSettingsWidget.RegisterForSettingsChange("bed_shape", RecreateBedAndPartPosition, ref unregisterEvents); SliceSettingsWidget.RegisterForSettingsChange("center_part_on_bed", RecreateBedAndPartPosition, ref unregisterEvents); SliceSettingsWidget.RegisterForSettingsChange("extruder_offset", Clear3DGCode, ref unregisterEvents); ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent(RecreateBedAndPartPosition, ref unregisterEvents); ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(RecreateBedAndPartPosition, ref unregisterEvents); }
public int GetIndex(PrintItemWrapper printItem) { return(PrintItems.IndexOf(printItem)); }
void sliceItem_Done(object sender, EventArgs e) { PrintItemWrapper sliceItem = (PrintItemWrapper)sender; sliceItem.Done -= new EventHandler(sliceItem_Done); savedGCodeFileNames.Add(sliceItem.GCodePathAndFileName); itemCountBeingWorkedOn++; if (itemCountBeingWorkedOn < allFilesToExport.Count) { if (StartingNextPart != null) { StartingNextPart(this, new StringEventArgs(ItemNameBeingWorkedOn)); } } else { UpdatePartStatus(this, new StringEventArgs("Calculating Total cm3...")); if (savedGCodeFileNames.Count > 0) { double total = 0; foreach (string gcodeFileName in savedGCodeFileNames) { string[] lines = File.ReadAllLines(gcodeFileName); if (lines.Length > 0) { string filamentAmountLine = lines[lines.Length - 1]; int startPos = filamentAmountLine.IndexOf("("); int endPos = filamentAmountLine.IndexOf("cm3)"); string value = filamentAmountLine.Substring(startPos + 1, endPos - (startPos + 1)); double amountForThisFile; if (double.TryParse(value, out amountForThisFile)) { total += amountForThisFile; } else { GCodeFile gcodeFile = new GCodeFile(gcodeFileName); total += gcodeFile.GetFilamentCubicMm(ActiveSliceSettings.Instance.FillamentDiameter) / 1000; } } } // now copy all the gcode to the path given for (int i = 0; i < savedGCodeFileNames.Count; i++) { string savedGcodeFileName = savedGCodeFileNames[i]; string originalFileName = Path.GetFileName(allFilesToExport[i].Name); string outputFileName = Path.ChangeExtension(originalFileName, ".gcode"); string outputPathAndName = Path.Combine(exportPath, outputFileName); if (PrinterCommunication.Instance.DoPrintLeveling) { GCodeFile unleveledGCode = new GCodeFile(savedGcodeFileName); PrintLeveling.Instance.ApplyLeveling(unleveledGCode); unleveledGCode.Save(outputPathAndName); } else { File.Copy(savedGcodeFileName, outputPathAndName, true); } } if (DoneSaving != null) { DoneSaving(this, new StringEventArgs(string.Format("{0:0.0}", total))); } } } }
public override void AddItem(PrintItemWrapper itemToAdd) { throw new NotImplementedException(); //PrintHistoryData.Instance.AddItem(itemToAdd); }
public void AddItem(PrintItemWrapper item, int indexToInsert = -1) { throw new NotImplementedException(); //PrintHistoryData.Instance.AddItem(item, indexToInsert); }
public void AddItem(PrintItemWrapper item, int indexToInsert = -1) { if (indexToInsert == -1) { indexToInsert = PrintItems.Count; } PrintItems.Insert(indexToInsert, item); // Check if the collection we are adding to is the the currently visible collection. List<ProviderLocatorNode> currentDisplayedCollection = LibraryProviderSQLite.Instance.GetProviderLocator(); if (currentDisplayedCollection.Count > 0 && currentDisplayedCollection[1].Key == LibraryProviderSQLite.StaticProviderKey) { //OnItemAdded(new IndexArgs(indexToInsert)); } item.PrintItem.PrintItemCollectionID = RootLibraryCollection.Id; item.PrintItem.Commit(); }
private void OpenExportWindow(PrintItemWrapper printItem) { if (exportingWindow == null) { exportingWindow = new ExportPrintItemWindow(printItem); exportingWindow.Closed += new EventHandler(ExportQueueItemWindow_Closed); exportingWindow.ShowAsSystemWindow(); } else { exportingWindow.BringToFront(); } }
public void RemoveItem(PrintItemWrapper printItemWrapper) { int index = PrintItems.IndexOf(printItemWrapper); if (index < 0) { // It may be possible to have the same item in the remove list twice. // so if it is not in the PrintItems then ignore it. return; } PrintItems.RemoveAt(index); // and remove it from the data base printItemWrapper.Delete(); }
public View3DWidget(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape, WindowMode windowType, AutoRotate autoRotate, OpenMode openMode = OpenMode.Viewing) { this.openMode = openMode; this.windowType = windowType; allowAutoRotate = (autoRotate == AutoRotate.Enabled); autoRotating = allowAutoRotate; MeshGroupExtraData = new List<PlatingMeshGroupData>(); MeshGroupExtraData.Add(new PlatingMeshGroupData()); this.printItemWrapper = printItemWrapper; FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight); centerPartPreviewAndControls.Name = "centerPartPreviewAndControls"; centerPartPreviewAndControls.AnchorAll(); GuiWidget viewArea = new GuiWidget(); viewArea.AnchorAll(); { meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "Press 'Add' to select an item.".Localize()); PutOemImageOnBed(); meshViewerWidget.AnchorAll(); } viewArea.AddChild(meshViewerWidget); centerPartPreviewAndControls.AddChild(viewArea); mainContainerTopToBottom.AddChild(centerPartPreviewAndControls); FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight; buttonBottomPanel.Padding = new BorderDouble(3, 3); buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRightPanel = CreateRightButtonPanel(viewerVolume.y); buttonRightPanel.Name = "buttonRightPanel"; buttonRightPanel.Visible = false; CreateOptionsContent(); // add in the plater tools { FlowLayoutWidget editToolBar = new FlowLayoutWidget(); string progressFindPartsLabel = "Entering Editor".Localize(); string progressFindPartsLabelFull = "{0}:".FormatWith(progressFindPartsLabel); processingProgressControl = new ProgressControl(progressFindPartsLabelFull, ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor); processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter; editToolBar.AddChild(processingProgressControl); editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter; processingProgressControl.Visible = false; // If the window is embeded (in the center pannel) and there is no item loaded then don't show the add button enterEditButtonsContainer = new FlowLayoutWidget(); { Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png"); addButton.ToolTipText = "Insert an .stl, .amf or .zip file".Localize(); addButton.Margin = new BorderDouble(right: 0); enterEditButtonsContainer.AddChild(addButton); addButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { DoAddFileAfterCreatingEditData = true; EnterEditAndCreateSelectionData(); }); }; if (printItemWrapper != null && printItemWrapper.PrintItem.ReadOnly) { addButton.Enabled = false; } Button enterEdittingButton = textImageButtonFactory.Generate("Edit".Localize(), "icon_edit_32x32.png"); enterEdittingButton.Margin = new BorderDouble(right: 4); enterEdittingButton.Click += (sender, e) => { EnterEditAndCreateSelectionData(); }; if (printItemWrapper != null && printItemWrapper.PrintItem.ReadOnly) { enterEdittingButton.Enabled = false; } Button exportButton = textImageButtonFactory.Generate("Export...".Localize()); if (printItemWrapper != null && (printItemWrapper.PrintItem.Protected || printItemWrapper.PrintItem.ReadOnly)) { exportButton.Enabled = false; } exportButton.Margin = new BorderDouble(right: 10); exportButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { OpenExportWindow(); }); }; enterEditButtonsContainer.AddChild(enterEdittingButton); enterEditButtonsContainer.AddChild(exportButton); } editToolBar.AddChild(enterEditButtonsContainer); doEdittingButtonsContainer = new FlowLayoutWidget(); doEdittingButtonsContainer.Visible = false; { Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png"); addButton.Margin = new BorderDouble(right: 10); doEdittingButtonsContainer.AddChild(addButton); addButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { FileDialog.OpenFileDialog( new OpenFileDialogParams(ApplicationSettings.OpenDesignFileParams, multiSelect: true), (openParams) => { LoadAndAddPartsToPlate(openParams.FileNames); }); }); }; GuiWidget separator = new GuiWidget(1, 2); separator.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor; separator.Margin = new BorderDouble(4, 2); separator.VAnchor = VAnchor.ParentBottomTop; doEdittingButtonsContainer.AddChild(separator); Button ungroupButton = textImageButtonFactory.Generate("Ungroup".Localize()); doEdittingButtonsContainer.AddChild(ungroupButton); ungroupButton.Click += (sender, e) => { UngroupSelectedMeshGroup(); }; Button groupButton = textImageButtonFactory.Generate("Group".Localize()); doEdittingButtonsContainer.AddChild(groupButton); groupButton.Click += (sender, e) => { GroupSelectedMeshs(); }; Button alignButton = textImageButtonFactory.Generate("Align".Localize()); doEdittingButtonsContainer.AddChild(alignButton); alignButton.Click += (sender, e) => { AlignToSelectedMeshGroup(); }; Button arrangeButton = textImageButtonFactory.Generate("Arrange".Localize()); doEdittingButtonsContainer.AddChild(arrangeButton); arrangeButton.Click += (sender, e) => { AutoArrangePartsInBackground(); }; GuiWidget separatorTwo = new GuiWidget(1, 2); separatorTwo.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor; separatorTwo.Margin = new BorderDouble(4, 2); separatorTwo.VAnchor = VAnchor.ParentBottomTop; doEdittingButtonsContainer.AddChild(separatorTwo); Button copyButton = textImageButtonFactory.Generate("Copy".Localize()); doEdittingButtonsContainer.AddChild(copyButton); copyButton.Click += (sender, e) => { MakeCopyOfGroup(); }; Button deleteButton = textImageButtonFactory.Generate("Remove".Localize()); doEdittingButtonsContainer.AddChild(deleteButton); deleteButton.Click += (sender, e) => { DeleteSelectedMesh(); }; GuiWidget separatorThree = new GuiWidget(1, 2); separatorThree.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor; separatorThree.Margin = new BorderDouble(4, 1); separatorThree.VAnchor = VAnchor.ParentBottomTop; doEdittingButtonsContainer.AddChild(separatorThree); Button leaveEditModeButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true); leaveEditModeButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (saveButtons.Visible) { StyledMessageBox.ShowMessageBox(ExitEditingAndSaveIfRequired, "Would you like to save your changes before exiting the editor?", "Save Changes", StyledMessageBox.MessageType.YES_NO); } else { if (partHasBeenEdited) { ExitEditingAndSaveIfRequired(false); } else { SwitchStateToNotEditing(); } } }); }; doEdittingButtonsContainer.AddChild(leaveEditModeButton); // put in the save button AddSaveAndSaveAs(doEdittingButtonsContainer); } KeyDown += (sender, e) => { KeyEventArgs keyEvent = e as KeyEventArgs; if (keyEvent != null && !keyEvent.Handled) { if (keyEvent.KeyCode == Keys.Delete || keyEvent.KeyCode == Keys.Back) { DeleteSelectedMesh(); } if (keyEvent.KeyCode == Keys.Escape) { if (meshSelectInfo.downOnPart) { meshSelectInfo.downOnPart = false; ScaleRotateTranslate translated = SelectedMeshGroupTransform; translated.translation = transformOnMouseDown; SelectedMeshGroupTransform = translated; Invalidate(); } } } }; editToolBar.AddChild(doEdittingButtonsContainer); buttonBottomPanel.AddChild(editToolBar); } GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop); buttonRightPanelHolder.Name = "buttonRightPanelHolder"; centerPartPreviewAndControls.AddChild(buttonRightPanelHolder); buttonRightPanelHolder.AddChild(buttonRightPanel); viewControls3D = new ViewControls3D(meshViewerWidget); buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop); buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150); buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover); viewControls3D.PartSelectVisible = false; LockEditControls(); GuiWidget leftRightSpacer = new GuiWidget(); leftRightSpacer.HAnchor = HAnchor.ParentLeftRight; buttonBottomPanel.AddChild(leftRightSpacer); if (windowType == WindowMode.StandAlone) { Button closeButton = textImageButtonFactory.Generate("Close".Localize()); buttonBottomPanel.AddChild(closeButton); closeButton.Click += (sender, e) => { CloseOnIdle(); }; } mainContainerTopToBottom.AddChild(buttonBottomPanel); this.AddChild(mainContainerTopToBottom); this.AnchorAll(); meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation; AddChild(viewControls3D); AddHandlers(); UiThread.RunOnIdle(AutoSpin); if (printItemWrapper == null && windowType == WindowMode.Embeded) { enterEditButtonsContainer.Visible = false; } if (windowType == WindowMode.Embeded) { PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetEditControlsBasedOnPrinterState, ref unregisterEvents); if (windowType == WindowMode.Embeded) { // make sure we lock the controls if we are printing or paused switch (PrinterConnectionAndCommunication.Instance.CommunicationState) { case PrinterConnectionAndCommunication.CommunicationStates.Printing: case PrinterConnectionAndCommunication.CommunicationStates.Paused: LockEditControls(); break; } } } ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); upArrow = new UpArrow3D(this); heightDisplay = new HeightValueDisplay(this); heightDisplay.Visible = false; meshViewerWidget.interactionVolumes.Add(upArrow); // make sure the colors are set correctl ThemeChanged(this, null); saveButtons.VisibleChanged += (sender, e) => { partHasBeenEdited = true; }; }
public override void AddItem(PrintItemWrapper itemToAdd) { if (Directory.Exists(itemToAdd.FileLocation)) { libraryCreators.Add(new LibraryProviderFileSystemCreator(itemToAdd.FileLocation, Path.GetFileName(itemToAdd.FileLocation))); AddFolderImage("folder.png"); UiThread.RunOnIdle(() => OnDataReloaded(null)); } }
private void mergeAndSavePartsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { SaveAsWindow.SaveAsReturnInfo returnInfo = e.Argument as SaveAsWindow.SaveAsReturnInfo; if (returnInfo != null) { printItemWrapper = returnInfo.printItemWrapper; } // 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); MeshFileIo.Save(asynchMeshGroups, printItemWrapper.FileLocation, outputInfo); printItemWrapper.OnFileHasChanged(); } catch (System.UnauthorizedAccessException) { saveSucceded = false; UiThread.RunOnIdle(() => { //Do something special when unauthorized? StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes.", "Unable to save"); }); } catch { saveSucceded = false; UiThread.RunOnIdle(() => { StyledMessageBox.ShowMessageBox(null, "Oops! Unable to save changes.", "Unable to save"); }); } e.Result = e.Argument; }
public override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int itemIndex) { var printItemWrapper = new PrintItemWrapper(new PrintItem(LibraryRowItem.SearchResultsNotAvailableToken, LibraryRowItem.SearchResultsNotAvailableToken), this.GetProviderLocator()) { UseIncrementedNameDuringTypeChange = true }; return Task.FromResult(printItemWrapper); }
public PrintItemWrapperEventArgs(PrintItemWrapper printItemWrapper) { this.printItemWrapper = printItemWrapper; }
public ViewGcodeBasic(PrintItemWrapper printItem, Vector3 viewerVolume, Vector2 bedCenter, BedShape bedShape, WindowMode windowMode) { this.viewerVolume = viewerVolume; this.bedShape = bedShape; this.bedCenter = bedCenter; this.windowMode = windowMode; this.printItem = printItem; if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen) { sliderWidth = 20; } else { sliderWidth = 10; } CreateAndAddChildren(); SliceSettingsWidget.SettingChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents); ApplicationController.Instance.AdvancedControlsPanelReloading.RegisterEvent((s, e) => ClearGCode(), ref unregisterEvents); ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents); }