private void onMouseClick(object sender, MouseEventArgs e) { if (printItem != null) { string pathAndFile = printItem.FileLocation; if (File.Exists(pathAndFile)) { new PartPreviewMainWindow(printItem); } else { PrintQueueItem.ShowCantFindFileMessage(printItem); } } }
void AddButtonOnIdle(object state) { OpenFileDialogParams openParams = new OpenFileDialogParams("Select an STL file|*.stl", multiSelect: true); FileDialog.OpenFileDialog(ref openParams); if (openParams.FileNames != null) { foreach (string loadedFileName in openParams.FileNames) { PrintQueueItem queueItem = new PrintQueueItem(System.IO.Path.GetFileNameWithoutExtension(loadedFileName), System.IO.Path.GetFullPath(loadedFileName)); PrintQueueControl.Instance.AddChild(queueItem); } PrintQueueControl.Instance.EnsureSelection(); PrintQueueControl.Instance.Invalidate(); } PrintQueueControl.Instance.SaveDefaultQueue(); }
public void ShouldCreateOneInstance() { var firstItem = new PrintQueueItem { DocumentName = "firstItem" }; var secondItem = new PrintQueueItem { DocumentName = "secondItem" }; var instance1 = Spooler.Instance; var instance2 = Spooler.Instance; Assert.Same(instance1, instance2); instance1.Queue.Add(firstItem); Assert.Equal(instance1.Queue.Count, instance2.Queue.Count); instance2.Queue.Add(secondItem); Assert.Equal(instance1.Queue.Count, instance2.Queue.Count); Assert.Same(instance1, instance2); }
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(); }