Don't crash if material null
removing dead code Turned Trim Perimeters back on
This commit is contained in:
parent
9110410d20
commit
d8a0ecd86b
3 changed files with 3 additions and 597 deletions
|
|
@ -83,7 +83,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
savePresetButton.Click += new EventHandler(savePresets_Click);
|
||||
duplicatePresetButton.Click += new EventHandler(duplicatePresets_Click);
|
||||
importPresetButton.Click += new EventHandler(importPresets_Click);
|
||||
exportPresetButton.Click += new EventHandler(exportPresets_Click);
|
||||
}
|
||||
|
||||
|
|
@ -142,10 +141,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
private SettingsDropDownList groupDropDownList;
|
||||
private SettingsDropDownList settingDropDownList;
|
||||
|
||||
private FlowLayoutWidget addSettingsContainer;
|
||||
private PresetListControl settingsRowContainer;
|
||||
private FlowLayoutWidget errorMessageContainer;
|
||||
|
||||
private GuiWidget GetMiddleRow()
|
||||
{
|
||||
NamedSettingsLayers layerFilter = NamedSettingsLayers.Material;
|
||||
|
|
@ -244,179 +239,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
private void PopulateAddSettingRow(int categoryDefaultIndex = -1, int groupDefaultIndex = -1, string settingDefaultConfigName = "-1")
|
||||
{
|
||||
errorMessageContainer.Visible = false;
|
||||
|
||||
categoryDropDownList = new SettingsDropDownList("- Select Category -");
|
||||
categoryDropDownList.Margin = new BorderDouble(right: 3);
|
||||
categoryDropDownList.MinimumSize = new Vector2(categoryDropDownList.LocalBounds.Width, categoryDropDownList.LocalBounds.Height);
|
||||
categoryDropDownList.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
categoryDropDownList.Height = 24;
|
||||
|
||||
groupDropDownList = new SettingsDropDownList("- Select Group -");
|
||||
groupDropDownList.Margin = new BorderDouble(right: 3);
|
||||
groupDropDownList.MinimumSize = new Vector2(groupDropDownList.LocalBounds.Width, groupDropDownList.LocalBounds.Height);
|
||||
groupDropDownList.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
groupDropDownList.Height = 24;
|
||||
|
||||
settingDropDownList = new SettingsDropDownList("- Select Setting -");
|
||||
settingDropDownList.Margin = new BorderDouble(right: 3);
|
||||
settingDropDownList.MinimumSize = new Vector2(settingDropDownList.LocalBounds.Width, settingDropDownList.LocalBounds.Height);
|
||||
settingDropDownList.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
settingDropDownList.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
||||
settingDropDownList.AlignToRightEdge = true;
|
||||
settingDropDownList.Height = 24;
|
||||
|
||||
string selectedCategoryValue = "{0}:-1:-1".FormatWith(categoryDefaultIndex);
|
||||
string selectedGroupValue = "{0}:{1}:-1".FormatWith(categoryDefaultIndex, groupDefaultIndex);
|
||||
string selectedSettingValue = "{0}:{1}:{2}".FormatWith(categoryDefaultIndex, groupDefaultIndex, settingDefaultConfigName);
|
||||
|
||||
string UserLevel = "Advanced"; //Show all settings
|
||||
for (int categoryIndex = 0; categoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; categoryIndex++)
|
||||
{
|
||||
OrganizerCategory category = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[categoryIndex];
|
||||
|
||||
//Always add all categories
|
||||
MenuItem categoryMenuItem = categoryDropDownList.AddItem(category.Name, "{0}:-1:-1".FormatWith(categoryIndex));
|
||||
categoryMenuItem.Selected += new EventHandler(OnItemSelected);
|
||||
|
||||
for (int groupIndex = 0; groupIndex < category.GroupsList.Count; groupIndex++)
|
||||
{
|
||||
OrganizerGroup group = category.GroupsList[groupIndex];
|
||||
string groupValue = "{0}:{1}:-1".FormatWith(categoryIndex, groupIndex);
|
||||
|
||||
//Add groups if within selected category or no category selected
|
||||
if (categoryIndex == categoryDefaultIndex || categoryDefaultIndex == -1)
|
||||
{
|
||||
MenuItem groupMenuItem = groupDropDownList.AddItem(group.Name, groupValue);
|
||||
groupMenuItem.Selected += new EventHandler(OnItemSelected);
|
||||
}
|
||||
|
||||
for (int subGroupIndex = 0; subGroupIndex < group.SubGroupsList.Count; subGroupIndex++)
|
||||
{
|
||||
OrganizerSubGroup subgroup = group.SubGroupsList[subGroupIndex];
|
||||
for (int settingIndex = 0; settingIndex < subgroup.SettingDataList.Count; settingIndex++)
|
||||
{
|
||||
//Add settings if within selected category and group or no category selected
|
||||
if (selectedGroupValue == groupValue || (groupDefaultIndex == -1 && categoryIndex == categoryDefaultIndex) || categoryDefaultIndex == -1)
|
||||
{
|
||||
OrganizerSettingsData setting = subgroup.SettingDataList[settingIndex];
|
||||
|
||||
if (setting.DataEditType != OrganizerSettingsData.DataEditTypes.HARDWARE_PRESENT)
|
||||
{
|
||||
string itemValue = "{0}:{1}:{2}".FormatWith(categoryIndex, groupIndex, setting.SlicerConfigName);
|
||||
string itemName = setting.PresentationName.Replace("\\n", "").Replace(":", "");
|
||||
if (setting.ExtraSettings.Trim() != "" && setting.DataEditType != OrganizerSettingsData.DataEditTypes.LIST)
|
||||
{
|
||||
itemName = "{0} ({1})".FormatWith(itemName, setting.ExtraSettings.Replace("\\n", " "));
|
||||
}
|
||||
if (ActiveSliceSettings.Instance.ActiveSliceEngine().MapContains(setting.SlicerConfigName))
|
||||
{
|
||||
MenuItem settingMenuItem = settingDropDownList.AddItem(itemName, itemValue);
|
||||
settingMenuItem.Selected += new EventHandler(OnItemSelected);
|
||||
settingMenuItem.Selected += new EventHandler(OnSettingSelected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (categoryDefaultIndex != -1)
|
||||
{
|
||||
categoryDropDownList.SelectedValue = selectedCategoryValue;
|
||||
}
|
||||
if (groupDefaultIndex != -1)
|
||||
{
|
||||
groupDropDownList.SelectedValue = selectedGroupValue;
|
||||
}
|
||||
if (settingDefaultConfigName != "-1")
|
||||
{
|
||||
settingDropDownList.SelectedValue = selectedSettingValue;
|
||||
}
|
||||
|
||||
addSettingsContainer.RemoveAllChildren();
|
||||
addSettingsContainer.AddChild(categoryDropDownList);
|
||||
addSettingsContainer.AddChild(groupDropDownList);
|
||||
addSettingsContainer.AddChild(settingDropDownList);
|
||||
//addSettingsContainer.AddChild(addButton);
|
||||
}
|
||||
|
||||
private void OnItemSelected(object sender, EventArgs e)
|
||||
{
|
||||
MenuItem item = (MenuItem)sender;
|
||||
string[] valueArray = item.Value.Split(':');
|
||||
UiThread.RunOnIdle(() => PopulateAddSettingRow(Int32.Parse(valueArray[0]), Int32.Parse(valueArray[1]), valueArray[2]));
|
||||
}
|
||||
|
||||
private void LoadSettingsRows()
|
||||
{
|
||||
settingsRowContainer.RemoveScrollChildren();
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
foreach (KeyValuePair<String, SliceSetting> item in this.windowController.ActivePresetLayer.settingsDictionary)
|
||||
{
|
||||
OrganizerSettingsData settingData = SliceSettingsOrganizer.Instance.GetSettingsData(item.Key);
|
||||
|
||||
// Don't add row if there is no entry
|
||||
if (settingData != null && ActiveSliceSettings.Instance.ActiveSliceEngine().MapContains(settingData.SlicerConfigName))
|
||||
{
|
||||
FlowLayoutWidget row = GetSettingsRow(settingData, item.Value.Value);
|
||||
row.Padding = new BorderDouble(3, 3, 3, 6);
|
||||
settingsRowContainer.AddChild(row);
|
||||
HorizontalLine horizontalLine = new HorizontalLine();
|
||||
horizontalLine.BackgroundColor = ActiveTheme.Instance.SecondaryTextColor;
|
||||
settingsRowContainer.AddChild(horizontalLine);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private OrganizerSettingsData addRowSettingData;
|
||||
|
||||
private void OnSettingSelected(object sender, EventArgs e)
|
||||
{
|
||||
MenuItem item = (MenuItem)sender;
|
||||
string[] valueArray = item.Value.Split(':');
|
||||
string configName = valueArray[2];
|
||||
addRowSettingData = SliceSettingsOrganizer.Instance.GetSettingsData(configName);
|
||||
|
||||
AddSettingToPreset();
|
||||
}
|
||||
|
||||
private void AddSettingToPreset()
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
if (addRowSettingData != null)
|
||||
{
|
||||
if (!this.windowController.ActivePresetLayer.settingsDictionary.ContainsKey(addRowSettingData.SlicerConfigName))
|
||||
{
|
||||
SliceSetting sliceSetting = new SliceSetting();
|
||||
sliceSetting.Name = addRowSettingData.SlicerConfigName;
|
||||
sliceSetting.Value = ActiveSliceSettings.Instance.ActiveValue(addRowSettingData.SlicerConfigName); //populate with current
|
||||
sliceSetting.SettingsCollectionId = this.windowController.ActivePresetLayer.settingsCollectionData.Id;
|
||||
|
||||
this.windowController.ActivePresetLayer.settingsDictionary[addRowSettingData.SlicerConfigName] = sliceSetting;
|
||||
|
||||
OnSettingsChanged();
|
||||
}
|
||||
addRowSettingData = null;
|
||||
PopulateAddSettingRow(-1, -1, "-1");
|
||||
LoadSettingsRows();
|
||||
|
||||
duplicatePresetButton.Visible = false;
|
||||
exportPresetButton.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessageContainer.Visible = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void OnSettingsChanged()
|
||||
{
|
||||
SettingsChanged.CallEvents(this, null);
|
||||
|
|
@ -429,23 +253,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
private List<SliceSetting> SliceSettingsToRemoveOnCommit = new List<SliceSetting>();
|
||||
|
||||
private void RemoveSetting(string configName)
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
if (this.windowController.ActivePresetLayer.settingsDictionary.ContainsKey(configName))
|
||||
{
|
||||
SliceSetting item = this.windowController.ActivePresetLayer.settingsDictionary[configName];
|
||||
SliceSettingsToRemoveOnCommit.Add(item);
|
||||
|
||||
this.windowController.ActivePresetLayer.settingsDictionary.Remove(configName);
|
||||
OnSettingsChanged();
|
||||
}
|
||||
|
||||
LoadSettingsRows();
|
||||
});
|
||||
}
|
||||
|
||||
public RootedObjectEventHandler CommitStatusChanged = new RootedObjectEventHandler();
|
||||
public RootedObjectEventHandler SettingsChanged = new RootedObjectEventHandler();
|
||||
|
||||
|
|
@ -488,360 +295,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
private FlowLayoutWidget GetSettingsRow(OrganizerSettingsData settingData, string sliceSettingValue = null)
|
||||
{
|
||||
FlowLayoutWidget container = new FlowLayoutWidget();
|
||||
container.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
double minSettingNameWidth = 400;
|
||||
|
||||
if (ActiveSliceSettings.Instance.InBaseConfig(settingData.SlicerConfigName))
|
||||
{
|
||||
int intEditWidth = 60;
|
||||
int doubleEditWidth = 60;
|
||||
int vectorXYEditWidth = 60;
|
||||
int multiLineEditHeight = 60;
|
||||
|
||||
//Get the current value as a default value
|
||||
if (sliceSettingValue == null)
|
||||
{
|
||||
sliceSettingValue = ActiveSliceSettings.Instance.ActiveValue(settingData.SlicerConfigName);
|
||||
}
|
||||
|
||||
//Get the presentation name from the SettingNameLookup
|
||||
TextWidget settingName = new TextWidget(SettingNameLookup[settingData.SlicerConfigName], pointSize: 10);
|
||||
settingName.AutoExpandBoundsToText = false;
|
||||
settingName.EllipsisIfClipped = true;
|
||||
settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
settingName.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.Height);
|
||||
settingName.Width = minSettingNameWidth;
|
||||
|
||||
container.AddChild(settingName);
|
||||
|
||||
switch (settingData.DataEditType)
|
||||
{
|
||||
case OrganizerSettingsData.DataEditTypes.INT:
|
||||
{
|
||||
int currentValue = 0;
|
||||
int.TryParse(sliceSettingValue, out currentValue);
|
||||
MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++);
|
||||
intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); };
|
||||
container.AddChild(intEditWidget);
|
||||
container.AddChild(getSettingInfoData(settingData));
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.DOUBLE:
|
||||
{
|
||||
double currentValue = 0;
|
||||
double.TryParse(sliceSettingValue, out currentValue);
|
||||
MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++);
|
||||
doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); };
|
||||
container.AddChild(doubleEditWidget);
|
||||
container.AddChild(getSettingInfoData(settingData));
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.POSITIVE_DOUBLE:
|
||||
{
|
||||
double currentValue = 0;
|
||||
double.TryParse(sliceSettingValue, out currentValue);
|
||||
MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++);
|
||||
doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); };
|
||||
container.AddChild(doubleEditWidget);
|
||||
container.AddChild(getSettingInfoData(settingData));
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.OFFSET:
|
||||
{
|
||||
double currentValue = 0;
|
||||
double.TryParse(sliceSettingValue, out currentValue);
|
||||
MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++);
|
||||
doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); };
|
||||
container.AddChild(doubleEditWidget);
|
||||
container.AddChild(getSettingInfoData(settingData));
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT:
|
||||
{
|
||||
FlowLayoutWidget content = new FlowLayoutWidget();
|
||||
|
||||
MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: doubleEditWidth - 2, tabIndex: tabIndexForItem++);
|
||||
stringEdit.ActualTextEditWidget.EditComplete += (sender, e) =>
|
||||
{
|
||||
TextEditWidget textEditWidget = (TextEditWidget)sender;
|
||||
string text = textEditWidget.Text;
|
||||
text = text.Trim();
|
||||
bool isPercent = text.Contains("%");
|
||||
if (isPercent)
|
||||
{
|
||||
text = text.Substring(0, text.IndexOf("%"));
|
||||
}
|
||||
double result;
|
||||
double.TryParse(text, out result);
|
||||
text = result.ToString();
|
||||
if (isPercent)
|
||||
{
|
||||
text += "%";
|
||||
}
|
||||
textEditWidget.Text = text;
|
||||
SaveSetting(settingData.SlicerConfigName, textEditWidget.Text);
|
||||
};
|
||||
stringEdit.SelectAllOnFocus = true;
|
||||
|
||||
stringEdit.ActualTextEditWidget.InternalTextEditWidget.AllSelected += (sender, e) =>
|
||||
{
|
||||
// select evrything up to the % (if present)
|
||||
InternalTextEditWidget textEditWidget = (InternalTextEditWidget)sender;
|
||||
int percentIndex = textEditWidget.Text.IndexOf("%");
|
||||
if (percentIndex != -1)
|
||||
{
|
||||
textEditWidget.SetSelection(0, percentIndex - 1);
|
||||
}
|
||||
};
|
||||
|
||||
content.AddChild(stringEdit);
|
||||
content.AddChild(getSettingInfoData(settingData));
|
||||
|
||||
container.AddChild(content);
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.INT_OR_MM:
|
||||
{
|
||||
FlowLayoutWidget content = new FlowLayoutWidget();
|
||||
|
||||
MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: doubleEditWidth - 2, tabIndex: tabIndexForItem++);
|
||||
|
||||
string startingText = stringEdit.Text;
|
||||
stringEdit.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 = stringEdit.Text;
|
||||
}
|
||||
|
||||
SaveSetting(settingData.SlicerConfigName, textEditWidget.Text);
|
||||
|
||||
// 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;
|
||||
});
|
||||
}
|
||||
};
|
||||
stringEdit.SelectAllOnFocus = true;
|
||||
|
||||
stringEdit.ActualTextEditWidget.InternalTextEditWidget.AllSelected += (sender, e) =>
|
||||
{
|
||||
// select evrything up to the mm (if present)
|
||||
InternalTextEditWidget textEditWidget = (InternalTextEditWidget)sender;
|
||||
int mMIndex = textEditWidget.Text.IndexOf("mm");
|
||||
if (mMIndex != -1)
|
||||
{
|
||||
textEditWidget.SetSelection(0, mMIndex - 1);
|
||||
}
|
||||
};
|
||||
|
||||
content.AddChild(stringEdit);
|
||||
content.AddChild(getSettingInfoData(settingData));
|
||||
|
||||
container.AddChild(content);
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.CHECK_BOX:
|
||||
{
|
||||
CheckBox checkBoxWidget = new CheckBox("");
|
||||
checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom;
|
||||
checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
checkBoxWidget.Checked = (sliceSettingValue == "1");
|
||||
checkBoxWidget.CheckedStateChanged += (sender, e) =>
|
||||
{
|
||||
if (((CheckBox)sender).Checked)
|
||||
{
|
||||
SaveSetting(settingData.SlicerConfigName, "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveSetting(settingData.SlicerConfigName, "0");
|
||||
}
|
||||
};
|
||||
container.AddChild(checkBoxWidget);
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.STRING:
|
||||
{
|
||||
MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++);
|
||||
stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); };
|
||||
container.AddChild(stringEdit);
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT:
|
||||
{
|
||||
string convertedNewLines = sliceSettingValue.Replace("\\n", "\n");
|
||||
MHTextEditWidget stringEdit = new MHTextEditWidget(convertedNewLines, pointSize: 10, pixelWidth: 280, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++);
|
||||
stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); };
|
||||
container.AddChild(stringEdit);
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.LIST:
|
||||
{
|
||||
StyledDropDownList selectableOptions = new StyledDropDownList("None", Direction.Down);
|
||||
selectableOptions.Margin = new BorderDouble();
|
||||
|
||||
string[] listItems = settingData.ExtraSettings.Split(',');
|
||||
foreach (string listItem in listItems)
|
||||
{
|
||||
MenuItem newItem = selectableOptions.AddItem(listItem);
|
||||
if (newItem.Text == sliceSettingValue)
|
||||
{
|
||||
selectableOptions.SelectedLabel = sliceSettingValue;
|
||||
}
|
||||
|
||||
newItem.Selected += (sender, e) =>
|
||||
{
|
||||
MenuItem menuItem = ((MenuItem)sender);
|
||||
SaveSetting(settingData.SlicerConfigName, menuItem.Text);
|
||||
};
|
||||
}
|
||||
container.AddChild(selectableOptions);
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.HARDWARE_PRESENT:
|
||||
// this is not editable for a detail setting (quality or material)
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.VECTOR2:
|
||||
{
|
||||
string[] xyValueStrings = sliceSettingValue.Split(',');
|
||||
if (xyValueStrings.Length != 2)
|
||||
{
|
||||
xyValueStrings = new string[] { "0", "0" };
|
||||
}
|
||||
double currentXValue = 0;
|
||||
double.TryParse(xyValueStrings[0], out currentXValue);
|
||||
MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++);
|
||||
|
||||
double currentYValue = 0;
|
||||
double.TryParse(xyValueStrings[1], out currentYValue);
|
||||
MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++);
|
||||
{
|
||||
xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); };
|
||||
container.AddChild(xEditWidget);
|
||||
TextWidget xText = new TextWidget("x");
|
||||
xText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
xText.Margin = new BorderDouble(5, 0);
|
||||
container.AddChild(xText);
|
||||
}
|
||||
{
|
||||
yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); };
|
||||
container.AddChild(yEditWidget);
|
||||
TextWidget yText = new TextWidget("y");
|
||||
yText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
yText.Margin = new BorderDouble(5, 0);
|
||||
container.AddChild(yText);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case OrganizerSettingsData.DataEditTypes.OFFSET2:
|
||||
{
|
||||
string[] xyValueStrings = sliceSettingValue.Split('x');
|
||||
if (xyValueStrings.Length != 2)
|
||||
{
|
||||
xyValueStrings = new string[] { "0", "0" };
|
||||
}
|
||||
double currentXValue = 0;
|
||||
double.TryParse(xyValueStrings[0], out currentXValue);
|
||||
MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++);
|
||||
|
||||
double currentYValue = 0;
|
||||
double.TryParse(xyValueStrings[1], out currentYValue);
|
||||
MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++);
|
||||
{
|
||||
xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); };
|
||||
container.AddChild(xEditWidget);
|
||||
TextWidget xText = new TextWidget("x");
|
||||
xText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
xText.Margin = new BorderDouble(5, 0);
|
||||
container.AddChild(xText);
|
||||
}
|
||||
{
|
||||
yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); };
|
||||
container.AddChild(yEditWidget);
|
||||
TextWidget yText = new TextWidget("y");
|
||||
yText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
yText.Margin = new BorderDouble(5, 0);
|
||||
container.AddChild(yText);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString()));
|
||||
missingSetting.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
missingSetting.BackgroundColor = RGBA_Bytes.Red;
|
||||
container.AddChild(missingSetting);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // the setting we think we are adding is not in the config.ini it may have been depricated
|
||||
{
|
||||
TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName));
|
||||
settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y);
|
||||
container.AddChild(settingName);
|
||||
container.BackgroundColor = RGBA_Bytes.Red;
|
||||
}
|
||||
container.AddChild(new HorizontalSpacer());
|
||||
Button removeLink = linkButtonFactory.Generate("remove");
|
||||
removeLink.Click += (sender, e) =>
|
||||
{
|
||||
RemoveSetting(settingData.SlicerConfigName);
|
||||
};
|
||||
removeLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
container.AddChild(removeLink);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private TextWidget getSettingInfoData(OrganizerSettingsData settingData)
|
||||
{
|
||||
string extraSettings = settingData.ExtraSettings;
|
||||
|
|
@ -944,53 +397,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
private string configFileExtension = "slice";
|
||||
|
||||
private void importPresets_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
OpenFileDialogParams openParams = new OpenFileDialogParams("Load Slice Preset|*.slice;*.ini");
|
||||
openParams.ActionButtonLabel = "Load Slice Preset";
|
||||
openParams.Title = "MatterControl: Select A File";
|
||||
|
||||
FileDialog.OpenFileDialog(openParams, onLoadPreset);
|
||||
}
|
||||
|
||||
private void onLoadPreset(OpenFileDialogParams openParams)
|
||||
{
|
||||
if (openParams.FileNames != null)
|
||||
{
|
||||
Dictionary<string, SliceSetting> settingsDictionary = new Dictionary<string, SliceSetting>();
|
||||
try
|
||||
{
|
||||
if (File.Exists(openParams.FileName))
|
||||
{
|
||||
string[] lines = System.IO.File.ReadAllLines(openParams.FileName);
|
||||
foreach (string line in lines)
|
||||
{
|
||||
//Ignore commented lines
|
||||
if (!line.StartsWith("#"))
|
||||
{
|
||||
string[] settingLine = line.Split('=');
|
||||
string keyName = settingLine[0].Trim();
|
||||
string settingDefaultValue = settingLine[1].Trim();
|
||||
|
||||
SliceSetting sliceSetting = new SliceSetting();
|
||||
sliceSetting.Name = keyName;
|
||||
sliceSetting.Value = settingDefaultValue;
|
||||
sliceSetting.SettingsCollectionId = windowController.ActivePresetLayer.settingsCollectionData.Id;
|
||||
|
||||
settingsDictionary.Add(keyName, sliceSetting);
|
||||
}
|
||||
}
|
||||
windowController.ActivePresetLayer.settingsDictionary = settingsDictionary;
|
||||
LoadSettingsRows();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Error loading configuration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void exportPresets_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
UiThread.RunOnIdle(SaveAs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue