private void AddModelInfo(FlowLayoutWidget buttonPanel)
		{
			buttonPanel.CloseAllChildren();

			double oldWidth = textImageButtonFactory.FixedWidth;
			textImageButtonFactory.FixedWidth = 44 * TextWidget.GlobalPointSizeScaleRatio;

			FlowLayoutWidget modelInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			modelInfoContainer.HAnchor = HAnchor.ParentLeftRight;
			modelInfoContainer.Padding = new BorderDouble(5);

			string printTimeLabel = "Print Time".Localize();
			string printTimeLabelFull = string.Format("{0}:", printTimeLabel);
			// put in the print time
			modelInfoContainer.AddChild(new TextWidget(printTimeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
			{
				string timeRemainingText = "---";

				if (gcodeViewWidget != null && gcodeViewWidget.LoadedGCode != null)
				{
					int secondsRemaining = (int)gcodeViewWidget.LoadedGCode.Instruction(0).secondsToEndFromHere;
					int hoursRemaining = (int)(secondsRemaining / (60 * 60));
					int minutesRemaining = (int)((secondsRemaining + 30) / 60 - hoursRemaining * 60); // +30 for rounding
					secondsRemaining = secondsRemaining % 60;
					if (hoursRemaining > 0)
					{
						timeRemainingText = string.Format("{0} h, {1} min", hoursRemaining, minutesRemaining);
					}
					else
					{
						timeRemainingText = string.Format("{0} min", minutesRemaining);
					}
				}

				GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0}", timeRemainingText), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 14);
				//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
				estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
				modelInfoContainer.AddChild(estimatedPrintTime);
			}

			//modelInfoContainer.AddChild(new TextWidget("Size:", textColor: ActiveTheme.Instance.PrimaryTextColor));

			string filamentLengthLabel = "Filament Length".Localize();
			string filamentLengthLabelFull = string.Format("{0}:", filamentLengthLabel);
			// show the filament used
			modelInfoContainer.AddChild(new TextWidget(filamentLengthLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
			{
				double filamentUsed = gcodeViewWidget.LoadedGCode.GetFilamentUsedMm(ActiveSliceSettings.Instance.FilamentDiameter);

				GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.0} mm", filamentUsed), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
				//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
				estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
				modelInfoContainer.AddChild(estimatedPrintTime);
			}

			string filamentVolumeLabel = "Filament Volume".Localize();
			string filamentVolumeLabelFull = string.Format("{0}:", filamentVolumeLabel);
			modelInfoContainer.AddChild(new TextWidget(filamentVolumeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
			{
				double filamentMm3 = gcodeViewWidget.LoadedGCode.GetFilamentCubicMm(ActiveSliceSettings.Instance.FilamentDiameter);

				GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} cm3", filamentMm3 / 1000), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
				//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
				estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
				modelInfoContainer.AddChild(estimatedPrintTime);
			}

			string weightLabel = "Estimated Weight".Localize();
			string weightLabelFull = string.Format("{0}:", weightLabel);
			modelInfoContainer.AddChild(new TextWidget(weightLabelFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor));
			{
				var density = 1.0;
				string filamentType = "PLA";
				if (filamentType == "ABS")
				{
					density = 1.04;
				}
				else if (filamentType == "PLA")
				{
					density = 1.24;
				}

				double filamentWeightGrams = gcodeViewWidget.LoadedGCode.GetFilamentWeightGrams(ActiveSliceSettings.Instance.FilamentDiameter, density);

				GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} g", filamentWeightGrams), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
				//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
				estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
				modelInfoContainer.AddChild(estimatedPrintTime);
			}

			//modelInfoContainer.AddChild(new TextWidget("Layer Count:", textColor: ActiveTheme.Instance.PrimaryTextColor));

			buttonPanel.AddChild(modelInfoContainer);

			textImageButtonFactory.FixedWidth = oldWidth;
		}
		private void AddDisplayControls(FlowLayoutWidget buttonPanel)
		{
			buttonPanel.CloseAllChildren();

			double oldWidth = textImageButtonFactory.FixedWidth;
			textImageButtonFactory.FixedWidth = 44 * TextWidget.GlobalPointSizeScaleRatio;

			FlowLayoutWidget layerInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			layerInfoContainer.HAnchor = HAnchor.ParentLeftRight;
			layerInfoContainer.Padding = new BorderDouble(5);

			// put in a show grid check box
			{
				CheckBox showGrid = new CheckBox(LocalizedString.Get("Print Bed"), textColor: ActiveTheme.Instance.PrimaryTextColor);
				showGrid.Checked = gcodeViewWidget.RenderGrid;
				meshViewerWidget.RenderBed = showGrid.Checked;
				showGrid.CheckedStateChanged += (sender, e) =>
				{
					gcodeViewWidget.RenderGrid = showGrid.Checked;
					meshViewerWidget.RenderBed = showGrid.Checked;
				};
				layerInfoContainer.AddChild(showGrid);
			}

			// put in a show moves checkbox
			{
				CheckBox showMoves = new CheckBox(LocalizedString.Get("Moves"), textColor: ActiveTheme.Instance.PrimaryTextColor);
				showMoves.Checked = gcodeViewWidget.RenderMoves;
				showMoves.CheckedStateChanged += (sender, e) =>
				{
					gcodeViewWidget.RenderMoves = showMoves.Checked;
				};
				layerInfoContainer.AddChild(showMoves);
			}

			// put in a show Retractions checkbox
			{
				CheckBox showRetractions = new CheckBox(LocalizedString.Get("Retractions"), textColor: ActiveTheme.Instance.PrimaryTextColor);
				showRetractions.Checked = gcodeViewWidget.RenderRetractions;
				showRetractions.CheckedStateChanged += (sender, e) =>
				{
					gcodeViewWidget.RenderRetractions = showRetractions.Checked;
				};
				layerInfoContainer.AddChild(showRetractions);
			}

			// put in a show speed checkbox
			{
				showSpeeds = new CheckBox(LocalizedString.Get("Speeds"), textColor: ActiveTheme.Instance.PrimaryTextColor);
				showSpeeds.Checked = gcodeViewWidget.RenderSpeeds;
				//showSpeeds.Checked = gradient.Visible;
				showSpeeds.CheckedStateChanged += (sender, e) =>
				{
					/* if (!showSpeeds.Checked)
					 {
						 gradient.Visible = false;
					 }
					 else
					 {
						 gradient.Visible = true;
					 }*/

					gradientWidget.Visible = showSpeeds.Checked;

					gcodeViewWidget.RenderSpeeds = showSpeeds.Checked;
				};

				layerInfoContainer.AddChild(showSpeeds);
			}

			// put in a simulate extrusion checkbox
			{
				CheckBox simulateExtrusion = new CheckBox(LocalizedString.Get("Extrusion"), textColor: ActiveTheme.Instance.PrimaryTextColor);
				simulateExtrusion.Checked = gcodeViewWidget.SimulateExtrusion;
				simulateExtrusion.CheckedStateChanged += (sender, e) =>
				{
					gcodeViewWidget.SimulateExtrusion = simulateExtrusion.Checked;
				};
				layerInfoContainer.AddChild(simulateExtrusion);
			}

            // put in a render extrusion transparent checkbox
            {
                CheckBox transparentExtrusion = new CheckBox(LocalizedString.Get("Transparent"), textColor: ActiveTheme.Instance.PrimaryTextColor)
                {
                    Checked = gcodeViewWidget.TransparentExtrusion,
                    Margin = new BorderDouble(5, 0, 0, 0) * TextWidget.GlobalPointSizeScaleRatio,
                    HAnchor = HAnchor.ParentLeft,
                };

                transparentExtrusion.CheckedStateChanged += (sender, e) =>
                {
                    gcodeViewWidget.TransparentExtrusion = transparentExtrusion.Checked;
                };
                layerInfoContainer.AddChild(transparentExtrusion);
            }

            // put in a simulate extrusion checkbox
            if (ActiveSliceSettings.Instance.ExtruderCount > 1)
			{
				CheckBox hideExtruderOffsets = new CheckBox("Hide Offsets", textColor: ActiveTheme.Instance.PrimaryTextColor);
				hideExtruderOffsets.Checked = gcodeViewWidget.HideExtruderOffsets;
				hideExtruderOffsets.CheckedStateChanged += (sender, e) =>
				{
					gcodeViewWidget.HideExtruderOffsets = hideExtruderOffsets.Checked;
				};
				layerInfoContainer.AddChild(hideExtruderOffsets);
			}

			// put in a show 3D view checkbox
			{
				viewControlsToggle.twoDimensionButton.CheckedStateChanged += (sender, e) =>
				{
					SetLayerViewType();
				};
				viewControlsToggle.threeDimensionButton.CheckedStateChanged += (sender, e) =>
				{
					SetLayerViewType();
				};
				SetLayerViewType();
			}

			// Put in the sync to print checkbox
			if (windowMode == WindowMode.Embeded)
			{
				syncToPrint = new CheckBox("Sync To Print".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
				syncToPrint.Checked = (UserSettings.Instance.get("LayerViewSyncToPrint") == "True");
				syncToPrint.CheckedStateChanged += (sender, e) =>
				{
					UserSettings.Instance.set("LayerViewSyncToPrint", syncToPrint.Checked.ToString());
					SetSyncToPrintVisibility();
				};
				layerInfoContainer.AddChild(syncToPrint);

				// The idea here is we just got asked to rebuild the window (and it is being created now)
				// because the gcode finished creating for the print that is printing.
				// We don't want to be notified if any other updates happen to this gcode while it is printing.
				if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting
					&& PrinterConnectionAndCommunication.Instance.ActivePrintItem == printItem)
				{
					printItem.SlicingOutputMessage -= sliceItem_SlicingOutputMessage;
					printItem.SlicingDone -= sliceItem_Done;

					generateGCodeButton.Visible = false;

					// However if the print finished or is canceled we are going to want to get updates again. So, hook the status event
					PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(HookUpGCodeMessagesWhenDonePrinting, ref unregisterEvents);
					UiThread.RunOnIdle(SetSyncToPrintVisibility);
				}
			}

			//layerInfoContainer.AddChild(new CheckBox("Show Retractions", textColor: ActiveTheme.Instance.PrimaryTextColor));

			buttonPanel.AddChild(layerInfoContainer);

			textImageButtonFactory.FixedWidth = oldWidth;
		}
		private void AddModelInfo(FlowLayoutWidget buttonPanel)
		{
			buttonPanel.CloseAllChildren();

			double oldWidth = textImageButtonFactory.FixedWidth;
			textImageButtonFactory.FixedWidth = 44 * GuiWidget.DeviceScale;

			FlowLayoutWidget modelInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			modelInfoContainer.HAnchor = HAnchor.ParentLeftRight;
			modelInfoContainer.Padding = new BorderDouble(5);

			string printTimeLabel = "Print Time".Localize();
			string printTimeLabelFull = string.Format("{0}:", printTimeLabel);
			// put in the print time
			modelInfoContainer.AddChild(new TextWidget(printTimeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
			{
				string timeRemainingText = "---";

				if (gcodeViewWidget != null && gcodeViewWidget.LoadedGCode != null)
				{
					int secondsRemaining = (int)gcodeViewWidget.LoadedGCode.Instruction(0).secondsToEndFromHere;
					int hoursRemaining = (int)(secondsRemaining / (60 * 60));
					int minutesRemaining = (int)((secondsRemaining + 30) / 60 - hoursRemaining * 60); // +30 for rounding
					secondsRemaining = secondsRemaining % 60;
					if (hoursRemaining > 0)
					{
						timeRemainingText = string.Format("{0} h, {1} min", hoursRemaining, minutesRemaining);
					}
					else
					{
						timeRemainingText = string.Format("{0} min", minutesRemaining);
					}
				}

				GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0}", timeRemainingText), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 14);
				//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
				estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
				modelInfoContainer.AddChild(estimatedPrintTime);
			}

			//modelInfoContainer.AddChild(new TextWidget("Size:", textColor: ActiveTheme.Instance.PrimaryTextColor));

			string filamentLengthLabel = "Filament Length".Localize();
			string filamentLengthLabelFull = string.Format("{0}:", filamentLengthLabel);
			// show the filament used
			modelInfoContainer.AddChild(new TextWidget(filamentLengthLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
			{
				double filamentUsed = gcodeViewWidget.LoadedGCode.GetFilamentUsedMm(ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.filament_diameter));

				GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.0} mm", filamentUsed), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
				//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
				estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
				modelInfoContainer.AddChild(estimatedPrintTime);
			}

			string filamentVolumeLabel = "Filament Volume".Localize();
			string filamentVolumeLabelFull = string.Format("{0}:", filamentVolumeLabel);
			modelInfoContainer.AddChild(new TextWidget(filamentVolumeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
			{
				double filamentMm3 = gcodeViewWidget.LoadedGCode.GetFilamentCubicMm(ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.filament_diameter));

				GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} cm³", filamentMm3 / 1000), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
				//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
				estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
				modelInfoContainer.AddChild(estimatedPrintTime);
			}

			modelInfoContainer.AddChild(GetEstimatedMassInfo());
			modelInfoContainer.AddChild(GetEstimatedCostInfo());

			PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(HookUpGCodeMessagesWhenDonePrinting, ref unregisterEvents);

			buttonPanel.AddChild(modelInfoContainer);

			textImageButtonFactory.FixedWidth = oldWidth;
		}