Removing PrinterCommunication from ActiveMaterialKey

issue: MatterHackers/MCCentral#4631
Remove PrinterConnection dependency in PrinterSettings.SetMaterialPreset
This commit is contained in:
Lars Brubaker 2018-11-26 14:23:03 -08:00
parent 5b5cfdff62
commit 04211ec613
3 changed files with 11 additions and 30 deletions

View file

@ -339,37 +339,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
internal set
{
SetMaterialPreset(0, value);
if (MaterialSettingsKeys.Count == 0 || value != MaterialSettingsKeys[0])
{
MaterialSettingsKeys.Clear();
MaterialSettingsKeys.Add(value);
MaterialLayer = GetMaterialLayer(value);
this.OnMaterialPresetChanged();
Save();
}
}
}
private void SetMaterialPreset(int extruderIndex, string materialKey)
{
if (extruderIndex >= PrinterCommunication.PrinterConnection.MAX_EXTRUDERS)
{
throw new ArgumentOutOfRangeException("Requested extruder index is outside of bounds: " + extruderIndex);
}
// TODO: This should really be in PrinterProfile and should be run when the extruder count changes
if (MaterialSettingsKeys.Count <= extruderIndex)
{
var resizedArray = new string[extruderIndex + 1];
MaterialSettingsKeys.CopyTo(resizedArray);
MaterialSettingsKeys = new List<string>(resizedArray);
}
MaterialSettingsKeys[extruderIndex] = materialKey;
if (extruderIndex == 0)
{
MaterialLayer = GetMaterialLayer(materialKey);
this.OnMaterialPresetChanged();
}
Save();
}
public List<string> MaterialSettingsKeys { get; set; } = new List<string>();
[JsonIgnore]

@ -1 +1 @@
Subproject commit 4be37568691a3913b3ce077405ee9efa0f20f680
Subproject commit c7442baf66d96135440e11a27070fd90fbb56db5

@ -1 +1 @@
Subproject commit eb71dfbdb9e22dc9603efe3fa551cc2a8bec8119
Subproject commit 16a8ca59abf20d4a07e829a1163130adfd58b0a8