Merge remote-tracking branch 'upstream/development'

Conflicts:
	MainSlidePanel.cs
	PrintLibrary/ExportLibraryItemWindow.cs
This commit is contained in:
gregory-diaz 2014-02-24 17:01:23 -08:00
commit 8fcb92d6ae
30 changed files with 1736 additions and 237 deletions

View file

@ -130,8 +130,10 @@ namespace MatterHackers.MatterControl
{
case PrinterCommunication.CommunicationStates.Disconnected:
return new LocalizedString("Not connected. Press 'Connect' to enable printing.").Translated;
case PrinterCommunication.CommunicationStates.AttemptingToConnect:
return new LocalizedString("Attempting to connect...").Translated;
case PrinterCommunication.CommunicationStates.AttemptingToConnect:
string attemptToConnect = new LocalizedString ("Attempting to Connect").Translated;
string attemptToConnectFull = string.Format ("{0}...", attemptToConnect);
return attemptToConnectFull;
case PrinterCommunication.CommunicationStates.ConnectionLost:
case PrinterCommunication.CommunicationStates.FailedToConnect:
return new LocalizedString("Unable to communicate with printer.").Translated;

View file

@ -92,19 +92,54 @@ namespace MatterHackers.MatterControl.ActionBar
temperatureWidgets.AddChild(extruderTemperatureWidget);
temperatureWidgets.AddChild(bedTemperatureWidget);
}
temperatureWidgets.VAnchor = VAnchor.ParentTop;
temperatureWidgets.VAnchor |= VAnchor.ParentTop;
temperatureWidgets.Margin = new BorderDouble(left: 6);
FlowLayoutWidget printStatusContainer = getActivePrinterInfo();
printStatusContainer.VAnchor = VAnchor.ParentTop;
printStatusContainer.VAnchor |= VAnchor.ParentTop;
FlowLayoutWidget iconContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
iconContainer.Name = "PrintStatusRow.IconContainer";
iconContainer.VAnchor |= VAnchor.ParentTop;
iconContainer.Margin = new BorderDouble(top: 3);
iconContainer.AddChild(GetAutoLevelIndicator());
this.AddChild(activePrintPreviewImage);
this.AddChild(printStatusContainer);
this.AddChild(iconContainer);
this.AddChild(temperatureWidgets);
UpdatePrintStatus();
UpdatePrintItemName();
}
private Button GetAutoLevelIndicator()
{
ImageButtonFactory imageButtonFactory = new ImageButtonFactory();
string notifyIconPath = Path.Combine("Icons", "PrintStatusControls", "leveling-16x16.png");
string notifyHoverIconPath = Path.Combine("Icons", "PrintStatusControls", "leveling-16x16.png");
Button notifyButton = imageButtonFactory.Generate(notifyIconPath, notifyHoverIconPath);
notifyButton.Cursor = Cursors.Hand;
notifyButton.Margin = new Agg.BorderDouble(top: 3);
notifyButton.MouseEnterBounds += (sender, mouseEvent) => { HelpTextWidget.Instance.ShowHoverText("Print leveling is enabled."); };
notifyButton.MouseLeaveBounds += (sender, mouseEvent) => { HelpTextWidget.Instance.HideHoverText(); };
notifyButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((sender, e) =>
{
notifyButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
}, ref unregisterEvents);
ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
{
notifyButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
}, ref unregisterEvents);
return notifyButton;
}
private FlowLayoutWidget getActivePrinterInfo()
{
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
@ -123,9 +158,9 @@ namespace MatterHackers.MatterControl.ActionBar
topRow.AddChild(activePrintLabel);
activePrintName = getPrintStatusLabel(new LocalizedString("this is the biggest name we will allow").Translated, pointSize: 14);
activePrintName = getPrintStatusLabel("this is the biggest name we will allow", pointSize: 14);
activePrintName.AutoExpandBoundsToText = false;
activePrintStatus = getPrintStatusLabel(new LocalizedString("this is the biggest label we will allow - bigger").Translated, pointSize: 11);
activePrintStatus = getPrintStatusLabel("this is the biggest label we will allow - bigger", pointSize: 11);
activePrintStatus.AutoExpandBoundsToText = false;
activePrintStatus.Text = "";
activePrintStatus.Margin = new BorderDouble(top: 3);
@ -200,73 +235,41 @@ namespace MatterHackers.MatterControl.ActionBar
{
if (PrinterCommunication.Instance.ActivePrintItem != null)
{
int secondsPrinted = PrinterCommunication.Instance.SecondsPrinted;
int hoursPrinted = (int)(secondsPrinted / (60 * 60));
int minutesPrinted = (int)(secondsPrinted / 60 - hoursPrinted * 60);
secondsPrinted = secondsPrinted % 60;
string timePrintedText;
if (hoursPrinted > 0)
{
string printTimeLbl = new LocalizedString ("Print Time").Translated;
timePrintedText = string.Format("{3}: {0}:{1:00}:{2:00}",
hoursPrinted,
minutesPrinted,
secondsPrinted,
printTimeLbl);
}
else
{
string printTimeLbl = new LocalizedString ("Print Time").Translated;
timePrintedText = string.Format("{2}: {0:00}:{1:00}",
minutesPrinted,
secondsPrinted,
printTimeLbl);
}
int totalSecondsInPrint = PrinterCommunication.Instance.TotalSecondsInPrint;
int secondsRemaining = PrinterCommunication.Instance.SecondsRemaining;
int hoursRemaining = (int)(secondsRemaining / (60 * 60));
int minutesRemaining = (int)(secondsRemaining / 60 - hoursRemaining * 60);
secondsRemaining = secondsRemaining % 60;
string timeRemainingText;
if (secondsRemaining > 0)
int totalHoursInPrint = (int)(totalSecondsInPrint / (60 * 60));
int totalMinutesInPrint = (int)(totalSecondsInPrint / 60 - totalHoursInPrint * 60);
totalSecondsInPrint = totalSecondsInPrint % 60;
string totalTimeLabel = new LocalizedString("Est. Print Time").Translated;
string calculatingLabel = new LocalizedString("Calculating...").Translated;
string totalPrintTimeText;
if (totalSecondsInPrint > 0)
{
if (hoursRemaining > 0)
if (totalHoursInPrint > 0)
{
string timeRemainingLbl = new LocalizedString ("Remaining").Translated;
timeRemainingText = string.Format("{3} (est): {0}:{1:00}:{2:00}",
hoursRemaining,
minutesRemaining,
secondsRemaining,
timeRemainingLbl);
totalPrintTimeText = string.Format("{3} {0}h {1:00}m {2:00}s",
totalHoursInPrint,
totalMinutesInPrint,
totalSecondsInPrint,
totalTimeLabel);
}
else
{
string timeRemainingLbl = new LocalizedString ("Remaining").Translated;
timeRemainingText = string.Format("{2} (est): {0:00}:{1:00}",
minutesRemaining,
secondsRemaining,
timeRemainingLbl);
totalPrintTimeText = string.Format("{2} {0}m {1:00}s",
totalMinutesInPrint,
totalSecondsInPrint,
totalTimeLabel);
}
}
else if (PrinterCommunication.Instance.PrintIsFinished)
{
timeRemainingText = "";
}
else
{
string timeRemainingLbl = new LocalizedString ("Remaining").Translated;
timeRemainingText = string.Format("{0} (est): --:--",
timeRemainingLbl,
secondsPrinted / 60,
secondsPrinted % 60);
totalPrintTimeText = string.Format("{0}: {1}", totalTimeLabel, calculatingLabel);
}
string printTimeInfoText = timePrintedText;
if (timeRemainingText != "")
{
printTimeInfoText += ", " + timeRemainingText;
}
//GC.WaitForFullGCComplete();
string printPercentRemainingText;
@ -286,7 +289,7 @@ namespace MatterHackers.MatterControl.ActionBar
case PrinterCommunication.CommunicationStates.Printing:
{
activePrintLabel.Text = PrinterCommunication.Instance.PrintingStateString;
ActivePrintStatusText = printPercentRemainingText;
ActivePrintStatusText = totalPrintTimeText;
}
break;
@ -295,7 +298,7 @@ namespace MatterHackers.MatterControl.ActionBar
string activePrintLblTxt = new LocalizedString ("Printing Paused").Translated;
string activePrintLblTxtFull = string.Format("{0}:", activePrintLblTxt);
activePrintLabel.Text = activePrintLblTxtFull;
ActivePrintStatusText = printPercentRemainingText;
ActivePrintStatusText = totalPrintTimeText;
}
break;
@ -303,7 +306,7 @@ namespace MatterHackers.MatterControl.ActionBar
string donePrintingTxt = new LocalizedString ("Done Printing").Translated;
string donePrintingTxtFull = string.Format ("{0}:", donePrintingTxt);
activePrintLabel.Text = donePrintingTxtFull;
ActivePrintStatusText = printPercentRemainingText;
ActivePrintStatusText = totalPrintTimeText;
break;
default:

View file

@ -190,9 +190,9 @@ namespace MatterHackers.MatterControl
HelpTextWidget.Instance.HideHoverText();
}
public CheckBox GenerateCheckBoxButton(string label, string normalImageName = null, string normalToPressedImageName = null, string pressedImageName = null, string pressedToNormalImageName = null)
public CheckBox GenerateCheckBoxButton(string label, string normalImageName = null, string normalToPressedImageName = null, string pressedImageName = null, string pressedToNormalImageName = null, string pressedLabel = null)
{
CheckBoxViewStates checkBoxButtonViewWidget = getCheckBoxButtonView(label, normalImageName, normalToPressedImageName, pressedImageName, pressedToNormalImageName);
CheckBoxViewStates checkBoxButtonViewWidget = getCheckBoxButtonView(label, normalImageName, normalToPressedImageName, pressedImageName, pressedToNormalImageName, pressedLabel);
//Override the width if requested
if (this.FixedWidth != 0)
@ -290,12 +290,18 @@ namespace MatterHackers.MatterControl
return buttonViewWidget;
}
private CheckBoxViewStates getCheckBoxButtonView(string label, string normalImageName = null, string normalToPressedImageName = null, string pressedImageName = null, string pressedToNormalImageName = null)
private CheckBoxViewStates getCheckBoxButtonView(string label, string normalImageName = null, string normalToPressedImageName = null, string pressedImageName = null, string pressedToNormalImageName = null, string pressedLabel = null)
{
ImageBuffer normalImage = new ImageBuffer();
ImageBuffer pressedImage = new ImageBuffer();
ImageBuffer normalToPressedImage = new ImageBuffer();
ImageBuffer pressedToNormalImage = new ImageBuffer();
string pressedText = pressedLabel;
if (pressedLabel == null)
{
pressedText = label;
}
if (normalImageName != null)
{
@ -345,7 +351,7 @@ namespace MatterHackers.MatterControl
GuiWidget normal = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
GuiWidget normalHover = new TextImageWidget(label, hoverFillColor, normalBorderColor, hoverTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
GuiWidget switchNormalToPressed = new TextImageWidget(label, pressedFillColor, normalBorderColor, pressedTextColor, borderWidth, Margin, normalToPressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
GuiWidget pressed = new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
GuiWidget pressed = new TextImageWidget(pressedText, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
GuiWidget pressedHover = new TextImageWidget(label, hoverFillColor, pressedBorderColor, hoverTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
GuiWidget switchPressedToNormal = new TextImageWidget(label, normalFillColor, pressedBorderColor, normalTextColor, borderWidth, Margin, pressedToNormalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
GuiWidget disabled = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);

View file

@ -80,10 +80,11 @@ namespace MatterHackers.MatterControl
if(showExportGCodeButton)
{
string exportGCodeTxt = new LocalizedString ("Export as").Translated;
string exportGCodeTxtFull = string.Format ("{0} GCode", exportGCodeTxt);
string exportGCodeText = new LocalizedString("Export as").Translated;
string exportGCodeTextFull = string.Format("{0} GCode", exportGCodeText);
Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull);
Button exportGCode = textImageButtonFactory.Generate(exportGCodeTxtFull);
//exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter;
exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click);
topToBottom.AddChild(exportGCode);

View file

@ -21,26 +21,23 @@ namespace MatterHackers.MatterControl
public PrintProgressBar()
{
MinimumSize = new Vector2(0, 30);
MinimumSize = new Vector2(0, 24);
HAnchor = HAnchor.ParentLeftRight;
BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
Margin = new BorderDouble(0);
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight);
container.AnchorAll();
container.Padding = new BorderDouble(7,0);
container.Padding = new BorderDouble(6,0);
RGBA_Bytes labelColor = ActiveTheme.Instance.PrimaryAccentColor;
//labelColor.alpha = 220;
printTimeElapsed = new TextWidget("2:30:00");
printTimeElapsed = new TextWidget("", pointSize:11);
printTimeElapsed.AutoExpandBoundsToText = true;
printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter;
printTimeElapsed.TextColor = labelColor;
printTimeRemaining = new TextWidget("4:50:30");
printTimeRemaining = new TextWidget("", pointSize: 11);
printTimeRemaining.AutoExpandBoundsToText = true;
printTimeRemaining.VAnchor = Agg.UI.VAnchor.ParentCenter;
printTimeRemaining.TextColor = labelColor;
GuiWidget spacer = new GuiWidget();
spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
@ -51,7 +48,8 @@ namespace MatterHackers.MatterControl
AddChild(container);
AddHandlers();
UpdatePrintStatus();
SetThemedColors();
UpdatePrintStatus();
UiThread.RunOnIdle(OnIdle);
}
@ -74,12 +72,17 @@ namespace MatterHackers.MatterControl
base.OnClosed(e);
}
private void onThemeChanged(object sender, EventArgs e)
private void SetThemedColors()
{
//Set background color to new theme
this.printTimeElapsed.TextColor = ActiveTheme.Instance.PrimaryAccentColor;
this.printTimeRemaining.TextColor = ActiveTheme.Instance.PrimaryAccentColor;
this.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
}
private void onThemeChanged(object sender, EventArgs e)
{
//Set background color to new theme
SetThemedColors();
this.Invalidate();
}
@ -158,26 +161,11 @@ namespace MatterHackers.MatterControl
printTimeElapsed.Text = string.Format("");
}
int secondsRemaining = PrinterCommunication.Instance.SecondsRemaining;
int hoursRemaining = (int)(secondsRemaining / (60 * 60));
int minutesRemaining = (int)(secondsRemaining / 60 - hoursRemaining * 60);
secondsRemaining = secondsRemaining % 60;
string printPercentRemainingText = string.Format("{0:0.0}%", currentPercent);
if (secondsRemaining > 0)
if (PrinterCommunication.Instance.PrinterIsPrinting || PrinterCommunication.Instance.PrinterIsPaused)
{
if (hoursRemaining > 0)
{
printTimeRemaining.Text = string.Format("{0}:{1:00}:{2:00}",
hoursRemaining,
minutesRemaining,
secondsRemaining);
}
else
{
printTimeRemaining.Text = string.Format("{0}:{1:00}",
minutesRemaining,
secondsRemaining);
}
printTimeRemaining.Text = printPercentRemainingText;
}
else if (PrinterCommunication.Instance.PrintIsFinished)
{

View file

@ -110,14 +110,18 @@ namespace MatterHackers.MatterControl.DataStorage
{
return "StaticData";
}
else
{
return Path.Combine(ApplicationPath, "StaticData");
}
else if(Directory.Exists(Path.Combine(ApplicationPath, "StaticData")))
{
return Path.Combine(ApplicationPath, "StaticData");
}
else
{
return Path.Combine("..", "..", "StaticData");
}
default:
throw new NotImplementedException();
}
}
}
}

View file

@ -0,0 +1,432 @@
/*
Copyright (c) 2014, Lars Brubaker
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.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MatterHackers.Agg.UI;
namespace MatterHackers.MatterControl.EeProm
{
public class EePromMarlinSettings : EventArgs
{
public event EventHandler eventAdded = null;
public string sx = "0";
public string sy = "0";
public string sz = "0";
public string se = "0";
public string fx = "0";
public string fy = "0";
public string fz = "0";
public string fe = "0";
public string ax = "0";
public string ay = "0";
public string az = "0";
public string ae = "0";
public string acc = "0";
public string racc = "0";
public string avs = "0";
public string avt = "0";
public string avb = "0";
public string avx = "0";
public string avz = "0";
public string ppid = "0";
public string ipid = "0";
public string dpid = "0";
public string hox = "0";
public string hoy = "0";
public string hoz = "0";
public bool hasPID = false;
bool changed = false;
public bool update(string line)
{
bool foundSetting = false;
// string[] lines = line.Substring(5).Split(' ');
string[] test = line.Split(' ');
string mode = "";
foreach (string token in test)
{
if ((token != " ") && ((token == "M92") || (mode == "M92")))
{
foundSetting = true;
mode = "M92";
if (token[0] == 'X')
{
sx = token.Substring(1);
}
if (token[0] == 'Y')
{
sy = token.Substring(1);
}
if (token[0] == 'Z')
{
sz = token.Substring(1);
}
if (token[0] == 'E')
{
se = token.Substring(1);
}
}
if ((token != " ") && ((token == "M203") || (mode == "M203")))
{
foundSetting = true;
mode = "M203";
if (token[0] == 'X')
{
fx = token.Substring(1);
}
if (token[0] == 'Y')
{
fy = token.Substring(1);
}
if (token[0] == 'Z')
{
fz = token.Substring(1);
}
if (token[0] == 'E')
{
fe = token.Substring(1);
}
}
if ((token != " ") && ((token == "M201") || (mode == "M201")))
{
foundSetting = true;
mode = "M201";
if (token[0] == 'X')
{
ax = token.Substring(1);
}
if (token[0] == 'Y')
{
ay = token.Substring(1);
}
if (token[0] == 'Z')
{
az = token.Substring(1);
}
if (token[0] == 'E')
{
ae = token.Substring(1);
}
}
if ((token != " ") && ((token == "M204") || (mode == "M204")))
{
foundSetting = true;
mode = "M204";
if (token[0] == 'S')
{
acc = token.Substring(1);
}
if (token[0] == 'T')
{
racc = token.Substring(1);
}
}
if ((token != " ") && ((token == "M205") || (mode == "M205")))
{
foundSetting = true;
mode = "M205";
if (token[0] == 'S')
{
avs = token.Substring(1);
}
if (token[0] == 'T')
{
avt = token.Substring(1);
}
if (token[0] == 'B')
{
avb = token.Substring(1);
}
if (token[0] == 'X')
{
avx = token.Substring(1);
}
if (token[0] == 'Z')
{
avz = token.Substring(1);
}
}
if ((token != " ") && ((token == "M301") || (mode == "M301")))
{
foundSetting = true;
mode = "M301";
hasPID = true;
if (token[0] == 'P')
{
ppid = token.Substring(1);
}
if (token[0] == 'I')
{
ipid = token.Substring(1);
}
if (token[0] == 'D')
{
dpid = token.Substring(1);
}
}
if ((token != " ") && ((token == "M206") || (mode == "M206")))
{
foundSetting = true;
mode = "M206";
hasPID = true;
if (token[0] == 'X')
{
hox = token.Substring(1);
}
if (token[0] == 'Y')
{
hoy = token.Substring(1);
}
if (token[0] == 'Z')
{
hoz = token.Substring(1);
}
}
}
changed = false;
return foundSetting;
}
public void Save()
{
if (!changed) return; // nothing changed
string cmdsteps = "M92 X" + sx + " Y" + sy + " Z" + sz + " E" + se;
string cmdfeed = "M203 X" + fx + " Y" + fy + " Z" + fz + " E" + fe;
string cmdmacc = "M201 X" + ax + " Y" + ay + " Z" + az + " E" + ae;
string cmdacc = "M204 S" + acc + " T" + racc;
string cmdav = "M205 S" + avs + " T" + avt + " B" + avb + " X" + avx + " Z" + avz;
string cmdho = "M206 X" + hox + " Y" + hoy + " Z" + hoz;
string cmdpid = "M301 P" + ppid + " I" + ipid + " D" + dpid;
PrinterCommunication.Instance.QueueLineToPrinter(cmdsteps);
PrinterCommunication.Instance.QueueLineToPrinter(cmdfeed);
PrinterCommunication.Instance.QueueLineToPrinter(cmdmacc);
PrinterCommunication.Instance.QueueLineToPrinter(cmdacc);
PrinterCommunication.Instance.QueueLineToPrinter(cmdav);
PrinterCommunication.Instance.QueueLineToPrinter(cmdho);
if (hasPID)
{
PrinterCommunication.Instance.QueueLineToPrinter(cmdpid);
}
changed = false;
}
public string SX
{
get { return sx; }
set { if (sx.Equals(value)) return; sx = value; changed = true; }
}
public string SY
{
get { return sy; }
set { if (sy.Equals(value)) return; sy = value; changed = true; }
}
public string SZ
{
get { return sz; }
set { if (sz.Equals(value)) return; sz = value; changed = true; }
}
public string SE
{
get { return se; }
set { if (se.Equals(value)) return; se = value; changed = true; }
}
public string FX
{
get { return fx; }
set { if (fx.Equals(value)) return; fx = value; changed = true; }
}
public string FY
{
get { return fy; }
set { if (fy.Equals(value)) return; fy = value; changed = true; }
}
public string FZ
{
get { return fz; }
set { if (fz.Equals(value)) return; fz = value; changed = true; }
}
public string FE
{
get { return fe; }
set { if (fe.Equals(value)) return; fe = value; changed = true; }
}
public string AX
{
get { return ax; }
set { if (ax.Equals(value)) return; ax = value; changed = true; }
}
public string AY
{
get { return ay; }
set { if (ay.Equals(value)) return; ay = value; changed = true; }
}
public string AZ
{
get { return az; }
set { if (az.Equals(value)) return; az = value; changed = true; }
}
public string AE
{
get { return ae; }
set { if (ae.Equals(value)) return; ae = value; changed = true; }
}
public string ACC
{
get { return acc; }
set { if (acc.Equals(value)) return; acc = value; changed = true; }
}
public string RACC
{
get { return racc; }
set { if (racc.Equals(value)) return; racc = value; changed = true; }
}
public string AVS
{
get { return avs; }
set { if (avs.Equals(value)) return; avs = value; changed = true; }
}
public string AVT
{
get { return avt; }
set { if (avt.Equals(value)) return; avt = value; changed = true; }
}
public string AVB
{
get { return avb; }
set { if (avb.Equals(value)) return; avb = value; changed = true; }
}
public string AVX
{
get { return avx; }
set { if (avx.Equals(value)) return; avx = value; changed = true; }
}
public string AVZ
{
get { return avz; }
set { if (avz.Equals(value)) return; avz = value; changed = true; }
}
public string PPID
{
get { return ppid; }
set { if (ppid.Equals(value)) return; ppid = value; changed = true; }
}
public string IPID
{
get { return ipid; }
set { if (ipid.Equals(value)) return; ipid = value; changed = true; }
}
public string DPID
{
get { return dpid; }
set { if (dpid.Equals(value)) return; dpid = value; changed = true; }
}
public string HOX
{
get { return hox; }
set { if (hox.Equals(value)) return; hox = value; changed = true; }
}
public string HOY
{
get { return hoy; }
set { if (hoy.Equals(value)) return; hoy = value; changed = true; }
}
public string HOZ
{
get { return hoz; }
set { if (hoz.Equals(value)) return; hoz = value; changed = true; }
}
public void SaveToEeProm()
{
PrinterCommunication.Instance.QueueLineToPrinter("M500");
}
// this does not save them to eeprom
public void SetPrinterToFactorySettings()
{
hasPID = false;
PrinterCommunication.Instance.QueueLineToPrinter("M502");
}
public void Add(object sender, EventArgs e)
{
StringEventArgs lineString = e as StringEventArgs;
if (e == null)
{
return;
}
if (update(lineString.Data))
{
if (eventAdded != null)
{
eventAdded(this, lineString);
}
}
}
public void Update()
{
hasPID = false;
PrinterCommunication.Instance.QueueLineToPrinter("M503");
}
}
}

View file

@ -0,0 +1,424 @@
/*
Copyright (c) 2014, Lars Brubaker
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.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
namespace MatterHackers.MatterControl.EeProm
{
public partial class EePromMarlinWidget : SystemWindow
{
EePromMarlinSettings currentEePromSettings;
bool reinit = true;
MHNumberEdit stepsPerMmX;
MHNumberEdit stepsPerMmY;
MHNumberEdit stepsPerMmZ;
MHNumberEdit stepsPerMmE;
MHNumberEdit maxFeedrateMmPerSX;
MHNumberEdit maxFeedrateMmPerSY;
MHNumberEdit maxFeedrateMmPerSZ;
MHNumberEdit maxFeedrateMmPerSE;
MHNumberEdit maxAccelerationMmPerSSqrdX;
MHNumberEdit maxAccelerationMmPerSSqrdY;
MHNumberEdit maxAccelerationMmPerSSqrdZ;
MHNumberEdit maxAccelerationMmPerSSqrdE;
MHNumberEdit acceleration;
MHNumberEdit retractAcceleration;
MHNumberEdit pidP;
MHNumberEdit pidI;
MHNumberEdit pidD;
MHNumberEdit homingOffsetX;
MHNumberEdit homingOffsetY;
MHNumberEdit homingOffsetZ;
MHNumberEdit minFeedrate;
MHNumberEdit minTravelFeedrate;
MHNumberEdit minSegmentTime;
MHNumberEdit maxXYJerk;
MHNumberEdit maxZJerk;
Button buttonAbort;
Button buttonReLoadSettings;
Button buttonSetActive;
Button buttonSetToFactorySettings;
Button buttonSave;
event EventHandler unregisterEvents;
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
double maxWidthOfLeftStuff = 0;
List<GuiWidget> leftStuffToSize = new List<GuiWidget>();
public EePromMarlinWidget()
: base(700, 480)
{
Title = new LocalizedString("Marlin Firmware EEPROM Settings").Translated;
currentEePromSettings = new EePromMarlinSettings();
currentEePromSettings.eventAdded += SetUiToPrinterSettings;
FlowLayoutWidget mainContainer = new FlowLayoutWidget (FlowDirection.TopToBottom);
mainContainer.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
mainContainer.Padding = new BorderDouble (3, 0);
FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
topToBottom.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
topToBottom.Padding = new BorderDouble (top: 3);
// the top button bar
{
FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
topButtonBar.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
topButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
CreateMainButton(ref buttonReLoadSettings, topButtonBar, "Re-Load Default Settings");
buttonReLoadSettings.Click += buttonReLoadSettings_Click;
topButtonBar.Margin = new BorderDouble (0, 3);
CreateMainButton(ref buttonSetToFactorySettings, topButtonBar, "Set Default To Factory Settings");
buttonSetToFactorySettings.Click += SetToFactorySettings;
mainContainer.AddChild(topButtonBar);
}
topToBottom.AddChild(Create4FieldSet("Steps per mm:",
"X:", ref stepsPerMmX,
"Y:", ref stepsPerMmY,
"Z:", ref stepsPerMmZ,
"E:", ref stepsPerMmE));
topToBottom.AddChild(Create4FieldSet("Maximum feedrates [mm/s]:",
"X:", ref maxFeedrateMmPerSX,
"Y:", ref maxFeedrateMmPerSY,
"Z:", ref maxFeedrateMmPerSZ,
"E:", ref maxFeedrateMmPerSE));
topToBottom.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]:",
"X:", ref maxAccelerationMmPerSSqrdX,
"Y:", ref maxAccelerationMmPerSSqrdY,
"Z:", ref maxAccelerationMmPerSSqrdZ,
"E:", ref maxAccelerationMmPerSSqrdE));
topToBottom.AddChild(CreateField("Acceleration:", ref acceleration));
topToBottom.AddChild(CreateField("Retract Acceleration:", ref retractAcceleration));
topToBottom.AddChild(Create3FieldSet("PID settings:",
"P:", ref pidP,
"I:", ref pidI,
"D:", ref pidD));
topToBottom.AddChild(Create3FieldSet("Homing Offset:",
"X:", ref homingOffsetX,
"Y:", ref homingOffsetY,
"Z:", ref homingOffsetZ));
topToBottom.AddChild(CreateField("Min feedrate [mm/s]:", ref minFeedrate));
topToBottom.AddChild(CreateField("Min travel feedrate [mm/s]:", ref minTravelFeedrate));
topToBottom.AddChild(CreateField("Minimum segment time [ms]:", ref minSegmentTime));
topToBottom.AddChild(CreateField("Maximum X-Y jerk [mm/s]:", ref maxXYJerk));
topToBottom.AddChild(CreateField("Maximum Z jerk [mm/s]:", ref maxZJerk));
GuiWidget topBottomSpacer = new GuiWidget(1, 1);
topBottomSpacer.VAnchor = VAnchor.ParentBottomTop;
topToBottom.AddChild(topBottomSpacer);
mainContainer.AddChild (topToBottom);
// the bottom button bar
{
FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
bottomButtonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
bottomButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
bottomButtonBar.Margin = new BorderDouble (0, 3);
CreateMainButton(ref buttonSetActive, bottomButtonBar, "Make Settings Active");
buttonSetActive.Click += buttonSetActive_Click;
CreateMainButton(ref buttonSave, bottomButtonBar, "Make Settings Active\nAnd Save To Default");
buttonSave.Click += buttonSave_Click;
CreateSpacer(bottomButtonBar);
CreateMainButton(ref buttonAbort, bottomButtonBar, "Cancel");
buttonAbort.Click += buttonAbort_Click;
mainContainer.AddChild(bottomButtonBar);
}
PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);
currentEePromSettings.eventAdded += SetUiToPrinterSettings;
AddChild(mainContainer);
ShowAsSystemWindow();
// and ask the printer to send the settings
currentEePromSettings.Update();
foreach (GuiWidget widget in leftStuffToSize)
{
widget.Width = maxWidthOfLeftStuff;
}
}
private GuiWidget CreateMHNumEdit(ref MHNumberEdit numberEditToCreate)
{
numberEditToCreate = new MHNumberEdit(0, pixelWidth: 80, allowNegatives: true, allowDecimals: true);
numberEditToCreate.VAnchor = Agg.UI.VAnchor.ParentCenter;
numberEditToCreate.Margin = new BorderDouble(3, 0);
return numberEditToCreate;
}
private GuiWidget CreateField(string label, ref MHNumberEdit field1)
{
MHNumberEdit none = null;
return Create4FieldSet(label,
"", ref field1,
null, ref none,
null, ref none,
null, ref none);
}
private GuiWidget Create3FieldSet(string label,
string field1Label, ref MHNumberEdit field1,
string field2Label, ref MHNumberEdit field2,
string field3Label, ref MHNumberEdit field3)
{
MHNumberEdit none = null;
return Create4FieldSet(label,
field1Label, ref field1,
field2Label, ref field2,
field3Label, ref field3,
null, ref none);
}
GuiWidget CreateTextField(string label)
{
GuiWidget textWidget = new TextWidget(label, textColor: ActiveTheme.Instance.PrimaryTextColor);
textWidget.VAnchor = VAnchor.ParentCenter;
textWidget.HAnchor = HAnchor.ParentRight;
GuiWidget container = new GuiWidget(textWidget.Height, 24);
container.AddChild(textWidget);
return container;
}
private GuiWidget Create4FieldSet(string label,
string field1Label, ref MHNumberEdit field1,
string field2Label, ref MHNumberEdit field2,
string field3Label, ref MHNumberEdit field3,
string field4Label, ref MHNumberEdit field4)
{
FlowLayoutWidget row = new FlowLayoutWidget();
row.Margin = new BorderDouble(3);
row.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
TextWidget labelWidget = new TextWidget(new LocalizedString(label).Translated, textColor: ActiveTheme.Instance.PrimaryTextColor);
labelWidget.VAnchor = VAnchor.ParentCenter;
maxWidthOfLeftStuff = Math.Max(maxWidthOfLeftStuff, labelWidget.Width);
GuiWidget holder = new GuiWidget(labelWidget.Width, labelWidget.Height);
holder.Margin = new BorderDouble(3, 0);
holder.AddChild(labelWidget);
leftStuffToSize.Add(holder);
row.AddChild(holder);
row.AddChild(CreateTextField(field1Label));
row.AddChild(CreateMHNumEdit(ref field1));
if (field2Label != null)
{
row.AddChild(CreateTextField(field2Label));
row.AddChild(CreateMHNumEdit(ref field2));
}
if (field3Label != null)
{
row.AddChild(CreateTextField(field3Label));
row.AddChild(CreateMHNumEdit(ref field3));
}
if (field4Label != null)
{
row.AddChild(CreateTextField(field4Label));
row.AddChild(CreateMHNumEdit(ref field4));
}
return row;
}
private static void CreateSpacer(FlowLayoutWidget buttonBar)
{
GuiWidget spacer = new GuiWidget(1, 1);
spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
buttonBar.AddChild(spacer);
}
private void CreateMainButton(ref Button button, FlowLayoutWidget buttonBar, string text)
{
button = textImageButtonFactory.Generate(new LocalizedString(text).Translated);
buttonBar.AddChild(button);
}
private void buttonReLoadSettings_Click(object sender, EventArgs e)
{
reinit = false;
currentEePromSettings.Update();
}
private void SetToFactorySettings(object sender, EventArgs e)
{
reinit = true;
currentEePromSettings.SetPrinterToFactorySettings();
currentEePromSettings.Update();
}
private void buttonAbort_Click(object sender, EventArgs e)
{
UiThread.RunOnIdle(DoButtonAbort_Click);
}
private void DoButtonAbort_Click(object state)
{
Close();
}
public override void OnClosed(EventArgs e)
{
if (unregisterEvents != null)
{
unregisterEvents(this, null);
}
base.OnClosed(e);
}
private void SetUiToPrinterSettings(object sender, EventArgs e)
{
stepsPerMmX.Text = currentEePromSettings.SX;
stepsPerMmY.Text = currentEePromSettings.SY;
stepsPerMmZ.Text = currentEePromSettings.SZ;
stepsPerMmE.Text = currentEePromSettings.SE;
maxFeedrateMmPerSX.Text = currentEePromSettings.FX;
maxFeedrateMmPerSY.Text = currentEePromSettings.FY;
maxFeedrateMmPerSZ.Text = currentEePromSettings.FZ;
maxFeedrateMmPerSE.Text = currentEePromSettings.FE;
maxAccelerationMmPerSSqrdX.Text = currentEePromSettings.AX;
maxAccelerationMmPerSSqrdY.Text = currentEePromSettings.AY;
maxAccelerationMmPerSSqrdZ.Text = currentEePromSettings.AZ;
maxAccelerationMmPerSSqrdE.Text = currentEePromSettings.AE;
acceleration.Text = currentEePromSettings.ACC;
retractAcceleration.Text = currentEePromSettings.RACC;
minFeedrate.Text = currentEePromSettings.AVS;
minTravelFeedrate.Text = currentEePromSettings.AVT;
minSegmentTime.Text = currentEePromSettings.AVB;
maxXYJerk.Text = currentEePromSettings.AVX;
maxZJerk.Text = currentEePromSettings.AVZ;
pidP.Enabled = pidI.Enabled = pidD.Enabled = currentEePromSettings.hasPID;
pidP.Text = currentEePromSettings.PPID;
pidI.Text = currentEePromSettings.IPID;
pidD.Text = currentEePromSettings.DPID;
homingOffsetX.Text = currentEePromSettings.hox;
homingOffsetY.Text = currentEePromSettings.hoy;
homingOffsetZ.Text = currentEePromSettings.hoz;
}
private void buttonSave_Click(object sender, EventArgs e)
{
UiThread.RunOnIdle(DoButtonSave_Click);
}
private void DoButtonSave_Click(object state)
{
SaveSettingsToActive();
currentEePromSettings.SaveToEeProm();
Close();
}
void buttonSetActive_Click(object sender, EventArgs e)
{
UiThread.RunOnIdle(DoButtonSetActive_Click);
}
void DoButtonSetActive_Click(object state)
{
SaveSettingsToActive();
Close();
}
void SaveSettingsToActive()
{
currentEePromSettings.SX = stepsPerMmX.Text;
currentEePromSettings.SY = stepsPerMmY.Text;
currentEePromSettings.SZ = stepsPerMmZ.Text;
currentEePromSettings.SE = stepsPerMmE.Text;
currentEePromSettings.FX = maxFeedrateMmPerSX.Text;
currentEePromSettings.FY = maxFeedrateMmPerSY.Text;
currentEePromSettings.FZ = maxFeedrateMmPerSZ.Text;
currentEePromSettings.FE = maxFeedrateMmPerSE.Text;
currentEePromSettings.AX = maxAccelerationMmPerSSqrdX.Text;
currentEePromSettings.AY = maxAccelerationMmPerSSqrdY.Text;
currentEePromSettings.AZ = maxAccelerationMmPerSSqrdZ.Text;
currentEePromSettings.AE = maxAccelerationMmPerSSqrdE.Text;
currentEePromSettings.ACC = acceleration.Text;
currentEePromSettings.RACC = retractAcceleration.Text;
currentEePromSettings.AVS = minFeedrate.Text;
currentEePromSettings.AVT = minTravelFeedrate.Text;
currentEePromSettings.AVB = minSegmentTime.Text;
currentEePromSettings.AVX = maxXYJerk.Text;
currentEePromSettings.AVZ = maxZJerk.Text;
currentEePromSettings.PPID = pidP.Text;
currentEePromSettings.IPID = pidI.Text;
currentEePromSettings.DPID = pidD.Text;
currentEePromSettings.HOX = homingOffsetX.Text;
currentEePromSettings.HOY = homingOffsetY.Text;
currentEePromSettings.HOZ = homingOffsetZ.Text;
currentEePromSettings.Save();
}
}
}

View file

@ -0,0 +1,92 @@
/*
Copyright (c) 2014, Lars Brubaker
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.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MatterHackers.MatterControl.EeProm
{
public class EePromRepetierParameter : EventArgs
{
public string description;
public int type;
public int position;
string val = "";
bool changed = false;
public EePromRepetierParameter(string line)
{
update(line);
}
public void update(string line)
{
string[] lines = line.Substring(4).Split(' ');
int.TryParse(lines[0], out type);
int.TryParse(lines[1], out position);
val = lines[2];
description = line.Substring(7 + lines[0].Length + lines[1].Length + lines[2].Length);
changed = false;
}
public void save()
{
if (!changed)
{
return;
}
string cmd = "M206 T" + type + " P" + position + " ";
if (type == 3) cmd += "X" + val;
else cmd += "S" + val;
PrinterCommunication.Instance.QueueLineToPrinter(cmd);
changed = false;
}
public string Description
{
get { return description; }
set { description = value; }
}
public string Value
{
get { return val; }
set
{
value = value.Replace(',', '.').Trim();
if (val.Equals(value)) return;
val = value;
changed = true;
}
}
}
}

View file

@ -0,0 +1,98 @@
/*
Copyright (c) 2014, Lars Brubaker
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.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MatterHackers.Agg.UI;
namespace MatterHackers.MatterControl.EeProm
{
public delegate void OnEePromRepetierAdded(EePromRepetierParameter param);
public class EePromRepetierStorage
{
public Dictionary<int, EePromRepetierParameter> eePromSettingsList;
public event EventHandler eventAdded = null;
public EePromRepetierStorage()
{
eePromSettingsList = new Dictionary<int, EePromRepetierParameter>();
}
public void Clear()
{
eePromSettingsList.Clear();
}
public void Save()
{
foreach (EePromRepetierParameter p in eePromSettingsList.Values)
{
p.save();
}
}
public void Add(object sender, EventArgs e)
{
StringEventArgs lineString = e as StringEventArgs;
if (e == null)
{
return;
}
string line = lineString.Data;
if (!line.StartsWith("EPR:"))
{
return;
}
EePromRepetierParameter parameter = new EePromRepetierParameter(line);
if (eePromSettingsList.ContainsKey(parameter.position))
{
eePromSettingsList.Remove(parameter.position);
}
eePromSettingsList.Add(parameter.position, parameter);
if (eventAdded != null)
{
eventAdded(this, parameter);
}
}
public void AskPrinterForSettings()
{
PrinterCommunication.Instance.QueueLineToPrinter("M205");
}
}
}

View file

@ -0,0 +1,227 @@
/*
Copyright (c) 2014, Lars Brubaker
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.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
namespace MatterHackers.MatterControl.EeProm
{
public partial class EePromRepetierWidget : SystemWindow
{
protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
EePromRepetierStorage currentEePromSettings;
BindingList<EePromRepetierParameter> data = new BindingList<EePromRepetierParameter>();
FlowLayoutWidget settingsColmun;
event EventHandler unregisterEvents;
Button buttonCancel;
Button buttonSave;
public EePromRepetierWidget()
: base(540, 480)
{
BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
currentEePromSettings = new EePromRepetierStorage();
FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
topToBottom.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
topToBottom.Padding = new BorderDouble (3, 0);
FlowLayoutWidget row = new FlowLayoutWidget();
row.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
GuiWidget descriptionWidget = AddDescription(new LocalizedString("Description").Translated);
descriptionWidget.Margin = new BorderDouble(left: 3);
row.AddChild(descriptionWidget);
CreateSpacer(row);
GuiWidget valueText = new TextWidget(new LocalizedString("Value").Translated, textColor: ActiveTheme.Instance.PrimaryTextColor);
valueText.VAnchor = Agg.UI.VAnchor.ParentCenter;
valueText.Margin = new BorderDouble(left: 5, right: 60);
row.AddChild(valueText);
topToBottom.AddChild(row);
{
ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true);
settingsAreaScrollBox.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
settingsAreaScrollBox.AnchorAll();
settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
topToBottom.AddChild(settingsAreaScrollBox);
settingsColmun = new FlowLayoutWidget(FlowDirection.TopToBottom);
settingsColmun.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
settingsAreaScrollBox.AddChild(settingsColmun);
}
FlowLayoutWidget buttonBar = new FlowLayoutWidget();
buttonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
buttonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
buttonSave = textImageButtonFactory.Generate(new LocalizedString("Save To EEPROM").Translated);
buttonSave.Margin = new BorderDouble(0,3);
buttonBar.AddChild(buttonSave);
CreateSpacer(buttonBar);
buttonCancel = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated);
buttonCancel.Margin = new BorderDouble(3);
buttonBar.AddChild(buttonCancel);
topToBottom.AddChild(buttonBar);
this.AddChild(topToBottom);
translate();
//MatterControlApplication.Instance.LanguageChanged += translate;
ShowAsSystemWindow();
currentEePromSettings.Clear();
PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);
currentEePromSettings.eventAdded += NewSettingReadFromPrinter;
currentEePromSettings.AskPrinterForSettings();
}
private static void CreateSpacer(FlowLayoutWidget buttonBar)
{
GuiWidget spacer = new GuiWidget(1, 1);
spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
buttonBar.AddChild(spacer);
}
public override void OnClosed(EventArgs e)
{
if (unregisterEvents != null)
{
unregisterEvents(this, null);
}
base.OnClosed(e);
}
public void translate()
{
Title = new LocalizedString("Firmware EEPROM Settings").Translated;
buttonCancel.Text = new LocalizedString("Cancel").Translated;
buttonCancel.Click += buttonAbort_Click;
buttonSave.Text = new LocalizedString("Save to EEPROM").Translated;
buttonSave.Click += buttonSave_Click;
}
private void NewSettingReadFromPrinter(object sender, EventArgs e)
{
EePromRepetierParameter newSetting = e as EePromRepetierParameter;
if (newSetting != null)
{
data.Add(newSetting);
UiThread.RunOnIdle(AddItemToUi, newSetting);
}
}
void AddItemToUi(object state)
{
EePromRepetierParameter newSetting = state as EePromRepetierParameter;
if (newSetting != null)
{
FlowLayoutWidget row = new FlowLayoutWidget();
row.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
row.AddChild(AddDescription(newSetting.Description));
row.Padding = new BorderDouble(5, 0);
if ((settingsColmun.Children.Count % 2) == 1)
{
row.BackgroundColor = new RGBA_Bytes(0, 0, 0, 50);
}
CreateSpacer(row);
double currentValue;
double.TryParse(newSetting.Value, out currentValue);
MHNumberEdit valueEdit = new MHNumberEdit(currentValue, pixelWidth: 80, allowNegatives: true, allowDecimals: true);
valueEdit.VAnchor = Agg.UI.VAnchor.ParentCenter;
valueEdit.ActuallNumberEdit.EditComplete += (sender, e) =>
{
newSetting.Value = valueEdit.ActuallNumberEdit.Value.ToString();
};
row.AddChild(valueEdit);
settingsColmun.AddChild(row);
}
}
private GuiWidget AddDescription(string description)
{
GuiWidget holder = new GuiWidget(340, 40);
TextWidget textWidget = new TextWidget(description, textColor: ActiveTheme.Instance.PrimaryTextColor);
textWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
holder.AddChild(textWidget);
return holder;
}
private void buttonSave_Click(object sender, EventArgs e)
{
UiThread.RunOnIdle(DoButtonSave_Click);
}
private void DoButtonSave_Click(object state)
{
currentEePromSettings.Save();
currentEePromSettings.Clear();
currentEePromSettings.eventAdded -= NewSettingReadFromPrinter;
Close();
}
private void buttonAbort_Click(object sender, EventArgs e)
{
UiThread.RunOnIdle(DoButtonAbort_Click);
}
private void DoButtonAbort_Click(object state)
{
currentEePromSettings.Clear();
data.Clear();
currentEePromSettings.eventAdded -= NewSettingReadFromPrinter;
Close();
}
}
}

View file

@ -1,4 +1,4 @@
#define DEBUG_SHOW_TRANSLATED_STRINGS
//#define DEBUG_SHOW_TRANSLATED_STRINGS
using System;
using System.Collections.Generic;

View file

@ -38,6 +38,7 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ReleaseVersion>0.8.2</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@ -74,6 +75,7 @@
<Compile Include="ActivePrinterProfile.cs" />
<Compile Include="CustomWidgets\ExportQueueItemWindow.cs" />
<Compile Include="CustomWidgets\ExportToFolderFeedbackWindow.cs" />
<Compile Include="EeProm\EePromMarlinSettings.cs" />
<Compile Include="FieldValidation.cs" />
<Compile Include="PartPreviewWindow\CreateDiscreteMeshes.cs" />
<Compile Include="CustomWidgets\EditableNumberDisplay.cs" />
@ -90,7 +92,7 @@
<Compile Include="PrinterControls\EditMacrosWindow.cs" />
<Compile Include="PrintLibrary\PluginChooserWindow.cs" />
<Compile Include="PrintLibrary\ExportLibraryItemWindow.cs" />
<Compile Include="PrintLibrary\RegisteredCreatort.cs" />
<Compile Include="PrintLibrary\RegisteredCreators.cs" />
<Compile Include="PrintQueue\ExportToSdCardProcess.cs" />
<Compile Include="SlicerConfiguration\SlicerMapping\EngineMappingCura.cs" />
<Compile Include="SlicerConfiguration\SlicerMapping\EngineMappingSlic3r.cs" />
@ -184,6 +186,10 @@
<Compile Include="CustomWidgets\ThemeColorSelectorWidget.cs" />
<Compile Include="ControlElements\TextImageButtonFactory.cs" />
<Compile Include="FrostedSerial\TermiosH.cs" />
<Compile Include="EeProm\EePromMarlinWidget.cs" />
<Compile Include="EeProm\EePromRepetierParameter.cs" />
<Compile Include="EeProm\EePromRepetierWidget.cs" />
<Compile Include="EeProm\EePromRepetierStorage.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Ionic.Zip">
@ -276,10 +282,6 @@
<Project>{D3ABF72C-64C2-4E51-A119-E077210FA990}</Project>
<Name>SerialPortCommunication</Name>
</ProjectReference>
<ProjectReference Include="..\agg-sharp\WindowsFileDialogs\WindowsFileDialogs.csproj">
<Project>{A526DC5D-65F3-461B-805F-D3AC9665F5C9}</Project>
<Name>WindowsFileDialogs</Name>
</ProjectReference>
<ProjectReference Include="Community.CsharpSqlite\Community.CsharpSqlite.csproj">
<Project>{F1653F20-D47D-4F29-8C55-3C835542AF5F}</Project>
<Name>Community.CsharpSqlite</Name>
@ -320,7 +322,7 @@
<Project>{865172A0-A1A9-49C2-9386-F2FDB4E141B7}</Project>
<Name>MatterControlPluginSystem</Name>
</ProjectReference>
<ProjectReference Include="..\agg-sharp\Agg\Agg.csproj">
<ProjectReference Include="..\agg-sharp\agg\Agg.csproj">
<Project>{657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}</Project>
<Name>Agg</Name>
</ProjectReference>

View file

@ -1,19 +1,30 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="Localizations\LocalizedString.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeFile.cs">
<Files>
<File FileName="Localizations\LocalizedString.cs" Line="14" Column="10" />
<File FileName="PrintLibrary\PrintLibraryListItem.cs" Line="1" Column="1" />
<File FileName="ActionBar\ActionBarBaseControls.cs" Line="1" Column="1" />
<File FileName="ActionBar\HelpTextWidget.cs" Line="1" Column="1" />
<File FileName="PrintQueue\PrintQueueMenu.cs" Line="1" Column="1" />
<File FileName="..\MatterControlPlugins\PrintNotifications\NotificationForm.cs" Line="1" Column="1" />
<File FileName="PrinterCommunication.cs" Line="1" Column="1" />
<File FileName="PrintLevelWizard.cs" Line="1" Column="1" />
<File FileName="PrinterCommunication.cs" Line="491" Column="7" />
<File FileName="PrintQueue\QueueControlsWidget.cs" Line="1" Column="1" />
<File FileName="CustomWidgets\ExportQueueItemWindow.cs" Line="84" Column="78" />
<File FileName="PrintLibrary\ExportLibraryItemWindow.cs" Line="83" Column="74" />
<File FileName="PartPreviewWindow\GcodeViewBasic.cs" Line="459" Column="1" />
<File FileName="Localizations\LocalizedString.cs" Line="15" Column="16" />
<File FileName="c:\Users\Matter Hackers 1\Development\agg-sharp\Gui\FileDialogs\FileDialog.cs" Line="14" Column="6" />
<File FileName="ActionBar\HelpTextWidget.cs" Line="136" Column="51" />
<File FileName="c:\Users\Matter Hackers 1\Development\agg-sharp\PlatformWin32\win32\WidgetForWindowsFormsAbstract.cs" Line="195" Column="1" />
<File FileName="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeViewWidget.cs" Line="399" Column="1" />
<File FileName="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeFile.cs" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
<BreakpointStore>
<Catchpoint exceptionName="System.Reflection.TargetInvocationException" includeSubclasses="True" />
<Breakpoint file="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeViewWidget.cs" line="399" column="31" />
<Breakpoint file="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeViewWidget.cs" line="241" column="1" />
<Breakpoint file="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeFile.cs" line="186" column="53" />
<Breakpoint file="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeFile.cs" line="242" column="36" />
<Breakpoint file="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeFile.cs" line="519" column="1" />
<Breakpoint file="c:\Users\Matter Hackers 1\Development\agg-sharp\examples\GCodeVisualizer\GCodeFile.cs" line="639" column="1" />
</BreakpointStore>
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>

View file

@ -510,13 +510,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
navigationWidget.Margin = new BorderDouble(0, 0, 20, 0);
layerSelectionButtonsPannel.AddChild(navigationWidget);
selectLayerSlider = new Slider(new Vector2(), 10, 0, gcodeViewWidget.gCodeView.NumLayers - 1, Orientation.Vertical);
selectLayerSlider = new Slider(new Vector2(), 10, 0, gcodeViewWidget.LoadedGCode.NumChangesInZ - 1, Orientation.Vertical);
selectLayerSlider.ValueChanged += new EventHandler(selectLayerSlider_ValueChanged);
gcodeViewWidget.ActiveLayerChanged += new EventHandler(gcodeViewWidget_ActiveLayerChanged);
AddChild(selectLayerSlider);
SetSliderSize();
// let's change the active layer so that it is set to the first layer with data
gcodeViewWidget.ActiveLayerIndex = gcodeViewWidget.ActiveLayerIndex + 1;
gcodeViewWidget.ActiveLayerIndex = gcodeViewWidget.ActiveLayerIndex - 1;
BoundsChanged += new EventHandler(PartPreviewGCode_BoundsChanged);
}
}
@ -719,7 +722,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
if (gcodeViewWidget.LoadedGCode != null)
{
layerCountTextWidget.Text = string.Format("{0} / {1}", gcodeViewWidget.ActiveLayerIndex + 1, gcodeViewWidget.gCodeView.NumLayers.ToString());
layerCountTextWidget.Text = string.Format("{0} / {1}", gcodeViewWidget.ActiveLayerIndex + 1, gcodeViewWidget.LoadedGCode.NumChangesInZ.ToString());
}
base.OnDraw(graphics2D);
}

View file

@ -79,11 +79,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
tabControl.AddTab(new SimpleTextTabWidget(layerView, 16,
ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()));
if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE")
{
tabControl.TabBar.SwitchToPage(layerView);
}
this.AddChild(tabControl);
this.AnchorAll();
@ -94,6 +89,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
ShowAsSystemWindow();
MinimumSize = new Vector2(400, 300);
// We do this after showing the system window so that when we try and take fucus the parent window (the system window)
// exists and can give the fucus to its child the gecode window.
if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE")
{
tabControl.TabBar.SwitchToPage(layerView);
partGcodeView.Focus();
}
}
PerformanceFeedbackWindow timingWindow = null;

View file

@ -80,10 +80,11 @@ namespace MatterHackers.MatterControl.PrintLibrary
if (showExportGCodeButton)
{
string exportGCodeTxt = new LocalizedString ("Export as").Translated;
string exportGCodeTxtFull = string.Format ("{0} GCode", exportGCodeTxt);
string exportGCodeText = new LocalizedString("Export as").Translated;
string exportGCodeTextFull = string.Format ("{0} GCode", exportGCodeText);
Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull);
Button exportGCode = textImageButtonFactory.Generate(exportGCodeTxtFull);
//exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter;
exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click);
topToBottom.AddChild(exportGCode);

View file

@ -98,6 +98,14 @@ namespace MatterHackers.MatterControl
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, int dwShareMode, IntPtr securityAttrs, int dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);
public enum FirmwareTypes { Unknown, Repetier, Marlin, Sprinter };
FirmwareTypes firmwareType = FirmwareTypes.Unknown;
public FirmwareTypes FirmwareType
{
get { return firmwareType; }
}
static PrinterCommunication globalInstance;
string connectionFailureMessage = "Unknown Reason";
@ -106,7 +114,8 @@ namespace MatterHackers.MatterControl
public RootedObjectEventHandler ActivePrintItemChanged = new RootedObjectEventHandler();
public RootedObjectEventHandler BedTemperatureRead = new RootedObjectEventHandler();
public RootedObjectEventHandler BedTemperatureSet = new RootedObjectEventHandler();
public RootedObjectEventHandler CommunicationUnconditional = new RootedObjectEventHandler();
public RootedObjectEventHandler CommunicationUnconditionalFromPrinter = new RootedObjectEventHandler();
public RootedObjectEventHandler CommunicationUnconditionalToPrinter = new RootedObjectEventHandler();
public RootedObjectEventHandler ConnectionFailed = new RootedObjectEventHandler();
public RootedObjectEventHandler ConnectionStateChanged = new RootedObjectEventHandler();
public RootedObjectEventHandler ConnectionSucceeded = new RootedObjectEventHandler();
@ -373,7 +382,7 @@ namespace MatterHackers.MatterControl
ReadLineStartCallBacks.AddCallBackToKey("ok", PrintingCanContinue);
ReadLineStartCallBacks.AddCallBackToKey("ok T:", ReadTemperatures); // marline
ReadLineStartCallBacks.AddCallBackToKey("ok T:", ReadTemperatures); // marlin
ReadLineStartCallBacks.AddCallBackToKey("T:", ReadTemperatures); // repatier
ReadLineStartCallBacks.AddCallBackToKey("C:", ReadPositions);
@ -381,6 +390,7 @@ namespace MatterHackers.MatterControl
ReadLineContainsCallBacks.AddCallBackToKey("RS:", PrinterRequestsResend);
ReadLineContainsCallBacks.AddCallBackToKey("Resend:", PrinterRequestsResend);
ReadLineContainsCallBacks.AddCallBackToKey("FIRMWARE_NAME:", PrinterStatesFirmware);
WriteLineStartCallBacks.AddCallBackToKey("G28", HomeWasWritenToPrinter);
@ -476,8 +486,9 @@ namespace MatterHackers.MatterControl
return new LocalizedString("Not Connected").Translated;
case CommunicationStates.Disconnecting:
return new LocalizedString("Disconnecting").Translated;
case CommunicationStates.AttemptingToConnect:
return "Connecting...";
case CommunicationStates.AttemptingToConnect:
string connectingMessageTxt = new LocalizedString ("Connecting").Translated;
return string.Format("{0}...",connectingMessageTxt);
case CommunicationStates.ConnectionLost:
return new LocalizedString("Connection Lost").Translated;
case CommunicationStates.FailedToConnect:
@ -933,6 +944,29 @@ namespace MatterHackers.MatterControl
firstLineToResendIndex = int.Parse(splitOnColon[1]) - 1;
}
public void PrinterStatesFirmware(object sender, EventArgs e)
{
FoundStringEventArgs foundStringEventArgs = e as FoundStringEventArgs;
string firmwareName = "";
if (GCodeFile.GetFirstStringAfter("FIRMWARE_NAME:", foundStringEventArgs.LineToCheck, " ", ref firmwareName))
{
firmwareName = firmwareName.ToLower();
if (firmwareName.Contains("repetier"))
{
firmwareType = FirmwareTypes.Repetier;
}
else if (firmwareName.Contains("marlin"))
{
firmwareType = FirmwareTypes.Marlin;
}
else if (firmwareName.Contains("sprinter"))
{
firmwareType = FirmwareTypes.Sprinter;
}
}
}
public void FoundStart(object sender, EventArgs e)
{
FoundStringEventArgs foundStringEventArgs = e as FoundStringEventArgs;
@ -1029,6 +1063,7 @@ namespace MatterHackers.MatterControl
//Attempt connecting to a specific printer
CommunicationState = CommunicationStates.AttemptingToConnect;
this.stopTryingToConnect = false;
firmwareType = FirmwareTypes.Unknown;
if (SerialPortIsAvailable(this.ActivePrinter.ComPort))
{
@ -1399,7 +1434,7 @@ namespace MatterHackers.MatterControl
// write data to communication
{
StringEventArgs currentEvent = new StringEventArgs(lineToWrite);
CommunicationUnconditional.CallEvents(this, new StringEventArgs("->" + currentEvent.Data));
CommunicationUnconditionalToPrinter.CallEvents(this, currentEvent);
if (lineWithoutChecksum != null)
{
@ -1758,7 +1793,7 @@ namespace MatterHackers.MatterControl
// process this command
{
StringEventArgs currentEvent = new StringEventArgs(lastLineRead);
CommunicationUnconditional.CallEvents(this, new StringEventArgs("<-" + currentEvent.Data));
CommunicationUnconditionalFromPrinter.CallEvents(this, currentEvent);
FoundStringEventArgs foundResponse = new FoundStringEventArgs(currentEvent.Data);
ReadLineStartCallBacks.CheckForKeys(foundResponse);

View file

@ -335,7 +335,12 @@ namespace MatterHackers.MatterControl
addMacroButton.Click += new ButtonBase.ButtonEventHandler(addMacro_Click);
Button cancelPresetsButton = textImageButtonFactory.Generate(new LocalizedString("Close").Translated);
cancelPresetsButton.Click += (sender, e) => { this.windowController.Close(); };
cancelPresetsButton.Click += (sender, e) => {
UiThread.RunOnIdle((state) =>
{
this.windowController.Close();
});
};
FlowLayoutWidget buttonRow = new FlowLayoutWidget();
buttonRow.HAnchor = HAnchor.ParentLeftRight;

View file

@ -173,7 +173,12 @@ namespace MatterHackers.MatterControl
savePresetsButton.Click += new ButtonBase.ButtonEventHandler(save_Click);
Button cancelPresetsButton = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated);
cancelPresetsButton.Click += (sender, e) => { Close(); };
cancelPresetsButton.Click += (sender, e) => {
UiThread.RunOnIdle((state) =>
{
Close();
});
};
FlowLayoutWidget buttonRow = new FlowLayoutWidget();
buttonRow.HAnchor = HAnchor.ParentLeftRight;

View file

@ -53,11 +53,11 @@ namespace MatterHackers.MatterControl
}
}
public class DisablablableWidget : GuiWidget
public class DisableableWidget : GuiWidget
{
public GuiWidget disableOverlay;
public DisablablableWidget()
public DisableableWidget()
{
HAnchor = Agg.UI.HAnchor.ParentLeftRight;
VAnchor = Agg.UI.VAnchor.FitToChildren;
@ -118,16 +118,19 @@ namespace MatterHackers.MatterControl
Button homeXButton;
Button homeYButton;
Button homeZButton;
Button enablePrintLevelingButton;
Button disablePrintLevelingButton;
DisablablableWidget extruderTemperatureControlWidget;
DisablablableWidget bedTemperatureControlWidget;
DisablablableWidget movementControlsContainer;
DisablablableWidget fanControlsContainer;
DisablablableWidget tuningAdjustmentControlsContainer;
DisablablableWidget terminalCommunicationsContainer;
DisablablableWidget sdCardManagerContainer;
DisablablableWidget printLevelContainer;
DisablablableWidget macroControls;
DisableableWidget extruderTemperatureControlWidget;
DisableableWidget bedTemperatureControlWidget;
DisableableWidget movementControlsContainer;
DisableableWidget fanControlsContainer;
DisableableWidget eePromControlsContainer;
DisableableWidget tuningAdjustmentControlsContainer;
DisableableWidget terminalCommunicationsContainer;
DisableableWidget sdCardManagerContainer;
DisableableWidget printLevelContainer;
DisableableWidget macroControls;
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
@ -198,37 +201,54 @@ namespace MatterHackers.MatterControl
controlsTopToBottomLayout.Padding = new BorderDouble(3, 0);
terminalCommunicationsContainer = new DisablablableWidget();
terminalCommunicationsContainer = new DisableableWidget();
terminalCommunicationsContainer.AddChild(CreateTerminalControlsContainer());
controlsTopToBottomLayout.AddChild(terminalCommunicationsContainer);
AddTemperatureControls(controlsTopToBottomLayout);
AddMovementControls(controlsTopToBottomLayout);
printLevelContainer = new DisablablableWidget();
printLevelContainer.AddChild(CreatePrintLevelingControlsContainer());
controlsTopToBottomLayout.AddChild(printLevelContainer);
FlowLayoutWidget centerControlsContainer = new FlowLayoutWidget ();
centerControlsContainer.HAnchor = HAnchor.ParentLeftRight;
sdCardManagerContainer = new DisablablableWidget();
FlowLayoutWidget rightColumnContainer = new FlowLayoutWidget (FlowDirection.TopToBottom);
rightColumnContainer.AddChild (terminalCommunicationsContainer);
rightColumnContainer.Width = 230;
rightColumnContainer.VAnchor |= VAnchor.ParentTop;
AddMovementControls(centerControlsContainer);
AddFanControls(rightColumnContainer);
AddEePromControls(rightColumnContainer);
centerControlsContainer.AddChild(rightColumnContainer);
controlsTopToBottomLayout.AddChild (centerControlsContainer);
sdCardManagerContainer = new DisableableWidget();
sdCardManagerContainer.AddChild(CreateSdCardManagerContainer());
if (false)// || ActivePrinterProfile.Instance.ActivePrinter == null || ActivePrinterProfile.Instance.ActivePrinter.GetFeatures().HasSdCard())
{
controlsTopToBottomLayout.AddChild(sdCardManagerContainer);
}
macroControls = new DisablablableWidget();
macroControls = new DisableableWidget();
macroControls.AddChild(new MacroControls());
controlsTopToBottomLayout.AddChild(macroControls);
PutInFanControls(controlsTopToBottomLayout);
AddAdjustmentControls(controlsTopToBottomLayout);
printLevelContainer = new DisableableWidget();
printLevelContainer.AddChild(CreatePrintLevelingControlsContainer());
controlsTopToBottomLayout.AddChild(printLevelContainer);
this.AddChild(controlsTopToBottomLayout);
AddHandlers();
SetVisibleControls();
}
private void PutInFanControls(FlowLayoutWidget controlsTopToBottomLayout)
private void AddFanControls(FlowLayoutWidget controlsTopToBottomLayout)
{
GroupBox fanControlsGroupBox = new GroupBox(new LocalizedString("Fan Controls").Translated);
@ -250,7 +270,7 @@ namespace MatterHackers.MatterControl
fanControlsGroupBox.AddChild(fanControlsLayout);
}
fanControlsContainer = new DisablablableWidget();
fanControlsContainer = new DisableableWidget();
fanControlsContainer.AddChild(fanControlsGroupBox);
if (ActivePrinterProfile.Instance.ActivePrinter == null
@ -260,6 +280,65 @@ namespace MatterHackers.MatterControl
}
}
private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout)
{
GroupBox eePromControlsGroupBox = new GroupBox(new LocalizedString("EEProm Settings").Translated);
eePromControlsGroupBox.Margin = new BorderDouble(0);
eePromControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
eePromControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
eePromControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
eePromControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;
eePromControlsGroupBox.Height = 68;
{
FlowLayoutWidget eePromControlsLayout = new FlowLayoutWidget();
eePromControlsLayout.HAnchor |= HAnchor.ParentLeftRight;
eePromControlsLayout.VAnchor |= Agg.UI.VAnchor.ParentCenter;
eePromControlsLayout.Margin = new BorderDouble(3, 0, 3, 6);
eePromControlsLayout.Padding = new BorderDouble(0);
{
Agg.Image.ImageBuffer eePromImage = new Agg.Image.ImageBuffer();
ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), eePromImage);
ImageWidget eePromIcon = new ImageWidget(eePromImage);
eePromIcon.Margin = new BorderDouble (right: 6);
Button openEePromWindow = textImageButtonFactory.Generate(new LocalizedString("CONFIGURE").Translated);
openEePromWindow.Click += (sender, e) =>
{
switch(PrinterCommunication.Instance.FirmwareType)
{
case PrinterCommunication.FirmwareTypes.Repetier:
new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
break;
case PrinterCommunication.FirmwareTypes.Marlin:
new MatterHackers.MatterControl.EeProm.EePromMarlinWidget();
break;
default:
UiThread.RunOnIdle((state) =>
{
string message = new LocalizedString("Oops! There is no eeprom mapping for your printer's firmware.").Translated;
StyledMessageBox.ShowMessageBox(message, "Warning no eeprom mapping", StyledMessageBox.MessageType.OK);
}
);
break;
}
};
//eePromControlsLayout.AddChild(eePromIcon);
eePromControlsLayout.AddChild(openEePromWindow);
}
eePromControlsGroupBox.AddChild(eePromControlsLayout);
}
eePromControlsContainer = new DisableableWidget();
eePromControlsContainer.AddChild(eePromControlsGroupBox);
controlsTopToBottomLayout.AddChild(eePromControlsContainer);
}
private void AddMovementControls(FlowLayoutWidget controlsTopToBottomLayout)
{
Button editButton;
@ -290,20 +369,16 @@ namespace MatterHackers.MatterControl
manualControlsLayout.Padding = new BorderDouble(3, 5, 3, 0);
{
manualControlsLayout.AddChild(GetHomeButtonBar());
manualControlsLayout.AddChild(CreateSeparatorLine());
manualControlsLayout.AddChild(new JogControls(new XYZColors()));
manualControlsLayout.AddChild(CreateSeparatorLine());
//manualControlsLayout.AddChild(GetManualMoveBar());
}
movementControlsGroupBox.AddChild(manualControlsLayout);
}
movementControlsContainer = new DisablablableWidget();
movementControlsContainer = new DisableableWidget();
movementControlsContainer.AddChild(movementControlsGroupBox);
controlsTopToBottomLayout.AddChild(movementControlsContainer);
}
@ -312,12 +387,13 @@ namespace MatterHackers.MatterControl
{
FlowLayoutWidget temperatureControlContainer = new FlowLayoutWidget();
temperatureControlContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
temperatureControlContainer.Margin = new BorderDouble (top: 10);
extruderTemperatureControlWidget = new DisablablableWidget();
extruderTemperatureControlWidget = new DisableableWidget();
extruderTemperatureControlWidget.AddChild(new ExtruderTemperatureControlWidget());
temperatureControlContainer.AddChild(extruderTemperatureControlWidget);
bedTemperatureControlWidget = new DisablablableWidget();
bedTemperatureControlWidget = new DisableableWidget();
bedTemperatureControlWidget.AddChild(new BedTemperatureControlWidget());
if (ActivePrinterProfile.Instance.ActivePrinter == null
@ -460,7 +536,7 @@ namespace MatterHackers.MatterControl
adjustmentControlsGroupBox.AddChild(tuningRatiosLayout);
}
tuningAdjustmentControlsContainer = new DisablablableWidget();
tuningAdjustmentControlsContainer = new DisableableWidget();
tuningAdjustmentControlsContainer.AddChild(adjustmentControlsGroupBox);
controlsTopToBottomLayout.AddChild(tuningAdjustmentControlsContainer);
}
@ -487,6 +563,8 @@ namespace MatterHackers.MatterControl
feedRateValue.Value = ((int)(PrinterCommunication.Instance.FeedRateRatio * 100 + .5)) / 100.0;
}
TextWidget printLevelingStatusLabel;
private GuiWidget CreatePrintLevelingControlsContainer()
{
GroupBox printLevelingControlsContainer;
@ -512,13 +590,41 @@ namespace MatterHackers.MatterControl
runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
runPrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(runPrintLeveling_Click);
Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer();
ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage);
ImageWidget levelingIcon = new ImageWidget(levelingImage);
levelingIcon.Margin = new BorderDouble (right: 6);
enablePrintLevelingButton = textImageButtonFactory.Generate(new LocalizedString("ENABLE").Translated);
enablePrintLevelingButton.Margin = new BorderDouble(left:6);
enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
enablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(enablePrintLeveling_Click);
disablePrintLevelingButton = textImageButtonFactory.Generate(new LocalizedString("DISABLE").Translated);
disablePrintLevelingButton.Margin = new BorderDouble(left:6);
disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
disablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(disablePrintLeveling_Click);
CheckBox doLevelingCheckBox = new CheckBox(new LocalizedString("Enable Automatic Print Leveling").Translated);
doLevelingCheckBox.Margin = new BorderDouble(left: 3);
doLevelingCheckBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
doLevelingCheckBox.VAnchor = VAnchor.ParentCenter;
doLevelingCheckBox.Checked = ActivePrinterProfile.Instance.DoPrintLeveling;
buttonBar.AddChild(doLevelingCheckBox);
printLevelingStatusLabel = new TextWidget ("");
printLevelingStatusLabel.AutoExpandBoundsToText = true;
printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter;
GuiWidget hSpacer = new GuiWidget ();
hSpacer.HAnchor = HAnchor.ParentLeftRight;
buttonBar.AddChild(levelingIcon);
//buttonBar.AddChild(doLevelingCheckBox);
buttonBar.AddChild (printLevelingStatusLabel);
buttonBar.AddChild (hSpacer);
buttonBar.AddChild(enablePrintLevelingButton);
buttonBar.AddChild(disablePrintLevelingButton);
buttonBar.AddChild(runPrintLevelingButton);
doLevelingCheckBox.CheckedStateChanged += (sender, e) =>
{
@ -526,17 +632,13 @@ namespace MatterHackers.MatterControl
};
ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
{
doLevelingCheckBox.Checked = ActivePrinterProfile.Instance.DoPrintLeveling;
if (doLevelingCheckBox.Checked && ActivePrinterProfile.Instance.ActivePrinter.PrintLevelingProbePositions == null)
{
//OpenPrintLevelWizard();
}
SetPrintLevelButtonVisiblity();
}, ref unregisterEvents);
printLevelingControlsContainer.AddChild(buttonBar);
}
SetPrintLevelButtonVisiblity ();
return printLevelingControlsContainer;
}
@ -562,7 +664,7 @@ namespace MatterHackers.MatterControl
GroupBox terminalControlsContainer;
terminalControlsContainer = new GroupBox(new LocalizedString("Printer Communications").Translated);
terminalControlsContainer.Margin = new BorderDouble(top: 10);
terminalControlsContainer.Margin = new BorderDouble(0);
terminalControlsContainer.TextColor = ActiveTheme.Instance.PrimaryTextColor;
terminalControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
terminalControlsContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
@ -572,17 +674,24 @@ namespace MatterHackers.MatterControl
FlowLayoutWidget buttonBar = new FlowLayoutWidget();
buttonBar.HAnchor |= HAnchor.ParentLeftRight;
buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
buttonBar.Margin = new BorderDouble(3, 0, 3, 6);
buttonBar.Margin = new BorderDouble(3, 0, 3, 6);
buttonBar.Padding = new BorderDouble(0);
this.textImageButtonFactory.FixedHeight = TallButtonHeight;
Agg.Image.ImageBuffer terminalImage = new Agg.Image.ImageBuffer();
ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "terminal-24x24.png"), terminalImage);
ImageWidget terminalIcon = new ImageWidget(terminalImage);
terminalIcon.Margin = new BorderDouble (right: 6);
Button showTerminal = textImageButtonFactory.Generate(new LocalizedString("SHOW TERMINAL").Translated);
showTerminal.Margin = new BorderDouble(0);
showTerminal.Click += (sender, e) =>
{
OutputScrollWindow.Show();
};
//buttonBar.AddChild(terminalIcon);
buttonBar.AddChild(showTerminal);
terminalControlsContainer.AddChild(buttonBar);
@ -646,15 +755,16 @@ namespace MatterHackers.MatterControl
if (ActivePrinterProfile.Instance.ActivePrinter == null)
{
// no printer selected
extruderTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
sdCardManagerContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
macroControls.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
extruderTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
bedTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
printLevelContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
sdCardManagerContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
macroControls.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
}
else // we at least have a printer selected
{
@ -665,28 +775,30 @@ namespace MatterHackers.MatterControl
case PrinterCommunication.CommunicationStates.Disconnected:
case PrinterCommunication.CommunicationStates.AttemptingToConnect:
case PrinterCommunication.CommunicationStates.FailedToConnect:
extruderTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.ConfigOnly);
bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.ConfigOnly);
movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.ConfigOnly);
fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
sdCardManagerContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
macroControls.SetEnableLevel(DisablablableWidget.EnableLevel.ConfigOnly);
extruderTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
bedTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
sdCardManagerContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
macroControls.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
break;
case PrinterCommunication.CommunicationStates.FinishedPrint:
case PrinterCommunication.CommunicationStates.Connected:
extruderTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
sdCardManagerContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
macroControls.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
extruderTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
bedTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
sdCardManagerContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
macroControls.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
break;
case PrinterCommunication.CommunicationStates.PreparingToPrint:
@ -697,15 +809,16 @@ namespace MatterHackers.MatterControl
case PrinterCommunication.DetailedPrintingState.HeatingBed:
case PrinterCommunication.DetailedPrintingState.HeatingExtruder:
case PrinterCommunication.DetailedPrintingState.Printing:
extruderTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.ConfigOnly);
fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
sdCardManagerContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
macroControls.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
extruderTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
bedTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
sdCardManagerContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
macroControls.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
break;
default:
@ -714,15 +827,16 @@ namespace MatterHackers.MatterControl
break;
case PrinterCommunication.CommunicationStates.Paused:
extruderTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
sdCardManagerContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
macroControls.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled);
extruderTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
bedTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
printLevelContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
sdCardManagerContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
macroControls.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
break;
default:
@ -864,6 +978,31 @@ namespace MatterHackers.MatterControl
this.Invalidate();
}
void enablePrintLeveling_Click(object sender, MouseEventArgs mouseEvent)
{
ActivePrinterProfile.Instance.DoPrintLeveling = true;
}
void disablePrintLeveling_Click(object sender, MouseEventArgs mouseEvent)
{
ActivePrinterProfile.Instance.DoPrintLeveling = false;
}
void SetPrintLevelButtonVisiblity()
{
enablePrintLevelingButton.Visible = !ActivePrinterProfile.Instance.DoPrintLeveling;
disablePrintLevelingButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
if (ActivePrinterProfile.Instance.DoPrintLeveling) {
printLevelingStatusLabel.Text = new LocalizedString ("Automatic Print Leveling (enabled)").Translated;
}
else
{
printLevelingStatusLabel.Text = new LocalizedString ("Automatic Print Leveling (disabled)").Translated;
}
}
void disableMotors_Click(object sender, MouseEventArgs mouseEvent)
{
PrinterCommunication.Instance.ReleaseMotors();

View file

@ -252,16 +252,30 @@ namespace MatterHackers.MatterControl
{
if (filterOutput.Checked)
{
PrinterCommunication.Instance.CommunicationUnconditional.UnregisterEvent(outputScrollWidget.WriteLine, ref unregisterEvents);
PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.UnregisterEvent(FromPrinter, ref unregisterEvents);
PrinterCommunication.Instance.CommunicationUnconditionalToPrinter.UnregisterEvent(ToPrinter, ref unregisterEvents);
PrinterCommunication.Instance.ReadLine.RegisterEvent(outputScrollWidget.WriteLine, ref unregisterEvents);
}
else
{
PrinterCommunication.Instance.CommunicationUnconditional.RegisterEvent(outputScrollWidget.WriteLine, ref unregisterEvents);
PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(FromPrinter, ref unregisterEvents);
PrinterCommunication.Instance.CommunicationUnconditionalToPrinter.RegisterEvent(ToPrinter, ref unregisterEvents);
PrinterCommunication.Instance.ReadLine.UnregisterEvent(outputScrollWidget.WriteLine, ref unregisterEvents);
}
}
void FromPrinter(Object sender, EventArgs e)
{
StringEventArgs lineString = e as StringEventArgs;
outputScrollWidget.WriteLine(sender, new StringEventArgs("<-" + lineString.Data));
}
void ToPrinter(Object sender, EventArgs e)
{
StringEventArgs lineString = e as StringEventArgs;
outputScrollWidget.WriteLine(sender, new StringEventArgs("->" + lineString.Data));
}
void Instance_ConnectionFailed(object sender, EventArgs e)
{
outputScrollWidget.WriteLine(sender, new StringEventArgs("Lost connection to printer."));

View file

@ -83,7 +83,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
{
printerListContainer.HAnchor = HAnchor.ParentLeftRight;
printerListContainer.VAnchor = VAnchor.ParentBottomTop;
printerListContainer.Padding = new BorderDouble(3);
printerListContainer.Padding = new BorderDouble(3);
printerListContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
//Get a list of printer records and add them to radio button list

View file

@ -126,7 +126,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
//Create the main container
GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
mainContainer.AnchorAll();
mainContainer.Padding = new BorderDouble(3, 0, 3, 5);
mainContainer.Padding = new BorderDouble(3, 5, 3, 5);
mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
//Create the header row for the widget

View file

@ -97,7 +97,8 @@ namespace MatterHackers.MatterControl
{
TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
buttonFactory.FixedHeight = 20;
buttonFactory.FixedWidth = 35;
buttonFactory.FixedWidth = 30;
buttonFactory.fontSize = 10;
buttonFactory.Margin = new BorderDouble(0);
FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget();
@ -123,11 +124,11 @@ namespace MatterHackers.MatterControl
moveRadioButtons.AddChild(oneHundredButton);
tenButton.Checked = true;
moveRadioButtons.Margin = new BorderDouble(3);
moveRadioButtons.Margin = new BorderDouble(0,3);
setMoveDistanceControl.AddChild(moveRadioButtons);
}
TextWidget mmLabel = new TextWidget("mm", textColor: RGBA_Bytes.White);
TextWidget mmLabel = new TextWidget("mm", textColor: RGBA_Bytes.White, pointSize:10);
mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
setMoveDistanceControl.AddChild(mmLabel);
setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft;
@ -227,7 +228,8 @@ namespace MatterHackers.MatterControl
{
TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
buttonFactory.FixedHeight = 20;
buttonFactory.FixedWidth = 35;
buttonFactory.FixedWidth = 30;
buttonFactory.fontSize = 10;
buttonFactory.Margin = new BorderDouble(0);
FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget();
@ -244,11 +246,11 @@ namespace MatterHackers.MatterControl
oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetEMoveAmount(100); };
moveRadioButtons.AddChild(oneHundredButton);
tenButton.Checked = true;
moveRadioButtons.Margin = new BorderDouble(3);
moveRadioButtons.Margin = new BorderDouble(0,3);
setMoveDistanceControl.AddChild(moveRadioButtons);
}
TextWidget mmLabel = new TextWidget("mm", textColor: RGBA_Bytes.White);
TextWidget mmLabel = new TextWidget("mm", textColor: RGBA_Bytes.White, pointSize:10);
mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
setMoveDistanceControl.AddChild(mmLabel);
setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft;

View file

@ -57,6 +57,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
hideItems.Add("cool_extruder_lift");
hideItems.Add("support_material_create_internal_support");
hideItems.Add("min_extrusion_before_retract");
hideItems.Add("support_material_xy_distance");
hideItems.Add("support_material_z_distance");
}
return instance;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB