public async override void AddItem(PrintItemWrapper itemToAdd) { await AddItemAsync(itemToAdd.Name, itemToAdd.FileLocation, fireDataReloaded : true); }
public void LibraryProviderFileSystem_NavigationWorking() { StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); string meshFileName = "Box20x20x10.stl"; string meshPathAndFileName = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "Tests", "TestData", "TestMeshes", "LibraryProviderData", meshFileName); int dataReloadedCount = 0; string downloadsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads"); string testLibraryDirectory = Path.Combine(downloadsDirectory, "LibraryProviderFileSystemTest"); if (Directory.Exists(testLibraryDirectory)) { Directory.Delete(testLibraryDirectory, true); } Directory.CreateDirectory(testLibraryDirectory); LibraryProviderFileSystem testProvider = new LibraryProviderFileSystem(testLibraryDirectory, "TestPath", null, null); testProvider.DataReloaded += (s, e) => { dataReloadedCount++; }; AutomationRunner.StaticDelay(() => { return(dataReloadedCount > 0); }, 1); dataReloadedCount = 0; Assert.IsTrue(testProvider.CollectionCount == 0, "Start with a new database for these tests."); Assert.IsTrue(testProvider.ItemCount == 0, "Start with a new database for these tests."); // create a collection and make sure it is on disk Assert.AreEqual(0, dataReloadedCount); // it has been loaded for the default set of parts string collectionName = "Collection1"; string createdDirectory = Path.Combine(testLibraryDirectory, collectionName); Assert.IsFalse(Directory.Exists(createdDirectory), "CreatedDirectory should *not* exist"); Assert.AreEqual(0, dataReloadedCount, "Reload should *not* have occurred"); testProvider.AddCollectionToLibrary(collectionName); AutomationRunner.StaticDelay(() => { return(testProvider.CollectionCount == 1); }, 1); Assert.AreEqual(1, testProvider.CollectionCount, "Incorrect collection count"); Assert.IsTrue(dataReloadedCount > 0, "Reload should *have* occurred"); Assert.IsTrue(Directory.Exists(createdDirectory), "CreatedDirectory *should* exist"); // add an item works correctly LibraryProvider subProvider = testProvider.GetProviderForCollection(testProvider.GetCollectionItem(0)); subProvider.DataReloaded += (sender, e) => { dataReloadedCount++; }; dataReloadedCount = 0; string subPathAndFile = Path.Combine(createdDirectory, meshFileName); Assert.IsFalse(File.Exists(subPathAndFile), "File should *not* exist: " + subPathAndFile); Assert.AreEqual(0, dataReloadedCount, "Reload should *not* have occurred"); // WIP: saving the name incorrectly for this location (does not need to be changed). subProvider.AddFilesToLibrary(new string[] { meshPathAndFileName }); AutomationRunner.StaticDelay(() => { return(subProvider.ItemCount == 1); }, 1); PrintItemWrapper itemAtRoot = subProvider.GetPrintItemWrapperAsync(0).Result; Assert.IsTrue(subProvider.ItemCount == 1); Assert.IsTrue(dataReloadedCount > 0); //Assert.IsTrue(itemAdded == true); Assert.IsTrue(File.Exists(subPathAndFile)); // make sure the provider locater is correct // remove item works dataReloadedCount = 0; Assert.IsTrue(dataReloadedCount == 0); subProvider.RemoveItem(0); AutomationRunner.StaticDelay(() => { return(subProvider.ItemCount == 0); }, 1); Assert.IsTrue(dataReloadedCount > 0); Assert.IsTrue(!File.Exists(subPathAndFile)); // remove collection gets rid of it dataReloadedCount = 0; testProvider.RemoveCollection(0); AutomationRunner.StaticDelay(() => { return(testProvider.CollectionCount == 0); }, 1); Assert.IsTrue(dataReloadedCount > 0); Assert.IsTrue(testProvider.CollectionCount == 0); Assert.IsTrue(!Directory.Exists(createdDirectory)); if (Directory.Exists(testLibraryDirectory)) { Directory.Delete(testLibraryDirectory, true); } }
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; } 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; }
void Load(PrintItemWrapper printItem) { tabControl = new TabControl(); tabControl.TabBar.BorderColor = new RGBA_Bytes(0, 0, 0, 0); tabControl.TabBar.Padding = new BorderDouble(top: 6); RGBA_Bytes selectedTabColor; if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Responsive) { tabControl.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; selectedTabColor = ActiveTheme.Instance.TabLabelSelected; } else { tabControl.TabBar.BackgroundColor = ActiveTheme.Instance.TransparentLightOverlay; selectedTabColor = ActiveTheme.Instance.SecondaryAccentColor; } View3DWidget.WindowType viewType; bool showCloseButton; if (widgetIsEmbedded) { viewType = View3DWidget.WindowType.Embeded; showCloseButton = false; } else { viewType = View3DWidget.WindowType.StandAlone; showCloseButton = true; } double buildHeight = ActiveSliceSettings.Instance.BuildHeight; // put in the 3D view { string part3DViewLabelFull = string.Format("{0} {1} ", "3D", "View".Localize()).ToUpper(); partPreviewView = new View3DWidget(printItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, viewType, autoRotate3DView, openInEditMode); partPreviewView.Closed += (sender, e) => { Close(); }; TabPage partPreview3DView = new TabPage(partPreviewView, part3DViewLabelFull); tabControl.AddTab(new SimpleTextTabWidget(partPreview3DView, "3D View Tab", 16, selectedTabColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes())); } // put in the 2d gcode view { viewGcodeBasic = new ViewGcodeBasic(printItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, showCloseButton); viewGcodeBasic.Closed += (sender, e) => { Close(); }; layerView = new TabPage(viewGcodeBasic, LocalizedString.Get("Layer View").ToUpper()); tabControl.AddTab(new SimpleTextTabWidget(layerView, "Layer View Tab", 16, selectedTabColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes())); } this.AddChild(tabControl); }
public override void AddItem(PrintItemWrapper itemToAdd) { QueueData.Instance.AddItem(itemToAdd); }
private void Load(PrintItemWrapper printItem) { tabControl = new TabControl(); tabControl.TabBar.BorderColor = new RGBA_Bytes(0, 0, 0, 0); tabControl.TabBar.Padding = new BorderDouble(top: 6); RGBA_Bytes selectedTabColor; if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Responsive) { tabControl.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; selectedTabColor = ActiveTheme.Instance.TabLabelSelected; } else { tabControl.TabBar.BackgroundColor = ActiveTheme.Instance.TransparentLightOverlay; selectedTabColor = ActiveTheme.Instance.SecondaryAccentColor; } double buildHeight = ActiveSliceSettings.Instance.BuildHeight; // put in the 3D view string part3DViewLabelFull = string.Format("{0} {1} ", "3D", "View".Localize()).ToUpper(); partPreviewView = new View3DWidget(printItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, windowMode, autoRotate3DView, openMode); TabPage partPreview3DView = new TabPage(partPreviewView, part3DViewLabelFull); // put in the gcode view ViewGcodeBasic.WindowMode gcodeWindowMode = ViewGcodeBasic.WindowMode.Embeded; if (windowMode == View3DWidget.WindowMode.StandAlone) { gcodeWindowMode = ViewGcodeBasic.WindowMode.StandAlone; } viewGcodeBasic = new ViewGcodeBasic(printItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, gcodeWindowMode); if (windowMode == View3DWidget.WindowMode.StandAlone) { partPreviewView.Closed += (sender, e) => { Close(); }; viewGcodeBasic.Closed += (sender, e) => { Close(); }; } layerView = new TabPage(viewGcodeBasic, LocalizedString.Get("Layer View").ToUpper()); int tabPointSize = 16; // add the correct tabs based on wether we are stand alone or embeded Tab threeDViewTab; Tab layerViewTab; if (windowMode == View3DWidget.WindowMode.StandAlone || OsInformation.OperatingSystem == OSType.Android) { threeDViewTab = new SimpleTextTabWidget(partPreview3DView, "3D View Tab", tabPointSize, selectedTabColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); tabControl.AddTab(threeDViewTab); layerViewTab = new SimpleTextTabWidget(layerView, "Layer View Tab", tabPointSize, selectedTabColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); tabControl.AddTab(layerViewTab); } else { threeDViewTab = new PopOutTextTabWidget(partPreview3DView, "3D View Tab", new Vector2(590, 400), tabPointSize); tabControl.AddTab(threeDViewTab); layerViewTab = new PopOutTextTabWidget(layerView, "Layer View Tab", new Vector2(590, 400), tabPointSize); tabControl.AddTab(layerViewTab); } threeDViewTab.ToolTipText = "Preview 3D Design".Localize(); layerViewTab.ToolTipText = "Preview layer Tool Paths".Localize(); this.AddChild(tabControl); }
private MatterControlApplication(double width, double height) : base(width, height) { ApplicationSettings.Instance.set("HardwareHasCamera", "false"); Name = "MatterControl"; // 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; for (int currentCommandIndex = 0; currentCommandIndex < commandLineArgs.Length; currentCommandIndex++) { string command = commandLineArgs[currentCommandIndex]; string commandUpper = command.ToUpper(); switch (commandUpper) { case "FORCE_SOFTWARE_RENDERING": GL.HardwareAvailable = false; break; case "CLEAR_CACHE": AboutWidget.DeleteCacheData(0); 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.LoadSettingsFromConfigFile(ActivePrinter.Make, ActivePrinter.Model); // ActiveSliceSettings.Instance = 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 (UserSettings.Instance.IsTouchScreen) { GuiWidget.DeviceScale = 1.3; SystemWindow.ShareSingleOsWindow = true; } //GuiWidget.DeviceScale = 2; 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 (GL.HardwareAvailable) { UseOpenGL = true; } string version = "1.6"; Title = "MatterHackers: 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(ApplicationSettingsKey.DesktopPosition); if (!string.IsNullOrEmpty(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); } else { DesktopPosition = new Point2D(-1, -1); } this.Maximized = ApplicationSettings.Instance.get(ApplicationSettingsKey.MainWindowMaximized) == "true"; }
public override IEnumerable <PrintItemAction> GetMenuItems() { return(new List <PrintItemAction>() { new PrintItemAction() { SingleItemOnly = false, Title = "Merge".Localize() + "...", Action = (items, queueDataWidget) => { List <QueueRowItem> allRowItems = new List <QueueRowItem>(items); if (allRowItems.Count > 1) { RenameItemWindow renameItemWindow = new RenameItemWindow(allRowItems[0].PrintItemWrapper.Name, (returnInfo) => { Task.Run(() => { List <MeshGroup> combinedMeshes = new List <MeshGroup>(); // Load up all the parts and merge them together foreach (QueueRowItem item in allRowItems) { List <MeshGroup> loadedMeshGroups = MeshFileIo.Load(item.PrintItemWrapper.FileLocation); combinedMeshes.AddRange(loadedMeshGroups); } // save them out string[] metaData = { "Created By", "MatterControl", "BedPosition", "Absolute" }; MeshOutputSettings outputInfo = new MeshOutputSettings(MeshOutputSettings.OutputType.Binary, metaData); string libraryDataPath = ApplicationDataStorage.Instance.ApplicationLibraryDataPath; if (!Directory.Exists(libraryDataPath)) { Directory.CreateDirectory(libraryDataPath); } string tempFileNameToSaveTo = Path.Combine(libraryDataPath, Path.ChangeExtension(Path.GetRandomFileName(), "amf")); bool savedSuccessfully = MeshFileIo.Save(combinedMeshes, tempFileNameToSaveTo, outputInfo); // Swap out the files if the save operation completed successfully if (savedSuccessfully && File.Exists(tempFileNameToSaveTo)) { // create a new print item // add it to the queue PrintItemWrapper newPrintItem = new PrintItemWrapper(new PrintItem(returnInfo.newName, tempFileNameToSaveTo)); QueueData.Instance.AddItem(newPrintItem, 0); // select the part we added, if possible QueueData.Instance.SelectedIndex = 0; queueDataWidget.LeaveEditMode(); } }); }, "Set Name".Localize()) { Title = "MatterHackers - Set Name".Localize(), ElementHeader = "Set Name".Localize(), }; } } } }); }
public PrintLibraryListItem(PrintItemWrapper printItem) { this.printItem = printItem; linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.White; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; SetDisplayAttributes(); FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { GuiWidget selectionCheckBoxContainer = new GuiWidget(); selectionCheckBoxContainer.VAnchor = VAnchor.Max_FitToChildren_ParentHeight; selectionCheckBoxContainer.HAnchor = Agg.UI.HAnchor.FitToChildren; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; selectionCheckBoxContainer.AddChild(selectionCheckBox); FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); leftColumn.VAnchor |= VAnchor.ParentTop; FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight; middleColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop; middleColumn.Padding = new BorderDouble(0, 6); middleColumn.Margin = new BorderDouble(10, 0); { string labelName = textInfo.ToTitleCase(printItem.Name); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 12); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 16); middleColumn.AddChild(partLabel); } FlowLayoutWidget rightColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); rightColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop; buttonContainer = new FlowLayoutWidget(); buttonContainer.Margin = new BorderDouble(0, 6); buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { addToQueueLink = linkButtonFactory.Generate(new LocalizedString("Add to Queue").Translated); addToQueueLink.Margin = new BorderDouble(left: 0, right: 10); addToQueueLink.VAnchor = VAnchor.ParentCenter; addToQueueLink.Click += (sender, e) => { PrintQueueItem queueItem = new PrintQueueItem(this.printItem.Name, this.printItem.FileLocation); PrintQueueControl.Instance.AddChild(queueItem); }; viewLink = linkButtonFactory.Generate(new LocalizedString("View").Translated); viewLink.Margin = new BorderDouble(left: 0, right: 10); viewLink.VAnchor = VAnchor.ParentCenter; exportLink = linkButtonFactory.Generate(new LocalizedString("Export").Translated); exportLink.Margin = new BorderDouble(left: 0, right: 10); exportLink.VAnchor = VAnchor.ParentCenter; exportLink.Click += (sender, e) => { ExportLibraryItemWindow exportingWindow = new ExportLibraryItemWindow(this); exportingWindow.ShowAsSystemWindow(); }; removeLink = linkButtonFactory.Generate(new LocalizedString("Remove").Translated); removeLink.Margin = new BorderDouble(left: 10, right: 10); removeLink.VAnchor = VAnchor.ParentCenter; buttonContainer.AddChild(addToQueueLink); buttonContainer.AddChild(viewLink); buttonContainer.AddChild(exportLink); buttonContainer.AddChild(removeLink); } middleColumn.AddChild(buttonContainer); //rightColumn.AddChild(buttonContainer); mainContainer.AddChild(selectionCheckBoxContainer); { PartThumbnailWidget thumbnailWidget = new PartThumbnailWidget(printItem, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", new Vector2(50, 50)); mainContainer.AddChild(thumbnailWidget); } mainContainer.AddChild(leftColumn); mainContainer.AddChild(middleColumn); mainContainer.AddChild(rightColumn); } this.AddChild(mainContainer); AddHandlers(); }
public async void OpenPartViewWindow(View3DWidget.OpenMode openMode = View3DWidget.OpenMode.Viewing, PrintItemWrapper printItemWrapper = null) { if (viewingWindow == null) { // Only call GetPrintItemWrapperAsync if need to avoid unneeded overhead if (printItemWrapper == null) { printItemWrapper = await this.GetPrintItemWrapperAsync(); } viewingWindow = new PartPreviewMainWindow(printItemWrapper, View3DWidget.AutoRotate.Enabled, openMode); viewingWindow.Closed += new EventHandler(PartPreviewMainWindow_Closed); } else { viewingWindow.BringToFront(); } }
public static string GetImageFilenameForItem(PrintItemWrapper item) { return(GetFilenameForSize(item.FileHashCode.ToString(), new Point2D(460, 460))); }
private void Load(PrintItemWrapper printItem) { tabControl = new TabControl(); tabControl.TabBar.BorderColor = new RGBA_Bytes(0, 0, 0, 0); tabControl.TabBar.Padding = new BorderDouble(top: 6); RGBA_Bytes selectedTabColor; if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Responsive) { tabControl.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; selectedTabColor = ActiveTheme.Instance.TabLabelSelected; } else { tabControl.TabBar.BackgroundColor = ActiveTheme.Instance.TransparentLightOverlay; selectedTabColor = ActiveTheme.Instance.SecondaryAccentColor; } double buildHeight = ActiveSliceSettings.Instance.GetValue <double>(SettingsKey.build_height); // put in the 3D view partPreviewView = new View3DWidget(printItem, new Vector3(ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.bed_size), buildHeight), ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.print_center), ActiveSliceSettings.Instance.GetValue <BedShape>(SettingsKey.bed_shape), windowMode, autoRotate3DView, openMode); TabPage partPreview3DView = new TabPage(partPreviewView, string.Format("3D {0} ", "View".Localize()).ToUpper()); // put in the gcode view ViewGcodeBasic.WindowMode gcodeWindowMode = ViewGcodeBasic.WindowMode.Embeded; if (windowMode == View3DWidget.WindowMode.StandAlone) { gcodeWindowMode = ViewGcodeBasic.WindowMode.StandAlone; } viewGcodeBasic = new ViewGcodeBasic(printItem, new Vector3(ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.bed_size), buildHeight), ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.print_center), ActiveSliceSettings.Instance.GetValue <BedShape>(SettingsKey.bed_shape), gcodeWindowMode); if (windowMode == View3DWidget.WindowMode.StandAlone) { partPreviewView.Closed += (s, e) => Close(); viewGcodeBasic.Closed += (s, e) => Close(); } TabPage layerView = new TabPage(viewGcodeBasic, "Layer View".Localize().ToUpper()); int tabPointSize = 16; // add the correct tabs based on whether we are stand alone or embedded Tab threeDViewTab; if (windowMode == View3DWidget.WindowMode.StandAlone || UserSettings.Instance.IsTouchScreen) { threeDViewTab = new SimpleTextTabWidget(partPreview3DView, "3D View Tab", tabPointSize, selectedTabColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); tabControl.AddTab(threeDViewTab); layerViewTab = new SimpleTextTabWidget(layerView, "Layer View Tab", tabPointSize, selectedTabColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); tabControl.AddTab(layerViewTab); } else { threeDViewTab = new PopOutTextTabWidget(partPreview3DView, "3D View Tab", new Vector2(590, 400), tabPointSize); tabControl.AddTab(threeDViewTab); layerViewTab = new PopOutTextTabWidget(layerView, "Layer View Tab", new Vector2(590, 400), tabPointSize); tabControl.AddTab(layerViewTab); } threeDViewTab.ToolTipText = "Preview 3D Design".Localize(); layerViewTab.ToolTipText = "Preview layer Tool Paths".Localize(); this.AddChild(tabControl); }
public LibraryRowItem(PrintItemWrapper printItem, LibraryDataView libraryDataView) { this.libraryDataView = libraryDataView; this.printItemWrapper = printItem; this.Cursor = Cursors.Hand; linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.White; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; SetDisplayAttributes(); FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; mainContainer.VAnchor = VAnchor.ParentBottomTop; { GuiWidget primaryContainer = new GuiWidget(); primaryContainer.HAnchor = HAnchor.ParentLeftRight; primaryContainer.VAnchor = VAnchor.ParentBottomTop; FlowLayoutWidget primaryFlow = new FlowLayoutWidget(FlowDirection.LeftToRight); primaryFlow.HAnchor = HAnchor.ParentLeftRight; primaryFlow.VAnchor = VAnchor.ParentBottomTop; PartThumbnailWidget thumbnailWidget = new PartThumbnailWidget(printItem, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", PartThumbnailWidget.ImageSizes.Size50x50); selectionCheckBoxContainer = new GuiWidget(); selectionCheckBoxContainer.VAnchor = VAnchor.ParentBottomTop; selectionCheckBoxContainer.Width = 40; selectionCheckBoxContainer.Visible = false; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; selectionCheckBoxContainer.AddChild(selectionCheckBox); GuiWidget middleColumn = new GuiWidget(0.0, 0.0); middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight; middleColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop; middleColumn.Margin = new BorderDouble(10, 6); { string labelName = textInfo.ToTitleCase(printItem.Name); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 14); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 18); partLabel.VAnchor = VAnchor.ParentCenter; middleColumn.AddChild(partLabel); } primaryFlow.AddChild(selectionCheckBoxContainer); primaryFlow.AddChild(thumbnailWidget); primaryFlow.AddChild(middleColumn); primaryContainer.AddChild(primaryFlow); // The ConditionalClickWidget supplies a user driven Enabled property based on a delegate of your choosing primaryClickContainer = new ConditionalClickWidget(() => libraryDataView.EditMode); primaryClickContainer.HAnchor = HAnchor.ParentLeftRight; primaryClickContainer.VAnchor = VAnchor.ParentBottomTop; primaryContainer.AddChild(primaryClickContainer); rightButtonOverlay = getItemActionButtons(); rightButtonOverlay.Visible = false; mainContainer.AddChild(primaryContainer); mainContainer.AddChild(rightButtonOverlay); } this.AddChild(mainContainer); AddHandlers(); }
public static ImageBuffer GetImageForItem(PrintItemWrapper itemWrapper, int width, int height) { if (itemWrapper == null) { return(StaticData.Instance.LoadIcon("part_icon_transparent_100x100.png")); } ImageBuffer thumbnailImage = new ImageBuffer((int)width, (int)height); if (itemWrapper.FileLocation == QueueData.SdCardFileName) { ImageBuffer sdCardImage = StaticData.Instance.LoadIcon(Path.ChangeExtension("icon_sd_card_115x115", partExtension)).InvertLightness(); thumbnailImage.SetRecieveBlender(new BlenderPreMultBGRA()); Graphics2D graphics = thumbnailImage.NewGraphics2D(); graphics.Render(sdCardImage, width / 2 - sdCardImage.Width / 2, height / 2 - sdCardImage.Height / 2); Ellipse outline = new Ellipse(new Vector2(width / 2.0, height / 2.0), width / 2 - width / 12); graphics.Render(new Stroke(outline, width / 12), RGBA_Bytes.White); return(thumbnailImage); } else if (Path.GetExtension(itemWrapper.FileLocation).ToUpper() == ".GCODE") { thumbnailImage.SetRecieveBlender(new BlenderPreMultBGRA()); Graphics2D graphics = thumbnailImage.NewGraphics2D(); Vector2 center = new Vector2(width / 2.0, height / 2.0); Ellipse outline = new Ellipse(center, width / 2 - width / 12); graphics.Render(new Stroke(outline, width / 12), RGBA_Bytes.White); graphics.DrawString("GCode", center.x, center.y, 8 * width / 50, Agg.Font.Justification.Center, Agg.Font.Baseline.BoundsCenter, color: RGBA_Bytes.White); return(thumbnailImage); } else if (!File.Exists(itemWrapper.FileLocation)) { thumbnailImage.SetRecieveBlender(new BlenderPreMultBGRA()); Graphics2D graphics = thumbnailImage.NewGraphics2D(); Vector2 center = new Vector2(width / 2.0, height / 2.0); graphics.DrawString("Missing", center.x, center.y, 8 * width / 50, Agg.Font.Justification.Center, Agg.Font.Baseline.BoundsCenter, color: RGBA_Bytes.White); return(thumbnailImage); } else if (MeshIsTooBigToLoad(itemWrapper.FileLocation)) { thumbnailImage.SetRecieveBlender(new BlenderPreMultBGRA()); Graphics2D graphics = thumbnailImage.NewGraphics2D(); Vector2 center = new Vector2(width / 2.0, height / 2.0); double yOffset = 8 * width / 50 * GuiWidget.DeviceScale * 2; graphics.DrawString("Reduce\nPolygons\nto\nRender", center.x, center.y + yOffset, 8 * width / 50, Agg.Font.Justification.Center, Agg.Font.Baseline.BoundsCenter, color: RGBA_Bytes.White); return(thumbnailImage); } string stlHashCode = itemWrapper.FileHashCode.ToString(); if (stlHashCode != "0") { ImageBuffer bigRender = LoadImageFromDisk(stlHashCode); if (bigRender != null) { thumbnailImage = bigRender; } bigRender.SetRecieveBlender(new BlenderPreMultBGRA()); thumbnailImage = ImageBuffer.CreateScaledImage(bigRender, (int)width, (int)height); } thumbnailImage.MarkImageChanged(); return(thumbnailImage); }
private static void CreateSlicedPartsThread() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (!haltSlicingThread) { if (listOfSlicingItems.Count > 0) { PrintItemWrapper itemToSlice = listOfSlicingItems[0]; bool doMergeInSlicer = false; string mergeRules = ""; doMergeInSlicer = ActivePrinterProfile.Instance.ActiveSliceEngineType == ActivePrinterProfile.SlicingEngineTypes.MatterSlice; string[] stlFileLocations = GetStlFileLocations(itemToSlice.FileLocation, doMergeInSlicer, ref mergeRules); string fileToSlice = stlFileLocations[0]; // check that the STL file is currently on disk if (File.Exists(fileToSlice)) { itemToSlice.CurrentlySlicing = true; string currentConfigurationFileAndPath = Path.Combine(ApplicationDataStorage.Instance.GCodeOutputPath, "config_" + ActiveSliceSettings.Instance.GetHashCode().ToString() + ".ini"); ActiveSliceSettings.Instance.GenerateConfigFile(currentConfigurationFileAndPath); string gcodePathAndFileName = itemToSlice.GetGCodePathAndFileName(); bool gcodeFileIsComplete = itemToSlice.IsGCodeFileComplete(gcodePathAndFileName); if (!File.Exists(gcodePathAndFileName) || !gcodeFileIsComplete) { string commandArgs = ""; switch (ActivePrinterProfile.Instance.ActiveSliceEngineType) { case ActivePrinterProfile.SlicingEngineTypes.Slic3r: commandArgs = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + fileToSlice + "\""; break; case ActivePrinterProfile.SlicingEngineTypes.CuraEngine: commandArgs = "-v -o \"" + gcodePathAndFileName + "\" " + EngineMappingCura.GetCuraCommandLineSettings() + " \"" + fileToSlice + "\""; break; case ActivePrinterProfile.SlicingEngineTypes.MatterSlice: { EngineMappingsMatterSlice.WriteMatterSliceSettingsFile(currentConfigurationFileAndPath); if (mergeRules == "") { commandArgs = "-v -o \"" + gcodePathAndFileName + "\" -c \"" + currentConfigurationFileAndPath + "\""; } else { commandArgs = "-b {0} -v -o \"".FormatWith(mergeRules) + gcodePathAndFileName + "\" -c \"" + currentConfigurationFileAndPath + "\""; } foreach (string filename in stlFileLocations) { commandArgs = commandArgs + " \"" + filename + "\""; } } break; } #if false Mesh loadedMesh = StlProcessing.Load(fileToSlice); SliceLayers layers = new SliceLayers(); layers.GetPerimetersForAllLayers(loadedMesh, .2, .2); layers.DumpSegmentsToGcode("test.gcode"); #endif if (OsInformation.OperatingSystem == OSType.Android || ((OsInformation.OperatingSystem == OSType.Mac || runInProcess) && ActivePrinterProfile.Instance.ActiveSliceEngineType == ActivePrinterProfile.SlicingEngineTypes.MatterSlice)) { itemCurrentlySlicing = itemToSlice; MatterHackers.MatterSlice.LogOutput.GetLogWrites += SendProgressToItem; MatterSlice.MatterSlice.ProcessArgs(commandArgs); MatterHackers.MatterSlice.LogOutput.GetLogWrites -= SendProgressToItem; itemCurrentlySlicing = null; } else { slicerProcess = new Process(); slicerProcess.StartInfo.Arguments = commandArgs; string slicerFullPath = getSlicerFullPath(); slicerProcess.StartInfo.CreateNoWindow = true; slicerProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; slicerProcess.StartInfo.RedirectStandardError = true; slicerProcess.StartInfo.RedirectStandardOutput = true; slicerProcess.StartInfo.FileName = slicerFullPath; slicerProcess.StartInfo.UseShellExecute = false; slicerProcess.OutputDataReceived += (sender, args) => { if (args.Data != null) { string message = args.Data; message = message.Replace("=>", "").Trim(); if (message.Contains(".gcode")) { message = "Saving intermediate file"; } message += "..."; UiThread.RunOnIdle(() => { itemToSlice.OnSlicingOutputMessage(new StringEventArgs(message)); }); } }; slicerProcess.Start(); slicerProcess.BeginOutputReadLine(); string stdError = slicerProcess.StandardError.ReadToEnd(); slicerProcess.WaitForExit(); lock (slicerProcess) { slicerProcess = null; } } } try { if (File.Exists(gcodePathAndFileName) && File.Exists(currentConfigurationFileAndPath)) { // make sure we have not already written the settings onto this file bool fileHaseSettings = false; int bufferSize = 32000; using (Stream fileStream = File.OpenRead(gcodePathAndFileName)) { byte[] buffer = new byte[bufferSize]; fileStream.Seek(Math.Max(0, fileStream.Length - bufferSize), SeekOrigin.Begin); int numBytesRead = fileStream.Read(buffer, 0, bufferSize); string fileEnd = System.Text.Encoding.UTF8.GetString(buffer); if (fileEnd.Contains("GCode settings used")) { fileHaseSettings = true; } } if (!fileHaseSettings) { using (StreamWriter gcodeWirter = File.AppendText(gcodePathAndFileName)) { string oemName = "MatterControl"; if (OemSettings.Instance.WindowTitleExtra != null && OemSettings.Instance.WindowTitleExtra.Trim().Length > 0) { oemName = oemName + " - {0}".FormatWith(OemSettings.Instance.WindowTitleExtra); } gcodeWirter.WriteLine("; {0} Version {1} Build {2} : GCode settings used".FormatWith(oemName, VersionInfo.Instance.ReleaseVersion, VersionInfo.Instance.BuildVersion)); gcodeWirter.WriteLine("; Date {0} Time {1}:{2:00}".FormatWith(DateTime.Now.Date, DateTime.Now.Hour, DateTime.Now.Minute)); foreach (string line in File.ReadLines(currentConfigurationFileAndPath)) { gcodeWirter.WriteLine("; {0}".FormatWith(line)); } } } } } catch (Exception) { } } UiThread.RunOnIdle(() => { itemToSlice.CurrentlySlicing = false; itemToSlice.DoneSlicing = true; }); lock (listOfSlicingItems) { listOfSlicingItems.RemoveAt(0); } } Thread.Sleep(100); } }
public void LibraryProviderFileSystem_NavigationWorking() { Datastore.Instance.Initialize(); Thread.Sleep(3000); // wait for the library to finish initializing LibraryProviderFileSystem testProvider = new LibraryProviderFileSystem(pathToMesh, "TestPath", null); testProvider.DataReloaded += (sender, e) => { dataReloaded = true; }; Assert.IsTrue(testProvider.CollectionCount == 0, "Start with a new database for these tests."); Assert.IsTrue(testProvider.ItemCount == 1, "Start with a new database for these tests."); // create a collection and make sure it is on disk dataReloaded = false; // it has been loaded for the default set of parts string collectionName = "Collection1"; string createdDirectory = Path.Combine(pathToMesh, collectionName); Assert.IsTrue(!Directory.Exists(createdDirectory)); Assert.IsTrue(dataReloaded == false); testProvider.AddCollectionToLibrary(collectionName); Assert.IsTrue(testProvider.CollectionCount == 1); Assert.IsTrue(dataReloaded == true); Assert.IsTrue(Directory.Exists(createdDirectory)); PrintItemWrapper itemAtRoot = testProvider.GetPrintItemWrapperAsync(0).Result; // add an item works correctly LibraryProvider subProvider = testProvider.GetProviderForCollection(testProvider.GetCollectionItem(0)); subProvider.DataReloaded += (sender, e) => { dataReloaded = true; }; dataReloaded = false; //itemAdded = false; string subPathAndFile = Path.Combine(createdDirectory, meshFileName); Assert.IsTrue(!File.Exists(subPathAndFile)); Assert.IsTrue(dataReloaded == false); //Assert.IsTrue(itemAdded == false); // WIP: saving the name incorectly for this location (does not need to be changed). subProvider.AddFilesToLibrary(new string[] { meshPathAndFileName }); Thread.Sleep(3000); // wait for the add to finihs Assert.IsTrue(subProvider.ItemCount == 1); Assert.IsTrue(dataReloaded == true); //Assert.IsTrue(itemAdded == true); Assert.IsTrue(File.Exists(subPathAndFile)); // make sure the provider locator is correct // remove item works dataReloaded = false; Assert.IsTrue(dataReloaded == false); subProvider.RemoveItem(0); Assert.IsTrue(dataReloaded == true); Assert.IsTrue(!File.Exists(subPathAndFile)); // remove collection gets rid of it dataReloaded = false; Assert.IsTrue(dataReloaded == false); testProvider.RemoveCollection(0); Assert.IsTrue(dataReloaded == true); Assert.IsTrue(testProvider.CollectionCount == 0); Assert.IsTrue(!Directory.Exists(createdDirectory)); }
public abstract void AddItem(PrintItemWrapper itemToAdd);
public static string GetImageFileName(PrintItemWrapper item) { return(GetImageFileName(item.FileHashCode.ToString())); }
static void CreateSlicedPartsThread() { while (!haltSlicingThread) { if (PrinterCommunication.Instance.ActivePrintItem != null && listOfSlicingItems.Count > 0) { PrintItemWrapper itemToSlice = listOfSlicingItems[0]; // check that the STL file is currently on disk if (File.Exists(itemToSlice.FileLocation)) { itemToSlice.CurrentlySlicing = true; string currentConfigurationFileAndPath = Path.Combine(ApplicationDataStorage.Instance.GCodeOutputPath, "config_" + ActiveSliceSettings.Instance.GetHashCode().ToString() + ".ini"); ActiveSliceSettings.Instance.GenerateConfigFile(currentConfigurationFileAndPath); string gcodePathAndFileName = itemToSlice.GCodePathAndFileName; bool gcodeFileIsComplete = itemToSlice.IsGCodeFileComplete(gcodePathAndFileName); if (!File.Exists(gcodePathAndFileName) || !gcodeFileIsComplete) { slicerProcess = new Process(); switch (ActivePrinterProfile.Instance.ActiveSliceEngineType) { case ActivePrinterProfile.SlicingEngineTypes.Slic3r: slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\""; break; case ActivePrinterProfile.SlicingEngineTypes.CuraEngine: slicerProcess.StartInfo.Arguments = "-v -o \"" + gcodePathAndFileName + "\" " + CuraEngineMappings.GetCuraCommandLineSettings() + " \"" + itemToSlice.PartToSlicePathAndFileName + "\""; //Debug.Write(slicerProcess.StartInfo.Arguments); break; case ActivePrinterProfile.SlicingEngineTypes.MatterSlice: slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\""; break; } string slicerFullPath = getSlicerFullPath(); slicerProcess.StartInfo.CreateNoWindow = true; slicerProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; slicerProcess.StartInfo.RedirectStandardError = true; slicerProcess.StartInfo.RedirectStandardOutput = true; slicerProcess.StartInfo.FileName = slicerFullPath; slicerProcess.StartInfo.UseShellExecute = false; slicerProcess.OutputDataReceived += (sender, args) => { if (args.Data != null) { string message = args.Data; message = message.Replace("=>", "").Trim(); if (message.Contains(".gcode")) { message = "Saving intermediate file"; } message += "..."; UiThread.RunOnIdle((state) => { itemToSlice.OnSlicingOutputMessage(new StringEventArgs(message)); }); } }; slicerProcess.Start(); slicerProcess.BeginOutputReadLine(); string stdError = slicerProcess.StandardError.ReadToEnd(); slicerProcess.WaitForExit(); using (TimedLock.Lock(slicerProcess, "SlicingProcess")) { slicerProcess = null; } } } UiThread.RunOnIdle((state) => { itemToSlice.CurrentlySlicing = false; itemToSlice.DoneSlicing = true; }); using (TimedLock.Lock(listOfSlicingItems, "CreateSlicedPartsThread()")) { listOfSlicingItems.RemoveAt(0); } } Thread.Sleep(100); } }
public SaveAsWindow(SetPrintItemWrapperAndSave functionToCallOnSaveAs) : base(480, 250) { Title = "MatterControl - Save As"; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { string saveAsLabel = "Save New Design to Queue:"; TextWidget elementHeader = new TextWidget(saveAsLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); this.AddChild(topToBottom); } //Creates container in the middle of window FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { presetsFormContainer.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.VAnchor = VAnchor.ParentBottomTop; presetsFormContainer.Padding = new BorderDouble(5); presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } string fileNameLabel = "Design Name"; TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12); textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeader.Margin = new BorderDouble(5); textBoxHeader.HAnchor = HAnchor.ParentLeft; string fileNameLabelFull = "Enter the name of your design."; TextWidget textBoxHeaderFull = new TextWidget(fileNameLabelFull, pointSize: 9); textBoxHeaderFull.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeaderFull.Margin = new BorderDouble(5); textBoxHeaderFull.HAnchor = HAnchor.ParentLeftRight; //Adds text box and check box to the above container MHTextEditWidget textToAddWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here"); textToAddWidget.HAnchor = HAnchor.ParentLeftRight; textToAddWidget.Margin = new BorderDouble(5); GuiWidget cTSpacer = new GuiWidget(); cTSpacer.HAnchor = HAnchor.ParentLeftRight; CheckBox addToLibraryOption = new CheckBox("Also save to Library", ActiveTheme.Instance.PrimaryTextColor); addToLibraryOption.Margin = new BorderDouble(5); addToLibraryOption.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.AddChild(textBoxHeader); presetsFormContainer.AddChild(textBoxHeaderFull); presetsFormContainer.AddChild(textToAddWidget); presetsFormContainer.AddChild(cTSpacer); presetsFormContainer.AddChild(addToLibraryOption); topToBottom.AddChild(presetsFormContainer); //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button saveAsButton = textImageButtonFactory.Generate("Save As".Localize(), centerText: true); saveAsButton.Visible = true; saveAsButton.Cursor = Cursors.Hand; buttonRow.AddChild(saveAsButton); saveAsButton.Click += (sender, e) => { 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(); } }; //Adds SaveAs and Close Button to button container GuiWidget hButtonSpacer = new GuiWidget(); hButtonSpacer.HAnchor = HAnchor.ParentLeftRight; buttonRow.AddChild(hButtonSpacer); Button cancelButton = textImageButtonFactory.Generate("Cancel", centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); ShowAsSystemWindow(); }
public void Reload(PrintItemWrapper printItem) { this.RemoveAllChildren(); this.Load(printItem); }
public virtual bool EnabledForCurrentPart(PrintItemWrapper printItemWrapper) { return(true); }
public override void AddItem(PrintItemWrapper itemToAdd) { AddItem(itemToAdd.Name, itemToAdd.FileLocation); }
public override void AddItem(PrintItemWrapper itemToAdd) { throw new NotImplementedException(); //PrintHistoryData.Instance.AddItem(itemToAdd); }
public void AddItem(PrintItemWrapper item, int indexToInsert = -1) { QueueData.Instance.AddItem(item, indexToInsert); }
public void AddItem(PrintItemWrapper item, int indexToInsert = -1) { throw new NotImplementedException(); //PrintHistoryData.Instance.AddItem(item, indexToInsert); }
public void CreateWindowContent() { this.RemoveAllChildren(); TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); topToBottom.AnchorAll(); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { TextWidget elementHeader = new TextWidget("File export options:".Localize(), pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); } // Creates container in the middle of window FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; middleRowContainer.Padding = new BorderDouble(5); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } if (!partIsGCode) { string exportStlText = LocalizedString.Get("Export as"); string exportStlTextFull = string.Format("{0} STL", exportStlText); Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTextFull); exportAsStlButton.HAnchor = HAnchor.ParentLeft; exportAsStlButton.Cursor = Cursors.Hand; exportAsStlButton.Click += new EventHandler(exportSTL_Click); middleRowContainer.AddChild(exportAsStlButton); } if (!partIsGCode) { string exportAmfText = LocalizedString.Get("Export as"); string exportAmfTextFull = string.Format("{0} AMF", exportAmfText); Button exportAsAmfButton = textImageButtonFactory.Generate(exportAmfTextFull); exportAsAmfButton.HAnchor = HAnchor.ParentLeft; exportAsAmfButton.Cursor = Cursors.Hand; exportAsAmfButton.Click += new EventHandler(exportAMF_Click); middleRowContainer.AddChild(exportAsAmfButton); } bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode; if (showExportGCodeButton) { string exportGCodeTextFull = string.Format("{0} G-Code", "Export as".Localize()); Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull); exportGCode.Name = "Export as GCode Button"; exportGCode.HAnchor = HAnchor.ParentLeft; exportGCode.Cursor = Cursors.Hand; exportGCode.Click += new EventHandler((object sender, EventArgs e) => { UiThread.RunOnIdle(ExportGCode_Click); }); middleRowContainer.AddChild(exportGCode); PluginFinder <ExportGcodePlugin> exportPluginFinder = new PluginFinder <ExportGcodePlugin>(); foreach (ExportGcodePlugin plugin in exportPluginFinder.Plugins) { //Create export button for each Plugin found string exportButtonText = plugin.GetButtonText().Localize(); Button exportButton = textImageButtonFactory.Generate(exportButtonText); exportButton.HAnchor = HAnchor.ParentLeft; exportButton.Cursor = Cursors.Hand; exportButton.Click += (object sender, EventArgs e) => { UiThread.RunOnIdle(() => { // Close the export window Close(); // Open a SaveFileDialog. If Save is clicked, slice the part if needed and pass the plugin the // path to the gcode file and the target save path FileDialog.SaveFileDialog( new SaveFileDialogParams(plugin.GetExtensionFilter()) { Title = "MatterControl: Export File", FileName = printItemWrapper.Name, ActionButtonLabel = "Export" }, (SaveFileDialogParams saveParam) => { string extension = Path.GetExtension(saveParam.FileName); if (extension == "") { saveParam.FileName += plugin.GetFileExtension(); } if (partIsGCode) { plugin.Generate(printItemWrapper.FileLocation, saveParam.FileName); } else { SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper); printItemWrapper.SlicingDone += (printItem, eventArgs) => { PrintItemWrapper sliceItem = (PrintItemWrapper)printItem; if (File.Exists(sliceItem.GetGCodePathAndFileName())) { plugin.Generate(sliceItem.GetGCodePathAndFileName(), saveParam.FileName); } }; } }); }); }; // End exportButton Click handler middleRowContainer.AddChild(exportButton); } } middleRowContainer.AddChild(new VerticalSpacer()); // If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked. if (showExportGCodeButton && ActivePrinterProfile.Instance.DoPrintLeveling) { applyLeveling = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10); applyLeveling.Checked = true; applyLeveling.HAnchor = HAnchor.ParentLeft; applyLeveling.Cursor = Cursors.Hand; //applyLeveling.Margin = new BorderDouble(top: 10); middleRowContainer.AddChild(applyLeveling); } // TODO: make this work on the mac and then delete this if if (OsInformation.OperatingSystem == OSType.Windows || OsInformation.OperatingSystem == OSType.X11) { showInFolderAfterSave = new CheckBox(LocalizedString.Get("Show file in folder after save"), ActiveTheme.Instance.PrimaryTextColor, 10); showInFolderAfterSave.HAnchor = HAnchor.ParentLeft; showInFolderAfterSave.Cursor = Cursors.Hand; //showInFolderAfterSave.Margin = new BorderDouble(top: 10); middleRowContainer.AddChild(showInFolderAfterSave); } if (!showExportGCodeButton) { string noGCodeMessageTextBeg = LocalizedString.Get("Note"); string noGCodeMessageTextEnd = LocalizedString.Get("To enable GCode export, select a printer profile."); string noGCodeMessageTextFull = string.Format("{0}: {1}", noGCodeMessageTextBeg, noGCodeMessageTextEnd); TextWidget noGCodeMessage = new TextWidget(noGCodeMessageTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); noGCodeMessage.HAnchor = HAnchor.ParentLeft; middleRowContainer.AddChild(noGCodeMessage); } //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button cancelButton = textImageButtonFactory.Generate("Cancel"); cancelButton.Name = "Export Item Window Cancel Button"; cancelButton.Cursor = Cursors.Hand; cancelButton.Click += (sender, e) => { CloseOnIdle(); }; buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(cancelButton); topToBottom.AddChild(middleRowContainer); topToBottom.AddChild(buttonRow); this.AddChild(topToBottom); }
public void LibraryProviderFileSystem_NavigationWorking() { string downloadsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads"); string testLibraryDirectory = Path.Combine(downloadsDirectory, "LibraryProviderFileSystemTest"); if (Directory.Exists(testLibraryDirectory)) { Directory.Delete(testLibraryDirectory, true); } Directory.CreateDirectory(testLibraryDirectory); LibraryProviderFileSystem testProvider = new LibraryProviderFileSystem(testLibraryDirectory, "TestPath", null, null); testProvider.DataReloaded += (s, e) => { dataReloaded = true; }; Assert.IsTrue(testProvider.CollectionCount == 0, "Start with a new database for these tests."); Assert.IsTrue(testProvider.ItemCount == 0, "Start with a new database for these tests."); // create a collection and make sure it is on disk dataReloaded = false; // it has been loaded for the default set of parts string collectionName = "Collection1"; string createdDirectory = Path.Combine(testLibraryDirectory, collectionName); Assert.IsFalse(Directory.Exists(createdDirectory), "CreatedDirectory should *not* exist"); Assert.IsFalse(dataReloaded, "Reload should *not* have occurred"); testProvider.AddCollectionToLibrary(collectionName); Thread.Sleep(500); // wait for the add to finish Assert.AreEqual(1, testProvider.CollectionCount, "Incorrect collection count"); Assert.IsTrue(dataReloaded, "Reload should *have* occurred"); Assert.IsTrue(Directory.Exists(createdDirectory), "CreatedDirectory *should* exist"); // add an item works correctly LibraryProvider subProvider = testProvider.GetProviderForCollection(testProvider.GetCollectionItem(0)); subProvider.DataReloaded += (sender, e) => { dataReloaded = true; }; dataReloaded = false; //itemAdded = false; string subPathAndFile = Path.Combine(createdDirectory, meshFileName); Assert.IsFalse(File.Exists(subPathAndFile), "File should *not* exist: " + subPathAndFile); Assert.IsFalse(dataReloaded, "Reload should *not* have occurred"); //Assert.IsTrue(itemAdded == false); // WIP: saving the name incorrectly for this location (does not need to be changed). subProvider.AddFilesToLibrary(new string[] { meshPathAndFileName }); Thread.Sleep(3000); // wait for the add to finish PrintItemWrapper itemAtRoot = subProvider.GetPrintItemWrapperAsync(0).Result; Assert.IsTrue(subProvider.ItemCount == 1); Assert.IsTrue(dataReloaded == true); //Assert.IsTrue(itemAdded == true); Assert.IsTrue(File.Exists(subPathAndFile)); // make sure the provider locator is correct // remove item works dataReloaded = false; Assert.IsTrue(dataReloaded == false); subProvider.RemoveItem(0); Thread.Sleep(500); // wait for the remove to finish Assert.IsTrue(dataReloaded == true); Assert.IsTrue(!File.Exists(subPathAndFile)); // remove collection gets rid of it dataReloaded = false; Assert.IsTrue(dataReloaded == false); testProvider.RemoveCollection(0); Thread.Sleep(500); // wait for the remove to finish Assert.IsTrue(dataReloaded == true); Assert.IsTrue(testProvider.CollectionCount == 0); Assert.IsTrue(!Directory.Exists(createdDirectory)); if (Directory.Exists(testLibraryDirectory)) { Directory.Delete(testLibraryDirectory, true); } }
public void LibraryProviderSqlite_NavigationWorking() { StaticData.Instance = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData")); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); LibraryProviderSQLite testProvider = new LibraryProviderSQLite(null, null, null, "Local Library"); testProvider.DataReloaded += (sender, e) => { dataReloaded = true; }; Thread.Sleep(3000); // wait for the library to finish initializing UiThread.InvokePendingActions(); Assert.AreEqual(0, testProvider.CollectionCount, "Start with a new database for these tests."); Assert.AreEqual(3, testProvider.ItemCount, "Start with a new database for these tests."); // create a collection and make sure it is on disk dataReloaded = false; // it has been loaded for the default set of parts string collectionName = "Collection1"; Assert.IsTrue(!NamedCollectionExists(collectionName)); // assert that the record does not exist in the DB Assert.IsTrue(dataReloaded == false); testProvider.AddCollectionToLibrary(collectionName); Assert.IsTrue(testProvider.CollectionCount == 1); Assert.IsTrue(dataReloaded == true); Assert.IsTrue(NamedCollectionExists(collectionName)); // assert that the record does exist in the DB PrintItemWrapper itemAtRoot = testProvider.GetPrintItemWrapperAsync(0).Result; // add an item works correctly dataReloaded = false; Assert.IsTrue(!NamedItemExists(collectionName)); Assert.IsTrue(dataReloaded == false); //testProvider.AddFilesToLibrary(new string[] { meshPathAndFileName }); throw new NotImplementedException("testProvider.AddFilesToLibrary(new string[] { meshPathAndFileName });"); Thread.Sleep(3000); // wait for the add to finish UiThread.InvokePendingActions(); Assert.IsTrue(testProvider.ItemCount == 4); Assert.IsTrue(dataReloaded == true); string fileNameWithExtension = Path.GetFileNameWithoutExtension(meshPathAndFileName); Assert.IsTrue(NamedItemExists(fileNameWithExtension)); // make sure the provider locater is correct // remove item works dataReloaded = false; Assert.IsTrue(dataReloaded == false); testProvider.RemoveItem(0); Assert.IsTrue(dataReloaded == true); Assert.IsTrue(!NamedItemExists(fileNameWithExtension)); // remove collection gets rid of it dataReloaded = false; Assert.IsTrue(dataReloaded == false); testProvider.RemoveCollection(0); Assert.IsTrue(dataReloaded == true); Assert.IsTrue(testProvider.CollectionCount == 0); Assert.IsTrue(!NamedCollectionExists(collectionName)); // assert that the record does not exist in the DB //MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true); }
public ToolsListItem(PrintItemWrapper printItem) { this.printItem = printItem; linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.White; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; SetDisplayAttributes(); FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); mainContainer.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; { GuiWidget selectionCheckBoxContainer = new GuiWidget(); selectionCheckBoxContainer.VAnchor = VAnchor.Max_FitToChildren_ParentHeight; selectionCheckBoxContainer.HAnchor = Agg.UI.HAnchor.FitToChildren; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; selectionCheckBoxContainer.AddChild(selectionCheckBox); FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); leftColumn.VAnchor |= VAnchor.ParentTop; FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); middleColumn.VAnchor |= VAnchor.ParentTop; middleColumn.HAnchor |= HAnchor.ParentLeftRight; middleColumn.Padding = new BorderDouble(6); middleColumn.Margin = new BorderDouble(10, 0); { string labelName = textInfo.ToTitleCase(printItem.Name); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 12); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 16); middleColumn.AddChild(partLabel); } FlowLayoutWidget rightColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); rightColumn.VAnchor |= VAnchor.ParentCenter; buttonContainer = new FlowLayoutWidget(); buttonContainer.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; buttonContainer.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; { viewLink = linkButtonFactory.Generate("View"); viewLink.Margin = new BorderDouble(left: 10, right: 10); viewLink.VAnchor = VAnchor.ParentCenter; removeLink = linkButtonFactory.Generate("Remove"); removeLink.Margin = new BorderDouble(right: 10); removeLink.VAnchor = VAnchor.ParentCenter; buttonContainer.AddChild(viewLink); buttonContainer.AddChild(removeLink); } rightColumn.AddChild(buttonContainer); mainContainer.AddChild(selectionCheckBoxContainer); mainContainer.AddChild(leftColumn); mainContainer.AddChild(middleColumn); mainContainer.AddChild(rightColumn); } this.AddChild(mainContainer); AddHandlers(); }