Making printerConnection passed to classes.
This commit is contained in:
parent
756fa03015
commit
b65d1f136d
14 changed files with 167 additions and 138 deletions
|
|
@ -59,15 +59,18 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public PrintActionRow(TextImageButtonFactory buttonFactory, GuiWidget parentWidget, BorderDouble defaultMargin)
|
||||
PrinterConnection printerConnection;
|
||||
|
||||
public PrintActionRow(PrinterConnection printerConnection, TextImageButtonFactory buttonFactory, GuiWidget parentWidget, BorderDouble defaultMargin)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
|
||||
AddChildElements(buttonFactory, parentWidget, defaultMargin);
|
||||
|
||||
// Add Handlers
|
||||
ApplicationController.Instance.ActivePrintItemChanged.RegisterEvent(onStateChanged, ref unregisterEvents);
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent(onStateChanged, ref unregisterEvents);
|
||||
printerConnection.CommunicationStateChanged.RegisterEvent(onStateChanged, ref unregisterEvents);
|
||||
ProfileManager.ProfilesListChanged.RegisterEvent(onStateChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
|
|
@ -96,14 +99,14 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
resetConnectionButton = buttonFactory.Generate("Reset".Localize().ToUpper(), AggContext.StaticData.LoadIcon("e_stop.png", 14, 14));
|
||||
resetConnectionButton.ToolTipText = "Reboots the firmware on the controller".Localize();
|
||||
resetConnectionButton.Margin = defaultMargin;
|
||||
resetConnectionButton.Click += (s, e) => UiThread.RunOnIdle(PrinterConnection.Instance.RebootBoard);
|
||||
resetConnectionButton.Click += (s, e) => UiThread.RunOnIdle(printerConnection.RebootBoard);
|
||||
|
||||
pauseButton = buttonFactory.Generate("Pause".Localize().ToUpper());
|
||||
pauseButton.ToolTipText = "Pause the current print".Localize();
|
||||
pauseButton.Margin = defaultMargin;
|
||||
pauseButton.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(PrinterConnection.Instance.RequestPause);
|
||||
UiThread.RunOnIdle(printerConnection.RequestPause);
|
||||
pauseButton.Enabled = false;
|
||||
};
|
||||
parentWidget.AddChild(pauseButton);
|
||||
|
|
@ -134,9 +137,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
resumeButton.Name = "Resume Button";
|
||||
resumeButton.Click += (s, e) =>
|
||||
{
|
||||
if (PrinterConnection.Instance.PrinterIsPaused)
|
||||
if (printerConnection.PrinterIsPaused)
|
||||
{
|
||||
PrinterConnection.Instance.Resume();
|
||||
printerConnection.Resume();
|
||||
}
|
||||
pauseButton.Enabled = true;
|
||||
};
|
||||
|
|
@ -189,8 +192,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
protected void SetButtonStates()
|
||||
{
|
||||
this.activePrintButtons.Clear();
|
||||
if (!PrinterConnection.Instance.PrinterIsConnected
|
||||
&& PrinterConnection.Instance.CommunicationState != CommunicationStates.AttemptingToConnect)
|
||||
if (!printerConnection.PrinterIsConnected
|
||||
&& printerConnection.CommunicationState != CommunicationStates.AttemptingToConnect)
|
||||
{
|
||||
if (!ProfileManager.Instance.ActiveProfiles.Any())
|
||||
{
|
||||
|
|
@ -203,7 +206,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
else
|
||||
{
|
||||
switch (PrinterConnection.Instance.CommunicationState)
|
||||
switch (printerConnection.CommunicationState)
|
||||
{
|
||||
case CommunicationStates.AttemptingToConnect:
|
||||
this.activePrintButtons.Add(cancelConnectButton);
|
||||
|
|
@ -232,7 +235,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
case CommunicationStates.PrintingFromSd:
|
||||
case CommunicationStates.Printing:
|
||||
if (!PrinterConnection.Instance.PrintWasCanceled)
|
||||
if (!printerConnection.PrintWasCanceled)
|
||||
{
|
||||
this.activePrintButtons.Add(pauseButton);
|
||||
this.activePrintButtons.Add(cancelButton);
|
||||
|
|
@ -262,7 +265,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
}
|
||||
|
||||
if (PrinterConnection.Instance.PrinterIsConnected
|
||||
if (printerConnection.PrinterIsConnected
|
||||
&& ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.show_reset_connection))
|
||||
{
|
||||
this.activePrintButtons.Add(resetConnectionButton);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using MatterHackers.Agg.ImageProcessing;
|
|||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
|
||||
namespace MatterHackers.MatterControl.ActionBar
|
||||
{
|
||||
|
|
@ -49,12 +50,14 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
};
|
||||
|
||||
protected EventHandler unregisterEvents;
|
||||
protected PrinterConnection printerConnection;
|
||||
|
||||
protected virtual int ActualTemperature { get; }
|
||||
protected virtual int TargetTemperature { get; }
|
||||
|
||||
public TemperatureWidgetBase(string textValue)
|
||||
public TemperatureWidgetBase(PrinterConnection printerConnection, string textValue)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
this.HAnchor = HAnchor.Fit;
|
||||
this.VAnchor = VAnchor.Fit | VAnchor.Center;
|
||||
this.Cursor = Cursors.Hand;
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
private TextWidget settingsTemperature;
|
||||
|
||||
public TemperatureWidgetBed()
|
||||
: base("150.3°")
|
||||
public TemperatureWidgetBed(PrinterConnection printerConnection)
|
||||
: base(printerConnection, "150.3°")
|
||||
{
|
||||
this.DisplayCurrentTemperature();
|
||||
this.ToolTipText = "Current bed temperature".Localize();
|
||||
|
|
@ -63,12 +63,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
this.PopupContent = this.GetPopupContent();
|
||||
|
||||
PrinterConnection.Instance.BedTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
printerConnection.BedTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected override int TargetTemperature => (int)PrinterConnection.Instance.TargetBedTemperature;
|
||||
protected override int TargetTemperature => (int)printerConnection.TargetBedTemperature;
|
||||
|
||||
protected override int ActualTemperature => (int)PrinterConnection.Instance.ActualBedTemperature;
|
||||
protected override int ActualTemperature => (int)printerConnection.ActualBedTemperature;
|
||||
|
||||
protected override void SetTargetTemperature()
|
||||
{
|
||||
|
|
@ -76,16 +76,16 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
if (targetTemp != 0)
|
||||
{
|
||||
double goalTemp = (int)(targetTemp + .5);
|
||||
if (PrinterConnection.Instance.PrinterIsPrinting
|
||||
&& PrinterConnection.Instance.DetailedPrintingState == DetailedPrintingState.HeatingBed
|
||||
&& goalTemp != PrinterConnection.Instance.TargetBedTemperature)
|
||||
if (printerConnection.PrinterIsPrinting
|
||||
&& printerConnection.DetailedPrintingState == DetailedPrintingState.HeatingBed
|
||||
&& goalTemp != printerConnection.TargetBedTemperature)
|
||||
{
|
||||
string message = string.Format(waitingForBedToHeatMessage, PrinterConnection.Instance.TargetBedTemperature, sliceSettingsNote);
|
||||
string message = string.Format(waitingForBedToHeatMessage, printerConnection.TargetBedTemperature, sliceSettingsNote);
|
||||
StyledMessageBox.ShowMessageBox(null, message, waitingForBedToHeatTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrinterConnection.Instance.TargetBedTemperature = (int)(targetTemp + .5);
|
||||
printerConnection.TargetBedTemperature = (int)(targetTemp + .5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -118,14 +118,14 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
var goalTemp = itemChecked ? ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.bed_temperature) : 0;
|
||||
|
||||
if (PrinterConnection.Instance.PrinterIsPrinting
|
||||
&& PrinterConnection.Instance.DetailedPrintingState == DetailedPrintingState.HeatingBed
|
||||
&& goalTemp != PrinterConnection.Instance.TargetBedTemperature)
|
||||
if (printerConnection.PrinterIsPrinting
|
||||
&& printerConnection.DetailedPrintingState == DetailedPrintingState.HeatingBed
|
||||
&& goalTemp != printerConnection.TargetBedTemperature)
|
||||
{
|
||||
string sliceSettingsNote = "Note: Slice Settings are applied before the print actually starts. Changes while printing will not effect the active print.";
|
||||
string message = string.Format(
|
||||
"The bed is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting bed temperature in 'Slice Settings' -> 'Filament'.\n\n{1}",
|
||||
PrinterConnection.Instance.TargetBedTemperature,
|
||||
printerConnection.TargetBedTemperature,
|
||||
sliceSettingsNote);
|
||||
|
||||
StyledMessageBox.ShowMessageBox(null, message, "Waiting For Bed To Heat");
|
||||
|
|
@ -138,7 +138,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
else
|
||||
{
|
||||
PrinterConnection.Instance.TargetBedTemperature = 0;
|
||||
printerConnection.TargetBedTemperature = 0;
|
||||
|
||||
//string displayString = string.Format("{0:0.0}°C", PrinterConnectionAndCommunication.Instance.TargetBedTemperature);
|
||||
//targetTemperatureDisplay.SetDisplayString(displayString);
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
private TextWidget settingsTemperature;
|
||||
|
||||
public TemperatureWidgetExtruder(TextImageButtonFactory buttonFactory)
|
||||
: base("150.3°")
|
||||
public TemperatureWidgetExtruder(PrinterConnection printerConnection, TextImageButtonFactory buttonFactory)
|
||||
: base(printerConnection, "150.3°")
|
||||
{
|
||||
this.buttonFactory = buttonFactory;
|
||||
this.DisplayCurrentTemperature();
|
||||
|
|
@ -62,12 +62,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
this.PopupContent = this.GetPopupContent();
|
||||
|
||||
PrinterConnection.Instance.ExtruderTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
printerConnection.ExtruderTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected override int TargetTemperature => (int)PrinterConnection.Instance.GetTargetExtruderTemperature(extruderIndex);
|
||||
protected override int TargetTemperature => (int)printerConnection.GetTargetExtruderTemperature(extruderIndex);
|
||||
|
||||
protected override int ActualTemperature => (int)PrinterConnection.Instance.GetActualExtruderTemperature(extruderIndex);
|
||||
protected override int ActualTemperature => (int)printerConnection.GetActualExtruderTemperature(extruderIndex);
|
||||
|
||||
protected override void SetTargetTemperature()
|
||||
{
|
||||
|
|
@ -75,16 +75,16 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
if (double.TryParse(ActiveSliceSettings.Instance.GetValue(SettingsKey.temperature), out targetTemp))
|
||||
{
|
||||
double goalTemp = (int)(targetTemp + .5);
|
||||
if (PrinterConnection.Instance.PrinterIsPrinting
|
||||
&& PrinterConnection.Instance.DetailedPrintingState == DetailedPrintingState.HeatingExtruder
|
||||
&& goalTemp != PrinterConnection.Instance.GetTargetExtruderTemperature(extruderIndex))
|
||||
if (printerConnection.PrinterIsPrinting
|
||||
&& printerConnection.DetailedPrintingState == DetailedPrintingState.HeatingExtruder
|
||||
&& goalTemp != printerConnection.GetTargetExtruderTemperature(extruderIndex))
|
||||
{
|
||||
string message = string.Format(waitingForExtruderToHeatMessage, PrinterConnection.Instance.GetTargetExtruderTemperature(extruderIndex), sliceSettingsNote);
|
||||
string message = string.Format(waitingForExtruderToHeatMessage, printerConnection.GetTargetExtruderTemperature(extruderIndex), sliceSettingsNote);
|
||||
StyledMessageBox.ShowMessageBox(null, message, "Waiting For Extruder To Heat".Localize());
|
||||
}
|
||||
else
|
||||
{
|
||||
PrinterConnection.Instance.SetTargetExtruderTemperature(extruderIndex, (int)(targetTemp + .5));
|
||||
printerConnection.SetTargetExtruderTemperature(extruderIndex, (int)(targetTemp + .5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
else
|
||||
{
|
||||
// Turn off extruder
|
||||
PrinterConnection.Instance.SetTargetExtruderTemperature(extruderIndex, 0);
|
||||
printerConnection.SetTargetExtruderTemperature(extruderIndex, 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -183,7 +183,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
retractButton.Margin = new BorderDouble(8, 0);
|
||||
retractButton.Click += (s, e) =>
|
||||
{
|
||||
PrinterConnection.Instance.MoveExtruderRelative(moveAmount * -1, MovementControls.EFeedRate(extruderIndex), extruderIndex);
|
||||
printerConnection.MoveExtruderRelative(moveAmount * -1, MovementControls.EFeedRate(extruderIndex), extruderIndex);
|
||||
};
|
||||
buttonContainer.AddChild(retractButton);
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
extrudeButton.Margin = 0;
|
||||
extrudeButton.Click += (s, e) =>
|
||||
{
|
||||
PrinterConnection.Instance.MoveExtruderRelative(moveAmount, MovementControls.EFeedRate(extruderIndex), extruderIndex);
|
||||
printerConnection.MoveExtruderRelative(moveAmount, MovementControls.EFeedRate(extruderIndex), extruderIndex);
|
||||
};
|
||||
buttonContainer.AddChild(extrudeButton);
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
// When the active layer changes we update the selected range accordingly - constrain to applicable values
|
||||
this.RenderInfo.EndLayerIndex = Math.Min(this.LoadedGCode.LayerCount - 1, Math.Max(activeLayerIndex, 1));
|
||||
this.RenderInfo.EndLayerIndex = Math.Min(this.LoadedGCode == null ? 0 : this.LoadedGCode.LayerCount - 1, Math.Max(activeLayerIndex, 1));
|
||||
|
||||
ActiveLayerChanged?.Invoke(this, null);
|
||||
}
|
||||
|
|
@ -679,12 +679,13 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
switch (PrinterConnection.Instance.CommunicationState)
|
||||
PrinterConnection printerConnection = s as PrinterConnection;
|
||||
switch (printerConnection.CommunicationState)
|
||||
{
|
||||
case CommunicationStates.Printing:
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
UiThread.RunOnIdle(PrintingWindow.Show);
|
||||
UiThread.RunOnIdle(() => PrintingWindow.Show(printerConnection));
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
public class BedStatusWidget : TemperatureStatusWidget
|
||||
{
|
||||
public BedStatusWidget(bool smallScreen)
|
||||
: base(smallScreen ? "Bed".Localize() : "Bed Temperature".Localize())
|
||||
public BedStatusWidget(PrinterConnection printerConnection, bool smallScreen)
|
||||
: base(printerConnection, smallScreen ? "Bed".Localize() : "Bed Temperature".Localize())
|
||||
{
|
||||
PrinterConnection.Instance.BedTemperatureRead.RegisterEvent((s, e) =>
|
||||
printerConnection.BedTemperatureRead.RegisterEvent((s, e) =>
|
||||
{
|
||||
UpdateTemperatures();
|
||||
}, ref unregisterEvents);
|
||||
|
|
@ -63,8 +63,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
public override void UpdateTemperatures()
|
||||
{
|
||||
double targetValue = PrinterConnection.Instance.TargetBedTemperature;
|
||||
double actualValue = Math.Max(0, PrinterConnection.Instance.ActualBedTemperature);
|
||||
double targetValue = printerConnection.TargetBedTemperature;
|
||||
double actualValue = Math.Max(0, printerConnection.ActualBedTemperature);
|
||||
|
||||
progressBar.RatioComplete = targetValue != 0 ? actualValue / targetValue : 1;
|
||||
|
||||
|
|
@ -77,12 +77,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
private int extruderIndex;
|
||||
|
||||
public ExtruderStatusWidget(int extruderIndex)
|
||||
: base($"{"Extruder".Localize()} {extruderIndex + 1}")
|
||||
public ExtruderStatusWidget(PrinterConnection printerConnection, int extruderIndex)
|
||||
: base(printerConnection, $"{"Extruder".Localize()} {extruderIndex + 1}")
|
||||
{
|
||||
this.extruderIndex = extruderIndex;
|
||||
|
||||
PrinterConnection.Instance.ExtruderTemperatureRead.RegisterEvent((s, e) =>
|
||||
printerConnection.ExtruderTemperatureRead.RegisterEvent((s, e) =>
|
||||
{
|
||||
UpdateTemperatures();
|
||||
}, ref unregisterEvents);
|
||||
|
|
@ -90,8 +90,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
public override void UpdateTemperatures()
|
||||
{
|
||||
double targetValue = PrinterConnection.Instance.GetTargetExtruderTemperature(extruderIndex);
|
||||
double actualValue = Math.Max(0, PrinterConnection.Instance.GetActualExtruderTemperature(extruderIndex));
|
||||
double targetValue = printerConnection.GetTargetExtruderTemperature(extruderIndex);
|
||||
double actualValue = Math.Max(0, printerConnection.GetActualExtruderTemperature(extruderIndex));
|
||||
|
||||
progressBar.RatioComplete = targetValue != 0 ? actualValue / targetValue : 1;
|
||||
|
||||
|
|
@ -107,9 +107,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
protected TextWidget targetTemp;
|
||||
protected EventHandler unregisterEvents;
|
||||
private int fontSize = 14;
|
||||
protected PrinterConnection printerConnection;
|
||||
|
||||
public TemperatureStatusWidget(string dispalyName)
|
||||
public TemperatureStatusWidget(PrinterConnection printerConnection, string dispalyName)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
var extruderName = new TextWidget(dispalyName, pointSize: fontSize, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
|
|
@ -187,10 +189,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
GuiWidget bodyContainer;
|
||||
|
||||
private BasicBody basicBody;
|
||||
PrinterConnection printerConnection;
|
||||
|
||||
public PrintingWindow()
|
||||
public PrintingWindow(PrinterConnection printerConnection)
|
||||
: base(1280, 750)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
}
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
|
|
@ -214,7 +218,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
topToBottom.AddChild(CreateDropShadow());
|
||||
|
||||
basicBody = new BasicBody();
|
||||
basicBody = new BasicBody(printerConnection);
|
||||
bodyContainer = new GuiWidget()
|
||||
{
|
||||
VAnchor = VAnchor.Stretch,
|
||||
|
|
@ -250,11 +254,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
PrinterConnection.Instance.RequestPause();
|
||||
printerConnection.RequestPause();
|
||||
});
|
||||
};
|
||||
pauseButton.Enabled = PrinterConnection.Instance.PrinterIsPrinting
|
||||
&& !PrinterConnection.Instance.PrinterIsPaused;
|
||||
pauseButton.Enabled = printerConnection.PrinterIsPrinting
|
||||
&& !printerConnection.PrinterIsPaused;
|
||||
|
||||
actionBar.AddChild(pauseButton);
|
||||
|
||||
|
|
@ -265,9 +269,9 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
if (PrinterConnection.Instance.PrinterIsPaused)
|
||||
if (printerConnection.PrinterIsPaused)
|
||||
{
|
||||
PrinterConnection.Instance.Resume();
|
||||
printerConnection.Resume();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -285,7 +289,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.Close();
|
||||
}
|
||||
};
|
||||
cancelButton.Enabled = PrinterConnection.Instance.PrinterIsPrinting || PrinterConnection.Instance.PrinterIsPaused;
|
||||
cancelButton.Enabled = printerConnection.PrinterIsPrinting || printerConnection.PrinterIsPaused;
|
||||
actionBar.AddChild(cancelButton);
|
||||
|
||||
actionBar.AddChild(CreateVerticalLine());
|
||||
|
|
@ -296,7 +300,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
resetButton.Visible = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.show_reset_connection);
|
||||
resetButton.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(PrinterConnection.Instance.RebootBoard);
|
||||
UiThread.RunOnIdle(printerConnection.RebootBoard);
|
||||
};
|
||||
actionBar.AddChild(resetButton);
|
||||
|
||||
|
|
@ -311,7 +315,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
bodyContainer.RemoveChild(basicBody);
|
||||
|
||||
bodyContainer.AddChild(new ManualPrinterControls()
|
||||
bodyContainer.AddChild(new ManualPrinterControls(printerConnection)
|
||||
{
|
||||
VAnchor = VAnchor.Stretch,
|
||||
HAnchor = HAnchor.Stretch
|
||||
|
|
@ -330,12 +334,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
}
|
||||
};
|
||||
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
printerConnection.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
pauseButton.Enabled = PrinterConnection.Instance.PrinterIsPrinting
|
||||
&& !PrinterConnection.Instance.PrinterIsPaused;
|
||||
pauseButton.Enabled = printerConnection.PrinterIsPrinting
|
||||
&& !printerConnection.PrinterIsPaused;
|
||||
|
||||
if(PrinterConnection.Instance.PrinterIsPaused)
|
||||
if(printerConnection.PrinterIsPaused)
|
||||
{
|
||||
resumeButton.Visible = true;
|
||||
pauseButton.Visible = false;
|
||||
|
|
@ -347,7 +351,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
}
|
||||
|
||||
// Close if not Preparing, Printing or Paused
|
||||
switch (PrinterConnection.Instance.CommunicationState)
|
||||
switch (printerConnection.CommunicationState)
|
||||
{
|
||||
case CommunicationStates.PreparingToPrint:
|
||||
case CommunicationStates.Printing:
|
||||
|
|
@ -360,9 +364,9 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
}
|
||||
}, ref unregisterEvents);
|
||||
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
printerConnection.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
cancelButton.Enabled = PrinterConnection.Instance.PrinterIsPrinting || PrinterConnection.Instance.PrinterIsPaused;
|
||||
cancelButton.Enabled = printerConnection.PrinterIsPrinting || printerConnection.PrinterIsPaused;
|
||||
}, ref unregisterEvents);
|
||||
|
||||
return actionBar;
|
||||
|
|
@ -381,11 +385,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
}
|
||||
}
|
||||
|
||||
public static void Show()
|
||||
public static void Show(PrinterConnection printerConnection)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new PrintingWindow();
|
||||
instance = new PrintingWindow(printerConnection);
|
||||
instance.ShowAsSystemWindow();
|
||||
}
|
||||
else
|
||||
|
|
@ -488,6 +492,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
private ProgressDial progressDial;
|
||||
private TextWidget timeWidget;
|
||||
private List<ExtruderStatusWidget> extruderStatusWidgets;
|
||||
PrinterConnection printerConnection;
|
||||
|
||||
private void CheckOnPrinter()
|
||||
{
|
||||
|
|
@ -496,7 +501,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
GetProgressInfo();
|
||||
|
||||
// Here for safety
|
||||
switch (PrinterConnection.Instance.CommunicationState)
|
||||
switch (printerConnection.CommunicationState)
|
||||
{
|
||||
case CommunicationStates.PreparingToPrint:
|
||||
case CommunicationStates.Printing:
|
||||
|
|
@ -514,7 +519,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
private void GetProgressInfo()
|
||||
{
|
||||
int secondsPrinted = PrinterConnection.Instance.SecondsPrinted;
|
||||
int secondsPrinted = printerConnection.SecondsPrinted;
|
||||
int hoursPrinted = (int)(secondsPrinted / (60 * 60));
|
||||
int minutesPrinted = (secondsPrinted / 60 - hoursPrinted * 60);
|
||||
secondsPrinted = secondsPrinted % 60;
|
||||
|
|
@ -522,9 +527,9 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
// TODO: Consider if the consistency of a common time format would look and feel better than changing formats based on elapsed duration
|
||||
timeWidget.Text = (hoursPrinted <= 0) ? $"{minutesPrinted}:{secondsPrinted:00}" : $"{hoursPrinted}:{minutesPrinted:00}:{secondsPrinted:00}";
|
||||
|
||||
progressDial.LayerCount = PrinterConnection.Instance.CurrentlyPrintingLayer;
|
||||
progressDial.LayerCompletedRatio = PrinterConnection.Instance.RatioIntoCurrentLayer;
|
||||
progressDial.CompletedRatio = PrinterConnection.Instance.PercentComplete / 100;
|
||||
progressDial.LayerCount = printerConnection.CurrentlyPrintingLayer;
|
||||
progressDial.LayerCompletedRatio = printerConnection.RatioIntoCurrentLayer;
|
||||
progressDial.CompletedRatio = printerConnection.PercentComplete / 100;
|
||||
}
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
|
|
@ -667,7 +672,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
int extruderCount = ActiveSliceSettings.Instance.GetValue<int>(SettingsKey.extruder_count);
|
||||
|
||||
extruderStatusWidgets = Enumerable.Range(0, extruderCount).Select((i) => new ExtruderStatusWidget(i)).ToList();
|
||||
extruderStatusWidgets = Enumerable.Range(0, extruderCount).Select((i) => new ExtruderStatusWidget(printerConnection, i)).ToList();
|
||||
|
||||
bool hasHeatedBed = ActiveSliceSettings.Instance.GetValue<bool>("has_heated_bed");
|
||||
if (hasHeatedBed)
|
||||
|
|
@ -683,7 +688,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
extruderColumn.AddChild(widget);
|
||||
}
|
||||
|
||||
footerBar.AddChild(new BedStatusWidget(smallScreen)
|
||||
footerBar.AddChild(new BedStatusWidget(printerConnection, smallScreen)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
});
|
||||
|
|
@ -725,7 +730,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
});
|
||||
}
|
||||
|
||||
public BasicBody()
|
||||
public BasicBody(PrinterConnection printerConnection)
|
||||
{
|
||||
VAnchor = VAnchor.Stretch;
|
||||
HAnchor = HAnchor.Stretch;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,12 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
public bool hasPID = false;
|
||||
|
||||
private bool changed = false;
|
||||
private PrinterConnection printerConnection;
|
||||
|
||||
public EePromMarlinSettings(PrinterConnection printerConnection)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
}
|
||||
|
||||
public bool update(string line)
|
||||
{
|
||||
|
|
@ -243,15 +249,15 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
string cmdho = "M206 X" + hox + " Y" + hoy + " Z" + hoz;
|
||||
string cmdpid = "M301 P" + ppid + " I" + ipid + " D" + dpid;
|
||||
|
||||
PrinterConnection.Instance.SendLineToPrinterNow(cmdsteps);
|
||||
PrinterConnection.Instance.SendLineToPrinterNow(cmdfeed);
|
||||
PrinterConnection.Instance.SendLineToPrinterNow(cmdmacc);
|
||||
PrinterConnection.Instance.SendLineToPrinterNow(cmdacc);
|
||||
PrinterConnection.Instance.SendLineToPrinterNow(cmdav);
|
||||
PrinterConnection.Instance.SendLineToPrinterNow(cmdho);
|
||||
printerConnection.SendLineToPrinterNow(cmdsteps);
|
||||
printerConnection.SendLineToPrinterNow(cmdfeed);
|
||||
printerConnection.SendLineToPrinterNow(cmdmacc);
|
||||
printerConnection.SendLineToPrinterNow(cmdacc);
|
||||
printerConnection.SendLineToPrinterNow(cmdav);
|
||||
printerConnection.SendLineToPrinterNow(cmdho);
|
||||
if (hasPID)
|
||||
{
|
||||
PrinterConnection.Instance.SendLineToPrinterNow(cmdpid);
|
||||
printerConnection.SendLineToPrinterNow(cmdpid);
|
||||
}
|
||||
|
||||
changed = false;
|
||||
|
|
@ -502,14 +508,14 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
|
||||
public void SaveToEeProm()
|
||||
{
|
||||
PrinterConnection.Instance.SendLineToPrinterNow("M500");
|
||||
printerConnection.SendLineToPrinterNow("M500");
|
||||
}
|
||||
|
||||
// this does not save them to eeprom
|
||||
public void SetPrinterToFactorySettings()
|
||||
{
|
||||
hasPID = false;
|
||||
PrinterConnection.Instance.SendLineToPrinterNow("M502");
|
||||
printerConnection.SendLineToPrinterNow("M502");
|
||||
}
|
||||
|
||||
public void Add(object sender, EventArgs e)
|
||||
|
|
@ -542,7 +548,7 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
public void Update()
|
||||
{
|
||||
hasPID = false;
|
||||
PrinterConnection.Instance.SendLineToPrinterNow("M503");
|
||||
printerConnection.SendLineToPrinterNow("M503");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -82,13 +82,13 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
|
||||
private int currentTabIndex = 0;
|
||||
|
||||
public EePromMarlinWindow()
|
||||
: base(650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale)
|
||||
public EePromMarlinWindow(PrinterConnection printerConnection)
|
||||
: base(printerConnection, 650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale)
|
||||
{
|
||||
AlwaysOnTopOfMain = true;
|
||||
Title = "Marlin Firmware EEPROM Settings".Localize();
|
||||
|
||||
currentEePromSettings = new EePromMarlinSettings();
|
||||
currentEePromSettings = new EePromMarlinSettings(printerConnection);
|
||||
currentEePromSettings.eventAdded += SetUiToPrinterSettings;
|
||||
|
||||
GuiWidget mainContainer = new GuiWidget();
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
{
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public CloseOnDisconnectWindow(double width, double height)
|
||||
public CloseOnDisconnectWindow(PrinterConnection printerConnection, double width, double height)
|
||||
: base(width, height)
|
||||
{
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
printerConnection.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
if(!PrinterConnection.Instance.PrinterIsConnected)
|
||||
if(!printerConnection.PrinterIsConnected)
|
||||
{
|
||||
this.CloseOnIdle();
|
||||
}
|
||||
|
|
@ -73,8 +73,8 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public EePromRepetierWindow()
|
||||
: base(650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale)
|
||||
public EePromRepetierWindow(PrinterConnection printerConnection)
|
||||
: base(printerConnection, 650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale)
|
||||
{
|
||||
AlwaysOnTopOfMain = true;
|
||||
BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
||||
|
|
@ -218,7 +218,7 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
ShowAsSystemWindow();
|
||||
|
||||
currentEePromSettings.Clear();
|
||||
PrinterConnection.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);
|
||||
printerConnection.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);
|
||||
currentEePromSettings.eventAdded += NewSettingReadFromPrinter;
|
||||
currentEePromSettings.AskPrinterForSettings();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using MatterHackers.Agg;
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrintQueue;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public PartPreviewContent(PrintItemWrapper printItem)
|
||||
{
|
||||
var printer = ApplicationController.Instance.Printer;
|
||||
var printerConfig = ApplicationController.Instance.Printer;
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
this.AnchorAll();
|
||||
|
|
@ -76,7 +77,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
var printerTab = new PrinterTab(
|
||||
tabTitle,
|
||||
"3D View Tab",
|
||||
new PrinterTabPage(printer, theme, printItem, tabTitle.ToUpper()));
|
||||
new PrinterTabPage(PrinterConnection.Instance, printerConfig, theme, printItem, tabTitle.ToUpper()));
|
||||
printerTab.ToolTipText = "Preview 3D Design".Localize();
|
||||
|
||||
theme.SetPrinterTabStyles(printerTab);
|
||||
|
|
@ -85,7 +86,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
// TODO: add in the printers and designs that are currently open (or were open last run).
|
||||
var plusTabSelect = new TextTab(
|
||||
new TabPage(new PlusTabPage(tabControl, printer, theme, printItem), "+"),
|
||||
new TabPage(new PlusTabPage(tabControl, printerConfig, theme, printItem), "+"),
|
||||
"Create New",
|
||||
tabControl.TextPointSize,
|
||||
selectedTabColor,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public class PrinterTabPage : PrinterTabBase
|
||||
{
|
||||
internal GCode2DWidget gcode2DWidget;
|
||||
PrinterConnection printerConnection;
|
||||
private View3DConfig gcodeOptions;
|
||||
private DoubleSolidSlider layerRenderRatioSlider;
|
||||
private SolidSlider selectLayerSlider;
|
||||
|
|
@ -54,9 +55,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
private ValueDisplayInfo currentLayerInfo;
|
||||
private SystemWindow parentSystemWindow;
|
||||
|
||||
public PrinterTabPage(PrinterConfig printer, ThemeConfig theme, PrintItemWrapper printItem, string tabTitle)
|
||||
public PrinterTabPage(PrinterConnection printerConnection, PrinterConfig printer, ThemeConfig theme, PrintItemWrapper printItem, string tabTitle)
|
||||
: base(printer, theme, printItem, tabTitle)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
modelViewer.meshViewerWidget.EditorMode = MeshViewerWidget.EditorType.Printer;
|
||||
|
||||
gcodeOptions = printer.Bed.RendererOptions;
|
||||
|
|
@ -174,7 +176,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
};
|
||||
|
||||
// Must come after we have an instance of View3DWidget an its undo buffer
|
||||
topToBottom.AddChild(new PrinterActionsBar(modelViewer, this)
|
||||
topToBottom.AddChild(new PrinterActionsBar(printerConnection, modelViewer, this)
|
||||
{
|
||||
Padding = theme.ToolbarPadding
|
||||
}, 0);
|
||||
|
|
@ -326,7 +328,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private void SetSyncToPrintVisibility()
|
||||
{
|
||||
bool printerIsRunningPrint = PrinterConnection.Instance.PrinterIsPaused || PrinterConnection.Instance.PrinterIsPrinting;
|
||||
bool printerIsRunningPrint = printerConnection.PrinterIsPaused || printerConnection.PrinterIsPrinting;
|
||||
|
||||
if (gcodeOptions.SyncToPrint && printerIsRunningPrint)
|
||||
{
|
||||
|
|
@ -365,7 +367,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
private void SetAnimationPosition()
|
||||
{
|
||||
int currentLayer = PrinterConnection.Instance.CurrentlyPrintingLayer;
|
||||
int currentLayer = printerConnection.CurrentlyPrintingLayer;
|
||||
if (currentLayer <= 0)
|
||||
{
|
||||
selectLayerSlider.Value = 0;
|
||||
|
|
@ -375,7 +377,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
else
|
||||
{
|
||||
selectLayerSlider.Value = currentLayer - 1;
|
||||
layerRenderRatioSlider.SecondValue = PrinterConnection.Instance.RatioIntoCurrentLayer;
|
||||
layerRenderRatioSlider.SecondValue = printerConnection.RatioIntoCurrentLayer;
|
||||
layerRenderRatioSlider.FirstValue = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -503,7 +505,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
bool printerIsRunningPrint = PrinterConnection.Instance.PrinterIsPaused || PrinterConnection.Instance.PrinterIsPrinting;
|
||||
bool printerIsRunningPrint = printerConnection.PrinterIsPaused || printerConnection.PrinterIsPrinting;
|
||||
if (gcodeOptions.SyncToPrint
|
||||
&& printerIsRunningPrint
|
||||
&& modelViewer.gcodeViewer.Visible)
|
||||
|
|
@ -593,7 +595,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
sideBar.AddPage("Slice Settings".Localize(), new NoSettingsWidget());
|
||||
}
|
||||
|
||||
sideBar.AddPage("Controls".Localize(), new ManualPrinterControls());
|
||||
sideBar.AddPage("Controls".Localize(), new ManualPrinterControls(printerConnection));
|
||||
|
||||
sideBar.AddPage("Terminal".Localize(), new TerminalWidget()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
public class PrinterActionsBar : FlowLayoutWidget
|
||||
{
|
||||
PrinterConnection printerConnection;
|
||||
private EventHandler unregisterEvents;
|
||||
private static EePromMarlinWindow openEePromMarlinWidget = null;
|
||||
private static EePromRepetierWindow openEePromRepetierWidget = null;
|
||||
|
|
@ -82,8 +83,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
public PrinterActionsBar(View3DWidget modelViewer, PrinterTabPage printerTabPage)
|
||||
public PrinterActionsBar(PrinterConnection printerConnection, View3DWidget modelViewer, PrinterTabPage printerTabPage)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
UndoBuffer undoBuffer = modelViewer.Scene.UndoBuffer;
|
||||
|
||||
var defaultMargin = ApplicationController.Instance.Theme.ButtonSpacing;
|
||||
|
|
@ -95,7 +97,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.VAnchor = VAnchor.Fit;
|
||||
this.AddChild(new PrinterConnectButton(buttonFactory, 0));
|
||||
|
||||
this.AddChild(new PrintActionRow(buttonFactory, this, defaultMargin));
|
||||
this.AddChild(new PrintActionRow(printerConnection, buttonFactory, this, defaultMargin));
|
||||
|
||||
var sliceButton = buttonFactory.Generate("Slice".Localize().ToUpper());
|
||||
sliceButton.ToolTipText = "Slice Parts".Localize();
|
||||
|
|
@ -157,22 +159,22 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
AutoExpandBoundsToText = true,
|
||||
PointSize = 8
|
||||
};
|
||||
PrinterConnection.Instance.PrintingStateChanged.RegisterEvent((e, s) =>
|
||||
printerConnection.PrintingStateChanged.RegisterEvent((e, s) =>
|
||||
{
|
||||
printerConnectionDetail.Text = PrinterConnection.Instance.PrinterConnectionStatus;
|
||||
printerConnectionDetail.Text = printerConnection.PrinterConnectionStatus;
|
||||
}, ref unregisterEvents);
|
||||
this.AddChild(printerConnectionDetail);
|
||||
|
||||
this.AddChild(new HorizontalSpacer());
|
||||
|
||||
this.AddChild(new TemperatureWidgetExtruder(ApplicationController.Instance.Theme.MenuButtonFactory)
|
||||
this.AddChild(new TemperatureWidgetExtruder(printerConnection, ApplicationController.Instance.Theme.MenuButtonFactory)
|
||||
{
|
||||
Margin = new BorderDouble(right: 10)
|
||||
});
|
||||
|
||||
if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_heated_bed))
|
||||
{
|
||||
this.AddChild(new TemperatureWidgetBed());
|
||||
this.AddChild(new TemperatureWidgetBed(printerConnection));
|
||||
}
|
||||
|
||||
overflowDropdown = new OverflowDropdown(allowLightnessInvert: true)
|
||||
|
|
@ -187,7 +189,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.Closed += (s, e) =>
|
||||
{
|
||||
overflowDropdown.DynamicPopupContent = GeneratePrinterOverflowMenu;
|
||||
};
|
||||
};
|
||||
|
||||
this.AddChild(overflowDropdown);
|
||||
}
|
||||
|
|
@ -267,7 +269,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware.
|
||||
new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
|
||||
#else
|
||||
switch (PrinterConnection.Instance.FirmwareType)
|
||||
switch (printerConnection.FirmwareType)
|
||||
{
|
||||
case FirmwareTypes.Repetier:
|
||||
if (openEePromRepetierWidget != null)
|
||||
|
|
@ -276,7 +278,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
else
|
||||
{
|
||||
openEePromRepetierWidget = new EePromRepetierWindow();
|
||||
openEePromRepetierWidget = new EePromRepetierWindow(printerConnection);
|
||||
openEePromRepetierWidget.Closed += (RepetierWidget, RepetierEvent) =>
|
||||
{
|
||||
openEePromRepetierWidget = null;
|
||||
|
|
@ -291,7 +293,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
else
|
||||
{
|
||||
openEePromMarlinWidget = new EePromMarlinWindow();
|
||||
openEePromMarlinWidget = new EePromMarlinWindow(printerConnection);
|
||||
openEePromMarlinWidget.Closed += (marlinWidget, marlinEvent) =>
|
||||
{
|
||||
openEePromMarlinWidget = null;
|
||||
|
|
@ -300,12 +302,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
break;
|
||||
|
||||
default:
|
||||
PrinterConnection.Instance.SendLineToPrinterNow("M115");
|
||||
printerConnection.SendLineToPrinterNow("M115");
|
||||
StyledMessageBox.ShowMessageBox(null, noEepromMappingMessage, noEepromMappingTitle, StyledMessageBox.MessageType.OK);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,8 +46,11 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
private bool doingDisplayUpdateFromPrinter = false;
|
||||
|
||||
public FanControls(int headingPointSize)
|
||||
PrinterConnection printerConnection;
|
||||
|
||||
public FanControls(PrinterConnection printerConnection, int headingPointSize)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
|
||||
|
|
@ -70,10 +73,10 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
}
|
||||
leftToRight.AddChild(fanControlsLayout);
|
||||
|
||||
fanSpeedDisplay = new EditableNumberDisplay("{0}%".FormatWith(PrinterConnection.Instance.FanSpeed0To255.ToString()), "100%");
|
||||
fanSpeedDisplay = new EditableNumberDisplay("{0}%".FormatWith(printerConnection.FanSpeed0To255.ToString()), "100%");
|
||||
fanSpeedDisplay.EditComplete += (sender, e) =>
|
||||
{
|
||||
PrinterConnection.Instance.FanSpeed0To255 = (int)(fanSpeedDisplay.GetValue() * 255.5 / 100);
|
||||
printerConnection.FanSpeed0To255 = (int)(fanSpeedDisplay.GetValue() * 255.5 / 100);
|
||||
};
|
||||
leftToRight.AddChild(fanSpeedDisplay);
|
||||
}
|
||||
|
|
@ -86,13 +89,13 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
private GuiWidget CreateFanControls()
|
||||
{
|
||||
PrinterConnection.Instance.FanSpeedSet.RegisterEvent(FanSpeedChanged_Event, ref unregisterEvents);
|
||||
printerConnection.FanSpeedSet.RegisterEvent(FanSpeedChanged_Event, ref unregisterEvents);
|
||||
|
||||
FlowLayoutWidget leftToRight = new FlowLayoutWidget();
|
||||
leftToRight.Padding = new BorderDouble(3, 0, 0, 5);
|
||||
|
||||
//Matt's test editing to add a on/off toggle switch
|
||||
bool fanActive = PrinterConnection.Instance.FanSpeed0To255 != 0;
|
||||
bool fanActive = printerConnection.FanSpeed0To255 != 0;
|
||||
|
||||
toggleSwitch = ImageButtonFactory.CreateToggleSwitch(fanActive);
|
||||
toggleSwitch.VAnchor = VAnchor.Center;
|
||||
|
|
@ -106,7 +109,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
private void FanSpeedChanged_Event(object sender, EventArgs e)
|
||||
{
|
||||
int printerFanSpeed = PrinterConnection.Instance.FanSpeed0To255;
|
||||
int printerFanSpeed = printerConnection.FanSpeed0To255;
|
||||
|
||||
fanSpeedDisplay.SetDisplayString("{0}%".FormatWith((int)(printerFanSpeed * 100.5 / 255)));
|
||||
|
||||
|
|
@ -131,11 +134,11 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
CheckBox toggleSwitch = (CheckBox)sender;
|
||||
if (toggleSwitch.Checked)
|
||||
{
|
||||
PrinterConnection.Instance.FanSpeed0To255 = 255;
|
||||
printerConnection.FanSpeed0To255 = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrinterConnection.Instance.FanSpeed0To255 = 0;
|
||||
printerConnection.FanSpeed0To255 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,13 +44,14 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
static public RootedObjectEventHandler AddPluginControls = new RootedObjectEventHandler();
|
||||
private static bool pluginsQueuedToAdd = false;
|
||||
PrinterConnection printerConnection;
|
||||
|
||||
public ManualPrinterControls()
|
||||
public ManualPrinterControls(PrinterConnection printerConnection)
|
||||
{
|
||||
this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground;
|
||||
AnchorAll();
|
||||
|
||||
AddChild(new ManualPrinterControlsDesktop());
|
||||
AddChild(new ManualPrinterControlsDesktop(printerConnection));
|
||||
}
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
|
|
@ -79,9 +80,11 @@ namespace MatterHackers.MatterControl
|
|||
private DisableableWidget calibrationControlsContainer;
|
||||
|
||||
private EventHandler unregisterEvents;
|
||||
PrinterConnection printerConnection;
|
||||
|
||||
public ManualPrinterControlsDesktop()
|
||||
public ManualPrinterControlsDesktop(PrinterConnection printerConnection)
|
||||
{
|
||||
this.printerConnection = printerConnection;
|
||||
ScrollArea.HAnchor |= HAnchor.Stretch;
|
||||
AnchorAll();
|
||||
AutoScroll = true;
|
||||
|
|
@ -123,7 +126,7 @@ namespace MatterHackers.MatterControl
|
|||
};
|
||||
controlsTopToBottomLayout.AddChild(linearPanel);
|
||||
|
||||
fanControlsContainer = new FanControls(headingPointSize);
|
||||
fanControlsContainer = new FanControls(printerConnection, headingPointSize);
|
||||
if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_fan))
|
||||
{
|
||||
controlsTopToBottomLayout.AddChild(fanControlsContainer);
|
||||
|
|
@ -138,8 +141,8 @@ namespace MatterHackers.MatterControl
|
|||
// HACK: this is a hack to make the layout engine fire again for this control
|
||||
UiThread.RunOnIdle(() => tuningAdjustmentControlsContainer.Width = tuningAdjustmentControlsContainer.Width + 1);
|
||||
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
PrinterConnection.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
printerConnection.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
printerConnection.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
|
||||
SetVisibleControls();
|
||||
}
|
||||
|
|
@ -169,7 +172,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
else // we at least have a printer selected
|
||||
{
|
||||
switch (PrinterConnection.Instance.CommunicationState)
|
||||
switch (printerConnection.CommunicationState)
|
||||
{
|
||||
case CommunicationStates.Disconnecting:
|
||||
case CommunicationStates.ConnectionLost:
|
||||
|
|
@ -218,7 +221,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
case CommunicationStates.PreparingToPrint:
|
||||
case CommunicationStates.Printing:
|
||||
switch (PrinterConnection.Instance.DetailedPrintingState)
|
||||
switch (printerConnection.DetailedPrintingState)
|
||||
{
|
||||
case DetailedPrintingState.HomingAxis:
|
||||
case DetailedPrintingState.HeatingBed:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue