Remove unused settingData param, IntOrMmField code
This commit is contained in:
parent
5d105dec21
commit
1e06cc2d57
3 changed files with 3 additions and 95 deletions
|
|
@ -66,10 +66,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
selectableOptions.Click += (s, e) =>
|
||||
{
|
||||
AddComMenuItems(settingData, settingsContext, selectableOptions);
|
||||
AddComMenuItems(settingsContext, selectableOptions);
|
||||
};
|
||||
|
||||
AddComMenuItems(settingData, settingsContext, selectableOptions);
|
||||
AddComMenuItems(settingsContext, selectableOptions);
|
||||
|
||||
// Prevent droplist interaction when connected
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
|
|
@ -95,7 +95,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
selectableOptions.SelectedLabel = ActiveSliceSettings.Instance.Helpers.ComPort();
|
||||
}
|
||||
|
||||
private void AddComMenuItems(SliceSettingData settingData, SettingsContext settingsContext, DropDownList selectableOptions)
|
||||
private void AddComMenuItems(SettingsContext settingsContext, DropDownList selectableOptions)
|
||||
{
|
||||
selectableOptions.MenuItems.Clear();
|
||||
string machineSpecificComPortValue = ActiveSliceSettings.Instance.Helpers.ComPort();
|
||||
|
|
|
|||
|
|
@ -68,95 +68,4 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
return currentValue + (hasUnitsToken ? unitsToken : "");
|
||||
}
|
||||
}
|
||||
|
||||
public class IntOrMmField2 : ISettingsField
|
||||
{
|
||||
private MHTextEditWidget editWidget;
|
||||
|
||||
public Action UpdateStyle { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
|
||||
public GuiWidget Create(SettingsContext settingsContext, SliceSettingData settingData, int tabIndex)
|
||||
{
|
||||
editWidget = new MHTextEditWidget(this.Value, pixelWidth: DoubleField.DoubleEditWidth - 2, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = settingData.HelpText,
|
||||
SelectAllOnFocus = true
|
||||
};
|
||||
|
||||
string startingText = editWidget.Text;
|
||||
editWidget.ActualTextEditWidget.EditComplete += (sender, e) =>
|
||||
{
|
||||
TextEditWidget textEditWidget = (TextEditWidget)sender;
|
||||
// only validate when we lose focus
|
||||
if (!textEditWidget.ContainsFocus)
|
||||
{
|
||||
string text = textEditWidget.Text;
|
||||
text = text.Trim();
|
||||
bool isMm = text.Contains("mm");
|
||||
if (isMm)
|
||||
{
|
||||
text = text.Substring(0, text.IndexOf("mm"));
|
||||
}
|
||||
double result;
|
||||
double.TryParse(text, out result);
|
||||
text = result.ToString();
|
||||
if (isMm)
|
||||
{
|
||||
text += "mm";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (int)result;
|
||||
text = result.ToString();
|
||||
}
|
||||
textEditWidget.Text = text;
|
||||
startingText = editWidget.Text;
|
||||
}
|
||||
|
||||
settingsContext.SetValue(settingData.SlicerConfigName, textEditWidget.Text);
|
||||
this.UpdateStyle();
|
||||
|
||||
// make sure we are still looking for the final validation before saving.
|
||||
if (textEditWidget.ContainsFocus)
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
string currentText = textEditWidget.Text;
|
||||
int cursorIndex = textEditWidget.InternalTextEditWidget.CharIndexToInsertBefore;
|
||||
textEditWidget.Text = startingText;
|
||||
textEditWidget.InternalTextEditWidget.MarkAsStartingState();
|
||||
textEditWidget.Text = currentText;
|
||||
textEditWidget.InternalTextEditWidget.CharIndexToInsertBefore = cursorIndex;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
editWidget.ActualTextEditWidget.InternalTextEditWidget.AllSelected += (sender, e) =>
|
||||
{
|
||||
// select everything up to the mm (if present)
|
||||
InternalTextEditWidget textEditWidget = (InternalTextEditWidget)sender;
|
||||
int mMIndex = textEditWidget.Text.IndexOf("mm");
|
||||
if (mMIndex != -1)
|
||||
{
|
||||
textEditWidget.SetSelection(0, mMIndex - 1);
|
||||
}
|
||||
};
|
||||
|
||||
if (settingData.QuickMenuSettings.Count > 0)
|
||||
{
|
||||
return SliceSettingsWidget.CreateQuickMenu(settingData, settingsContext, editWidget, editWidget.ActualTextEditWidget.InternalTextEditWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
return editWidget;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnValueChanged(string text)
|
||||
{
|
||||
editWidget.Text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue