public LayerNavigationWidget(GCodeViewWidget gcodeViewWidget) : base(FlowDirection.LeftToRight) { this.gcodeViewWidget = gcodeViewWidget; textImageButtonFactory.normalTextColor = RGBA_Bytes.White; textImageButtonFactory.hoverTextColor = RGBA_Bytes.White; textImageButtonFactory.disabledTextColor = RGBA_Bytes.White; textImageButtonFactory.pressedTextColor = RGBA_Bytes.White; prevLayerButton = textImageButtonFactory.Generate("<<"); prevLayerButton.Click += new Button.ButtonEventHandler(prevLayer_ButtonClick); this.AddChild(prevLayerButton); layerCountTextWidget = new TextWidget("/1____", 12); layerCountTextWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; layerCountTextWidget.VAnchor = VAnchor.ParentCenter; layerCountTextWidget.AutoExpandBoundsToText = true; layerCountTextWidget.Margin = new BorderDouble(5, 0); this.AddChild(layerCountTextWidget); nextLayerButton = textImageButtonFactory.Generate(">>"); nextLayerButton.Click += new Button.ButtonEventHandler(nextLayer_ButtonClick); this.AddChild(nextLayerButton); }
private GuiWidget CreateGCodeViewWidget(string pathAndFileName) { gcodeViewWidget = new GCodeViewWidget(bedSizeFunction(), bedCenterFunction()); gcodeViewWidget.DoneLoading += DoneLoadingGCode; gcodeViewWidget.LoadingProgressChanged += LoadingProgressChanged; partToStartLoadingOnFirstDraw = pathAndFileName; return(gcodeViewWidget); }
public SetLayerWidget(GCodeViewWidget gcodeViewWidget) : base(FlowDirection.LeftToRight) { this.gcodeViewWidget = gcodeViewWidget; textImageButtonFactory.normalTextColor = RGBA_Bytes.White; textImageButtonFactory.hoverTextColor = RGBA_Bytes.White; textImageButtonFactory.disabledTextColor = RGBA_Bytes.White; textImageButtonFactory.pressedTextColor = RGBA_Bytes.White; editCurrentLayerIndex = new NumberEdit(1, pixelWidth: 40); editCurrentLayerIndex.VAnchor = VAnchor.ParentCenter; editCurrentLayerIndex.Margin = new BorderDouble(5, 0); editCurrentLayerIndex.EditComplete += new EventHandler(editCurrentLayerIndex_EditComplete); this.AddChild(editCurrentLayerIndex); gcodeViewWidget.ActiveLayerChanged += new EventHandler(gcodeViewWidget_ActiveLayerChanged); setLayerButton = textImageButtonFactory.Generate(new LocalizedString("Go").Translated); setLayerButton.VAnchor = Agg.UI.VAnchor.ParentCenter; setLayerButton.Click += new Button.ButtonEventHandler(layerCountTextWidget_EditComplete); this.AddChild(setLayerButton); }
void CreateAndAddChildren(object state) { RemoveAllChildren(); gcodeViewWidget = null; gcodeProcessingStateInfoText = null; FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight; buttonBottomPanel.Padding = new BorderDouble(3, 3); buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; generateGCodeButton = textImageButtonFactory.Generate(LocalizedString.Get("Generate")); generateGCodeButton.Click += new ButtonBase.ButtonEventHandler(generateButton_Click); buttonBottomPanel.AddChild(generateGCodeButton); layerSelectionButtonsPanel = new FlowLayoutWidget(FlowDirection.RightToLeft); layerSelectionButtonsPanel.HAnchor = HAnchor.ParentLeftRight; layerSelectionButtonsPanel.Padding = new BorderDouble(0); GuiWidget holdPanelOpen = new GuiWidget(1, generateGCodeButton.Height); layerSelectionButtonsPanel.AddChild(holdPanelOpen); if (widgetHasCloseButton) { Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close")); layerSelectionButtonsPanel.AddChild(closeButton); closeButton.Click += (sender, e) => { CloseOnIdle(); }; } FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight); centerPartPreviewAndControls.AnchorAll(); gcodeDispalyWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop); SetProcessingMessage("Press 'Add' to select an item.".Localize()); if (printItem != null) { SetProcessingMessage(LocalizedString.Get("Loading GCode...")); if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") { gcodeDispalyWidget.AddChild(CreateGCodeViewWidget(printItem.FileLocation)); } else { if (File.Exists(printItem.FileLocation)) { string gcodePathAndFileName = printItem.GCodePathAndFileName; bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName); if (printItem.SlicingHadError) { SetProcessingMessage(slicingErrorMessage); } else { SetProcessingMessage(pressGenerateMessage); } if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete) { gcodeDispalyWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName)); } // we only hook these up to make sure we can regenerate the gcode when we want printItem.SlicingOutputMessage.RegisterEvent(sliceItem_SlicingOutputMessage, ref unregisterEvents); printItem.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents); } else { SetProcessingMessage(string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name)); } } } else { generateGCodeButton.Visible = false; } centerPartPreviewAndControls.AddChild(gcodeDispalyWidget); buttonRightPanel = CreateRightButtonPanel(); centerPartPreviewAndControls.AddChild(buttonRightPanel); // add in a spacer layerSelectionButtonsPanel.AddChild(new GuiWidget(HAnchor.ParentLeftRight)); buttonBottomPanel.AddChild(layerSelectionButtonsPanel); mainContainerTopToBottom.AddChild(centerPartPreviewAndControls); mainContainerTopToBottom.AddChild(buttonBottomPanel); this.AddChild(mainContainerTopToBottom); Add2DViewControls(); translateButton.Click += (sender, e) => { gcodeViewWidget.TransformState = GCodeViewWidget.ETransformState.Move; }; scaleButton.Click += (sender, e) => { gcodeViewWidget.TransformState = GCodeViewWidget.ETransformState.Scale; }; AddHandlers(); }