diff --git a/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs b/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs index 2f2926699..d6b41a138 100644 --- a/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/RadialPinchObject3D.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Threading; using System.Threading.Tasks; using MatterHackers.Agg; @@ -58,7 +59,7 @@ namespace MatterHackers.MatterControl.DesignTools private ImageWidget imageWidget; private Object3D object3D; - public GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context) + public GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context, ref int tabIndex) { if (property.Source is Object3D object3D) { @@ -98,7 +99,6 @@ namespace MatterHackers.MatterControl.DesignTools graphics2D.Clear(theme.BackgroundColor); var bounds = imageWidget.Image.GetBounds(); - bounds.Inflate(-1); graphics2D.Rectangle(bounds, theme.PrimaryAccentColor); var pathBounds = vertexStorage.GetBounds(); diff --git a/MatterControlLib/DesignTools/PropertyEditor.cs b/MatterControlLib/DesignTools/PropertyEditor.cs index 40d08a5d3..6b9b4e249 100644 --- a/MatterControlLib/DesignTools/PropertyEditor.cs +++ b/MatterControlLib/DesignTools/PropertyEditor.cs @@ -51,7 +51,7 @@ namespace MatterHackers.MatterControl.DesignTools { public interface IPropertyEditorFactory { - GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context); + GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context, ref int tabIndex); } public class PropertyEditor : IObjectEditor @@ -302,6 +302,8 @@ namespace MatterHackers.MatterControl.DesignTools rows.Clear(); + int tabIndex = 0; + // Create a field editor for each editable property detected via reflection foreach (var property in GetEditablePropreties(context.Item)) { @@ -347,7 +349,7 @@ namespace MatterHackers.MatterControl.DesignTools scope = mainContainer; } - var editor = CreatePropertyEditor(property, undoBuffer, context, theme); + var editor = CreatePropertyEditor(property, undoBuffer, context, theme, ref tabIndex); if (editor != null) { scope.AddChild(editor); @@ -387,7 +389,7 @@ namespace MatterHackers.MatterControl.DesignTools return mainContainer; } - public GuiWidget CreatePropertyEditor(EditableProperty property, UndoBuffer undoBuffer, EditorContext context, ThemeConfig theme) + public GuiWidget CreatePropertyEditor(EditableProperty property, UndoBuffer undoBuffer, EditorContext context, ThemeConfig theme, ref int tabIndex) { if (property == null || context == null) @@ -411,7 +413,7 @@ namespace MatterHackers.MatterControl.DesignTools if (AllowedTypes.ContainsKey(propertyValue.GetType()) && AllowedTypes[propertyValue.GetType()] != null) { - rowContainer = AllowedTypes[propertyValue.GetType()].CreateEditor(this, property, context); + rowContainer = AllowedTypes[propertyValue.GetType()].CreateEditor(this, property, context, ref tabIndex); } else if (propertyValue is double doubleValue) { @@ -442,7 +444,7 @@ namespace MatterHackers.MatterControl.DesignTools else // normal edit row { var field = new DoubleField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.DoubleValue = doubleValue; field.ClearUndoHistory(); RegisterValueChanged(property, undoBuffer, context, field, (valueString) => { return double.Parse(valueString); }); @@ -479,7 +481,7 @@ namespace MatterHackers.MatterControl.DesignTools else if (propertyValue is Color color) { var field = new ColorField(theme, color, null, false); - field.Initialize(0); + field.Initialize(ref tabIndex); field.ValueChanged += (s, e) => { property.SetValue(field.Color); @@ -492,7 +494,7 @@ namespace MatterHackers.MatterControl.DesignTools else if (propertyValue is Vector2 vector2) { var field = new Vector2Field(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.Vector2 = vector2; field.ClearUndoHistory(); @@ -512,7 +514,7 @@ namespace MatterHackers.MatterControl.DesignTools else if (propertyValue is Vector3 vector3) { var field = new Vector3Field(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.Vector3 = vector3; field.ClearUndoHistory(); @@ -536,7 +538,7 @@ namespace MatterHackers.MatterControl.DesignTools field.Labels = vectorFieldLabels.Labels; } - field.Initialize(0); + field.Initialize(ref tabIndex); field.Vector4 = vector4; field.ClearUndoHistory(); @@ -555,7 +557,7 @@ namespace MatterHackers.MatterControl.DesignTools else if (propertyValue is DirectionVector directionVector) { var field = new DirectionVectorField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.SetValue(directionVector); field.ClearUndoHistory(); @@ -573,7 +575,7 @@ namespace MatterHackers.MatterControl.DesignTools rowContainer = CreateSettingsColumn(property); var field1 = new DirectionVectorField(theme); - field1.Initialize(0); + field1.Initialize(ref tabIndex); field1.ClearUndoHistory(); field1.SetValue(new DirectionVector() @@ -587,7 +589,7 @@ namespace MatterHackers.MatterControl.DesignTools // the distance from the center of the part // create a double editor var field2 = new Vector3Field(theme); - field2.Initialize(0); + field2.Initialize(ref tabIndex); field2.Vector3 = directionAxis.Origin - propertyIObject3D.Children.First().GetAxisAlignedBoundingBox().Center; field2.ClearUndoHistory(); @@ -745,7 +747,7 @@ namespace MatterHackers.MatterControl.DesignTools else if (propertyValue is List stringList) { var field = new SurfacedEditorsField(theme, propertyIObject3D); - field.Initialize(0); + field.Initialize(ref tabIndex); field.ListValue = stringList; field.ValueChanged += (s, e) => { @@ -803,7 +805,7 @@ namespace MatterHackers.MatterControl.DesignTools else // normal edit row { var field = new IntField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.IntValue = intValue; field.ClearUndoHistory(); @@ -834,7 +836,7 @@ namespace MatterHackers.MatterControl.DesignTools { // create a bool editor var field = new ToggleboxField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.Checked = boolValue; RegisterValueChanged(property, undoBuffer, context, @@ -850,7 +852,7 @@ namespace MatterHackers.MatterControl.DesignTools { Name = property.DisplayName + " Field" }; - field.Initialize(0); + field.Initialize(ref tabIndex); if (doubleExpresion.Expression.Contains("=")) { field.SetValue(doubleExpresion.Expression, false); @@ -926,7 +928,7 @@ namespace MatterHackers.MatterControl.DesignTools { Name = property.DisplayName + " Field" }; - field.Initialize(0); + field.Initialize(ref tabIndex); if (intExpresion.Expression.Contains("=")) { field.SetValue(intExpresion.Expression, false); @@ -1001,7 +1003,7 @@ namespace MatterHackers.MatterControl.DesignTools { // create a a multi-line string editor var field = new MultilineStringField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.SetValue(stringOrExpression.Expression, false); field.ClearUndoHistory(); field.Content.HAnchor = HAnchor.Stretch; @@ -1022,7 +1024,7 @@ namespace MatterHackers.MatterControl.DesignTools { // create a string editor var field = new TextField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.SetValue(stringOrExpression.Expression, false); field.ClearUndoHistory(); field.Content.HAnchor = HAnchor.Stretch; @@ -1040,7 +1042,7 @@ namespace MatterHackers.MatterControl.DesignTools { // create a string editor var field = new TextField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.SetValue(dateTime.ToString("MM/dd/yyyy HH:mm"), false); field.ClearUndoHistory(); field.Content.HAnchor = HAnchor.Stretch; @@ -1057,7 +1059,7 @@ namespace MatterHackers.MatterControl.DesignTools { // create a char editor var field = new CharField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.SetValue(charValue.ToString(), false); field.ClearUndoHistory(); field.ValueChanged += (s, e) => @@ -1099,7 +1101,7 @@ namespace MatterHackers.MatterControl.DesignTools } } - field.Initialize(0); + field.Initialize(ref tabIndex); RegisterValueChanged(property, undoBuffer, context, field, (valueString) => diff --git a/MatterControlLib/DesignTools/SelectedChildrenPropertyEditor.cs b/MatterControlLib/DesignTools/SelectedChildrenPropertyEditor.cs index d6cf7d2de..ea94d087e 100644 --- a/MatterControlLib/DesignTools/SelectedChildrenPropertyEditor.cs +++ b/MatterControlLib/DesignTools/SelectedChildrenPropertyEditor.cs @@ -36,6 +36,7 @@ using MatterHackers.MatterControl.SlicerConfiguration; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Threading; using static MatterHackers.Agg.UI.OnScreenKeyboard; @@ -43,7 +44,7 @@ namespace MatterHackers.MatterControl.DesignTools { public class SelectedChildrenPropertyEditor : IPropertyEditorFactory { - public GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context) + public GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context, ref int tabIndex) { if (property.Value is SelectedChildren childSelector) { @@ -60,7 +61,7 @@ namespace MatterHackers.MatterControl.DesignTools { UIField field = new ChildrenSelectorListField(property, theme); - field.Initialize(0); + field.Initialize(ref tabIndex); PropertyEditor.RegisterValueChanged(property, undoBuffer, context, field, (valueString) => diff --git a/MatterControlLib/DesignTools/StringPropertyEditor.cs b/MatterControlLib/DesignTools/StringPropertyEditor.cs index b5a7771fb..bd50125e4 100644 --- a/MatterControlLib/DesignTools/StringPropertyEditor.cs +++ b/MatterControlLib/DesignTools/StringPropertyEditor.cs @@ -41,12 +41,13 @@ using System.Web; using System.ComponentModel; using MatterHackers.VectorMath; using System.IO; +using System.Reflection.Metadata.Ecma335; namespace MatterHackers.MatterControl.DesignTools { public class StringPropertyEditor : IPropertyEditorFactory { - public GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context) + public GuiWidget CreateEditor(PropertyEditor propertyEditor, EditableProperty property, EditorContext context, ref int tabIndex) { if (property.Value is string stringValue) { @@ -156,7 +157,7 @@ namespace MatterHackers.MatterControl.DesignTools { // create a a multi-line string editor var field = new MultilineStringField(theme, property.PropertyInfo.GetCustomAttributes(true).OfType().FirstOrDefault() != null); - field.Initialize(0); + field.Initialize(ref tabIndex); field.SetValue(stringValue, false); field.ClearUndoHistory(); field.Content.HAnchor = HAnchor.Stretch; @@ -171,7 +172,7 @@ namespace MatterHackers.MatterControl.DesignTools { // create a string editor var field = new TextField(theme); - field.Initialize(0); + field.Initialize(ref tabIndex); field.SetValue(stringValue, false); field.ClearUndoHistory(); field.Content.HAnchor = HAnchor.Stretch; diff --git a/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs b/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs index 7e59e5110..bd2e18f84 100644 --- a/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs +++ b/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs @@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project. using System.Collections.Generic; using System.Reflection; +using System.Reflection.Metadata.Ecma335; using System.Threading.Tasks; using MatterHackers.Agg; using MatterHackers.Agg.UI; @@ -62,11 +63,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var propertyEditor = new PropertyEditor(theme, new UndoBuffer()); + int tabIndex = 0; + var editor = propertyEditor.CreatePropertyEditor( new EditableProperty(propertyInfo, supportGenerator), null, new EditorContext(), - theme); + theme, + ref tabIndex); if (editor != null) { @@ -75,7 +79,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in support pillar size var pillarSizeField = new DoubleField(theme); - pillarSizeField.Initialize(0); + pillarSizeField.Initialize(ref tabIndex); pillarSizeField.DoubleValue = supportGenerator.PillarSize; pillarSizeField.ValueChanged += (s, e) => { @@ -97,7 +101,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in the angle setting var overHangField = new DoubleField(theme); - overHangField.Initialize(0); + overHangField.Initialize(ref tabIndex); overHangField.DoubleValue = supportGenerator.MaxOverHangAngle; overHangField.ValueChanged += (s, e) => { diff --git a/MatterControlLib/PartPreviewWindow/ItemColorButton.cs b/MatterControlLib/PartPreviewWindow/ItemColorButton.cs index 05466511c..d14a3d1b8 100644 --- a/MatterControlLib/PartPreviewWindow/ItemColorButton.cs +++ b/MatterControlLib/PartPreviewWindow/ItemColorButton.cs @@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Linq; +using System.Reflection.Metadata.Ecma335; using MatterHackers.Agg; using MatterHackers.Agg.Image; using MatterHackers.Agg.Platform; @@ -145,8 +146,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Stretch, }); - // put in an html edit field - htmlField.Initialize(0); + int tabIndex = 0; + + // put in an html edit field + htmlField.Initialize(ref tabIndex); htmlField.SetValue(startingColor.Html.Substring(1, 6), false); htmlField.ClearUndoHistory(); htmlField.ValueChanged += (s, e) => diff --git a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs index e09914f08..569da8a1d 100644 --- a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs +++ b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs @@ -42,6 +42,7 @@ using MatterHackers.MatterControl.SlicerConfiguration; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Threading; using System.Threading.Tasks; using static JsonPath.JsonPathContext.ReflectionValueSystem; @@ -182,6 +183,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public void SetActiveItem(ISceneContext sceneContext) { + int tabIndex = 0; var selectedItem = sceneContext?.Scene?.SelectedItem; if (this.item == selectedItem) { @@ -296,7 +298,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (!(selectedItem.GetType().GetCustomAttributes(typeof(HideMeterialAndColor), true).FirstOrDefault() is HideMeterialAndColor)) { - AddMaterialAndColorSelector(sceneContext, selectedItem, undoBuffer); + AddMaterialAndColorSelector(sceneContext, selectedItem, undoBuffer, ref tabIndex); } var rows = new SafeList(); @@ -305,7 +307,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (selectedItem is ComponentObject3D componentObject && componentObject.Finalized) { - AddComponentEditor(selectedItem, undoBuffer, rows, componentObject); + AddComponentEditor(selectedItem, undoBuffer, rows, componentObject, ref tabIndex); } else { @@ -316,7 +318,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - void AddMaterialAndColorSelector(ISceneContext sceneContext, IObject3D selectedItem, UndoBuffer undoBuffer) + void AddMaterialAndColorSelector(ISceneContext sceneContext, IObject3D selectedItem, UndoBuffer undoBuffer, ref int tabIndex) { var firstDetectedColor = selectedItem.VisibleMeshes()?.FirstOrDefault()?.WorldColor(); var worldColor = Color.White; @@ -327,7 +329,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in a color edit field var colorField = new ColorField(theme, worldColor, GetNextSelectionColor, true); - colorField.Initialize(0); + colorField.Initialize(ref tabIndex); colorField.ValueChanged += (s, e) => { if (selectedItem.Color != colorField.Color) @@ -513,7 +515,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in a material edit field var materialField = new MaterialIndexField(sceneContext.Printer, theme, selectedItem.MaterialIndex); - materialField.Initialize(0); + materialField.Initialize(ref tabIndex); materialField.ValueChanged += (s, e) => { if (selectedItem.MaterialIndex != materialField.MaterialIndex) @@ -536,7 +538,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - private void AddComponentEditor(IObject3D selectedItem, UndoBuffer undoBuffer, SafeList rows, ComponentObject3D componentObject) + private void AddComponentEditor(IObject3D selectedItem, UndoBuffer undoBuffer, SafeList rows, ComponentObject3D componentObject, ref int tabIndex) { var context = new EditorContext(); PropertyEditor.AddUnlockLinkIfRequired(selectedItem, editorPanel, theme); @@ -578,7 +580,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var editableProperty = new EditableProperty(reflectionTarget.PropertyInfo, reflectionTarget.Source); var propertyEditor = new PropertyEditor(theme, undoBuffer); - var editor = propertyEditor.CreatePropertyEditor(editableProperty, undoBuffer, context, theme); + var editor = propertyEditor.CreatePropertyEditor(editableProperty, undoBuffer, context, theme, ref tabIndex); if (editor != null) { editorPanel.AddChild(editor); @@ -612,7 +614,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { Name = cellId + " Field", }; - field.Initialize(0); + int tabIndex = 0; + field.Initialize(ref tabIndex); field.SetValue(cellData, false); field.ClearUndoHistory(); field.Content.HAnchor = HAnchor.Stretch; diff --git a/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs b/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs index 84a01d2a1..6dfac24bd 100644 --- a/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs +++ b/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs @@ -866,7 +866,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration uiField.HelpText = settingData.HelpText; uiField.Name = $"{settingData.PresentationName} Field"; - uiField.Initialize(tabIndexForItem++); + uiField.Initialize(ref tabIndexForItem); if (settingData.DataEditType == SliceSettingData.DataEditTypes.WIDE_STRING) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/BoundDoubleField.cs b/MatterControlLib/SlicerConfiguration/UIFields/BoundDoubleField.cs index 5d670db88..a56bea329 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/BoundDoubleField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/BoundDoubleField.cs @@ -49,9 +49,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.settingData = settingData; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { - base.Initialize(tabIndex); + base.Initialize(ref tabIndex); this.textEditWidget.BackgroundColor = Color.Pink; ChangesMultipleOtherSettings = settingData.SetSettingsOnChange.Count > 0; } diff --git a/MatterControlLib/SlicerConfiguration/UIFields/CharField.cs b/MatterControlLib/SlicerConfiguration/UIFields/CharField.cs index 4728baa2a..c2a38cf10 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/CharField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/CharField.cs @@ -42,7 +42,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { textEditWidget = new ThemedTextEditWidget("", theme, pixelWidth: ControlWidth, tabIndex: tabIndex) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/CheckboxField.cs b/MatterControlLib/SlicerConfiguration/UIFields/CheckboxField.cs index b627ee8cb..c8a31f23f 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/CheckboxField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/CheckboxField.cs @@ -46,14 +46,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { checkBoxWidget = new CheckBox("") { VAnchor = VAnchor.Bottom, Name = this.Name, TextColor = theme.TextColor, - Checked = this.Value == "1" + Checked = this.Value == "1", + TabIndex = tabIndex++, }; checkBoxWidget.CheckedStateChanged += (s, e) => { @@ -89,7 +90,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { var pixelWidth = this.ControlWidth + 6; // HACK: work around agg-bug where text fields are padding*2 bigger than ControlWidth diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ChildrenSelectorListField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ChildrenSelectorListField.cs index 91a6c0f50..4bfaab163 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ChildrenSelectorListField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ChildrenSelectorListField.cs @@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { // Enum keyed on name to friendly name List<(string key, string value)> names = null; @@ -70,9 +70,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - dropDownList = new MHDropDownList("Name".Localize(), theme); + dropDownList = new MHDropDownList("Name".Localize(), theme) + { + TabIndex = tabIndex++, + }; - var orderedItems = names.OrderBy(n => n.value); + + var orderedItems = names.OrderBy(n => n.value); foreach (var orderItem in orderedItems) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ColorField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ColorField.cs index a42b5bdfd..ef9ee5955 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ColorField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ColorField.cs @@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration set => colorWidget.Color = value; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { var container = new FlowLayoutWidget(); diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs index 02bf9c3fa..afc5e6ba5 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs @@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public new string Name { get; set; } public static bool ShowPortWizardButton { get; set; } = true; - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { EventHandler unregisterEvents = null; @@ -71,11 +71,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { ToolTipText = this.HelpText, Margin = new BorderDouble(), - TabIndex = tabIndex, Name = "com_port Field", // Prevent droplist interaction when connected Enabled = canChangeComPort, - }; + TabIndex = tabIndex++, + }; dropdownList.Click += (s, e) => { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/DirectionVectorField.cs b/MatterControlLib/SlicerConfiguration/UIFields/DirectionVectorField.cs index 90d21fa2f..f5f9d65a8 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/DirectionVectorField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/DirectionVectorField.cs @@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { dropDownList = new MHDropDownList("Name".Localize(), theme); diff --git a/MatterControlLib/SlicerConfiguration/UIFields/EnumDisplayField.cs b/MatterControlLib/SlicerConfiguration/UIFields/EnumDisplayField.cs index cbd0cd74d..47ba015bc 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/EnumDisplayField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/EnumDisplayField.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Reflection.Metadata.Ecma335; using MatterHackers.Agg; using MatterHackers.Agg.Image; using MatterHackers.Agg.Platform; @@ -69,7 +70,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration .SingleOrDefault(); } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { (string key, string name) GetKeyName(Enum value) { @@ -117,9 +118,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration default: throw new NotImplementedException(); } + + tabIndex++; } - private void EnableReduceWidth(ThemedRadioTextButton enumTab) + private void EnableReduceWidth(ThemedRadioTextButton enumTab) { var deviceScale = GuiWidget.DeviceScale; var padingSize = enumTab.Padding.Left * deviceScale; diff --git a/MatterControlLib/SlicerConfiguration/UIFields/EnumField.cs b/MatterControlLib/SlicerConfiguration/UIFields/EnumField.cs index 92ec2f522..06a904780 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/EnumField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/EnumField.cs @@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { // Enum keyed on name to friendly name var enumItems = Enum.GetNames(property.PropertyType).Select(enumName => diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ExpressionField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ExpressionField.cs index 9a5691c4f..acf2ed5c3 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ExpressionField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ExpressionField.cs @@ -54,7 +54,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { var aligner = new GuiWidget() { @@ -67,7 +67,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration ToolTipText = this.HelpText, SelectAllOnFocus = true, Name = this.Name, - }); + TabIndex = tabIndex++, + }); textEditWidget.ActualTextEditWidget.EditComplete += (s, e) => { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs index d463b4608..c825c727e 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ExtruderOffsetField.cs @@ -52,7 +52,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { childFields = new List(); @@ -89,7 +89,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration row.AddChild(labelWidget); var field = new Vector3Field(theme); - field.Initialize(tabIndex++); + field.Initialize(ref tabIndex); field.Content.Margin = new BorderDouble(right: 55); field.Content.VAnchor = VAnchor.Center; field.ValueChanged += (s, e) => @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration childFields.Add(field); } - base.Initialize(tabIndex); + base.Initialize(ref tabIndex); } private static double StripZeroSign(double x) diff --git a/MatterControlLib/SlicerConfiguration/UIFields/FontSelectorField.cs b/MatterControlLib/SlicerConfiguration/UIFields/FontSelectorField.cs index 4c079a5c5..d8ee2fe49 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/FontSelectorField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/FontSelectorField.cs @@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { // Enum keyed on name to friendly name var enumItems = Enum.GetNames(property.PropertyType).Select(enumName => diff --git a/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs b/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs index da2d1344f..801fc1680 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs @@ -29,9 +29,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { - base.Initialize(tabIndex); + base.Initialize(ref tabIndex); bool canChangeComPort = !printer.Connection.IsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; //This setting defaults to Manual var selectedMachine = printer.Settings.GetValue(SettingsKey.selector_ip_address); diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ListField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ListField.cs index e6ace7149..b348746cc 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ListField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ListField.cs @@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration return 0; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { dropdownList = new MHDropDownList("None".Localize(), theme, maxHeight: 200 * GuiWidget.DeviceScale) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ListStringField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ListStringField.cs index 1b46efa9d..eec642536 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ListStringField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ListStringField.cs @@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { this.Content = new FlowLayoutWidget(FlowDirection.TopToBottom) { @@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration VAnchor = VAnchor.Fit, }; - base.Initialize(tabIndex); + base.Initialize(ref tabIndex); } public List _list = new List(); diff --git a/MatterControlLib/SlicerConfiguration/UIFields/MarkdownEditField.cs b/MatterControlLib/SlicerConfiguration/UIFields/MarkdownEditField.cs index 74eaecded..da85c3ac9 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/MarkdownEditField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/MarkdownEditField.cs @@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.fieldTitle = fieldTitle; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { var editButton = new ThemedIconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).GrayToColor(theme.TextColor), theme) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/MaterialIndexField.cs b/MatterControlLib/SlicerConfiguration/UIFields/MaterialIndexField.cs index 39964b5db..51349fadb 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/MaterialIndexField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/MaterialIndexField.cs @@ -48,7 +48,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public int MaterialIndex { get; set; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { var container = new FlowLayoutWidget(); diff --git a/MatterControlLib/SlicerConfiguration/UIFields/MultilineStringField.cs b/MatterControlLib/SlicerConfiguration/UIFields/MultilineStringField.cs index 12ea2f205..7c3bfa256 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/MultilineStringField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/MultilineStringField.cs @@ -51,7 +51,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { editWidget = new ThemedTextEditWidget("", theme, pixelWidth: 320, multiLine: true, tabIndex: tabIndex, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono)) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/NumberField.cs b/MatterControlLib/SlicerConfiguration/UIFields/NumberField.cs index 5f52e4f65..0a995180d 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/NumberField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/NumberField.cs @@ -105,7 +105,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { numberEdit = new ThemedNumberEdit(0, theme, pixelWidth: ControlWidth, allowDecimals: this.AllowDecimals, allowNegatives: this.AllowNegatives, tabIndex: tabIndex) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/SliceEngineField.cs b/MatterControlLib/SlicerConfiguration/UIFields/SliceEngineField.cs index e674926f7..ec0ba8cd9 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/SliceEngineField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/SliceEngineField.cs @@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public new string Name { get; set; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { EventHandler unregisterEvents = null; diff --git a/MatterControlLib/SlicerConfiguration/UIFields/TextField.cs b/MatterControlLib/SlicerConfiguration/UIFields/TextField.cs index 89ae50b29..e77e22eec 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/TextField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/TextField.cs @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { textEditWidget = new ThemedTextEditWidget("", theme, pixelWidth: ControlWidth, tabIndex: tabIndex) { @@ -95,7 +95,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.theme = theme; } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { textWidget = new TextWidget("", textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/UIField.cs b/MatterControlLib/SlicerConfiguration/UIFields/UIField.cs index 292caa0d6..654ec391d 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/UIField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/UIField.cs @@ -71,7 +71,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration return newValue; } - public virtual void Initialize(int tabIndex) + public virtual void Initialize(ref int tabIndex) { } diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ValueOrUnitsField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ValueOrUnitsField.cs index 2cfe57ac2..a03367a18 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ValueOrUnitsField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ValueOrUnitsField.cs @@ -41,9 +41,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { - base.Initialize(tabIndex); + base.Initialize(ref tabIndex); textEditWidget.ActualTextEditWidget.InternalTextEditWidget.AllSelected += (s, e) => { diff --git a/MatterControlLib/SlicerConfiguration/UIFields/Vector2Field.cs b/MatterControlLib/SlicerConfiguration/UIFields/Vector2Field.cs index c41b3e8c0..9c348f491 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/Vector2Field.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/Vector2Field.cs @@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { var container = new FlowLayoutWidget(); @@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration xEditWidget = new ThemedNumberEdit(currentXValue, theme, singleCharLabel: 'X', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex, + TabIndex = tabIndex++, SelectAllOnFocus = true, Margin = theme.ButtonSpacing }; @@ -95,7 +95,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration yEditWidget = new ThemedNumberEdit(currentYValue, theme, 'Y', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex + 1, + TabIndex = tabIndex++, SelectAllOnFocus = true, }; yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => diff --git a/MatterControlLib/SlicerConfiguration/UIFields/Vector3Field.cs b/MatterControlLib/SlicerConfiguration/UIFields/Vector3Field.cs index 78ed3f0fe..1eabbfb0e 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/Vector3Field.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/Vector3Field.cs @@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { var container = new FlowLayoutWidget(); @@ -71,10 +71,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration double.TryParse(xyzStrings[0], out double currentXValue); - xEditWidget = new ThemedNumberEdit(currentXValue, theme, 'X', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex++) + xEditWidget = new ThemedNumberEdit(currentXValue, theme, 'X', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex, + TabIndex = tabIndex++, SelectAllOnFocus = true, Margin = theme.ButtonSpacing }; @@ -93,10 +93,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration double.TryParse(xyzStrings[1], out double currentYValue); - yEditWidget = new ThemedNumberEdit(currentYValue, theme, 'Y', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex++) + yEditWidget = new ThemedNumberEdit(currentYValue, theme, 'Y', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex + 1, + TabIndex = tabIndex++, SelectAllOnFocus = true, Margin = theme.ButtonSpacing }; @@ -115,10 +115,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration double.TryParse(xyzStrings[2], out double currentZValue); - zEditWidget = new ThemedNumberEdit(currentZValue, theme, 'Z', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex++) + zEditWidget = new ThemedNumberEdit(currentZValue, theme, 'Z', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex + 1, + TabIndex = tabIndex++, SelectAllOnFocus = true, Margin = theme.ButtonSpacing }; diff --git a/MatterControlLib/SlicerConfiguration/UIFields/Vector4Field.cs b/MatterControlLib/SlicerConfiguration/UIFields/Vector4Field.cs index 8e144d5d9..c372e5ae9 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/Vector4Field.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/Vector4Field.cs @@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - public override void Initialize(int tabIndex) + public override void Initialize(ref int tabIndex) { var container = new FlowLayoutWidget(); @@ -79,7 +79,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration xEditWidget = new ThemedNumberEdit(currentXValue, theme, Labels[0] /* X */, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZWEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex, + TabIndex = tabIndex++, SelectAllOnFocus = true, Margin = theme.ButtonSpacing }; @@ -101,7 +101,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration yEditWidget = new ThemedNumberEdit(currentYValue, theme, Labels[1] /* Y */, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZWEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex + 1, + TabIndex = tabIndex++, SelectAllOnFocus = true, Margin = theme.ButtonSpacing }; @@ -123,7 +123,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration zEditWidget = new ThemedNumberEdit(currentZValue, theme, Labels[2] /* Z */, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZWEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex + 1, + TabIndex = tabIndex++, SelectAllOnFocus = true, Margin = theme.ButtonSpacing }; @@ -145,7 +145,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration wEditWidget = new ThemedNumberEdit(currentZValue, theme, Labels[3] /* W */, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYZWEditWidth, tabIndex: tabIndex) { ToolTipText = this.HelpText, - TabIndex = tabIndex + 1, + TabIndex = tabIndex++, SelectAllOnFocus = true, Margin = theme.ButtonSpacing }; diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 91d15ff1d..cce111496 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 91d15ff1d8a9d934c309de1279f977ce0537a9c9 +Subproject commit cce11149641f4190905877c8e680eda3c50c99e0 diff --git a/Tests/MatterControl.Tests/MatterControl/UIFieldTestWindow.cs b/Tests/MatterControl.Tests/MatterControl/UIFieldTestWindow.cs index b5abfe5d5..36633ada2 100644 --- a/Tests/MatterControl.Tests/MatterControl/UIFieldTestWindow.cs +++ b/Tests/MatterControl.Tests/MatterControl/UIFieldTestWindow.cs @@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project. */ using System; +using System.Reflection.Metadata.Ecma335; using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.MatterControl.SlicerConfiguration; @@ -53,8 +54,9 @@ namespace MatterControl.Tests.MatterControl // Store this.field = field; - // Initialize the field and store the generated content reference - field.Initialize(0); + int tabIndex = 0; + // Initialize the field and store the generated content reference + field.Initialize(ref tabIndex); GuiWidget widgetUnderTest = field.Content;