2017-07-06 12:22:56 -07:00
/ *
Copyright ( c ) 2017 , Lars Brubaker , John Lewin
All rights reserved .
Redistribution and use in source and binary forms , with or without
modification , are permitted provided that the following conditions are met :
1. Redistributions of source code must retain the above copyright notice , this
list of conditions and the following disclaimer .
2. Redistributions in binary form must reproduce the above copyright notice ,
this list of conditions and the following disclaimer in the documentation
and / or other materials provided with the distribution .
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES
( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ;
LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies ,
either expressed or implied , of the FreeBSD Project .
* /
2017-07-07 16:50:47 -07:00
using System ;
2017-07-10 12:32:41 -07:00
using System.Linq ;
2017-07-06 12:22:56 -07:00
using MatterHackers.Agg ;
using MatterHackers.Agg.UI ;
2017-07-07 16:50:47 -07:00
using MatterHackers.GCodeVisualizer ;
2017-07-06 12:22:56 -07:00
using MatterHackers.Localizations ;
using MatterHackers.MatterControl.CustomWidgets ;
using MatterHackers.MatterControl.SlicerConfiguration ;
using MatterHackers.MeshVisualizer ;
using MatterHackers.VectorMath ;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
2017-08-16 22:45:46 -07:00
public class PrinterTabPage : PrinterTabBase
2017-07-06 12:22:56 -07:00
{
2017-07-10 12:23:02 -07:00
internal GCode2DWidget gcode2DWidget ;
2017-09-15 16:49:21 -07:00
2017-08-16 22:45:46 -07:00
private View3DConfig gcodeOptions ;
2017-07-06 14:41:32 -07:00
private DoubleSolidSlider layerRenderRatioSlider ;
2017-07-10 12:32:41 -07:00
private SystemWindow parentSystemWindow ;
2017-10-21 20:22:14 -07:00
private SliceLayerSelector layerScrollbar ;
2017-09-15 16:49:21 -07:00
private PrinterConfig printer ;
2017-09-15 18:45:21 -07:00
public PrinterTabPage ( PrinterConfig printer , ThemeConfig theme , string tabTitle )
2017-09-17 01:11:18 -07:00
: base ( printer , printer . Bed , theme , tabTitle )
2017-07-06 12:22:56 -07:00
{
2017-09-15 16:49:21 -07:00
this . printer = printer ;
2017-10-06 12:23:32 -07:00
view3DWidget . meshViewerWidget . EditorMode = MeshViewerWidget . EditorType . Printer ;
2017-08-17 10:52:47 -07:00
2017-09-15 16:49:21 -07:00
gcodeOptions = sceneContext . RendererOptions ;
2017-07-06 14:41:32 -07:00
2017-07-10 12:23:02 -07:00
viewControls3D . TransformStateChanged + = ( s , e ) = >
{
switch ( e . TransformMode )
{
case ViewControls3DButtons . Translate :
if ( gcode2DWidget ! = null )
{
gcode2DWidget . TransformState = GCode2DWidget . ETransformState . Move ;
}
break ;
case ViewControls3DButtons . Scale :
if ( gcode2DWidget ! = null )
{
gcode2DWidget . TransformState = GCode2DWidget . ETransformState . Scale ;
}
break ;
}
} ;
2017-07-06 12:22:56 -07:00
viewControls3D . ResetView + = ( sender , e ) = >
{
2017-07-13 15:35:05 -07:00
if ( gcode2DWidget ? . Visible = = true )
2017-07-10 12:23:02 -07:00
{
gcode2DWidget . CenterPartInView ( ) ;
}
2017-07-06 12:22:56 -07:00
} ;
2017-08-16 22:45:46 -07:00
viewControls3D . ViewModeChanged + = ( s , e ) = >
2017-07-06 12:22:56 -07:00
{
2017-08-16 22:45:46 -07:00
this . ViewMode = e . ViewMode ;
2017-07-06 12:22:56 -07:00
} ;
2017-10-21 20:22:14 -07:00
layerScrollbar = new SliceLayerSelector ( printer , sceneContext )
2017-07-07 16:50:47 -07:00
{
2017-09-13 15:55:12 -07:00
VAnchor = VAnchor . Stretch ,
2017-10-21 20:22:14 -07:00
HAnchor = HAnchor . Right | HAnchor . Absolute ,
Width = 60 ,
Margin = new BorderDouble ( 0 , 80 , 8 , 42 ) ,
2017-07-06 14:41:32 -07:00
} ;
2017-10-21 20:22:14 -07:00
view3DContainer . AddChild ( layerScrollbar ) ;
2017-07-06 14:41:32 -07:00
2017-10-21 20:22:14 -07:00
layerRenderRatioSlider = new DoubleSolidSlider ( new Vector2 ( ) , SliceLayerSelector . SliderWidth ) ;
2017-07-06 14:41:32 -07:00
layerRenderRatioSlider . FirstValue = 0 ;
layerRenderRatioSlider . FirstValueChanged + = ( s , e ) = >
{
2017-09-15 16:49:21 -07:00
sceneContext . RenderInfo . FeatureToStartOnRatio0To1 = layerRenderRatioSlider . FirstValue ;
sceneContext . RenderInfo . FeatureToEndOnRatio0To1 = layerRenderRatioSlider . SecondValue ;
2017-07-06 14:41:32 -07:00
this . Invalidate ( ) ;
} ;
layerRenderRatioSlider . SecondValue = 1 ;
layerRenderRatioSlider . SecondValueChanged + = ( s , e ) = >
{
2017-09-01 17:41:43 -07:00
if ( printer ? . Bed ? . RenderInfo ! = null )
{
2017-09-15 16:49:21 -07:00
sceneContext . RenderInfo . FeatureToStartOnRatio0To1 = layerRenderRatioSlider . FirstValue ;
sceneContext . RenderInfo . FeatureToEndOnRatio0To1 = layerRenderRatioSlider . SecondValue ;
2017-09-01 17:41:43 -07:00
}
2017-07-06 14:41:32 -07:00
this . Invalidate ( ) ;
} ;
view3DContainer . AddChild ( layerRenderRatioSlider ) ;
2017-10-21 20:22:14 -07:00
AddSettingsTabBar ( leftToRight , view3DWidget ) ;
2017-07-07 12:52:00 -07:00
2017-09-15 16:49:21 -07:00
sceneContext . LoadedGCodeChanged + = BedPlate_LoadedGCodeChanged ;
2017-08-16 22:45:46 -07:00
this . ShowSliceLayers = false ;
2017-10-06 12:23:32 -07:00
view3DWidget . BoundsChanged + = ( s , e ) = >
2017-08-16 22:45:46 -07:00
{
SetSliderSizes ( ) ;
} ;
2017-10-19 09:04:36 -07:00
var printerActionsBar = new PrinterActionsBar ( printer , this , theme )
2017-08-16 22:45:46 -07:00
{
Padding = theme . ToolbarPadding
2017-10-19 09:04:36 -07:00
} ;
// Must come after we have an instance of View3DWidget an its undo buffer
topToBottom . AddChild ( printerActionsBar , 0 ) ;
var margin = viewControls3D . Margin ;
viewControls3D . Margin = new BorderDouble ( margin . Left , margin . Bottom , margin . Right , printerActionsBar . Height ) ;
2017-08-16 22:45:46 -07:00
SetSliderSizes ( ) ;
}
2017-07-06 12:22:56 -07:00
2017-09-15 16:49:21 -07:00
private GCodeFile loadedGCode = > sceneContext . LoadedGCode ;
2017-07-06 12:22:56 -07:00
2017-08-16 22:45:46 -07:00
private bool showSliceLayers ;
private bool ShowSliceLayers
{
get = > showSliceLayers ;
set
2017-07-06 12:22:56 -07:00
{
2017-08-16 22:45:46 -07:00
showSliceLayers = value ;
2017-10-06 12:23:32 -07:00
view3DWidget . gcodeViewer . Visible = value ;
2017-07-06 12:22:56 -07:00
2017-10-06 12:23:32 -07:00
view3DWidget . meshViewerWidget . IsActive = ! value ;
2017-07-06 12:22:56 -07:00
2017-08-16 22:45:46 -07:00
if ( showSliceLayers )
{
2017-09-16 01:11:44 -07:00
printer . Bed . Scene . ClearSelection ( ) ;
2017-08-16 22:45:46 -07:00
}
2017-07-06 14:41:32 -07:00
2017-09-15 16:49:21 -07:00
var slidersVisible = sceneContext . RenderInfo ! = null & & value ;
2017-07-06 12:22:56 -07:00
2017-10-21 20:22:14 -07:00
layerScrollbar . Visible = slidersVisible ;
2017-08-16 22:45:46 -07:00
layerRenderRatioSlider . Visible = slidersVisible ;
2017-07-06 12:22:56 -07:00
2017-10-20 07:26:14 -07:00
view3DWidget . selectedObjectContainer . Visible = ! showSliceLayers & & sceneContext . Scene . HasSelection ;
2017-08-16 22:45:46 -07:00
}
2017-07-06 12:22:56 -07:00
}
2017-08-16 22:45:46 -07:00
private PartViewMode viewMode ;
public PartViewMode ViewMode
2017-07-07 16:50:47 -07:00
{
2017-08-16 22:45:46 -07:00
get = > viewMode ;
set
2017-07-07 16:50:47 -07:00
{
2017-08-16 22:45:46 -07:00
if ( viewMode ! = value )
{
viewMode = value ;
viewControls3D . ViewMode = viewMode ;
switch ( viewMode )
{
case PartViewMode . Layers2D :
UserSettings . Instance . set ( "LayerViewDefault" , "2D Layer" ) ;
if ( gcode2DWidget ! = null )
{
gcode2DWidget . Visible = true ;
// HACK: Getting the Layer2D view to show content only works if CenterPartInView is called after the control is visible and after some cycles have passed
UiThread . RunOnIdle ( gcode2DWidget . CenterPartInView ) ;
}
this . ShowSliceLayers = true ;
break ;
case PartViewMode . Layers3D :
UserSettings . Instance . set ( "LayerViewDefault" , "3D Layer" ) ;
if ( gcode2DWidget ! = null )
{
gcode2DWidget . Visible = false ;
}
this . ShowSliceLayers = true ;
break ;
case PartViewMode . Model :
this . ShowSliceLayers = false ;
break ;
}
}
}
2017-07-07 16:50:47 -07:00
}
2017-07-06 14:41:32 -07:00
private void BedPlate_LoadedGCodeChanged ( object sender , EventArgs e )
{
2017-10-17 12:55:58 -07:00
bool gcodeLoaded = sceneContext . LoadedGCode ! = null ;
2017-10-21 20:22:14 -07:00
layerScrollbar . Visible = gcodeLoaded ;
2017-10-17 12:55:58 -07:00
layerRenderRatioSlider . Visible = gcodeLoaded ;
if ( ! gcodeLoaded )
{
return ;
}
2017-10-21 20:22:14 -07:00
layerScrollbar . Maximum = sceneContext . LoadedGCode . LayerCount ;
2017-07-07 16:50:47 -07:00
2017-07-06 15:58:14 -07:00
// ResetRenderInfo
2017-09-15 16:49:21 -07:00
sceneContext . RenderInfo = new GCodeRenderInfo (
2017-07-06 15:58:14 -07:00
0 ,
1 ,
Agg . Transform . Affine . NewIdentity ( ) ,
1 ,
0 ,
1 ,
new Vector2 [ ]
{
2017-09-15 12:08:00 -07:00
printer . Settings . Helpers . ExtruderOffset ( 0 ) ,
printer . Settings . Helpers . ExtruderOffset ( 1 )
2017-07-06 15:58:14 -07:00
} ,
this . GetRenderType ,
2017-07-12 14:28:43 -07:00
MeshViewerWidget . GetExtruderColor ) ;
2017-07-10 12:23:02 -07:00
// Close and remove any existing widget reference
gcode2DWidget ? . Close ( ) ;
2017-09-15 16:49:21 -07:00
var viewerVolume = sceneContext . ViewerVolume ;
2017-08-16 05:53:26 -07:00
2017-07-10 12:23:02 -07:00
// Create and append new widget
2017-09-15 16:49:21 -07:00
gcode2DWidget = new GCode2DWidget ( new Vector2 ( viewerVolume . x , viewerVolume . y ) , sceneContext . BedCenter )
2017-07-10 12:23:02 -07:00
{
Visible = ( this . ViewMode = = PartViewMode . Layers2D )
} ;
view3DContainer . AddChild ( gcode2DWidget ) ;
viewControls3D . Layers2DButton . Enabled = true ;
2017-07-06 15:58:14 -07:00
}
private RenderType GetRenderType ( )
{
RenderType renderType = RenderType . Extrusions ;
if ( gcodeOptions . RenderMoves )
{
renderType | = RenderType . Moves ;
}
if ( gcodeOptions . RenderRetractions )
{
renderType | = RenderType . Retractions ;
}
if ( gcodeOptions . RenderSpeeds )
{
renderType | = RenderType . SpeedColors ;
}
if ( gcodeOptions . SimulateExtrusion )
{
renderType | = RenderType . SimulateExtrusion ;
}
if ( gcodeOptions . TransparentExtrusion )
{
renderType | = RenderType . TransparentExtrusion ;
}
if ( gcodeOptions . HideExtruderOffsets )
{
renderType | = RenderType . HideExtruderOffsets ;
}
return renderType ;
2017-07-06 14:41:32 -07:00
}
2017-08-16 22:45:46 -07:00
private void SetSyncToPrintVisibility ( )
2017-07-06 12:22:56 -07:00
{
2017-09-16 01:36:19 -07:00
bool printerIsRunningPrint = printer . Connection . PrinterIsPaused | | printer . Connection . PrinterIsPrinting ;
2017-07-06 12:22:56 -07:00
2017-08-16 22:45:46 -07:00
if ( gcodeOptions . SyncToPrint & & printerIsRunningPrint )
2017-07-06 12:22:56 -07:00
{
2017-08-16 22:45:46 -07:00
SetAnimationPosition ( ) ;
layerRenderRatioSlider . Visible = false ;
2017-10-21 20:22:14 -07:00
layerScrollbar . Visible = false ;
2017-07-06 12:22:56 -07:00
}
else
{
2017-08-16 22:45:46 -07:00
if ( layerRenderRatioSlider ! = null )
{
layerRenderRatioSlider . FirstValue = 0 ;
layerRenderRatioSlider . SecondValue = 1 ;
}
2017-07-06 12:22:56 -07:00
2017-08-16 22:45:46 -07:00
layerRenderRatioSlider . Visible = true ;
2017-10-21 20:22:14 -07:00
layerScrollbar . Visible = true ;
2017-08-16 22:45:46 -07:00
}
2017-07-06 12:22:56 -07:00
}
2017-09-17 01:11:18 -07:00
// TODO: Moved from View3DWidget as printer specialized logic can't be in the generic base. Consider moving to model
private bool PartsAreInPrintVolume ( )
{
AxisAlignedBoundingBox allBounds = AxisAlignedBoundingBox . Empty ;
foreach ( var aabb in printer . Bed . Scene . Children . Select ( item = > item . GetAxisAlignedBoundingBox ( Matrix4X4 . Identity ) ) )
{
allBounds + = aabb ;
}
bool onBed = allBounds . minXYZ . z > - . 001 & & allBounds . minXYZ . z < . 001 ; // really close to the bed
RectangleDouble bedRect = new RectangleDouble ( 0 , 0 , printer . Settings . GetValue < Vector2 > ( SettingsKey . bed_size ) . x , printer . Settings . GetValue < Vector2 > ( SettingsKey . bed_size ) . y ) ;
bedRect . Offset ( printer . Settings . GetValue < Vector2 > ( SettingsKey . print_center ) - printer . Settings . GetValue < Vector2 > ( SettingsKey . bed_size ) / 2 ) ;
bool inBounds = bedRect . Contains ( new Vector2 ( allBounds . minXYZ ) ) & & bedRect . Contains ( new Vector2 ( allBounds . maxXYZ ) ) ;
return onBed & & inBounds ;
}
2017-08-16 22:45:46 -07:00
private void SetSliderSizes ( )
2017-07-06 14:41:32 -07:00
{
2017-10-21 20:22:14 -07:00
if ( layerScrollbar = = null | | view3DWidget = = null )
2017-07-06 14:41:32 -07:00
{
2017-08-16 22:45:46 -07:00
return ;
}
2017-07-06 14:41:32 -07:00
2017-10-21 20:22:14 -07:00
2017-08-16 22:45:46 -07:00
layerRenderRatioSlider . OriginRelativeParent = new Vector2 ( 11 , 65 ) ;
2017-10-06 12:23:32 -07:00
layerRenderRatioSlider . TotalWidthInPixels = view3DWidget . Width - 45 ;
2017-07-06 12:22:56 -07:00
}
2017-10-21 20:22:14 -07:00
2017-08-16 22:45:46 -07:00
private void SetAnimationPosition ( )
2017-07-07 06:18:58 -07:00
{
2017-09-16 01:36:19 -07:00
int currentLayer = printer . Connection . CurrentlyPrintingLayer ;
2017-08-16 22:45:46 -07:00
if ( currentLayer < = 0 )
2017-07-07 06:18:58 -07:00
{
2017-10-21 20:22:14 -07:00
layerScrollbar . Value = 0 ;
2017-08-16 22:45:46 -07:00
layerRenderRatioSlider . SecondValue = 0 ;
layerRenderRatioSlider . FirstValue = 0 ;
2017-07-10 12:32:41 -07:00
}
2017-08-16 22:45:46 -07:00
else
2017-07-10 12:32:41 -07:00
{
2017-10-21 20:22:14 -07:00
layerScrollbar . Value = currentLayer - 1 ;
2017-09-16 01:36:19 -07:00
layerRenderRatioSlider . SecondValue = printer . Connection . RatioIntoCurrentLayer ;
2017-08-16 22:45:46 -07:00
layerRenderRatioSlider . FirstValue = 0 ;
2017-07-10 12:32:41 -07:00
}
}
2017-07-06 14:41:32 -07:00
internal GuiWidget ShowGCodeOverflowMenu ( )
{
var textColor = RGBA_Bytes . Black ;
var popupContainer = new FlowLayoutWidget ( FlowDirection . TopToBottom )
{
2017-08-07 15:47:27 -07:00
HAnchor = HAnchor . Stretch ,
2017-07-06 14:41:32 -07:00
Padding = 12 ,
BackgroundColor = RGBA_Bytes . White
} ;
// put in a show grid check box
CheckBox showGrid = new CheckBox ( "Print Bed" . Localize ( ) , textColor : textColor ) ;
showGrid . Checked = gcodeOptions . RenderGrid ;
showGrid . CheckedStateChanged + = ( sender , e ) = >
{
// TODO: How (if at all) do we disable bed rendering on GCode2D?
gcodeOptions . RenderGrid = showGrid . Checked ;
} ;
popupContainer . AddChild ( showGrid ) ;
// put in a show moves checkbox
var showMoves = new CheckBox ( "Moves" . Localize ( ) , textColor : textColor ) ;
showMoves . Checked = gcodeOptions . RenderMoves ;
showMoves . CheckedStateChanged + = ( sender , e ) = >
{
gcodeOptions . RenderMoves = showMoves . Checked ;
} ;
popupContainer . AddChild ( showMoves ) ;
// put in a show Retractions checkbox
CheckBox showRetractions = new CheckBox ( "Retractions" . Localize ( ) , textColor : textColor ) ;
showRetractions . Checked = gcodeOptions . RenderRetractions ;
showRetractions . CheckedStateChanged + = ( sender , e ) = >
{
gcodeOptions . RenderRetractions = showRetractions . Checked ;
} ;
popupContainer . AddChild ( showRetractions ) ;
// Speeds checkbox
var showSpeeds = new CheckBox ( "Speeds" . Localize ( ) , textColor : textColor ) ;
showSpeeds . Checked = gcodeOptions . RenderSpeeds ;
showSpeeds . CheckedStateChanged + = ( sender , e ) = >
{
//gradientWidget.Visible = showSpeeds.Checked;
gcodeOptions . RenderSpeeds = showSpeeds . Checked ;
} ;
popupContainer . AddChild ( showSpeeds ) ;
// Extrusion checkbox
var simulateExtrusion = new CheckBox ( "Extrusion" . Localize ( ) , textColor : textColor ) ;
simulateExtrusion . Checked = gcodeOptions . SimulateExtrusion ;
simulateExtrusion . CheckedStateChanged + = ( sender , e ) = >
{
gcodeOptions . SimulateExtrusion = simulateExtrusion . Checked ;
} ;
popupContainer . AddChild ( simulateExtrusion ) ;
// Transparent checkbox
var transparentExtrusion = new CheckBox ( "Transparent" . Localize ( ) , textColor : textColor )
{
Checked = gcodeOptions . TransparentExtrusion ,
Margin = new BorderDouble ( 5 , 0 , 0 , 0 ) ,
2017-08-07 15:47:27 -07:00
HAnchor = HAnchor . Left ,
2017-07-06 14:41:32 -07:00
} ;
transparentExtrusion . CheckedStateChanged + = ( sender , e ) = >
{
gcodeOptions . TransparentExtrusion = transparentExtrusion . Checked ;
} ;
popupContainer . AddChild ( transparentExtrusion ) ;
// Extrusion checkbox
2017-09-15 12:08:00 -07:00
if ( printer . Settings . GetValue < int > ( SettingsKey . extruder_count ) > 1 )
2017-07-06 14:41:32 -07:00
{
CheckBox hideExtruderOffsets = new CheckBox ( "Hide Offsets" , textColor : textColor ) ;
hideExtruderOffsets . Checked = gcodeOptions . HideExtruderOffsets ;
hideExtruderOffsets . CheckedStateChanged + = ( sender , e ) = >
{
gcodeOptions . HideExtruderOffsets = hideExtruderOffsets . Checked ;
} ;
popupContainer . AddChild ( hideExtruderOffsets ) ;
}
// Sync To Print checkbox
{
var syncToPrint = new CheckBox ( "Sync To Print" . Localize ( ) , textColor : textColor ) ;
syncToPrint . Checked = ( UserSettings . Instance . get ( "LayerViewSyncToPrint" ) = = "True" ) ;
syncToPrint . Name = "Sync To Print Checkbox" ;
syncToPrint . CheckedStateChanged + = ( s , e ) = >
{
gcodeOptions . SyncToPrint = syncToPrint . Checked ;
SetSyncToPrintVisibility ( ) ;
} ;
popupContainer . AddChild ( syncToPrint ) ;
}
return popupContainer ;
}
2017-08-16 22:45:46 -07:00
public override void OnDraw ( Graphics2D graphics2D )
2017-07-06 14:41:32 -07:00
{
2017-09-16 01:36:19 -07:00
bool printerIsRunningPrint = printer . Connection . PrinterIsPaused | | printer . Connection . PrinterIsPrinting ;
2017-08-16 22:45:46 -07:00
if ( gcodeOptions . SyncToPrint
& & printerIsRunningPrint
2017-10-06 12:23:32 -07:00
& & view3DWidget . gcodeViewer . Visible )
2017-07-06 14:41:32 -07:00
{
SetAnimationPosition ( ) ;
2017-08-16 22:45:46 -07:00
this . Invalidate ( ) ;
}
base . OnDraw ( graphics2D ) ;
}
protected override GuiWidget GetViewControls3DOverflowMenu ( )
{
2017-10-06 12:23:32 -07:00
if ( view3DWidget . gcodeViewer . Visible )
2017-08-16 22:45:46 -07:00
{
return this . ShowGCodeOverflowMenu ( ) ;
2017-07-06 14:41:32 -07:00
}
else
{
2017-10-06 12:23:32 -07:00
return view3DWidget . ShowOverflowMenu ( ) ;
2017-08-16 22:45:46 -07:00
}
}
2017-07-06 14:41:32 -07:00
2017-08-16 22:45:46 -07:00
public override void OnLoad ( EventArgs args )
{
// Find and hook the parent system window KeyDown event
if ( this . Parents < SystemWindow > ( ) . FirstOrDefault ( ) is SystemWindow systemWindow )
{
systemWindow . KeyDown + = Parent_KeyDown ;
parentSystemWindow = systemWindow ;
2017-07-06 14:41:32 -07:00
}
2017-08-16 22:45:46 -07:00
base . OnLoad ( args ) ;
2017-07-06 14:41:32 -07:00
}
2017-08-16 22:45:46 -07:00
public override void OnClosed ( ClosedEventArgs e )
2017-07-06 14:41:32 -07:00
{
2017-08-16 22:45:46 -07:00
// Find and unhook the parent system window KeyDown event
if ( parentSystemWindow ! = null )
2017-07-06 14:41:32 -07:00
{
2017-08-16 22:45:46 -07:00
parentSystemWindow . KeyDown - = Parent_KeyDown ;
2017-07-06 14:41:32 -07:00
}
2017-09-15 16:49:21 -07:00
sceneContext . LoadedGCodeChanged - = BedPlate_LoadedGCodeChanged ;
2017-07-06 14:41:32 -07:00
2017-08-16 22:45:46 -07:00
base . OnClosed ( e ) ;
2017-07-06 14:41:32 -07:00
}
2017-08-16 22:45:46 -07:00
private void Parent_KeyDown ( object sender , KeyEventArgs keyEvent )
2017-07-06 14:41:32 -07:00
{
2017-10-06 12:23:32 -07:00
if ( view3DWidget . gcodeViewer . Visible )
2017-07-06 14:41:32 -07:00
{
2017-08-16 22:45:46 -07:00
switch ( keyEvent . KeyCode )
{
case Keys . Up :
2017-10-21 20:22:14 -07:00
layerScrollbar . Value + = 1 ;
2017-08-16 22:45:46 -07:00
break ;
case Keys . Down :
2017-10-21 20:22:14 -07:00
layerScrollbar . Value - = 1 ;
2017-08-16 22:45:46 -07:00
break ;
}
}
}
private void AddSettingsTabBar ( GuiWidget parent , GuiWidget widgetTodockTo )
{
2017-09-17 14:01:58 -07:00
var sideBar = new DockingTabControl ( widgetTodockTo , DockSide . Right , ApplicationController . Instance . ActivePrinter )
2017-08-16 22:45:46 -07:00
{
2017-09-17 14:01:58 -07:00
ControlIsPinned = ApplicationController . Instance . ActivePrinter . ViewState . SliceSettingsTabPinned
2017-08-16 22:45:46 -07:00
} ;
sideBar . PinStatusChanged + = ( s , e ) = >
{
2017-09-17 14:01:58 -07:00
ApplicationController . Instance . ActivePrinter . ViewState . SliceSettingsTabPinned = sideBar . ControlIsPinned ;
2017-08-16 22:45:46 -07:00
} ;
parent . AddChild ( sideBar ) ;
2017-10-19 10:50:40 -07:00
sideBar . AddPage (
2017-10-21 20:22:14 -07:00
"Slice Settings" . Localize ( ) ,
2017-10-19 10:50:40 -07:00
new SliceSettingsWidget (
2017-10-21 20:22:14 -07:00
printer ,
2017-10-19 10:50:40 -07:00
new SettingsContext (
printer ,
2017-10-21 20:22:14 -07:00
null ,
2017-10-19 10:50:40 -07:00
NamedSettingsLayers . All ) ) ) ;
2017-08-16 22:45:46 -07:00
2017-09-15 12:08:00 -07:00
sideBar . AddPage ( "Controls" . Localize ( ) , new ManualPrinterControls ( printer ) ) ;
2017-08-16 22:45:46 -07:00
2017-09-17 13:30:05 -07:00
sideBar . AddPage ( "Terminal" . Localize ( ) , new TerminalWidget ( printer )
2017-08-24 17:09:10 -07:00
{
VAnchor = VAnchor . Stretch ,
HAnchor = HAnchor . Stretch
} ) ;
2017-07-06 14:41:32 -07:00
}
2017-08-16 22:45:46 -07:00
}
2017-07-06 12:22:56 -07:00
}