Use event pattern

This commit is contained in:
John Lewin 2018-08-03 13:00:15 -07:00
parent db84a6ec83
commit 523a218d47
3 changed files with 14 additions and 14 deletions

View file

@ -261,7 +261,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
ActiveSliceSettings.Instance.SetValue("boolean_operations", mergeRules);
var matrixAndMeshArgs = new StringBuilder(); ;
var matrixAndMeshArgs = new StringBuilder();
foreach (var matrixAndFile in stlFileLocations)
{
var matrixString = "";

View file

@ -41,9 +41,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class SurfacedEditorPage : DialogPage
{
public event EventHandler ValueChanged;
private MHTextEditWidget editWidget;
public SurfacedEditorPage(UIField uiField, IObject3D selectedItem)
public SurfacedEditorPage(IObject3D selectedItem)
{
this.WindowTitle = "MatterControl - " + "Editor Selector".Localize();
this.HeaderText = "Surfaced Editor".Localize();
@ -142,9 +144,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
var saveButton = theme.CreateDialogButton("Save".Localize());
saveButton.Click += (s, e) =>
{
uiField.SetValue(
editWidget.Text.Replace("\n", "\\n"),
userInitiated: true);
this.ValueChanged?.Invoke(this, null);
this.DialogWindow.CloseOnIdle();
};

View file

@ -58,17 +58,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
if (sender is InlineStringEdit inlineEdit)
{
var uifield = new TextField();
uifield.Initialize(0);
uifield.ValueChanged += (s, e2) =>
{
inlineEdit.Text = uifield.Value;
};
DialogWindow.Show(new SurfacedEditorPage(uifield, selectedItem)
var editorPage = new SurfacedEditorPage(selectedItem)
{
EditorString = inlineEdit.Text,
});
};
editorPage.ValueChanged += (s, e2) =>
{
inlineEdit.Text = editorPage.EditorString;
};
DialogWindow.Show(editorPage);
}
}
}