From c246b1c6a4c8aa3e473fe7737adcc1c1934895b8 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Tue, 18 Feb 2014 10:26:11 -0800 Subject: [PATCH 01/24] Refectoring GCode viewer so that it draws everything in order. --- PartPreviewWindow/GcodeViewBasic.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs index 0ced2aaf4..428295b88 100644 --- a/PartPreviewWindow/GcodeViewBasic.cs +++ b/PartPreviewWindow/GcodeViewBasic.cs @@ -511,7 +511,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow 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); @@ -719,7 +719,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); } From 9c8a0fa5a8a06bcd3b4dd45085b9c2c880c60486 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Tue, 18 Feb 2014 17:52:50 -0800 Subject: [PATCH 02/24] Creating eePromSettings window for repetier firmware. Put in detection of firmware. Creating base window and data to construct it. --- EeProm/EePromRepatierParameter.cs | 92 ++++++++++++++++ EeProm/EePromRepatierStorage.cs | 87 +++++++++++++++ EeProm/EePromRepatierWidget.cs | 130 +++++++++++++++++++++++ MatterControl.csproj | 3 + PrinterCommunication.cs | 35 +++++- PrinterControls/ManualPrinterControls.cs | 47 ++++++++ 6 files changed, 393 insertions(+), 1 deletion(-) create mode 100644 EeProm/EePromRepatierParameter.cs create mode 100644 EeProm/EePromRepatierStorage.cs create mode 100644 EeProm/EePromRepatierWidget.cs diff --git a/EeProm/EePromRepatierParameter.cs b/EeProm/EePromRepatierParameter.cs new file mode 100644 index 000000000..612ae5c5b --- /dev/null +++ b/EeProm/EePromRepatierParameter.cs @@ -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 EePromRepatierParameter + { + public string description; + public int type; + public int position; + string val = ""; + bool changed = false; + + public EePromRepatierParameter(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; + } + } + } +} diff --git a/EeProm/EePromRepatierStorage.cs b/EeProm/EePromRepatierStorage.cs new file mode 100644 index 000000000..6417157f1 --- /dev/null +++ b/EeProm/EePromRepatierStorage.cs @@ -0,0 +1,87 @@ +/* +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 delegate void OnEePromRepatierAdded(EePromRepatierParameter param); + + public class EePromRepatierStorage + { + public Dictionary eePromSettingsList; + public event OnEePromRepatierAdded eventAdded = null; + + public EePromRepatierStorage() + { + eePromSettingsList = new Dictionary(); + } + + public void Clear() + { + eePromSettingsList.Clear(); + } + + public void Save() + { + foreach (EePromRepatierParameter p in eePromSettingsList.Values) + { + p.save(); + } + } + + public void Add(string line) + { + if (!line.StartsWith("EPR:")) + { + return; + } + + EePromRepatierParameter parameter = new EePromRepatierParameter(line); + if (eePromSettingsList.ContainsKey(parameter.position)) + { + eePromSettingsList.Remove(parameter.position); + } + + eePromSettingsList.Add(parameter.position, parameter); + if (eventAdded != null) + { + eventAdded(parameter); + } + } + + public void AskPrinterForSettings() + { + PrinterCommunication.Instance.QueueLineToPrinter("M205"); + } + } +} \ No newline at end of file diff --git a/EeProm/EePromRepatierWidget.cs b/EeProm/EePromRepatierWidget.cs new file mode 100644 index 000000000..23512b7c6 --- /dev/null +++ b/EeProm/EePromRepatierWidget.cs @@ -0,0 +1,130 @@ +/* +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 + { + EePromRepatierStorage storage; + BindingList data = new BindingList(); + FlowLayoutWidget descriptionColmun; + FlowLayoutWidget valueColmun; + + Button buttonCancel; + Button buttonSave; + + bool reinit = true; + public EePromRepetierWidget() + : base(640, 480) + { + BackgroundColor = RGBA_Bytes.White; + + storage = new EePromRepatierStorage(); + + FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); + + { + FlowLayoutWidget columnHolder = new FlowLayoutWidget(); + descriptionColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); + columnHolder.AddChild(descriptionColmun); + + valueColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); + columnHolder.AddChild(valueColmun); + + descriptionColmun.AddChild(new TextWidget("Description")); + valueColmun.AddChild(new TextWidget("Value")); + + topToBottom.AddChild(columnHolder); + } + + buttonCancel = new Button(new LocalizedString("Cancel").Translated); + topToBottom.AddChild(buttonCancel); + + buttonSave = new Button(new LocalizedString("Save To EEPROM").Translated); + topToBottom.AddChild(buttonSave); + + //MatterControlApplication.Instance.LanguageChanged += translate; + this.AddChild(topToBottom); + + translate(); + + ShowAsSystemWindow(); + } + + 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 newline(EePromRepatierParameter p) + { + data.Add(p); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + storage.Save(); + storage.Clear(); + storage.eventAdded -= newline; + } + + private void buttonAbort_Click(object sender, EventArgs e) + { + storage.Clear(); + data.Clear(); + storage.eventAdded -= newline; + } + + private void EEPROMRepetier_Activated(object sender, EventArgs e) + { + if (reinit) + { + reinit = false; + storage.Clear(); + storage.eventAdded += newline; + storage.AskPrinterForSettings(); + } + } + } +} diff --git a/MatterControl.csproj b/MatterControl.csproj index f89b1bf9d..16e9f3747 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -75,6 +75,9 @@ + + + diff --git a/PrinterCommunication.cs b/PrinterCommunication.cs index e0a60933e..f7057fcdc 100644 --- a/PrinterCommunication.cs +++ b/PrinterCommunication.cs @@ -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"; @@ -373,7 +381,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 +389,7 @@ namespace MatterHackers.MatterControl ReadLineContainsCallBacks.AddCallBackToKey("RS:", PrinterRequestsResend); ReadLineContainsCallBacks.AddCallBackToKey("Resend:", PrinterRequestsResend); + ReadLineContainsCallBacks.AddCallBackToKey("FIRMWARE_NAME:", PrinterStatesFirmware); WriteLineStartCallBacks.AddCallBackToKey("G28", HomeWasWritenToPrinter); @@ -933,6 +942,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 +1061,7 @@ namespace MatterHackers.MatterControl //Attempt connecting to a specific printer CommunicationState = CommunicationStates.AttemptingToConnect; this.stopTryingToConnect = false; + firmwareType = FirmwareTypes.Unknown; if (SerialPortIsAvailable(this.ActivePrinter.ComPort)) { diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index e5c03f2f3..f820b6d21 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -123,6 +123,7 @@ namespace MatterHackers.MatterControl DisablablableWidget bedTemperatureControlWidget; DisablablableWidget movementControlsContainer; DisablablableWidget fanControlsContainer; + DisablablableWidget eePromControlsContainer; DisablablableWidget tuningAdjustmentControlsContainer; DisablablableWidget terminalCommunicationsContainer; DisablablableWidget sdCardManagerContainer; @@ -221,6 +222,8 @@ namespace MatterHackers.MatterControl controlsTopToBottomLayout.AddChild(macroControls); PutInFanControls(controlsTopToBottomLayout); + PutInEePromControls(controlsTopToBottomLayout); + AddAdjustmentControls(controlsTopToBottomLayout); this.AddChild(controlsTopToBottomLayout); @@ -260,6 +263,45 @@ namespace MatterHackers.MatterControl } } + private void PutInEePromControls(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; + + { + FlowLayoutWidget eePromControlsLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); + eePromControlsLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + eePromControlsLayout.VAnchor = Agg.UI.VAnchor.FitToChildren; + eePromControlsLayout.Padding = new BorderDouble(3, 5, 3, 0); + { + Button openEePromWindow = textImageButtonFactory.Generate(new LocalizedString("CONFIGURE").Translated); + openEePromWindow.Margin = new BorderDouble(left: 6); + //openEePromWindow.VAnchor = VAnchor.ParentCenter; + openEePromWindow.Click += (sender, e) => + { + if (PrinterCommunication.Instance.FirmwareType == PrinterCommunication.FirmwareTypes.Repetier) + { + new MatterHackers.MatterControl.EeProm.EePromRepetierWidget(); + } + }; + + eePromControlsLayout.AddChild(openEePromWindow); + } + + eePromControlsGroupBox.AddChild(eePromControlsLayout); + } + + eePromControlsContainer = new DisablablableWidget(); + eePromControlsContainer.AddChild(eePromControlsGroupBox); + + controlsTopToBottomLayout.AddChild(eePromControlsContainer); + } + private void AddMovementControls(FlowLayoutWidget controlsTopToBottomLayout) { Button editButton; @@ -650,6 +692,7 @@ namespace MatterHackers.MatterControl bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); + eePromControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); @@ -669,6 +712,7 @@ namespace MatterHackers.MatterControl bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.ConfigOnly); movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.ConfigOnly); fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); + eePromControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); @@ -682,6 +726,7 @@ namespace MatterHackers.MatterControl bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); + eePromControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); sdCardManagerContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); @@ -701,6 +746,7 @@ namespace MatterHackers.MatterControl bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.ConfigOnly); fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); + eePromControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); @@ -718,6 +764,7 @@ namespace MatterHackers.MatterControl bedTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); movementControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); fanControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); + eePromControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); tuningAdjustmentControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); terminalCommunicationsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Enabled); printLevelContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); From 4a46fb472aecd9ba2fdbac6648fd8b6bcbbb98cc Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Tue, 18 Feb 2014 18:04:23 -0800 Subject: [PATCH 03/24] Turned off localization debug. Localized two strings. --- EeProm/EePromRepatierWidget.cs | 4 ++-- Localizations/LocalizedString.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EeProm/EePromRepatierWidget.cs b/EeProm/EePromRepatierWidget.cs index 23512b7c6..16ca6575d 100644 --- a/EeProm/EePromRepatierWidget.cs +++ b/EeProm/EePromRepatierWidget.cs @@ -67,8 +67,8 @@ namespace MatterHackers.MatterControl.EeProm valueColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); columnHolder.AddChild(valueColmun); - descriptionColmun.AddChild(new TextWidget("Description")); - valueColmun.AddChild(new TextWidget("Value")); + descriptionColmun.AddChild(new TextWidget(new LocalizedString("Description").Translated)); + valueColmun.AddChild(new TextWidget(new LocalizedString("Value").Translated)); topToBottom.AddChild(columnHolder); } diff --git a/Localizations/LocalizedString.cs b/Localizations/LocalizedString.cs index f7bb8bfb6..8b64adb51 100644 --- a/Localizations/LocalizedString.cs +++ b/Localizations/LocalizedString.cs @@ -1,4 +1,4 @@ -#define DEBUG_SHOW_TRANSLATED_STRINGS +//#define DEBUG_SHOW_TRANSLATED_STRINGS using System; using System.Collections.Generic; From b6f3ff311e8be8d238976cdd8d8b58ff83c1cb84 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 20 Feb 2014 09:39:12 -0800 Subject: [PATCH 04/24] These settings do nothing in slic3r so hiding them. --- SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs b/SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs index dd847659f..312243561 100644 --- a/SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs +++ b/SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs @@ -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; } From c302bc2ae01ac2ac84bbfa6f99c10e1caee64ac7 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 20 Feb 2014 09:47:08 -0800 Subject: [PATCH 05/24] Don't translate placeholder text. --- ActionBar/PrintStatusRow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index f13819fbe..939d4c15e 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -123,9 +123,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); From b83a0354d7839359adb59bac90410169a7131134 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 20 Feb 2014 18:25:23 -0800 Subject: [PATCH 06/24] Made printer communication unconditional have a separate event for read and write. Got the repatier eeprom working and looking better. --- EeProm/EePromRepatierParameter.cs | 2 +- EeProm/EePromRepatierStorage.cs | 17 ++- EeProm/EePromRepatierWidget.cs | 151 ++++++++++++++++++++------ PrinterCommunication.cs | 7 +- PrinterControls/OutputScrollWindow.cs | 18 ++- 5 files changed, 154 insertions(+), 41 deletions(-) diff --git a/EeProm/EePromRepatierParameter.cs b/EeProm/EePromRepatierParameter.cs index 612ae5c5b..b68b63102 100644 --- a/EeProm/EePromRepatierParameter.cs +++ b/EeProm/EePromRepatierParameter.cs @@ -34,7 +34,7 @@ using System.Text; namespace MatterHackers.MatterControl.EeProm { - public class EePromRepatierParameter + public class EePromRepatierParameter : EventArgs { public string description; public int type; diff --git a/EeProm/EePromRepatierStorage.cs b/EeProm/EePromRepatierStorage.cs index 6417157f1..8bd1a4bcb 100644 --- a/EeProm/EePromRepatierStorage.cs +++ b/EeProm/EePromRepatierStorage.cs @@ -32,6 +32,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using MatterHackers.Agg.UI; + namespace MatterHackers.MatterControl.EeProm { public delegate void OnEePromRepatierAdded(EePromRepatierParameter param); @@ -39,7 +41,7 @@ namespace MatterHackers.MatterControl.EeProm public class EePromRepatierStorage { public Dictionary eePromSettingsList; - public event OnEePromRepatierAdded eventAdded = null; + public event EventHandler eventAdded = null; public EePromRepatierStorage() { @@ -59,8 +61,17 @@ namespace MatterHackers.MatterControl.EeProm } } - public void Add(string line) + 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; @@ -75,7 +86,7 @@ namespace MatterHackers.MatterControl.EeProm eePromSettingsList.Add(parameter.position, parameter); if (eventAdded != null) { - eventAdded(parameter); + eventAdded(this, parameter); } } diff --git a/EeProm/EePromRepatierWidget.cs b/EeProm/EePromRepatierWidget.cs index 16ca6575d..f8000235b 100644 --- a/EeProm/EePromRepatierWidget.cs +++ b/EeProm/EePromRepatierWidget.cs @@ -41,43 +41,67 @@ namespace MatterHackers.MatterControl.EeProm { public partial class EePromRepetierWidget : SystemWindow { + protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); + EePromRepatierStorage storage; BindingList data = new BindingList(); - FlowLayoutWidget descriptionColmun; - FlowLayoutWidget valueColmun; + FlowLayoutWidget settingsColmun; + + event EventHandler unregisterEvents; Button buttonCancel; Button buttonSave; - bool reinit = true; public EePromRepetierWidget() - : base(640, 480) + : base(540, 480) { - BackgroundColor = RGBA_Bytes.White; + BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; storage = new EePromRepatierStorage(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); + topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; + topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + + FlowLayoutWidget row = new FlowLayoutWidget(); + row.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + row.AddChild(AddDescription(new LocalizedString("Description").Translated)); + + GuiWidget valueText = new TextWidget(new LocalizedString("Value").Translated, textColor: ActiveTheme.Instance.PrimaryTextColor); + valueText.VAnchor = Agg.UI.VAnchor.ParentCenter; + valueText.Margin = new BorderDouble(left: 5); + row.AddChild(valueText); + topToBottom.AddChild(row); { - FlowLayoutWidget columnHolder = new FlowLayoutWidget(); - descriptionColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); - columnHolder.AddChild(descriptionColmun); + ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true); + settingsAreaScrollBox.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; + settingsAreaScrollBox.AnchorAll(); + topToBottom.AddChild(settingsAreaScrollBox); - valueColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); - columnHolder.AddChild(valueColmun); + settingsColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); + settingsColmun.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; - descriptionColmun.AddChild(new TextWidget(new LocalizedString("Description").Translated)); - valueColmun.AddChild(new TextWidget(new LocalizedString("Value").Translated)); - - topToBottom.AddChild(columnHolder); + settingsAreaScrollBox.AddChild(settingsColmun); } - buttonCancel = new Button(new LocalizedString("Cancel").Translated); - topToBottom.AddChild(buttonCancel); + 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(3); + buttonBar.AddChild(buttonSave); - buttonSave = new Button(new LocalizedString("Save To EEPROM").Translated); - topToBottom.AddChild(buttonSave); + GuiWidget spacer = new GuiWidget(1, 1); + spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + buttonBar.AddChild(spacer); + + buttonCancel = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated); + buttonCancel.Margin = new BorderDouble(3); + buttonBar.AddChild(buttonCancel); + + topToBottom.AddChild(buttonBar); //MatterControlApplication.Instance.LanguageChanged += translate; this.AddChild(topToBottom); @@ -85,6 +109,20 @@ namespace MatterHackers.MatterControl.EeProm translate(); ShowAsSystemWindow(); + + storage.Clear(); + PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(storage.Add, ref unregisterEvents); + storage.eventAdded += NewSettingReadFromPrinter; + storage.AskPrinterForSettings(); + } + + public override void OnClosed(EventArgs e) + { + if (unregisterEvents != null) + { + unregisterEvents(this, null); + } + base.OnClosed(e); } public void translate() @@ -97,34 +135,83 @@ namespace MatterHackers.MatterControl.EeProm buttonSave.Click += buttonSave_Click; } - private void newline(EePromRepatierParameter p) + private void NewSettingReadFromPrinter(object sender, EventArgs e) { - data.Add(p); + EePromRepatierParameter newSetting = e as EePromRepatierParameter; + if (newSetting != null) + { + data.Add(newSetting); + + UiThread.RunOnIdle(AddItemToUi, newSetting); + } + } + + void AddItemToUi(object state) + { + EePromRepatierParameter newSetting = state as EePromRepatierParameter; + 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); + } + + GuiWidget spacer = new GuiWidget(1, 1); + spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + row.AddChild(spacer); + + 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) { storage.Save(); storage.Clear(); - storage.eventAdded -= newline; + storage.eventAdded -= NewSettingReadFromPrinter; + Close(); } private void buttonAbort_Click(object sender, EventArgs e) { - storage.Clear(); - data.Clear(); - storage.eventAdded -= newline; + UiThread.RunOnIdle(DoButtonAbort_Click); } - private void EEPROMRepetier_Activated(object sender, EventArgs e) + private void DoButtonAbort_Click(object state) { - if (reinit) - { - reinit = false; - storage.Clear(); - storage.eventAdded += newline; - storage.AskPrinterForSettings(); - } + storage.Clear(); + data.Clear(); + storage.eventAdded -= NewSettingReadFromPrinter; + Close(); } } } diff --git a/PrinterCommunication.cs b/PrinterCommunication.cs index 918bc3ea0..4480a3874 100644 --- a/PrinterCommunication.cs +++ b/PrinterCommunication.cs @@ -114,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(); @@ -1432,7 +1433,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) { @@ -1791,7 +1792,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); diff --git a/PrinterControls/OutputScrollWindow.cs b/PrinterControls/OutputScrollWindow.cs index 330e8d876..b7692fdf3 100644 --- a/PrinterControls/OutputScrollWindow.cs +++ b/PrinterControls/OutputScrollWindow.cs @@ -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.")); From 910cb06c5a30da7738c074f98863fc023dc1d727 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 20 Feb 2014 18:35:28 -0800 Subject: [PATCH 07/24] Change print status row to display estimated total print time. --- ActionBar/PrintStatusRow.cs | 84 ++++++++++++------------------------- 1 file changed, 26 insertions(+), 58 deletions(-) diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index 939d4c15e..e01c033ef 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -200,73 +200,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 +254,7 @@ namespace MatterHackers.MatterControl.ActionBar case PrinterCommunication.CommunicationStates.Printing: { activePrintLabel.Text = PrinterCommunication.Instance.PrintingStateString; - ActivePrintStatusText = printPercentRemainingText; + ActivePrintStatusText = totalPrintTimeText; } break; @@ -295,7 +263,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 +271,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: From 53bd49189c88f608f79dbd7ed407817ae501c76d Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Thu, 20 Feb 2014 18:38:46 -0800 Subject: [PATCH 08/24] Changed print progress bar to show % complete and be sensitive to theme changes. --- CustomWidgets/PrintProgressBarWidget.cs | 50 ++++++++++--------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/CustomWidgets/PrintProgressBarWidget.cs b/CustomWidgets/PrintProgressBarWidget.cs index 73afad7ee..847a42060 100644 --- a/CustomWidgets/PrintProgressBarWidget.cs +++ b/CustomWidgets/PrintProgressBarWidget.cs @@ -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) { From b14bf4891dae1488c9b296c125cfeb786afb117e Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Fri, 21 Feb 2014 09:56:43 -0800 Subject: [PATCH 09/24] Finished up the layout of repatier eeprom. --- EeProm/EePromRepatierWidget.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/EeProm/EePromRepatierWidget.cs b/EeProm/EePromRepatierWidget.cs index f8000235b..1bbd85737 100644 --- a/EeProm/EePromRepatierWidget.cs +++ b/EeProm/EePromRepatierWidget.cs @@ -66,11 +66,17 @@ namespace MatterHackers.MatterControl.EeProm FlowLayoutWidget row = new FlowLayoutWidget(); row.HAnchor = Agg.UI.HAnchor.ParentLeftRight; row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; - row.AddChild(AddDescription(new LocalizedString("Description").Translated)); + GuiWidget descriptionWidget = AddDescription(new LocalizedString("Description").Translated); + descriptionWidget.Margin = new BorderDouble(left: 3); + row.AddChild(descriptionWidget); + + GuiWidget topSpacer = new GuiWidget(1, 1); + topSpacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + row.AddChild(topSpacer); GuiWidget valueText = new TextWidget(new LocalizedString("Value").Translated, textColor: ActiveTheme.Instance.PrimaryTextColor); valueText.VAnchor = Agg.UI.VAnchor.ParentCenter; - valueText.Margin = new BorderDouble(left: 5); + valueText.Margin = new BorderDouble(left: 5, right: 60); row.AddChild(valueText); topToBottom.AddChild(row); From cf9bc2611f0dc171c21c1b523791207d9ae26b23 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Fri, 21 Feb 2014 13:36:23 -0800 Subject: [PATCH 10/24] Renamed RegisteredCreators file. --- MatterControl.csproj | 2 +- PrintLibrary/{RegisteredCreatort.cs => RegisteredCreators.cs} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename PrintLibrary/{RegisteredCreatort.cs => RegisteredCreators.cs} (100%) diff --git a/MatterControl.csproj b/MatterControl.csproj index afe39a9c0..69958958c 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -93,7 +93,7 @@ - + diff --git a/PrintLibrary/RegisteredCreatort.cs b/PrintLibrary/RegisteredCreators.cs similarity index 100% rename from PrintLibrary/RegisteredCreatort.cs rename to PrintLibrary/RegisteredCreators.cs From e78ae5a7c5d45b0f0dc94c4f8a52aad0461fdb93 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Fri, 21 Feb 2014 18:32:41 -0800 Subject: [PATCH 11/24] Added 'leveling icon' to Action Bar. --- ActionBar/PrintStatusRow.cs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index e01c033ef..07c6251d3 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -92,19 +92,48 @@ 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", "ruler.png"); + string notifyHoverIconPath = Path.Combine("Icons", "PrintStatusControls", "ruler.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.DoPrintLevelingChanged.RegisterEvent((sender, e) => + { + notifyButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling; + + }, ref unregisterEvents); + + return notifyButton; + } + private FlowLayoutWidget getActivePrinterInfo() { FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); From 301ba01ab2f6dda8fdcd4df474f296e4b493d8e1 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Fri, 21 Feb 2014 18:34:36 -0800 Subject: [PATCH 12/24] Added 'pressed' label to Checkbox buttons. Committing leveling indicator icon. --- ControlElements/TextImageButtonFactory.cs | 14 +- PrinterControls/ManualPrinterControls.cs | 152 +++++++++--------- .../Icons/PrintStatusControls/ruler.png | Bin 0 -> 281 bytes 3 files changed, 90 insertions(+), 76 deletions(-) create mode 100644 StaticData/Icons/PrintStatusControls/ruler.png diff --git a/ControlElements/TextImageButtonFactory.cs b/ControlElements/TextImageButtonFactory.cs index f274e8320..5a38b07b1 100644 --- a/ControlElements/TextImageButtonFactory.cs +++ b/ControlElements/TextImageButtonFactory.cs @@ -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); diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index f820b6d21..8803e72ec 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -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; @@ -119,16 +119,16 @@ namespace MatterHackers.MatterControl Button homeYButton; Button homeZButton; - DisablablableWidget extruderTemperatureControlWidget; - DisablablableWidget bedTemperatureControlWidget; - DisablablableWidget movementControlsContainer; - DisablablableWidget fanControlsContainer; - DisablablableWidget eePromControlsContainer; - 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(); @@ -199,25 +199,25 @@ 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 = new DisableableWidget(); printLevelContainer.AddChild(CreatePrintLevelingControlsContainer()); controlsTopToBottomLayout.AddChild(printLevelContainer); - sdCardManagerContainer = new DisablablableWidget(); + 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); @@ -253,7 +253,7 @@ namespace MatterHackers.MatterControl fanControlsGroupBox.AddChild(fanControlsLayout); } - fanControlsContainer = new DisablablableWidget(); + fanControlsContainer = new DisableableWidget(); fanControlsContainer.AddChild(fanControlsGroupBox); if (ActivePrinterProfile.Instance.ActivePrinter == null @@ -296,7 +296,7 @@ namespace MatterHackers.MatterControl eePromControlsGroupBox.AddChild(eePromControlsLayout); } - eePromControlsContainer = new DisablablableWidget(); + eePromControlsContainer = new DisableableWidget(); eePromControlsContainer.AddChild(eePromControlsGroupBox); controlsTopToBottomLayout.AddChild(eePromControlsContainer); @@ -345,7 +345,7 @@ namespace MatterHackers.MatterControl movementControlsGroupBox.AddChild(manualControlsLayout); } - movementControlsContainer = new DisablablableWidget(); + movementControlsContainer = new DisableableWidget(); movementControlsContainer.AddChild(movementControlsGroupBox); controlsTopToBottomLayout.AddChild(movementControlsContainer); } @@ -355,11 +355,11 @@ namespace MatterHackers.MatterControl FlowLayoutWidget temperatureControlContainer = new FlowLayoutWidget(); temperatureControlContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; - 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 @@ -502,7 +502,7 @@ namespace MatterHackers.MatterControl adjustmentControlsGroupBox.AddChild(tuningRatiosLayout); } - tuningAdjustmentControlsContainer = new DisablablableWidget(); + tuningAdjustmentControlsContainer = new DisableableWidget(); tuningAdjustmentControlsContainer.AddChild(adjustmentControlsGroupBox); controlsTopToBottomLayout.AddChild(tuningAdjustmentControlsContainer); } @@ -554,13 +554,21 @@ 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", "ruler.png"), levelingImage); + ImageWidget levelingIcon = new ImageWidget(levelingImage); + + CheckBox enableLevelingCheckbox = textImageButtonFactory.GenerateCheckBoxButton("Disabled",pressedLabel:"Enabled"); + 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(levelingIcon); buttonBar.AddChild(doLevelingCheckBox); + buttonBar.AddChild(enableLevelingCheckbox); buttonBar.AddChild(runPrintLevelingButton); doLevelingCheckBox.CheckedStateChanged += (sender, e) => { @@ -688,16 +696,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); - eePromControlsContainer.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.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.Disabled); } else // we at least have a printer selected { @@ -708,30 +716,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); - eePromControlsContainer.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); - eePromControlsContainer.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: @@ -742,16 +750,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); - eePromControlsContainer.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled); - 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: @@ -760,16 +768,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); - eePromControlsContainer.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: diff --git a/StaticData/Icons/PrintStatusControls/ruler.png b/StaticData/Icons/PrintStatusControls/ruler.png new file mode 100644 index 0000000000000000000000000000000000000000..2ff3872558374963347fdb04142d4e1bc6bccfbb GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^PXNr}OT51_lPs z0*}aI1_o|n5N2eUHAjMhfq}im)7O>#9+RjjljjowE4PRH6%1bW@?cZ>KGd*PPY*mKPq|I9F1)dDA-tSCYcDax* zVZO!fClMMOoc?ave2#15;{5hc@(eQZ`ehe(Wdtdfz7P}qT-I^AV@EoJTdn=Q_Ex)w bT Date: Sat, 22 Feb 2014 14:52:53 -0800 Subject: [PATCH 13/24] Put in marlin eeprom settings panel. --- EeProm/EePromMarlinSettings.cs | 432 +++++++++++++++++++++++ EeProm/EePromMarlineWidget.cs | 413 ++++++++++++++++++++++ EeProm/EePromRepatierWidget.cs | 43 +-- MatterControl.csproj | 2 + PrinterControls/ManualPrinterControls.cs | 19 +- 5 files changed, 886 insertions(+), 23 deletions(-) create mode 100644 EeProm/EePromMarlinSettings.cs create mode 100644 EeProm/EePromMarlineWidget.cs diff --git a/EeProm/EePromMarlinSettings.cs b/EeProm/EePromMarlinSettings.cs new file mode 100644 index 000000000..e2f4dab81 --- /dev/null +++ b/EeProm/EePromMarlinSettings.cs @@ -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"); + } + } +} diff --git a/EeProm/EePromMarlineWidget.cs b/EeProm/EePromMarlineWidget.cs new file mode 100644 index 000000000..b70f1a71d --- /dev/null +++ b/EeProm/EePromMarlineWidget.cs @@ -0,0 +1,413 @@ +/* +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 leftStuffToSize = new List(); + + public EePromMarlinWidget() + : base(700, 480) + { + Title = new LocalizedString("Marlin Firmware EEPROM Settings").Translated; + + BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; + + currentEePromSettings = new EePromMarlinSettings(); + currentEePromSettings.eventAdded += SetUiToPrinterSettings; + + FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); + topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; + topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + + // 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.AddChild(new GuiWidget(10, 1)); + + CreateMainButton(ref buttonSetToFactorySettings, topButtonBar, "Set Default To Factory Settings"); + buttonSetToFactorySettings.Click += SetToFactorySettings; + + topToBottom.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); + + + // the bottom button bar + { + FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget(); + bottomButtonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; + bottomButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + + CreateMainButton(ref buttonSetActive, bottomButtonBar, "Make Settings Active"); + buttonSetActive.Click += buttonSetActive_Click; + + bottomButtonBar.AddChild(new GuiWidget(10, 1)); + + 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; + + topToBottom.AddChild(bottomButtonBar); + } + + PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); + + currentEePromSettings.eventAdded += SetUiToPrinterSettings; + + AddChild(topToBottom); + + 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); + button.Margin = new BorderDouble(3); + 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) + { + DoButtonSetActive_Click(state); + currentEePromSettings.SaveToEeProm(); + Close(); + } + + void buttonSetActive_Click(object sender, EventArgs e) + { + UiThread.RunOnIdle(DoButtonSetActive_Click); + } + + void DoButtonSetActive_Click(object state) + { + 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(); + } + } +} \ No newline at end of file diff --git a/EeProm/EePromRepatierWidget.cs b/EeProm/EePromRepatierWidget.cs index 1bbd85737..c263fed24 100644 --- a/EeProm/EePromRepatierWidget.cs +++ b/EeProm/EePromRepatierWidget.cs @@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.EeProm { protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); - EePromRepatierStorage storage; + EePromRepatierStorage currentEePromSettings; BindingList data = new BindingList(); FlowLayoutWidget settingsColmun; @@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl.EeProm { BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; - storage = new EePromRepatierStorage(); + currentEePromSettings = new EePromRepatierStorage(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; @@ -70,9 +70,7 @@ namespace MatterHackers.MatterControl.EeProm descriptionWidget.Margin = new BorderDouble(left: 3); row.AddChild(descriptionWidget); - GuiWidget topSpacer = new GuiWidget(1, 1); - topSpacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; - row.AddChild(topSpacer); + CreateSpacer(row); GuiWidget valueText = new TextWidget(new LocalizedString("Value").Translated, textColor: ActiveTheme.Instance.PrimaryTextColor); valueText.VAnchor = Agg.UI.VAnchor.ParentCenter; @@ -99,9 +97,7 @@ namespace MatterHackers.MatterControl.EeProm buttonSave.Margin = new BorderDouble(3); buttonBar.AddChild(buttonSave); - GuiWidget spacer = new GuiWidget(1, 1); - spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; - buttonBar.AddChild(spacer); + CreateSpacer(buttonBar); buttonCancel = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated); buttonCancel.Margin = new BorderDouble(3); @@ -109,17 +105,24 @@ namespace MatterHackers.MatterControl.EeProm topToBottom.AddChild(buttonBar); - //MatterControlApplication.Instance.LanguageChanged += translate; this.AddChild(topToBottom); translate(); + //MatterControlApplication.Instance.LanguageChanged += translate; ShowAsSystemWindow(); - storage.Clear(); - PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(storage.Add, ref unregisterEvents); - storage.eventAdded += NewSettingReadFromPrinter; - storage.AskPrinterForSettings(); + 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) @@ -166,9 +169,7 @@ namespace MatterHackers.MatterControl.EeProm row.BackgroundColor = new RGBA_Bytes(0, 0, 0, 50); } - GuiWidget spacer = new GuiWidget(1, 1); - spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; - row.AddChild(spacer); + CreateSpacer(row); double currentValue; double.TryParse(newSetting.Value, out currentValue); @@ -201,9 +202,9 @@ namespace MatterHackers.MatterControl.EeProm private void DoButtonSave_Click(object state) { - storage.Save(); - storage.Clear(); - storage.eventAdded -= NewSettingReadFromPrinter; + currentEePromSettings.Save(); + currentEePromSettings.Clear(); + currentEePromSettings.eventAdded -= NewSettingReadFromPrinter; Close(); } @@ -214,9 +215,9 @@ namespace MatterHackers.MatterControl.EeProm private void DoButtonAbort_Click(object state) { - storage.Clear(); + currentEePromSettings.Clear(); data.Clear(); - storage.eventAdded -= NewSettingReadFromPrinter; + currentEePromSettings.eventAdded -= NewSettingReadFromPrinter; Close(); } } diff --git a/MatterControl.csproj b/MatterControl.csproj index afe39a9c0..c11f57bae 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -74,6 +74,8 @@ + + diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index f820b6d21..e6a15e5a3 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -284,9 +284,24 @@ namespace MatterHackers.MatterControl //openEePromWindow.VAnchor = VAnchor.ParentCenter; openEePromWindow.Click += (sender, e) => { - if (PrinterCommunication.Instance.FirmwareType == PrinterCommunication.FirmwareTypes.Repetier) + switch(PrinterCommunication.Instance.FirmwareType) { - new MatterHackers.MatterControl.EeProm.EePromRepetierWidget(); + 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("There is no eeprom mapping for your printer's firmware.").Translated; + StyledMessageBox.ShowMessageBox(message, "Warning no eeprom mapping", StyledMessageBox.MessageType.OK); + } + ); + break; } }; From cbae2f0236b84c4cb8b0ff2677ad47680f23c117 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Sat, 22 Feb 2014 15:33:46 -0800 Subject: [PATCH 14/24] Making SaveSettingToActive do a close. --- EeProm/EePromMarlineWidget.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/EeProm/EePromMarlineWidget.cs b/EeProm/EePromMarlineWidget.cs index b70f1a71d..5184b26cf 100644 --- a/EeProm/EePromMarlineWidget.cs +++ b/EeProm/EePromMarlineWidget.cs @@ -369,7 +369,7 @@ namespace MatterHackers.MatterControl.EeProm private void DoButtonSave_Click(object state) { - DoButtonSetActive_Click(state); + SaveSettingsToActive(); currentEePromSettings.SaveToEeProm(); Close(); } @@ -380,6 +380,12 @@ namespace MatterHackers.MatterControl.EeProm } void DoButtonSetActive_Click(object state) + { + SaveSettingsToActive(); + Close(); + } + + void SaveSettingsToActive() { currentEePromSettings.SX = stepsPerMmX.Text; currentEePromSettings.SY = stepsPerMmY.Text; From 9d1ea3f8cff11904398ecc219030523c7ddea353 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Sun, 23 Feb 2014 21:48:17 -0800 Subject: [PATCH 15/24] Refactoring and UI Changes - eeprom --- ...MarlineWidget.cs => EePromMarlinWidget.cs} | 23 +++++++++++-------- ...arameter.cs => EePromRepetierParameter.cs} | 4 ++-- ...ierStorage.cs => EePromRepetierStorage.cs} | 14 +++++------ ...atierWidget.cs => EePromRepetierWidget.cs} | 15 +++++++----- MatterControl.csproj | 15 +++++------- 5 files changed, 38 insertions(+), 33 deletions(-) rename EeProm/{EePromMarlineWidget.cs => EePromMarlinWidget.cs} (95%) rename EeProm/{EePromRepatierParameter.cs => EePromRepetierParameter.cs} (96%) rename EeProm/{EePromRepatierStorage.cs => EePromRepetierStorage.cs} (87%) rename EeProm/{EePromRepatierWidget.cs => EePromRepetierWidget.cs} (93%) diff --git a/EeProm/EePromMarlineWidget.cs b/EeProm/EePromMarlinWidget.cs similarity index 95% rename from EeProm/EePromMarlineWidget.cs rename to EeProm/EePromMarlinWidget.cs index 5184b26cf..47dc71bad 100644 --- a/EeProm/EePromMarlineWidget.cs +++ b/EeProm/EePromMarlinWidget.cs @@ -93,14 +93,20 @@ namespace MatterHackers.MatterControl.EeProm { Title = new LocalizedString("Marlin Firmware EEPROM Settings").Translated; - BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; - 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 { @@ -111,12 +117,12 @@ namespace MatterHackers.MatterControl.EeProm CreateMainButton(ref buttonReLoadSettings, topButtonBar, "Re-Load Default Settings"); buttonReLoadSettings.Click += buttonReLoadSettings_Click; - topButtonBar.AddChild(new GuiWidget(10, 1)); + topButtonBar.Margin = new BorderDouble (0, 3); CreateMainButton(ref buttonSetToFactorySettings, topButtonBar, "Set Default To Factory Settings"); buttonSetToFactorySettings.Click += SetToFactorySettings; - topToBottom.AddChild(topButtonBar); + mainContainer.AddChild(topButtonBar); } topToBottom.AddChild(Create4FieldSet("Steps per mm:", @@ -160,18 +166,18 @@ namespace MatterHackers.MatterControl.EeProm 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; - bottomButtonBar.AddChild(new GuiWidget(10, 1)); - CreateMainButton(ref buttonSave, bottomButtonBar, "Make Settings Active\nAnd Save To Default"); buttonSave.Click += buttonSave_Click; @@ -180,14 +186,14 @@ namespace MatterHackers.MatterControl.EeProm CreateMainButton(ref buttonAbort, bottomButtonBar, "Cancel"); buttonAbort.Click += buttonAbort_Click; - topToBottom.AddChild(bottomButtonBar); + mainContainer.AddChild(bottomButtonBar); } PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); currentEePromSettings.eventAdded += SetUiToPrinterSettings; - AddChild(topToBottom); + AddChild(mainContainer); ShowAsSystemWindow(); @@ -296,7 +302,6 @@ namespace MatterHackers.MatterControl.EeProm private void CreateMainButton(ref Button button, FlowLayoutWidget buttonBar, string text) { button = textImageButtonFactory.Generate(new LocalizedString(text).Translated); - button.Margin = new BorderDouble(3); buttonBar.AddChild(button); } diff --git a/EeProm/EePromRepatierParameter.cs b/EeProm/EePromRepetierParameter.cs similarity index 96% rename from EeProm/EePromRepatierParameter.cs rename to EeProm/EePromRepetierParameter.cs index b68b63102..9bd656fc2 100644 --- a/EeProm/EePromRepatierParameter.cs +++ b/EeProm/EePromRepetierParameter.cs @@ -34,7 +34,7 @@ using System.Text; namespace MatterHackers.MatterControl.EeProm { - public class EePromRepatierParameter : EventArgs + public class EePromRepetierParameter : EventArgs { public string description; public int type; @@ -42,7 +42,7 @@ namespace MatterHackers.MatterControl.EeProm string val = ""; bool changed = false; - public EePromRepatierParameter(string line) + public EePromRepetierParameter(string line) { update(line); } diff --git a/EeProm/EePromRepatierStorage.cs b/EeProm/EePromRepetierStorage.cs similarity index 87% rename from EeProm/EePromRepatierStorage.cs rename to EeProm/EePromRepetierStorage.cs index 8bd1a4bcb..d1963d4d8 100644 --- a/EeProm/EePromRepatierStorage.cs +++ b/EeProm/EePromRepetierStorage.cs @@ -36,16 +36,16 @@ using MatterHackers.Agg.UI; namespace MatterHackers.MatterControl.EeProm { - public delegate void OnEePromRepatierAdded(EePromRepatierParameter param); + public delegate void OnEePromRepetierAdded(EePromRepetierParameter param); - public class EePromRepatierStorage + public class EePromRepetierStorage { - public Dictionary eePromSettingsList; + public Dictionary eePromSettingsList; public event EventHandler eventAdded = null; - public EePromRepatierStorage() + public EePromRepetierStorage() { - eePromSettingsList = new Dictionary(); + eePromSettingsList = new Dictionary(); } public void Clear() @@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.EeProm public void Save() { - foreach (EePromRepatierParameter p in eePromSettingsList.Values) + foreach (EePromRepetierParameter p in eePromSettingsList.Values) { p.save(); } @@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.EeProm return; } - EePromRepatierParameter parameter = new EePromRepatierParameter(line); + EePromRepetierParameter parameter = new EePromRepetierParameter(line); if (eePromSettingsList.ContainsKey(parameter.position)) { eePromSettingsList.Remove(parameter.position); diff --git a/EeProm/EePromRepatierWidget.cs b/EeProm/EePromRepetierWidget.cs similarity index 93% rename from EeProm/EePromRepatierWidget.cs rename to EeProm/EePromRepetierWidget.cs index c263fed24..6ea20c92d 100644 --- a/EeProm/EePromRepatierWidget.cs +++ b/EeProm/EePromRepetierWidget.cs @@ -43,8 +43,8 @@ namespace MatterHackers.MatterControl.EeProm { protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); - EePromRepatierStorage currentEePromSettings; - BindingList data = new BindingList(); + EePromRepetierStorage currentEePromSettings; + BindingList data = new BindingList(); FlowLayoutWidget settingsColmun; event EventHandler unregisterEvents; @@ -57,11 +57,13 @@ namespace MatterHackers.MatterControl.EeProm { BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; - currentEePromSettings = new EePromRepatierStorage(); + 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; @@ -82,6 +84,7 @@ namespace MatterHackers.MatterControl.EeProm 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); @@ -94,7 +97,7 @@ namespace MatterHackers.MatterControl.EeProm 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(3); + buttonSave.Margin = new BorderDouble(0,3); buttonBar.AddChild(buttonSave); CreateSpacer(buttonBar); @@ -146,7 +149,7 @@ namespace MatterHackers.MatterControl.EeProm private void NewSettingReadFromPrinter(object sender, EventArgs e) { - EePromRepatierParameter newSetting = e as EePromRepatierParameter; + EePromRepetierParameter newSetting = e as EePromRepetierParameter; if (newSetting != null) { data.Add(newSetting); @@ -157,7 +160,7 @@ namespace MatterHackers.MatterControl.EeProm void AddItemToUi(object state) { - EePromRepatierParameter newSetting = state as EePromRepatierParameter; + EePromRepetierParameter newSetting = state as EePromRepetierParameter; if (newSetting != null) { FlowLayoutWidget row = new FlowLayoutWidget(); diff --git a/MatterControl.csproj b/MatterControl.csproj index 0b9cc825b..ad0289bea 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -38,6 +38,7 @@ 1.0.0.%2a false true + 0.8.2 True @@ -74,11 +75,7 @@ - - - - @@ -189,6 +186,10 @@ + + + + @@ -281,10 +282,6 @@ {D3ABF72C-64C2-4E51-A119-E077210FA990} SerialPortCommunication - - {A526DC5D-65F3-461B-805F-D3AC9665F5C9} - WindowsFileDialogs - {F1653F20-D47D-4F29-8C55-3C835542AF5F} Community.CsharpSqlite @@ -325,7 +322,7 @@ {865172A0-A1A9-49C2-9386-F2FDB4E141B7} MatterControlPluginSystem - + {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B} Agg From 728af4bc07e004b0d678c5bd4f5a25edf9edc374 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Sun, 23 Feb 2014 21:48:49 -0800 Subject: [PATCH 16/24] UI Fixes for connection setup widgets. --- PrinterControls/PrinterConnections/ChooseConnectionWidget.cs | 2 +- PrinterControls/PrinterConnections/SetupConnectionWidgetBase.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PrinterControls/PrinterConnections/ChooseConnectionWidget.cs b/PrinterControls/PrinterConnections/ChooseConnectionWidget.cs index cdb906f16..3b8c60ce7 100644 --- a/PrinterControls/PrinterConnections/ChooseConnectionWidget.cs +++ b/PrinterControls/PrinterConnections/ChooseConnectionWidget.cs @@ -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 diff --git a/PrinterControls/PrinterConnections/SetupConnectionWidgetBase.cs b/PrinterControls/PrinterConnections/SetupConnectionWidgetBase.cs index f4e0185ff..b2b0b8ceb 100644 --- a/PrinterControls/PrinterConnections/SetupConnectionWidgetBase.cs +++ b/PrinterControls/PrinterConnections/SetupConnectionWidgetBase.cs @@ -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 From 4ec57b97ca8017a241aa37d547c3ad7bd3c566df Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Sun, 23 Feb 2014 21:50:09 -0800 Subject: [PATCH 17/24] UI - Manual controls more compact. More clarify for automatic print leveling UI --- ActionBar/PrintStatusRow.cs | 4 +- PrinterControls/ManualPrinterControls.cs | 147 +++++++++++++----- .../{ruler.png => leveling-16x16.png} | Bin .../PrintStatusControls/leveling-24x24.png | Bin 0 -> 3262 bytes .../PrintStatusControls/terminal-24x24.png | Bin 0 -> 3152 bytes 5 files changed, 110 insertions(+), 41 deletions(-) rename StaticData/Icons/PrintStatusControls/{ruler.png => leveling-16x16.png} (100%) create mode 100644 StaticData/Icons/PrintStatusControls/leveling-24x24.png create mode 100644 StaticData/Icons/PrintStatusControls/terminal-24x24.png diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index 07c6251d3..43d7a4460 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -116,8 +116,8 @@ namespace MatterHackers.MatterControl.ActionBar private Button GetAutoLevelIndicator() { ImageButtonFactory imageButtonFactory = new ImageButtonFactory(); - string notifyIconPath = Path.Combine("Icons", "PrintStatusControls", "ruler.png"); - string notifyHoverIconPath = Path.Combine("Icons", "PrintStatusControls", "ruler.png"); + 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); diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index fc9cf33d4..243dbc127 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -118,6 +118,8 @@ namespace MatterHackers.MatterControl Button homeXButton; Button homeYButton; Button homeZButton; + Button enablePrintLevelingButton; + Button disablePrintLevelingButton; DisableableWidget extruderTemperatureControlWidget; DisableableWidget bedTemperatureControlWidget; @@ -201,14 +203,28 @@ namespace MatterHackers.MatterControl terminalCommunicationsContainer = new DisableableWidget(); terminalCommunicationsContainer.AddChild(CreateTerminalControlsContainer()); - controlsTopToBottomLayout.AddChild(terminalCommunicationsContainer); + AddTemperatureControls(controlsTopToBottomLayout); - AddMovementControls(controlsTopToBottomLayout); - printLevelContainer = new DisableableWidget(); - printLevelContainer.AddChild(CreatePrintLevelingControlsContainer()); - controlsTopToBottomLayout.AddChild(printLevelContainer); + FlowLayoutWidget centerControlsContainer = new FlowLayoutWidget (); + centerControlsContainer.HAnchor = HAnchor.ParentLeftRight; + + 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()); @@ -221,17 +237,18 @@ namespace MatterHackers.MatterControl macroControls.AddChild(new MacroControls()); controlsTopToBottomLayout.AddChild(macroControls); - PutInFanControls(controlsTopToBottomLayout); - PutInEePromControls(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); @@ -263,28 +280,33 @@ namespace MatterHackers.MatterControl } } - private void PutInEePromControls(FlowLayoutWidget controlsTopToBottomLayout) + private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout) { GroupBox eePromControlsGroupBox = new GroupBox(new LocalizedString("EEProm Settings").Translated); - eePromControlsGroupBox.Margin = new BorderDouble(0); + 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(FlowDirection.TopToBottom); - eePromControlsLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight; - eePromControlsLayout.VAnchor = Agg.UI.VAnchor.FitToChildren; - eePromControlsLayout.Padding = new BorderDouble(3, 5, 3, 0); + 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); { - Button openEePromWindow = textImageButtonFactory.Generate(new LocalizedString("CONFIGURE").Translated); - openEePromWindow.Margin = new BorderDouble(left: 6); - //openEePromWindow.VAnchor = VAnchor.ParentCenter; + 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) + switch(PrinterCommunication.Instance.FirmwareType) { case PrinterCommunication.FirmwareTypes.Repetier: new MatterHackers.MatterControl.EeProm.EePromRepetierWidget(); @@ -297,14 +319,14 @@ namespace MatterHackers.MatterControl default: UiThread.RunOnIdle((state) => { - string message = new LocalizedString("There is no eeprom mapping for your printer's firmware.").Translated; + 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); } @@ -347,13 +369,9 @@ 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()); } @@ -369,6 +387,7 @@ namespace MatterHackers.MatterControl { FlowLayoutWidget temperatureControlContainer = new FlowLayoutWidget(); temperatureControlContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; + temperatureControlContainer.Margin = new BorderDouble (top: 10); extruderTemperatureControlWidget = new DisableableWidget(); extruderTemperatureControlWidget.AddChild(new ExtruderTemperatureControlWidget()); @@ -544,6 +563,8 @@ namespace MatterHackers.MatterControl feedRateValue.Value = ((int)(PrinterCommunication.Instance.FeedRateRatio * 100 + .5)) / 100.0; } + TextWidget printLevelingStatusLabel; + private GuiWidget CreatePrintLevelingControlsContainer() { GroupBox printLevelingControlsContainer; @@ -570,10 +591,19 @@ namespace MatterHackers.MatterControl runPrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(runPrintLeveling_Click); Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer(); - ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "ruler.png"), levelingImage); + ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage); ImageWidget levelingIcon = new ImageWidget(levelingImage); + levelingIcon.Margin = new BorderDouble (right: 6); - CheckBox enableLevelingCheckbox = textImageButtonFactory.GenerateCheckBoxButton("Disabled",pressedLabel:"Enabled"); + 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); @@ -581,9 +611,20 @@ namespace MatterHackers.MatterControl doLevelingCheckBox.VAnchor = VAnchor.ParentCenter; doLevelingCheckBox.Checked = ActivePrinterProfile.Instance.DoPrintLeveling; + 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(enableLevelingCheckbox); + //buttonBar.AddChild(doLevelingCheckBox); + buttonBar.AddChild (printLevelingStatusLabel); + buttonBar.AddChild (hSpacer); + buttonBar.AddChild(enablePrintLevelingButton); + buttonBar.AddChild(disablePrintLevelingButton); buttonBar.AddChild(runPrintLevelingButton); doLevelingCheckBox.CheckedStateChanged += (sender, e) => { @@ -591,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; } @@ -627,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; @@ -637,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); @@ -715,9 +759,9 @@ namespace MatterHackers.MatterControl bedTemperatureControlWidget.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); - eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); + eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); - terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); + terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); printLevelContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); sdCardManagerContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); macroControls.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); @@ -934,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(); diff --git a/StaticData/Icons/PrintStatusControls/ruler.png b/StaticData/Icons/PrintStatusControls/leveling-16x16.png similarity index 100% rename from StaticData/Icons/PrintStatusControls/ruler.png rename to StaticData/Icons/PrintStatusControls/leveling-16x16.png diff --git a/StaticData/Icons/PrintStatusControls/leveling-24x24.png b/StaticData/Icons/PrintStatusControls/leveling-24x24.png new file mode 100644 index 0000000000000000000000000000000000000000..9c4ee060bb2d3fd7f7fe62de9a3dc929a05e7e6e GIT binary patch literal 3262 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 E08y$q>;M1& literal 0 HcmV?d00001 diff --git a/StaticData/Icons/PrintStatusControls/terminal-24x24.png b/StaticData/Icons/PrintStatusControls/terminal-24x24.png new file mode 100644 index 0000000000000000000000000000000000000000..af811b51feaa7bda3682fcace752faa050f17595 GIT binary patch literal 3152 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4mJh`h6m-gKNuLeoHL!B13aCb6$*;-(=u~X z85k;V%?&P(nEYML?*8{w{xGK-A2v?UX=G4RUc+%hAaaqwB!8@~7*6PgoDg9+A;GXAcykID!xRRFoXQ#}C5BbJ z3~#=8+Oaa+SULHQIKz!aGAlV4dKnpJYPhQ~IqYUg2yG0~VLEV#VZj;)B|Vk{>lhm% zw;8!JHSA?&DC>)u!0(X2&@j_U=L~~_1rvj_obXv@1s~=G2AB3fSQ%f?y2FE!;lSys zXQz8#G8Wk}^@3FSrw9duEJ)SfBoa13&kotM?;6Drd z3D2KBdH5{tdCvPUM;HCe{*bR^r}**yzdb!nEDQpE=ilFofBN(qbHQ=O4W;|DS4K13 z3S-E)|1;M3Hs^vUt_xK^yDKgJILOUg7;wTyR)&k4`>kry!o3EMyY2oPKg@s7UH9#e zgWSK{RUa4%XF1GVdth<%-@?SavUNdy&rh>B8RmU|uKe$KYyICo&5MsrHpb|Pc72TK z+!3JUd%SXI&_ox-lT#lFy{tF-C_n8l=j3u;hBa;e2mH3NZ#|uJpza+bQ#W74r7{MG zy3e{jQrr_61kz26D!(%@Oy2*q-$9#^;q3G!j~N*DypV`lF-6?x7zYD`%YsI&4UX(Q z2SwH#;G1($cFzHErbIRu2OgCJHUds;Pa0&n7D`NWlngmwb%SN=24<-Rg0mh9Y&mFX z!TbDyP)y_N0&%tkiFt=4_Ox-bIG*4TPE@q&5KQX3p>&Qzd}beuQlf{+q=qF5FFQm6 zm5!b$TEeu_DQjY^hw>-gA`#2p7>8dIZl6#v>iW~Q$K7yB&hJ6Fg{bsbw! ze6hrYKel1oqU?)OTjXpTwk=wI(fdVd2}5mHUvk4mL%y`0n~5cmx)Rrn3wpTLxrikLHG?vT#LY=oTdpA+#`GU_fSlRZ@UPELB_$EBz`!N`-_Guz{~ zhwhT#C3cqtGUxcHy`GSJ^4=4UO$}=lrcc~Hfq#Pkq~9kGKiMu~b+qG=59cD4pe0j; zyi8N=pRz2SZ{##{!K%QsE9YI|Sk+-QKgu(AL0N!)aQjMOlhRqLXJ?B!pI)N7`09mO zndzC|GxT4U?BcxJEay7?!t_hoFW6r`f7$${oQJoKxB0k7l7?iqWVPgSiS3g5Gkun^ zUYC9ujITUw)*Ny+0fl9&DNa@Di7)pI3F0lcwhYAreDdto7!647PNUR4oTjA zOtM!|?3hvN#|WouMPbaZb+TvpCPi=h`NpS=^|y4Hezi}qbMdOQHE9#m<~}Pt%gA?Z zDH|KbrQ#{9eu3DE_*IswywXC&iYwOmU->SN`?^e>=qPJpiU*CFPS}@mPuFl-A zR=HN+OF4I$?F!u0y6bl7`B!$AlV4Z9=~ImE`DfvxI*xB#;%D+G8SL-T&%uB?Ol8NW77(8yRt==jWs9V^jTh=lRYnS-_1R@ z|Ma#lb)9q6tJ|#m__SNoYEH9G^PTp6&5SU+u*$HnVb|AqUW<9H^E&rhcus(H_-vlp zR>C@0Q`4KX16+%zDH2*7958H`Q;s-_FaPkr9%; zW?f=kQ&duVrYxsm&+8=*O%AU-vhwiD@O0_)g~f9}n~E>fNqOTQ7fIJbU--J8N&|Ub%b5_GsaTMzneC3*G0m@<-@b3z zKBfD%`;_ah)y=G9|1-^`+w|zSoulpqaSMm<3Yx!jC&iU8aFd%Gt0BgWLe5? z%G%4in@yj`PSlBqlQ&YnXmb7m@lVn}la24B>&&_+dWvJNXq5CXgEMMAa@Pd=+Rk&_ z7pTi$_S5I(nQa^$58QJ)cF1Q+&J_PyE261ov`X();FjQ$!jkVg*Va6V{GGnH?_>YU zo}JdWv$hqLrLW1#3Cc-+GkZtFj#WDvE82g!ew;2;BCNvsw)4r68%JzA9~Uz{&zWUB z=gF*)X(h?)p59rsQ~cS>bEoH(+eDg1PN=bHogp-Rll{|X1*ZUg3IC_d^L%B6Kefzm z^>^L3sCQA|#_c=2Y$iRM8#eWu#a-)K=U*9Z{%)nmj5+;-v@0h{PTHyb**DDP+PyXB zZx-IvwVX0%%ACbPyqVLsXkRzjuCd)eOKjx1aj{MEPg&=i8z=tv(kQ zZwXo#z$fOTze2krS|Yk)hsR!zs4K?z)Be5ssm$FZRU zx9&^S&ScTVsVSlFv!-8-4y)G^pBlfWV9knkKQ_4Sc=jmVFaB!H*UH>mx9)juKlS#t z$Ll4p^VWQi+`ryyZvgYWVO7@GzO!4-o;u5HnrQkq`pmX9 zw?8d3Tl}qRZhh?Ou)k|pZ{K%Q?bfyZcgw3k^EJzgTHkv=<;|Y0+7;p1dtGb4=3RQ% zbhlqBNqX1*XLWaXxR?7Mo!4Kzw3_{!>-*PPCHXmb*6-iHi8D9ItXIy%s^IDDhWuNz z-_9!ES`ekhcgXSSLG}B~YN{UxyjXbd@SVeF@6W8?{*~jkN2T^9tNo>GbQk9?uwA(K z{fnN(b7kXX-S=((U-#bdadPQ#)Bf;z3+8Ire*F2QY4YRcDa+^0^|QCVGV@O5cb`8q zvtt8e_oh3apJy*#^3G>_{P&Ze?>+C2{jjIti_-U`+p62W*V?YLb+0S<`_N;3bpGqq z@2B5}+pH`3;``eA;`__>zp@ToEx!Kax?b%3%DwN8y^-FYr*>Cnhw84cKgzzn6))#{ z=W{2vs=s3WpMAIfzGDBy|Ehk=zm2H}av%IiIFNAua3ueGKF;=e|EB!E-2U*A`x*DE z%5KWN{d48zrFo_Heo8qv`Qh?S%Z1OMstfyH`MP-Z^ZS1v{q{Z|@#n?|?w{S~_phs5 z`MK!*>XqxQjw>IR-*c|g_T#cYYtP-TeZS-VuKUOL%FopJ1$&oIW?*38EbxddW??rVNo{9}uuj9j?OggO&3L8QcFL2Z~ z$TP^)FbZ`ZTy&v^gKw(W(@VWOZeD3)D&m~zb2aSi+jG9>zq~!e_}}b!#&5m@sth;P z7?=ty=5g`N4oeJ{NW-)mj_@XOZTs6}e#=BlP6zQQ9~4NzC^BwamADS1EY~#jWmq+uM<$l^!-%jzNiYYWA}>R~D783_V_puWnw^ z*>O;dZQ>Hcll$J5iKVhm*}|T{lCa?ck5&aw!rnZSWnsq5d7;8nRl1k?Ov*H?KlpVA s-=ynTLrYkv9}|6e_P>4Yx>_dB3v2$Y`p(_Sz`(%Z>FVdQ&MBb@0DvU=wg3PC literal 0 HcmV?d00001 From d23065a2f87bddced85f8b21a2e55e1441ea5593 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Mon, 24 Feb 2014 10:52:24 -0800 Subject: [PATCH 18/24] Changing printer profiles now triggers refresh of the auto-level indicator. --- ActionBar/PrintStatusRow.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index 43d7a4460..f51d37ef1 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -125,6 +125,12 @@ namespace MatterHackers.MatterControl.ActionBar 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; From 3dcc5cf74b0480c0b776c5f1943734d65232e470 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Mon, 24 Feb 2014 10:53:08 -0800 Subject: [PATCH 19/24] Edit macros window now closes on the UI thread. --- PrinterControls/EditMacrosWindow.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PrinterControls/EditMacrosWindow.cs b/PrinterControls/EditMacrosWindow.cs index 5fc89c939..2470b7af1 100644 --- a/PrinterControls/EditMacrosWindow.cs +++ b/PrinterControls/EditMacrosWindow.cs @@ -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; From f8ab5158e79dc0d6444e0a63dd3d8e9b42bed3bf Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Mon, 24 Feb 2014 10:53:36 -0800 Subject: [PATCH 20/24] Edit manual movement speeds window now closes on the UI thread. --- PrinterControls/EditManualMovementSpeedsWindow.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PrinterControls/EditManualMovementSpeedsWindow.cs b/PrinterControls/EditManualMovementSpeedsWindow.cs index 6beadeae6..43b764fae 100644 --- a/PrinterControls/EditManualMovementSpeedsWindow.cs +++ b/PrinterControls/EditManualMovementSpeedsWindow.cs @@ -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; From bd099dff57e4d37ae632bb8ebc8be130a61ff84f Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Mon, 24 Feb 2014 10:54:20 -0800 Subject: [PATCH 21/24] Further compression of manual controls (jog controls specifically). --- PrinterControls/XYZJogControls.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PrinterControls/XYZJogControls.cs b/PrinterControls/XYZJogControls.cs index 7aeba47a9..386790244 100644 --- a/PrinterControls/XYZJogControls.cs +++ b/PrinterControls/XYZJogControls.cs @@ -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; From 1aac6990377578749cb98aa8d17a79ffa0c7ba5e Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Mon, 24 Feb 2014 10:59:25 -0800 Subject: [PATCH 22/24] Made the selected gcode layer match the first layer with rendering made the window be focused when it is in gcode mode. --- PartPreviewWindow/GcodeViewBasic.cs | 5 ++++- PartPreviewWindow/PartPreviewMainWindow.cs | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs index 428295b88..895aae343 100644 --- a/PartPreviewWindow/GcodeViewBasic.cs +++ b/PartPreviewWindow/GcodeViewBasic.cs @@ -510,13 +510,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow navigationWidget.Margin = new BorderDouble(0, 0, 20, 0); layerSelectionButtonsPannel.AddChild(navigationWidget); - selectLayerSlider = new Slider(new Vector2(), 10, 0, gcodeViewWidget.LoadedGCode.NumChangesInZ - 1, Orientation.Vertical); selectLayerSlider.ValueChanged += new EventHandler(selectLayerSlider_ValueChanged); gcodeViewWidget.ActiveLayerChanged += new EventHandler(gcodeViewWidget_ActiveLayerChanged); AddChild(selectLayerSlider); SetSliderSize(); + // let's change the active layer so that it is set to the first layer with data + gcodeViewWidget.ActiveLayerIndex = gcodeViewWidget.ActiveLayerIndex + 1; + gcodeViewWidget.ActiveLayerIndex = gcodeViewWidget.ActiveLayerIndex - 1; + BoundsChanged += new EventHandler(PartPreviewGCode_BoundsChanged); } } diff --git a/PartPreviewWindow/PartPreviewMainWindow.cs b/PartPreviewWindow/PartPreviewMainWindow.cs index 36c6dcee1..f77e65ca6 100644 --- a/PartPreviewWindow/PartPreviewMainWindow.cs +++ b/PartPreviewWindow/PartPreviewMainWindow.cs @@ -79,11 +79,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow tabControl.AddTab(new SimpleTextTabWidget(layerView, 16, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes())); - if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") - { - tabControl.TabBar.SwitchToPage(layerView); - } - this.AddChild(tabControl); this.AnchorAll(); @@ -94,6 +89,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ShowAsSystemWindow(); MinimumSize = new Vector2(400, 300); + + // We do this after showing the system window so that when we try and take fucus the parent window (the system window) + // exists and can give the fucus to its child the gecode window. + if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") + { + tabControl.TabBar.SwitchToPage(layerView); + partGcodeView.Focus(); + } } PerformanceFeedbackWindow timingWindow = null; From 907e73094a2dff49f9b241f764ce85e2c7fd30e3 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Mon, 24 Feb 2014 12:30:59 -0800 Subject: [PATCH 23/24] Made the mac able to find the static data folder from the solution file. --- DataStorage/Datastore.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/DataStorage/Datastore.cs b/DataStorage/Datastore.cs index df80b9406..499b965ee 100644 --- a/DataStorage/Datastore.cs +++ b/DataStorage/Datastore.cs @@ -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(); - } + } } } From 1ac21b2179ed32e731338c5a96aa7c0fabb21bfb Mon Sep 17 00:00:00 2001 From: gregory-diaz Date: Mon, 24 Feb 2014 16:43:35 -0800 Subject: [PATCH 24/24] More Localization --- ActionBar/HelpTextWidget.cs | 6 +++-- CustomWidgets/ExportQueueItemWindow.cs | 5 +++- MatterControl.userprefs | 31 +++++++++++++++++-------- PrintLibrary/ExportLibraryItemWindow.cs | 5 +++- PrinterCommunication.cs | 5 ++-- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/ActionBar/HelpTextWidget.cs b/ActionBar/HelpTextWidget.cs index e66fe7429..01ee812a7 100644 --- a/ActionBar/HelpTextWidget.cs +++ b/ActionBar/HelpTextWidget.cs @@ -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; diff --git a/CustomWidgets/ExportQueueItemWindow.cs b/CustomWidgets/ExportQueueItemWindow.cs index a2dcd91de..5da005c20 100644 --- a/CustomWidgets/ExportQueueItemWindow.cs +++ b/CustomWidgets/ExportQueueItemWindow.cs @@ -80,7 +80,10 @@ namespace MatterHackers.MatterControl if(showExportGCodeButton) { - Button exportGCode = textImageButtonFactory.Generate(new LocalizedString("Export as GCode").Translated); + string exportGCodeText = new LocalizedString("Export as").Translated; + string exportGCodeTextFull = string.Format("{0} GCode", exportGCodeText); + + Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull); //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter; exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click); topToBottom.AddChild(exportGCode); diff --git a/MatterControl.userprefs b/MatterControl.userprefs index 4e970df75..78a05af8a 100644 --- a/MatterControl.userprefs +++ b/MatterControl.userprefs @@ -1,19 +1,30 @@  - + - - - - - - - - + + + + + + + + + + + - + + + + + + + + + \ No newline at end of file diff --git a/PrintLibrary/ExportLibraryItemWindow.cs b/PrintLibrary/ExportLibraryItemWindow.cs index 5e0e0507e..c716ccd96 100644 --- a/PrintLibrary/ExportLibraryItemWindow.cs +++ b/PrintLibrary/ExportLibraryItemWindow.cs @@ -80,7 +80,10 @@ namespace MatterHackers.MatterControl.PrintLibrary if (showExportGCodeButton) { - Button exportGCode = textImageButtonFactory.Generate(new LocalizedString("Export as GCode").Translated); + string exportGCodeText = new LocalizedString("Export as").Translated; + string exportGCodeTextFull = string.Format ("{0} GCode", exportGCodeText); + + Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull); //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter; exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click); topToBottom.AddChild(exportGCode); diff --git a/PrinterCommunication.cs b/PrinterCommunication.cs index 4480a3874..89cc0aff4 100644 --- a/PrinterCommunication.cs +++ b/PrinterCommunication.cs @@ -486,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: