Clamp extruder_count

- Issue MatterHackers/MCCentral#2616
Add extruder count constraints
This commit is contained in:
John Lewin 2018-01-13 11:38:46 -08:00
parent 3cc73d0933
commit 8964c59919
3 changed files with 21 additions and 4 deletions

View file

@ -469,7 +469,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
switch (settingData.DataEditType)
{
case SliceSettingData.DataEditTypes.INT:
uiField = new IntField();
var intField = new IntField();
uiField = intField;
if (settingData.SlicerConfigName == "extruder_count")
{
intField.MaxValue = 4;
intField.MinValue = 0;
}
break;
case SliceSettingData.DataEditTypes.DOUBLE:

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2017, Lars Brubaker, John Lewin
Copyright (c) 2018, Lars Brubaker, John Lewin
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
@ -34,10 +35,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
private int intValue;
public int MinValue { get; set; } = int.MinValue;
public int MaxValue { get; set; } = int.MaxValue;
protected override string ConvertValue(string newValue)
{
decimal.TryParse(newValue, out decimal currentValue);
intValue = (int)currentValue;
// Clamp to range
intValue = Math.Min((int)currentValue, this.MaxValue);
intValue = Math.Max(intValue, this.MinValue);
return intValue.ToString();
}

@ -1 +1 @@
Subproject commit 62ffc915f217c8a2232810fb4f567f9b4b1009f3
Subproject commit e28826c49a73ed885dd459b4631f021d6d26406c