Merge pull request #1270 from unlimitedbacon/master

Switched custom GCode boxes to monospace font
This commit is contained in:
Lars Brubaker 2016-08-10 15:35:28 -07:00 committed by GitHub
commit 0d2e60a1dc
3 changed files with 15 additions and 7 deletions

View file

@ -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;

View file

@ -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 = "";
}
}
}
}

View file

@ -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) =>
{
ActiveSliceSettings.Instance.SetValue(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n"), persistenceLayer);
@ -1763,4 +1767,4 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
topToBottomItemList.AddChild(itemHolder, indexInChildrenList);
}
}
}
}