diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs index 428295b88..895aae343 100644 --- a/PartPreviewWindow/GcodeViewBasic.cs +++ b/PartPreviewWindow/GcodeViewBasic.cs @@ -510,13 +510,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow navigationWidget.Margin = new BorderDouble(0, 0, 20, 0); layerSelectionButtonsPannel.AddChild(navigationWidget); - selectLayerSlider = new Slider(new Vector2(), 10, 0, gcodeViewWidget.LoadedGCode.NumChangesInZ - 1, Orientation.Vertical); selectLayerSlider.ValueChanged += new EventHandler(selectLayerSlider_ValueChanged); gcodeViewWidget.ActiveLayerChanged += new EventHandler(gcodeViewWidget_ActiveLayerChanged); AddChild(selectLayerSlider); SetSliderSize(); + // let's change the active layer so that it is set to the first layer with data + gcodeViewWidget.ActiveLayerIndex = gcodeViewWidget.ActiveLayerIndex + 1; + gcodeViewWidget.ActiveLayerIndex = gcodeViewWidget.ActiveLayerIndex - 1; + BoundsChanged += new EventHandler(PartPreviewGCode_BoundsChanged); } } diff --git a/PartPreviewWindow/PartPreviewMainWindow.cs b/PartPreviewWindow/PartPreviewMainWindow.cs index 36c6dcee1..f77e65ca6 100644 --- a/PartPreviewWindow/PartPreviewMainWindow.cs +++ b/PartPreviewWindow/PartPreviewMainWindow.cs @@ -79,11 +79,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow tabControl.AddTab(new SimpleTextTabWidget(layerView, 16, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes())); - if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") - { - tabControl.TabBar.SwitchToPage(layerView); - } - this.AddChild(tabControl); this.AnchorAll(); @@ -94,6 +89,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ShowAsSystemWindow(); MinimumSize = new Vector2(400, 300); + + // We do this after showing the system window so that when we try and take fucus the parent window (the system window) + // exists and can give the fucus to its child the gecode window. + if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") + { + tabControl.TabBar.SwitchToPage(layerView); + partGcodeView.Focus(); + } } PerformanceFeedbackWindow timingWindow = null;