diff --git a/ActionBar/HelpTextWidget.cs b/ActionBar/HelpTextWidget.cs index 5c6bed18a..e66fe7429 100644 --- a/ActionBar/HelpTextWidget.cs +++ b/ActionBar/HelpTextWidget.cs @@ -129,20 +129,20 @@ namespace MatterHackers.MatterControl switch (PrinterCommunication.Instance.CommunicationState) { case PrinterCommunication.CommunicationStates.Disconnected: - return new LocalizedString("Not connected. Press 'Connect' to enable printing.").Translated; + return new LocalizedString("Not connected. Press 'Connect' to enable printing.").Translated; case PrinterCommunication.CommunicationStates.AttemptingToConnect: - return new LocalizedString("Attempting to connect...").Translated; + return new LocalizedString("Attempting to connect...").Translated; case PrinterCommunication.CommunicationStates.ConnectionLost: case PrinterCommunication.CommunicationStates.FailedToConnect: - return new LocalizedString("Unable to communicate with printer.").Translated; + return new LocalizedString("Unable to communicate with printer.").Translated; case PrinterCommunication.CommunicationStates.Connected: if (PrinterCommunication.Instance.ActivePrintItem != null) { - return new LocalizedString("Item selected. Press 'Start' to begin your print.").Translated; + return new LocalizedString("Item selected. Press 'Start' to begin your print.").Translated; } else { - return new LocalizedString("No items to select. Press 'Add' to select a file to print.").Translated; + return new LocalizedString("No items to select. Press 'Add' to select a file to print.").Translated; } default: return ""; diff --git a/CustomWidgets/ExportQueueItemWindow.cs b/CustomWidgets/ExportQueueItemWindow.cs index 9464fa900..a2dcd91de 100644 --- a/CustomWidgets/ExportQueueItemWindow.cs +++ b/CustomWidgets/ExportQueueItemWindow.cs @@ -70,10 +70,10 @@ namespace MatterHackers.MatterControl string exportStlTxt = new LocalizedString("Export as").Translated; string exportStlTxtFull = string.Format("{0} STL", exportStlTxt); - Button exportSTL = textImageButtonFactory.Generate(exportStlTxtFull); - exportSTL.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click); + Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTxtFull); + exportAsStlButton.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click); //exportSTL.HAnchor = Agg.UI.HAnchor.ParentCenter; - topToBottom.AddChild(exportSTL); + topToBottom.AddChild(exportAsStlButton); } bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode; @@ -115,11 +115,12 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(DoExportGCode_Click); } - string GetExtension (string filename) + string GetExtension (string filename) { string extension; int indexOfDot = filename.LastIndexOf("."); - if (indexOfDot == -1) { + if (indexOfDot == -1) + { extension = ""; } else @@ -141,21 +142,17 @@ namespace MatterHackers.MatterControl if (streamToSaveTo != null) { streamToSaveTo.Close (); - string filePathToSave = saveParams.FileName; string extension = GetExtension(filePathToSave); - if(extension == "") { + File.Delete (filePathToSave); filePathToSave += ".gcode"; } - - if (System.IO.Path.GetExtension(printQueueItem.PrintItemWrapper.FileLocation).ToUpper() == ".STL") { - pathAndFilenameToSave = saveParams.FileName; Close(); SlicingQueue.Instance.QueuePartForSlicing(printQueueItem.PrintItemWrapper); printQueueItem.PrintItemWrapper.Done += new EventHandler(sliceItem_Done); @@ -163,7 +160,7 @@ namespace MatterHackers.MatterControl else if (partIsGCode) { Close(); - SaveGCodeToNewLocation(printQueueItem.PrintItemWrapper.FileLocation, saveParams.FileName); + SaveGCodeToNewLocation(printQueueItem.PrintItemWrapper.FileLocation, filePathToSave); } } } @@ -249,13 +246,11 @@ namespace MatterHackers.MatterControl string filePathToSave = saveParams.FileName; string extension = CheckExtension(filePathToSave); - if (extension == "") - { - + { + File.Delete (filePathToSave); filePathToSave += ".stl"; } - File.Copy (printQueueItem.PrintItemWrapper.FileLocation, filePathToSave, true); ShowFileIfRequested (filePathToSave); } 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/MatterControl.userprefs b/MatterControl.userprefs index 5728f2341..4e970df75 100644 --- a/MatterControl.userprefs +++ b/MatterControl.userprefs @@ -1,26 +1,19 @@  - + - - - - - - - - - - - - + + + + + + + - - - + \ No newline at end of file diff --git a/PrintQueue/PrintQueueMenu.cs b/PrintQueue/PrintQueueMenu.cs index 8a0a0a40f..36ce1daeb 100644 --- a/PrintQueue/PrintQueueMenu.cs +++ b/PrintQueue/PrintQueueMenu.cs @@ -61,10 +61,10 @@ namespace MatterHackers.MatterControl.PrintQueue //Set the name and callback function of the menu items menuItems = new TupleList> { - {new LocalizedString("STL").Translated, null}, + {"STL", null}, {new LocalizedString(" Import from Zip").Translated, importQueueFromZipMenu_Click}, {new LocalizedString(" Export to Zip").Translated, exportQueueToZipMenu_Click}, - {new LocalizedString("GCode").Translated, null}, + {"GCode", null}, {new LocalizedString(" Export to Folder").Translated, exportGCodeToFolderButton_Click}, //{" Export to SD Card", exportToSDCardButton_Click}, {new LocalizedString("Extra").Translated, null}, 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.")); 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; }