From 0b4bc4cbbc274bf44a520874f438d3e72a803ab8 Mon Sep 17 00:00:00 2001 From: Tyler Anderson Date: Wed, 10 Aug 2016 15:18:03 -0700 Subject: [PATCH] Switched custom GCode boxes to monospace font --- ControlElements/MHTextEditWidget.cs | 5 +++-- PrinterControls/TerminalWindow/TerminalWidget.cs | 7 +++++-- SlicerConfiguration/SliceSettingsWidget.cs | 10 +++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ControlElements/MHTextEditWidget.cs b/ControlElements/MHTextEditWidget.cs index 8ad73aed4..5940d93bf 100644 --- a/ControlElements/MHTextEditWidget.cs +++ b/ControlElements/MHTextEditWidget.cs @@ -1,4 +1,5 @@ using MatterHackers.Agg; +using MatterHackers.Agg.Font; using MatterHackers.Agg.UI; using MatterHackers.VectorMath; using System; @@ -16,10 +17,10 @@ namespace MatterHackers.MatterControl get { return actuallTextEditWidget; } } - public MHTextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, string messageWhenEmptyAndNotSelected = "") + public MHTextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, string messageWhenEmptyAndNotSelected = "", TypeFace typeFace = null) { Padding = new BorderDouble(3); - actuallTextEditWidget = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex); + actuallTextEditWidget = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex, typeFace: typeFace); actuallTextEditWidget.HAnchor = Agg.UI.HAnchor.ParentLeftRight; actuallTextEditWidget.MinimumSize = new Vector2(Math.Max(actuallTextEditWidget.MinimumSize.x, pixelWidth), Math.Max(actuallTextEditWidget.MinimumSize.y, pixelHeight)); actuallTextEditWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; diff --git a/PrinterControls/TerminalWindow/TerminalWidget.cs b/PrinterControls/TerminalWindow/TerminalWidget.cs index 9bce5fdf0..ea05cec6c 100644 --- a/PrinterControls/TerminalWindow/TerminalWidget.cs +++ b/PrinterControls/TerminalWindow/TerminalWidget.cs @@ -29,6 +29,8 @@ either expressed or implied, of the FreeBSD Project. using MatterHackers.Agg; using MatterHackers.Agg.UI; +using MatterHackers.Agg.Font; +using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.PrinterCommunication; @@ -138,7 +140,8 @@ namespace MatterHackers.MatterControl manualEntryLayout.BackgroundColor = this.backgroundColor; manualEntryLayout.HAnchor = HAnchor.ParentLeftRight; { - manualCommandTextEdit = new MHTextEditWidget(""); + string pathToFont = StaticData.Instance.ReadAllText(Path.Combine("Fonts", "LiberationMono.svg")); + manualCommandTextEdit = new MHTextEditWidget("", typeFace: TypeFace.LoadFrom(pathToFont)); //manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White; manualCommandTextEdit.Margin = new BorderDouble(right: 3); manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight; @@ -304,4 +307,4 @@ namespace MatterHackers.MatterControl manualCommandTextEdit.Text = ""; } } -} \ No newline at end of file +} diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 1013464e8..64f0d0f99 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -26,7 +26,9 @@ 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 MatterHackers.Agg; +using MatterHackers.Agg.Font; using MatterHackers.Agg.Image; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; @@ -37,6 +39,7 @@ using MatterHackers.SerialPortCommunication.FrostedSerial; using MatterHackers.VectorMath; using System; using System.Collections.Generic; +using System.IO; using System.Linq; namespace MatterHackers.MatterControl.SlicerConfiguration @@ -1210,11 +1213,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration case SliceSettingData.DataEditTypes.MULTI_LINE_TEXT: { string convertedNewLines = sliceSettingValue.Replace("\\n", "\n"); - var stringEdit = new MHTextEditWidget(convertedNewLines, pixelWidth: 320, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++) + string pathToFont = StaticData.Instance.ReadAllText(Path.Combine("Fonts", "LiberationMono.svg")); + var stringEdit = new MHTextEditWidget(convertedNewLines, pixelWidth: 320, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++, typeFace: TypeFace.LoadFrom(pathToFont)) { HAnchor = HAnchor.ParentLeftRight, }; - + stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n"), persistenceLayer); @@ -1780,4 +1784,4 @@ namespace MatterHackers.MatterControl.SlicerConfiguration topToBottomItemList.AddChild(itemHolder, indexInChildrenList); } } -} \ No newline at end of file +}