2014-04-16 15:11:01 -07:00
/ *
2018-11-16 08:44:56 -08:00
Copyright ( c ) 2018 , Kevin Pope , John Lewin
2014-04-16 15:11:01 -07:00
All rights reserved .
Redistribution and use in source and binary forms , with or without
2015-04-08 15:20:10 -07:00
modification , are permitted provided that the following conditions are met :
2014-04-16 15:11:01 -07:00
1. Redistributions of source code must retain the above copyright notice , this
2015-04-08 15:20:10 -07:00
list of conditions and the following disclaimer .
2014-04-16 15:11:01 -07:00
2. Redistributions in binary form must reproduce the above copyright notice ,
this list of conditions and the following disclaimer in the documentation
2015-04-08 15:20:10 -07:00
and / or other materials provided with the distribution .
2014-04-16 15:11:01 -07:00
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
2015-04-08 15:20:10 -07:00
of the authors and should not be interpreted as representing official policies ,
2014-04-16 15:11:01 -07:00
either expressed or implied , of the FreeBSD Project .
* /
2017-06-30 18:00:02 -07:00
using System ;
2018-10-19 11:57:27 -07:00
using System.Collections.Generic ;
2017-06-27 18:41:34 -07:00
using System.Linq ;
using MatterHackers.Agg ;
using MatterHackers.Agg.UI ;
2014-04-16 15:11:01 -07:00
using MatterHackers.Localizations ;
2017-06-27 18:41:34 -07:00
using MatterHackers.MatterControl.ConfigurationPage ;
2018-11-02 16:14:37 -07:00
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling ;
2017-06-30 18:00:02 -07:00
using MatterHackers.MatterControl.CustomWidgets ;
2014-06-11 14:52:58 -07:00
using MatterHackers.MatterControl.PrinterCommunication ;
2015-04-08 15:20:10 -07:00
using MatterHackers.MatterControl.SlicerConfiguration ;
2014-04-16 15:11:01 -07:00
namespace MatterHackers.MatterControl.ActionBar
{
2017-09-08 10:23:28 -07:00
internal class ControlContentExtruder : FlowLayoutWidget
2015-04-08 15:20:10 -07:00
{
2018-08-16 16:47:56 -07:00
private int moveAmount = 10 ;
2017-09-15 12:08:00 -07:00
private PrinterConfig printer ;
2017-09-08 10:23:28 -07:00
2018-04-07 14:31:10 -07:00
internal ControlContentExtruder ( PrinterConfig printer , int extruderIndex , ThemeConfig theme )
2017-09-08 10:23:28 -07:00
: base ( FlowDirection . TopToBottom )
{
2018-04-10 14:42:13 -07:00
this . HAnchor = HAnchor . Stretch ;
2017-09-15 12:08:00 -07:00
this . printer = printer ;
2017-09-08 10:23:28 -07:00
2019-02-05 17:39:52 -08:00
GuiWidget loadUnloadButtonRow = null ;
2019-02-05 17:39:11 -08:00
// We do not yet support loading filament into extruders other than 0 & 1, fix it when needed.
2019-02-05 11:22:22 -08:00
if ( extruderIndex < 2 )
2018-01-23 14:21:47 -08:00
{
// add in load and unload buttons
2019-02-05 17:39:52 -08:00
loadUnloadButtonRow = new FlowLayoutWidget ( )
2018-04-10 16:57:34 -07:00
{
Padding = theme . ToolbarPadding ,
} ;
2018-10-30 10:39:33 -07:00
var loadButton = theme . CreateDialogButton ( "Load" . Localize ( ) ) ;
loadButton . ToolTipText = "Load filament" . Localize ( ) ;
2018-08-23 14:46:06 -07:00
loadButton . Name = "Load Filament Button" ;
2019-04-01 16:35:44 -07:00
loadButton . Click + = ( s , e ) = > UiThread . RunOnIdle ( ( ) = >
2018-11-02 16:14:37 -07:00
{
2019-02-16 13:55:27 -08:00
DialogWindow . Show (
new LoadFilamentWizard ( printer , extruderIndex , showAlreadyLoadedButton : false ) ) ;
} ) ;
2019-04-01 16:35:44 -07:00
2019-02-05 17:39:52 -08:00
loadUnloadButtonRow . AddChild ( loadButton ) ;
2018-04-10 16:57:34 -07:00
2018-10-30 10:39:33 -07:00
var unloadButton = theme . CreateDialogButton ( "Unload" . Localize ( ) ) ;
unloadButton . ToolTipText = "Unload filament" . Localize ( ) ;
2019-02-16 13:55:27 -08:00
unloadButton . Click + = ( s , e ) = > UiThread . RunOnIdle ( ( ) = >
2018-11-05 11:08:21 -08:00
{
2019-02-16 13:55:27 -08:00
DialogWindow . Show ( new UnloadFilamentWizard ( printer , extruderIndex ) ) ;
} ) ;
2019-02-05 17:39:52 -08:00
loadUnloadButtonRow . AddChild ( unloadButton ) ;
2018-04-10 16:57:34 -07:00
2019-02-05 17:39:52 -08:00
this . AddChild ( new SettingsItem ( "Filament" . Localize ( ) , loadUnloadButtonRow , theme , enforceGutter : false ) ) ;
2018-01-23 14:21:47 -08:00
}
2017-09-08 10:23:28 -07:00
// Add the Extrude buttons
2019-02-05 17:39:52 -08:00
var extrudeRetractButtonRow = new FlowLayoutWidget ( )
2017-09-08 10:23:28 -07:00
{
HAnchor = HAnchor . Fit ,
2018-04-10 16:57:34 -07:00
VAnchor = VAnchor . Fit ,
Padding = theme . ToolbarPadding ,
2017-09-08 10:23:28 -07:00
} ;
2019-02-05 17:39:52 -08:00
int extruderButtonTopMargin = loadUnloadButtonRow = = null ? 8 : 0 ;
2018-01-23 14:21:47 -08:00
2018-10-30 10:39:33 -07:00
var extrudeButton = theme . CreateDialogButton ( "Extrude" . Localize ( ) ) ;
extrudeButton . Name = "Extrude Button" ;
extrudeButton . ToolTipText = "Extrude filament" . Localize ( ) ;
2017-09-08 10:23:28 -07:00
extrudeButton . Click + = ( s , e ) = >
{
2017-09-15 12:08:00 -07:00
printer . Connection . MoveExtruderRelative ( moveAmount , printer . Settings . EFeedRate ( extruderIndex ) , extruderIndex ) ;
2017-09-08 10:23:28 -07:00
} ;
2019-02-05 17:39:52 -08:00
extrudeRetractButtonRow . AddChild ( extrudeButton ) ;
2017-09-08 10:23:28 -07:00
2018-10-31 19:10:12 -07:00
var retractButton = theme . CreateDialogButton ( "Retract" . Localize ( ) ) ;
retractButton . ToolTipText = "Retract filament" . Localize ( ) ;
retractButton . Click + = ( s , e ) = >
{
printer . Connection . MoveExtruderRelative ( moveAmount * - 1 , printer . Settings . EFeedRate ( extruderIndex ) , extruderIndex ) ;
} ;
2019-02-05 17:39:52 -08:00
extrudeRetractButtonRow . AddChild ( retractButton ) ;
2018-10-31 19:10:12 -07:00
2017-09-08 10:23:28 -07:00
this . AddChild ( new SettingsItem (
2019-02-05 17:39:52 -08:00
loadUnloadButtonRow = = null ? "Filament" . Localize ( ) : "" , // Don't put the name if we put in a load and unload button (it has the name)
extrudeRetractButtonRow ,
2018-04-12 08:42:10 -07:00
theme ,
2017-09-08 10:23:28 -07:00
enforceGutter : false ) ) ;
var moveButtonsContainer = new FlowLayoutWidget ( )
{
2018-04-10 16:57:34 -07:00
VAnchor = VAnchor . Fit | VAnchor . Center ,
2017-09-08 10:23:28 -07:00
HAnchor = HAnchor . Fit ,
2018-04-10 16:57:34 -07:00
Padding = theme . ToolbarPadding ,
2017-09-08 10:23:28 -07:00
} ;
2018-04-14 13:01:16 -07:00
var oneButton = theme . CreateMicroRadioButton ( "1" ) ;
2017-09-08 10:23:28 -07:00
oneButton . CheckedStateChanged + = ( s , e ) = >
{
if ( oneButton . Checked )
{
moveAmount = 1 ;
}
} ;
moveButtonsContainer . AddChild ( oneButton ) ;
2018-04-14 13:01:16 -07:00
var tenButton = theme . CreateMicroRadioButton ( "10" ) ;
2017-09-08 10:23:28 -07:00
tenButton . CheckedStateChanged + = ( s , e ) = >
{
if ( tenButton . Checked )
{
moveAmount = 10 ;
}
} ;
moveButtonsContainer . AddChild ( tenButton ) ;
2018-04-14 13:01:16 -07:00
var oneHundredButton = theme . CreateMicroRadioButton ( "100" ) ;
2017-09-08 10:23:28 -07:00
oneHundredButton . CheckedStateChanged + = ( s , e ) = >
{
if ( oneHundredButton . Checked )
{
moveAmount = 100 ;
}
} ;
moveButtonsContainer . AddChild ( oneHundredButton ) ;
2018-08-16 16:47:44 -07:00
switch ( moveAmount )
{
case 1 :
oneButton . Checked = true ;
break ;
case 10 :
tenButton . Checked = true ;
break ;
case 100 :
oneHundredButton . Checked = true ;
break ;
}
2017-09-08 10:23:28 -07:00
2018-11-03 09:13:07 -07:00
moveButtonsContainer . AddChild ( new TextWidget ( "mm" , textColor : theme . TextColor , pointSize : 8 )
2017-09-08 10:23:28 -07:00
{
VAnchor = VAnchor . Center ,
Margin = new BorderDouble ( 3 , 0 )
} ) ;
2018-04-12 08:42:10 -07:00
this . AddChild ( new SettingsItem ( "Distance" . Localize ( ) , moveButtonsContainer , theme , enforceGutter : false ) ) ;
2017-09-08 10:23:28 -07:00
}
2017-09-06 18:16:45 -07:00
}
internal class TemperatureWidgetHotend : TemperatureWidgetBase
{
2017-09-08 10:23:28 -07:00
private int hotendIndex = - 1 ;
2016-05-03 08:49:16 -07:00
private string sliceSettingsNote = "Note: Slice Settings are applied before the print actually starts. Changes while printing will not effect the active print." . Localize ( ) ;
private string waitingForExtruderToHeatMessage = "The extruder is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting extruder temperature in 'Slice Settings' -> 'Filament'.\n\n{1}" . Localize ( ) ;
2018-10-19 11:57:27 -07:00
private Dictionary < string , UIField > allUiFields = new Dictionary < string , UIField > ( ) ;
2018-11-16 08:44:56 -08:00
private RunningInterval runningInterval ;
2018-12-10 14:26:29 -08:00
private ThemeConfig theme ;
2015-04-08 15:20:10 -07:00
2018-12-10 13:58:59 -08:00
public TemperatureWidgetHotend ( PrinterConfig printer , int hotendIndex , ThemeConfig theme , int totalHotends )
2018-04-12 08:42:10 -07:00
: base ( printer , "150.3°" , theme )
2015-04-08 15:20:10 -07:00
{
2018-12-10 14:26:29 -08:00
this . theme = theme ;
2017-09-07 16:24:11 -07:00
this . Name = $"Hotend {hotendIndex}" ;
2017-09-08 10:23:28 -07:00
this . hotendIndex = hotendIndex ;
2017-06-27 18:41:34 -07:00
this . DisplayCurrentTemperature ( ) ;
2018-12-10 13:58:59 -08:00
if ( totalHotends = = 1 )
{
this . ToolTipText = "Hotend Temperature" . Localize ( ) . FormatWith ( hotendIndex ) ;
}
else
{
this . ToolTipText = "Hotend {0} Temperature" . Localize ( ) . FormatWith ( hotendIndex + 1 ) ;
}
2015-08-12 13:16:39 -07:00
2018-04-12 08:42:10 -07:00
this . PopupContent = this . GetPopupContent ( ApplicationController . Instance . MenuTheme ) ;
2018-04-10 14:42:13 -07:00
2018-11-16 08:44:56 -08:00
// Register listeners
printer . Connection . HotendTemperatureRead + = Connection_HotendTemperatureRead ;
2019-03-18 14:12:09 -07:00
printer . Connection . HotendTargetTemperatureChanged + = this . Connection_HotendTargetTemperatureChanged ;
2015-04-08 15:20:10 -07:00
}
2018-01-10 14:41:14 -08:00
protected override int ActualTemperature = > ( int ) printer . Connection . GetActualHotendTemperature ( this . hotendIndex ) ;
2019-04-01 16:35:44 -07:00
2018-01-10 14:41:14 -08:00
protected override int TargetTemperature = > ( int ) printer . Connection . GetTargetHotendTemperature ( this . hotendIndex ) ;
2015-04-08 15:20:10 -07:00
2018-04-10 14:42:13 -07:00
private string TemperatureKey
2018-01-10 12:55:41 -08:00
{
2018-04-10 14:42:13 -07:00
get = > "temperature" + ( ( this . hotendIndex > 0 & & this . hotendIndex < 4 ) ? hotendIndex . ToString ( ) : "" ) ;
2018-01-10 12:55:41 -08:00
}
2018-10-14 07:33:45 -07:00
private GuiWidget GetPopupContent ( ThemeConfig menuTheme )
2017-01-23 12:38:34 -08:00
{
2017-06-27 18:41:34 -07:00
var widget = new IgnoredPopupWidget ( )
{
2020-07-22 08:05:39 -07:00
Width = 350 * GuiWidget . DeviceScale ,
2017-08-07 15:47:27 -07:00
HAnchor = HAnchor . Absolute ,
VAnchor = VAnchor . Fit ,
2018-10-13 17:58:54 -07:00
Padding = new BorderDouble ( 12 , 0 ) ,
2018-11-03 09:50:09 -07:00
BackgroundColor = menuTheme . BackgroundColor
2017-06-27 18:41:34 -07:00
} ;
var container = new FlowLayoutWidget ( FlowDirection . TopToBottom )
{
2017-08-07 15:47:27 -07:00
HAnchor = HAnchor . Stretch ,
VAnchor = VAnchor . Fit ,
2017-06-27 18:41:34 -07:00
} ;
2017-09-06 18:16:45 -07:00
widget . AddChild ( container ) ;
2017-06-27 18:41:34 -07:00
2017-09-07 16:24:11 -07:00
GuiWidget hotendRow ;
2019-04-01 16:35:44 -07:00
2017-09-07 16:24:11 -07:00
container . AddChild ( hotendRow = new SettingsItem (
2019-05-01 14:57:31 -07:00
printer . Settings . Helpers . HotendCount ( ) = = 1 ? "Hotend" . Localize ( ) : "Hotend {0}" . Localize ( ) . FormatWith ( hotendIndex + 1 ) ,
2018-10-14 07:33:45 -07:00
menuTheme ,
2017-06-27 18:41:34 -07:00
new SettingsItem . ToggleSwitchConfig ( )
{
2019-03-18 14:12:09 -07:00
Checked = printer . Connection . GetTargetHotendTemperature ( hotendIndex ) > 0 ,
2017-06-27 18:41:34 -07:00
ToggleAction = ( itemChecked ) = >
{
if ( itemChecked )
{
// Set to goal temp
2019-03-18 14:12:09 -07:00
printer . Connection . SetTargetHotendTemperature ( hotendIndex , printer . Settings . Helpers . ExtruderTargetTemperature ( hotendIndex ) ) ;
2017-06-27 18:41:34 -07:00
}
else
{
// Turn off extruder
2017-09-15 12:08:00 -07:00
printer . Connection . SetTargetHotendTemperature ( hotendIndex , 0 ) ;
2017-06-27 18:41:34 -07:00
}
}
2017-09-06 18:16:45 -07:00
} ,
2017-06-27 18:41:34 -07:00
enforceGutter : false ) ) ;
2019-04-01 16:35:44 -07:00
var toggleWidget = hotendRow . Children . FirstOrDefault ( o = > o is ICheckbox ) ;
2018-04-05 16:19:14 -07:00
toggleWidget . Name = "Toggle Heater" ;
heatToggle = toggleWidget as ICheckbox ;
2017-09-07 16:24:11 -07:00
2018-01-08 18:21:30 -08:00
int tabIndex = 0 ;
var settingsContext = new SettingsContext ( printer , null , NamedSettingsLayers . All ) ;
2019-01-06 11:38:12 -08:00
// TODO: Add guards around computed settings key to handle invalid/missing keys
2019-01-06 13:19:01 -08:00
var settingsData = PrinterSettings . SettingsData [ TemperatureKey ] ;
2018-10-19 11:57:27 -07:00
var temperatureRow = SliceSettingsTabView . CreateItemRow ( settingsData , settingsContext , printer , menuTheme , ref tabIndex , allUiFields ) ;
2018-04-10 14:42:13 -07:00
container . AddChild ( temperatureRow ) ;
2018-01-08 18:21:30 -08:00
2018-04-10 14:42:13 -07:00
// Add the temperature row to the always enabled list ensuring the field can be set when disconnected
alwaysEnabled . Add ( temperatureRow ) ;
2019-03-08 07:42:57 -08:00
alwaysEnabled . Add ( hotendRow ) ;
2017-09-06 18:16:45 -07:00
2019-04-11 20:11:11 -07:00
if ( hotendIndex = = 1 )
{
// add the extrusion movement speed multiplier
var extruderMultiplier = SliceSettingsTabView . CreateItemRow ( PrinterSettings . SettingsData [ SettingsKey . t1_extrusion_move_speed_multiplier ] ,
settingsContext ,
printer ,
menuTheme ,
ref tabIndex ,
allUiFields ) ;
container . AddChild ( extruderMultiplier ) ;
alwaysEnabled . Add ( extruderMultiplier ) ;
}
2017-09-06 18:16:45 -07:00
// add in the temp graph
var graph = new DataViewGraph ( )
{
2018-10-18 17:57:45 -07:00
DynamicallyScaleRange = false ,
2017-09-08 11:46:53 -07:00
MinValue = 0 ,
ShowGoal = true ,
2018-10-15 18:25:53 -07:00
GoalColor = menuTheme . PrimaryAccentColor ,
2019-02-05 11:22:22 -08:00
GoalValue = printer . Settings . Helpers . ExtruderTargetTemperature ( hotendIndex ) ,
2017-09-08 11:46:53 -07:00
MaxValue = 280 , // could come from some profile value in the future
2020-07-22 08:05:39 -07:00
Width = widget . Width - 20 * GuiWidget . DeviceScale ,
Height = 35 * GuiWidget . DeviceScale , // this works better if it is a common multiple of the Width
2017-09-08 11:46:53 -07:00
} ;
2018-11-16 08:44:56 -08:00
runningInterval = UiThread . SetInterval ( ( ) = >
2017-09-06 18:16:45 -07:00
{
graph . AddData ( this . ActualTemperature ) ;
2018-04-11 17:35:34 -07:00
} , 1 ) ;
2019-01-06 11:38:12 -08:00
2018-04-10 14:42:13 -07:00
var valueField = temperatureRow . Descendants < MHNumberEdit > ( ) . FirstOrDefault ( ) ;
2018-01-09 15:26:06 -08:00
valueField . Name = "Temperature Input" ;
2018-10-19 11:57:27 -07:00
2019-03-18 14:12:09 -07:00
valueField . ActuallNumberEdit . EditComplete + = ( s , e ) = >
{
if ( printer . Connection . GetTargetHotendTemperature ( hotendIndex ) > 0 )
{
printer . Settings . SetValue ( TemperatureKey , valueField . Value . ToString ( ) ) ;
}
} ;
2018-04-10 14:42:13 -07:00
var settingsRow = temperatureRow . DescendantsAndSelf < SliceSettingsRow > ( ) . FirstOrDefault ( ) ;
2018-11-12 17:20:59 -08:00
2018-12-20 12:38:05 -08:00
void Printer_SettingChanged ( object s , StringEventArgs stringEvent )
2018-01-08 18:21:30 -08:00
{
2018-12-20 12:38:05 -08:00
if ( stringEvent ! = null )
2018-01-08 18:21:30 -08:00
{
2018-10-19 11:57:27 -07:00
string settingsKey = stringEvent . Data ;
if ( this . allUiFields . TryGetValue ( settingsKey , out UIField uifield ) )
{
string currentValue = settingsContext . GetValue ( settingsKey ) ;
if ( uifield . Value ! = currentValue )
{
uifield . SetValue (
currentValue ,
userInitiated : false ) ;
}
}
if ( stringEvent . Data = = this . TemperatureKey )
2018-01-08 18:21:30 -08:00
{
2019-03-18 14:12:09 -07:00
graph . GoalValue = printer . Settings . Helpers . ExtruderTargetTemperature ( hotendIndex ) ;
2018-10-19 11:57:27 -07:00
settingsRow . UpdateStyle ( ) ;
2018-01-08 18:21:30 -08:00
}
2018-11-12 17:20:59 -08:00
}
}
2018-11-13 09:47:58 -08:00
2018-11-15 21:00:18 -08:00
printer . Settings . SettingChanged + = Printer_SettingChanged ;
printer . Disposed + = ( s , e ) = > printer . Settings . SettingChanged - = Printer_SettingChanged ;
2018-01-08 18:21:30 -08:00
2017-09-06 18:16:45 -07:00
container . AddChild ( graph ) ;
2018-01-10 12:55:41 -08:00
if ( hotendIndex = = 0 )
2017-06-27 18:41:34 -07:00
{
2018-01-10 12:55:41 -08:00
// put in the material selector
2019-02-05 17:39:11 -08:00
var presetsSelector = new PresetSelectorWidget ( printer , "Material" . Localize ( ) , Color . Transparent , NamedSettingsLayers . Material , hotendIndex , menuTheme , true )
2018-04-20 13:51:21 -07:00
{
2018-10-14 07:33:45 -07:00
Margin = new BorderDouble ( right : menuTheme . ToolbarPadding . Right ) ,
2018-04-20 13:51:21 -07:00
Padding = 0 ,
BackgroundColor = Color . Transparent ,
VAnchor = VAnchor . Center | VAnchor . Fit
} ;
// Hide TextWidget
presetsSelector . Children . First ( ) . Visible = false ;
2017-09-21 09:12:33 -07:00
2018-12-29 16:37:17 -08:00
var pulldownContainer = presetsSelector . FindDescendant ( "Preset Pulldown Container" ) ;
2018-01-10 12:55:41 -08:00
if ( pulldownContainer ! = null )
{
2018-10-14 07:33:45 -07:00
pulldownContainer . Padding = menuTheme . ToolbarPadding ;
2018-10-30 17:49:58 -07:00
pulldownContainer . HAnchor = HAnchor . MaxFitOrStretch ;
2018-04-10 16:57:34 -07:00
pulldownContainer . Margin = 0 ;
2018-04-20 13:51:21 -07:00
pulldownContainer . Padding = 0 ;
2018-01-10 12:55:41 -08:00
}
2017-06-27 18:41:34 -07:00
2018-04-20 13:51:21 -07:00
pulldownContainer . Parent . Margin = 0 ;
2018-04-10 16:57:34 -07:00
var dropList = pulldownContainer . Children . OfType < DropDownList > ( ) . FirstOrDefault ( ) ;
2018-01-10 12:55:41 -08:00
if ( dropList ! = null )
{
2018-04-10 16:57:34 -07:00
dropList . Name = "Hotend Preset Selector" ;
2018-10-30 17:49:58 -07:00
dropList . HAnchor = HAnchor . Stretch ;
2018-04-10 16:57:34 -07:00
dropList . Margin = 0 ;
2018-01-10 12:55:41 -08:00
}
2019-02-05 17:39:11 -08:00
// add in the material selector
GuiWidget materialSettingsRow = new SettingsItem ( "Material" . Localize ( ) , presetsSelector , menuTheme , enforceGutter : false )
{
2019-02-06 10:34:19 -08:00
Border = new BorderDouble ( 0 , 1 ) ,
BorderColor = AppContext . MenuTheme . RowBorder
2019-02-05 17:39:11 -08:00
} ;
2018-10-30 17:49:58 -07:00
2019-02-06 10:34:19 -08:00
container . AddChild ( materialSettingsRow ) ;
// material can be changed even when the printer is not connected
alwaysEnabled . Add ( materialSettingsRow ) ;
2019-02-05 17:39:11 -08:00
// add in a shop button
var shopButton = theme . CreateDialogButton ( "Shop" . Localize ( ) ) ;
shopButton . Margin = new BorderDouble ( 3 , 3 , 6 , 3 ) ;
shopButton . ToolTipText = "Shop Filament at MatterHackers" . Localize ( ) ;
shopButton . Click + = ( s , e ) = >
{
UiThread . RunOnIdle ( ( ) = >
{
ApplicationController . Instance . LaunchBrowser ( "https://www.matterhackers.com/store/c/3d-printer-filament" ) ;
} ) ;
} ;
2019-02-06 10:34:19 -08:00
materialSettingsRow . AddChild ( shopButton ) ;
2018-10-30 17:49:58 -07:00
presetsSelector . PerformLayout ( ) ;
2017-06-27 18:41:34 -07:00
}
2018-01-10 12:55:41 -08:00
else // put in a temperature selector for the correct material
{
}
2017-06-27 18:41:34 -07:00
2017-09-08 10:23:28 -07:00
// put in the actual extruder controls
2017-09-15 12:08:00 -07:00
bool shareTemp = printer . Settings . GetValue < bool > ( SettingsKey . extruders_share_temperature ) ;
int extruderCount = printer . Settings . GetValue < int > ( SettingsKey . extruder_count ) ;
2017-09-08 11:46:53 -07:00
if ( shareTemp & & extruderCount > 1 )
2017-06-27 18:41:34 -07:00
{
2017-09-08 10:23:28 -07:00
for ( int extruderIndex = 0 ; extruderIndex < extruderCount ; extruderIndex + + )
2017-06-27 18:41:34 -07:00
{
2018-10-17 09:01:10 -07:00
container . AddChild ( new HorizontalLine ( )
2017-09-08 10:23:28 -07:00
{
Margin = new BorderDouble ( 0 , 5 , 0 , 0 )
} ) ;
2017-06-27 18:41:34 -07:00
2018-10-14 07:33:45 -07:00
container . AddChild ( new TextWidget ( "Extruder" . Localize ( ) + " " + ( extruderIndex + 1 ) . ToString ( ) , pointSize : menuTheme . DefaultFontSize )
2017-09-08 10:23:28 -07:00
{
AutoExpandBoundsToText = true ,
2018-12-10 14:26:29 -08:00
TextColor = theme . TextColor ,
2017-09-11 10:54:46 -07:00
HAnchor = HAnchor . Left ,
2017-09-08 10:23:28 -07:00
} ) ;
2018-10-31 19:19:10 -07:00
container . AddChild ( new ControlContentExtruder ( printer , extruderIndex , menuTheme )
{
Border = new BorderDouble ( top : 1 ) ,
BorderColor = AppContext . MenuTheme . MinimalShade
} ) ;
2017-06-27 18:41:34 -07:00
}
2017-09-08 10:23:28 -07:00
}
else
2017-06-27 18:41:34 -07:00
{
2018-10-14 07:33:45 -07:00
container . AddChild ( new ControlContentExtruder ( printer , hotendIndex , menuTheme ) ) ;
2017-09-08 10:23:28 -07:00
}
2017-06-27 18:41:34 -07:00
2017-09-06 18:16:45 -07:00
return widget ;
}
2017-06-30 18:00:02 -07:00
2018-11-16 08:44:56 -08:00
public override void OnClosed ( EventArgs e )
{
// Unregister listeners
printer . Connection . HotendTemperatureRead - = Connection_HotendTemperatureRead ;
2019-03-18 14:12:09 -07:00
printer . Connection . HotendTargetTemperatureChanged - = this . Connection_HotendTargetTemperatureChanged ;
2018-11-16 08:44:56 -08:00
UiThread . ClearInterval ( runningInterval ) ;
base . OnClosed ( e ) ;
}
2019-03-18 14:12:09 -07:00
private void Connection_HotendTemperatureRead ( object s , EventArgs e )
2017-07-31 17:57:10 -07:00
{
2019-03-18 14:12:09 -07:00
DisplayCurrentTemperature ( ) ;
2017-07-31 17:57:10 -07:00
}
2018-11-16 08:44:56 -08:00
2019-04-01 16:35:18 -07:00
private void Connection_HotendTargetTemperatureChanged ( object sender , int changedHotendIndex )
2018-11-16 08:44:56 -08:00
{
2019-04-01 16:35:18 -07:00
if ( this . hotendIndex = = changedHotendIndex )
{
heatToggle . Checked = printer . Connection . GetTargetHotendTemperature ( changedHotendIndex ) ! = 0 ;
}
2018-11-16 08:44:56 -08:00
}
2015-04-08 15:20:10 -07:00
}
}