Added multi-line text
fixed more tests
This commit is contained in:
parent
569e316f38
commit
aebb0ff868
6 changed files with 595 additions and 41 deletions
|
|
@ -31,6 +31,7 @@ using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MatterHackers.Agg;
|
||||||
using MatterHackers.Agg.Font;
|
using MatterHackers.Agg.Font;
|
||||||
using MatterHackers.Agg.Transform;
|
using MatterHackers.Agg.Transform;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
|
|
@ -91,8 +92,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
foreach (var child in this.Children)
|
foreach (var child in this.Children)
|
||||||
{
|
{
|
||||||
var clone = child.Clone();
|
var clone = child.Clone();
|
||||||
var newName = index < nameToWrite.Length ? nameToWrite[index++].ToString() : "Letter".Localize();
|
|
||||||
clone.Name = MapIfSymbol(newName);
|
|
||||||
newContainer.Children.Add(clone);
|
newContainer.Children.Add(clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,19 +99,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
newContainer.Name = this.Name + " - " + "Flattened".Localize();
|
newContainer.Name = this.Name + " - " + "Flattened".Localize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string MapIfSymbol(string newName)
|
|
||||||
{
|
|
||||||
switch (newName)
|
|
||||||
{
|
|
||||||
case " ":
|
|
||||||
return "space";
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return newName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async void OnInvalidate(InvalidateArgs invalidateArgs)
|
public override async void OnInvalidate(InvalidateArgs invalidateArgs)
|
||||||
{
|
{
|
||||||
if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Children)
|
if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Children)
|
||||||
|
|
@ -150,7 +136,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
bool valuesChanged = false;
|
bool valuesChanged = false;
|
||||||
var height = Height.ClampIfNotCalculated(this, .01, 1000000, ref valuesChanged);
|
var height = Height.ClampIfNotCalculated(this, .01, 1000000, ref valuesChanged);
|
||||||
var nameToWrite = NameToWrite.Value(this);
|
var nameToWrite = NameToWrite.Value(this).Replace("\\n", "\n").Replace("\r", "\n").Replace("\n\n", "\n");
|
||||||
if (string.IsNullOrWhiteSpace(nameToWrite))
|
if (string.IsNullOrWhiteSpace(nameToWrite))
|
||||||
{
|
{
|
||||||
Mesh = PlatonicSolids.CreateCube(20, 10, height);
|
Mesh = PlatonicSolids.CreateCube(20, 10, height);
|
||||||
|
|
@ -162,26 +148,62 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
list.Clear();
|
list.Clear();
|
||||||
|
|
||||||
var offest = 0.0;
|
var offset = Vector2.Zero;
|
||||||
double pointsToMm = 0.352778;
|
double pointsToMm = 0.352778;
|
||||||
|
var pointSize = PointSize.Value(this);
|
||||||
|
var lineNumber = 1;
|
||||||
|
var leterNumber = 1;
|
||||||
|
var lineObject = new Object3D()
|
||||||
|
{
|
||||||
|
Name = "Line {0}".Localize().FormatWith(lineNumber)
|
||||||
|
};
|
||||||
|
list.Add(lineObject);
|
||||||
|
|
||||||
foreach (var letter in nameToWrite.ToCharArray())
|
foreach (var letter in nameToWrite.ToCharArray())
|
||||||
{
|
{
|
||||||
var style = new StyledTypeFace(ApplicationController.GetTypeFace(this.Font), PointSize.Value(this));
|
var style = new StyledTypeFace(ApplicationController.GetTypeFace(this.Font), pointSize);
|
||||||
var letterPrinter = new TypeFacePrinter(letter.ToString(), style)
|
var letterPrinter = new TypeFacePrinter(letter.ToString(), style)
|
||||||
{
|
{
|
||||||
ResolutionScale = 10
|
ResolutionScale = 10
|
||||||
};
|
};
|
||||||
var scaledLetterPrinter = new VertexSourceApplyTransform(letterPrinter, Affine.NewScaling(pointsToMm));
|
var scaledLetterPrinter = new VertexSourceApplyTransform(letterPrinter, Affine.NewScaling(pointsToMm));
|
||||||
|
|
||||||
list.Add(new Object3D()
|
if (letter == '\n')
|
||||||
{
|
{
|
||||||
Mesh = VertexSourceToMesh.Extrude(scaledLetterPrinter, this.Height.Value(this)),
|
leterNumber = 0;
|
||||||
Matrix = Matrix4X4.CreateTranslation(offest, 0, 0),
|
lineNumber++;
|
||||||
Name = letter.ToString()
|
offset.X = 0;
|
||||||
});
|
offset.Y -= style.EmSizeInPoints * pointsToMm * 1.4;
|
||||||
|
lineObject = new Object3D()
|
||||||
|
{
|
||||||
|
Matrix = Matrix4X4.CreateTranslation(0, offset.Y, 0),
|
||||||
|
Name = "Line {0}".Localize().FormatWith(lineNumber)
|
||||||
|
};
|
||||||
|
list.Add(lineObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var letterObject = new Object3D()
|
||||||
|
{
|
||||||
|
Mesh = VertexSourceToMesh.Extrude(scaledLetterPrinter, this.Height.Value(this)),
|
||||||
|
Matrix = Matrix4X4.CreateTranslation(offset.X, 0, 0),
|
||||||
|
Name = leterNumber.ToString("000") + " - '" + letter.ToString() + "'"
|
||||||
|
};
|
||||||
|
if (letterObject.Mesh.Faces.Count > 0)
|
||||||
|
{
|
||||||
|
lineObject.Children.Add(letterObject);
|
||||||
|
leterNumber++;
|
||||||
|
}
|
||||||
|
offset.X += letterPrinter.GetSize(letter.ToString()).X * pointsToMm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
offest += letterPrinter.GetSize(letter.ToString()).X * pointsToMm;
|
for (int i=list.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (list[i].Children.Count == 0)
|
||||||
|
{
|
||||||
|
list.RemoveAt(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1068,19 +1068,23 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
else if (propertyValue is StringOrExpression stringOrExpression)
|
else if (propertyValue is StringOrExpression stringOrExpression)
|
||||||
{
|
{
|
||||||
// create a string editor
|
// create a a multi-line string editor
|
||||||
var field = new TextField(theme);
|
var field = new MultilineStringField(theme);
|
||||||
field.Initialize(0);
|
field.Initialize(0);
|
||||||
field.SetValue(stringOrExpression.Expression, false);
|
field.SetValue(stringOrExpression.Expression, false);
|
||||||
field.ClearUndoHistory();
|
field.ClearUndoHistory();
|
||||||
field.Content.HAnchor = HAnchor.Stretch;
|
field.Content.HAnchor = HAnchor.Stretch;
|
||||||
|
field.Content.Descendants<ScrollableWidget>().FirstOrDefault().MaximumSize = new Vector2(double.MaxValue, 200);
|
||||||
|
field.Content.Descendants<ScrollingArea>().FirstOrDefault().Parent.VAnchor = VAnchor.Top;
|
||||||
|
field.Content.MinimumSize = new Vector2(0, 100 * GuiWidget.DeviceScale);
|
||||||
|
field.Content.Margin = new BorderDouble(0, 0, 0, 5);
|
||||||
RegisterValueChanged(field,
|
RegisterValueChanged(field,
|
||||||
(valueString) => new StringOrExpression(valueString),
|
(valueString) => new StringOrExpression(valueString),
|
||||||
(value) =>
|
(value) =>
|
||||||
{
|
{
|
||||||
return ((StringOrExpression)value).Expression;
|
return ((StringOrExpression)value).Expression;
|
||||||
});
|
});
|
||||||
rowContainer = CreateSettingsRow(property, field.Content, theme, rows);
|
rowContainer = CreateSettingsColumn(property, field, fullWidth: true);
|
||||||
}
|
}
|
||||||
else if (propertyValue is char charValue)
|
else if (propertyValue is char charValue)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,8 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
HAnchor = HAnchor.Fit,
|
HAnchor = HAnchor.Fit,
|
||||||
VAnchor = VAnchor.Fit,
|
VAnchor = VAnchor.Fit,
|
||||||
Margin = new BorderDouble(15)
|
Margin = new BorderDouble(15),
|
||||||
|
Name = "Start New Design"
|
||||||
}, "Start New Design".Localize()));
|
}, "Start New Design".Localize()));
|
||||||
lastButton.Click += (s, e) => UiThread.RunOnIdle(() =>
|
lastButton.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -144,19 +144,19 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
||||||
|
|
||||||
var mainViewWidget = ApplicationController.Instance.MainView;
|
var mainViewWidget = ApplicationController.Instance.MainView;
|
||||||
var tabControl = mainViewWidget.TabControl;
|
var tabControl = mainViewWidget.TabControl;
|
||||||
Assert.AreEqual(6, mainViewWidget.TabControl.AllTabs.Count());
|
Assert.AreEqual(5, mainViewWidget.TabControl.AllTabs.Count());
|
||||||
|
|
||||||
// open the design for editing
|
// open the design for editing
|
||||||
testRunner.ClickByName("Library Tab")
|
testRunner.ClickByName("Library Tab")
|
||||||
.DoubleClickByName("Library Row Item Collection")
|
.DoubleClickByName("Library Row Item Collection")
|
||||||
.DoubleClickByName("Local Library Row Item Collection")
|
.DoubleClickByName("Local Library Row Item Collection")
|
||||||
.DoubleClickByName("Row Item Cube Design")
|
.DoubleClickByName("Row Item Cube Design")
|
||||||
.WaitFor(() => mainViewWidget.TabControl.AllTabs.Count() == 7);
|
.WaitFor(() => mainViewWidget.TabControl.AllTabs.Count() == 6);
|
||||||
|
|
||||||
// we have opened a new tab
|
// we have opened a new tab
|
||||||
Assert.AreEqual(7, mainViewWidget.TabControl.AllTabs.Count());
|
Assert.AreEqual(6, mainViewWidget.TabControl.AllTabs.Count());
|
||||||
// we are on the design tab
|
// we are on the design tab
|
||||||
Assert.AreEqual(6, tabControl.SelectedTabIndex);
|
Assert.AreEqual(5, tabControl.SelectedTabIndex);
|
||||||
Assert.AreEqual("Cube Design", tabControl.SelectedTabKey);
|
Assert.AreEqual("Cube Design", tabControl.SelectedTabKey);
|
||||||
|
|
||||||
// double click it again and prove that it goes to the currently open tab
|
// double click it again and prove that it goes to the currently open tab
|
||||||
|
|
@ -164,9 +164,9 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
||||||
.DoubleClickByName("Row Item Cube Design");
|
.DoubleClickByName("Row Item Cube Design");
|
||||||
|
|
||||||
// we have not opened a new tab
|
// we have not opened a new tab
|
||||||
Assert.AreEqual(7, mainViewWidget.TabControl.AllTabs.Count());
|
Assert.AreEqual(6, mainViewWidget.TabControl.AllTabs.Count());
|
||||||
// we are on the design tab
|
// we are on the design tab
|
||||||
Assert.AreEqual(6, tabControl.SelectedTabIndex);
|
Assert.AreEqual(5, tabControl.SelectedTabIndex);
|
||||||
|
|
||||||
// rename in the library tab
|
// rename in the library tab
|
||||||
// assert tab name has change
|
// assert tab name has change
|
||||||
|
|
|
||||||
|
|
@ -244,12 +244,10 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
||||||
testRunner.GetWidgetByName("Hardware Tab", out systemWindow, 10);
|
testRunner.GetWidgetByName("Hardware Tab", out systemWindow, 10);
|
||||||
testRunner.WaitforDraw(systemWindow);
|
testRunner.WaitforDraw(systemWindow);
|
||||||
|
|
||||||
// Latest product starts at empty part tab
|
|
||||||
|
|
||||||
// close the welcome message
|
// close the welcome message
|
||||||
if (testRunner.NameExists("Cancel Wizard Button", 10))
|
if (testRunner.NameExists("Start New Design", 1))
|
||||||
{
|
{
|
||||||
testRunner.ClickByName("Cancel Wizard Button");
|
testRunner.ClickByName("Start New Design");
|
||||||
}
|
}
|
||||||
|
|
||||||
return testRunner;
|
return testRunner;
|
||||||
|
|
@ -468,9 +466,10 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
||||||
public static AutomationRunner EnsureWelcomePageClosed(this AutomationRunner testRunner)
|
public static AutomationRunner EnsureWelcomePageClosed(this AutomationRunner testRunner)
|
||||||
{
|
{
|
||||||
// Close the WelcomePage window if active
|
// Close the WelcomePage window if active
|
||||||
if (testRunner.GetWidgetByName("HeaderRow", out _) is GuiWidget headerRow
|
if (//testRunner.GetWidgetByName("HeaderRow", out _) is GuiWidget headerRow
|
||||||
&& headerRow.Parents<DialogPage>().FirstOrDefault() is Tour.WelcomePage welcomePage
|
//&& headerRow.Parents<DialogPage>().FirstOrDefault() is Tour.WelcomePage welcomePage
|
||||||
&& testRunner.NameExists("Cancel Wizard Button", 1))
|
//&& testRunner.NameExists("Cancel Wizard Button", 1))
|
||||||
|
testRunner.NameExists("Cancel Wizard Button", 1))
|
||||||
{
|
{
|
||||||
testRunner.ClickByName("Cancel Wizard Button");
|
testRunner.ClickByName("Cancel Wizard Button");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue