Merge branch 'master' of https://github.com/MatterHackers/MatterControl
This commit is contained in:
commit
76012aeef9
10 changed files with 159 additions and 94 deletions
|
|
@ -35,6 +35,7 @@ using MatterHackers.MatterControl.PrinterCommunication;
|
||||||
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
||||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.ActionBar
|
namespace MatterHackers.MatterControl.ActionBar
|
||||||
|
|
@ -133,19 +134,17 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
{
|
{
|
||||||
HAnchor = HAnchor.ParentLeftRight,
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
};
|
};
|
||||||
printerSelector = new PrinterSelector();
|
|
||||||
printerSelector.HAnchor = HAnchor.ParentLeftRight;
|
int rightMarginForWideScreenMode = ApplicationController.Instance.WidescreenMode ? 6 : 0;
|
||||||
printerSelector.Cursor = Cursors.Hand;
|
printerSelector = new PrinterSelector()
|
||||||
|
{
|
||||||
|
HAnchor = HAnchor.ParentLeftRight,
|
||||||
|
Cursor = Cursors.Hand,
|
||||||
|
Margin = new BorderDouble(0, 6, rightMarginForWideScreenMode, 3)
|
||||||
|
};
|
||||||
printerSelector.AddPrinter += (s, e) => WizardWindow.Show();
|
printerSelector.AddPrinter += (s, e) => WizardWindow.Show();
|
||||||
if (ApplicationController.Instance.WidescreenMode)
|
|
||||||
{
|
|
||||||
printerSelector.Margin = new BorderDouble(0, 6, 0, 3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printerSelector.Margin = new BorderDouble(0, 6, 6, 3);
|
|
||||||
}
|
|
||||||
printerSelectorAndEditButton.AddChild(printerSelector);
|
printerSelectorAndEditButton.AddChild(printerSelector);
|
||||||
|
|
||||||
Button editButton = TextImageButtonFactory.GetThemedEditButton();
|
Button editButton = TextImageButtonFactory.GetThemedEditButton();
|
||||||
editButton.VAnchor = VAnchor.ParentCenter;
|
editButton.VAnchor = VAnchor.ParentCenter;
|
||||||
editButton.Click += UiNavigation.GoToEditPrinter_Click;
|
editButton.Click += UiNavigation.GoToEditPrinter_Click;
|
||||||
|
|
@ -153,7 +152,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
this.AddChild(printerSelectorAndEditButton);
|
this.AddChild(printerSelectorAndEditButton);
|
||||||
|
|
||||||
this.AddChild(resetConnectionButton);
|
this.AddChild(resetConnectionButton);
|
||||||
//this.AddChild(CreateOptionsMenu());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddHandlers()
|
protected override void AddHandlers()
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
||||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||||
using MatterHackers.VectorMath;
|
using MatterHackers.VectorMath;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl
|
namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
|
|
@ -44,21 +45,16 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
public event EventHandler AddPrinter;
|
public event EventHandler AddPrinter;
|
||||||
|
|
||||||
|
private EventHandler unregisterEvents;
|
||||||
|
|
||||||
public PrinterSelector() : base("Printers".Localize() + "... ", useLeftIcons: true)
|
public PrinterSelector() : base("Printers".Localize() + "... ", useLeftIcons: true)
|
||||||
{
|
{
|
||||||
//Add the menu items to the menu itself
|
Rebuild();
|
||||||
foreach (var printer in ActiveSliceSettings.ProfileData.Profiles)
|
|
||||||
{
|
|
||||||
this.AddItem(printer.Name, printer.Id.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ActiveSliceSettings.Instance != null)
|
this.AddItem(
|
||||||
{
|
StaticData.Instance.LoadIcon("icon_plus.png", 32, 32),
|
||||||
this.SelectedValue = ActiveSliceSettings.Instance.ID;
|
"Add New Printer...",
|
||||||
}
|
"new");
|
||||||
|
|
||||||
ImageBuffer plusImage = StaticData.Instance.LoadIcon("icon_plus.png", 32, 32);
|
|
||||||
this.AddItem(plusImage, "Add New Printer...", "new");
|
|
||||||
|
|
||||||
this.SelectionChanged += (s, e) =>
|
this.SelectionChanged += (s, e) =>
|
||||||
{
|
{
|
||||||
|
|
@ -75,6 +71,46 @@ namespace MatterHackers.MatterControl
|
||||||
ActiveSliceSettings.SwitchToProfile(printerID);
|
ActiveSliceSettings.SwitchToProfile(printerID);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SliceSettingsWidget.SettingChanged.RegisterEvent(SettingChanged, ref unregisterEvents);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Rebuild()
|
||||||
|
{
|
||||||
|
this.MenuItems.Clear();
|
||||||
|
|
||||||
|
//Add the menu items to the menu itself
|
||||||
|
foreach (var printer in ActiveSliceSettings.ProfileData.Profiles)
|
||||||
|
{
|
||||||
|
this.AddItem(printer.Name, printer.Id.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ActiveSliceSettings.Instance != null)
|
||||||
|
{
|
||||||
|
this.SelectedValue = ActiveSliceSettings.Instance.ID;
|
||||||
|
this.mainControlText.Text = ActiveSliceSettings.Instance.Name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SettingChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string settingsName = (e as StringEventArgs)?.Data;
|
||||||
|
if (settingsName != null && settingsName == "MatterControl.PrinterName")
|
||||||
|
{
|
||||||
|
var profileInfo = ActiveSliceSettings.ProfileData.Profiles.Where(p => p.Id == ActiveSliceSettings.Instance.ID).FirstOrDefault();
|
||||||
|
if (profileInfo != null)
|
||||||
|
{
|
||||||
|
profileInfo.Name = ActiveSliceSettings.Instance.Name();
|
||||||
|
}
|
||||||
|
|
||||||
|
Rebuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnClosed(EventArgs e)
|
||||||
|
{
|
||||||
|
unregisterEvents?.Invoke(this, null);
|
||||||
|
base.OnClosed(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +151,7 @@ namespace MatterHackers.MatterControl.DataStorage.ClassicDB
|
||||||
foreach (var collection in collections)
|
foreach (var collection in collections)
|
||||||
{
|
{
|
||||||
var settingsDictionary = LoadSettings(collection);
|
var settingsDictionary = LoadSettings(collection);
|
||||||
layeredProfile.MaterialLayers[collection.Name] = new SettingsLayer(settingsDictionary);
|
layeredProfile.MaterialLayers.Add(new SettingsLayer(settingsDictionary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ namespace MatterHackers.MatterControl.DataStorage.ClassicDB
|
||||||
foreach (var collection in collections)
|
foreach (var collection in collections)
|
||||||
{
|
{
|
||||||
var settingsDictionary = LoadSettings(collection);
|
var settingsDictionary = LoadSettings(collection);
|
||||||
layeredProfile.QualityLayers[collection.Name] = new SettingsLayer(settingsDictionary);
|
layeredProfile.QualityLayers.Add(new SettingsLayer(settingsDictionary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace MatterHackers.MatterControl.Queue.OptionsMenu
|
||||||
new PrintItemAction()
|
new PrintItemAction()
|
||||||
{
|
{
|
||||||
SingleItemOnly = false,
|
SingleItemOnly = false,
|
||||||
Title = "Create Combine...",
|
Title = "Merge...",
|
||||||
Action = (items, queueDataWidget) =>
|
Action = (items, queueDataWidget) =>
|
||||||
{
|
{
|
||||||
List<QueueRowItem> allRowItems = new List<QueueRowItem>(items);
|
List<QueueRowItem> allRowItems = new List<QueueRowItem>(items);
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static void AcquireNewProfile(string make, string model, string printerName)
|
internal static void AcquireNewProfile(string make, string model, string printerName)
|
||||||
{
|
{
|
||||||
string guid = Guid.NewGuid().ToString();
|
string guid = Guid.NewGuid().ToString();
|
||||||
|
|
@ -292,15 +291,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy OemProfile presets into user layers
|
// Copy OemProfile presets into user layers
|
||||||
foreach(var layer in layeredProfile.OemProfile.MaterialLayers)
|
layeredProfile.MaterialLayers.AddRange(layeredProfile.OemProfile.MaterialLayers);
|
||||||
{
|
layeredProfile.QualityLayers.AddRange(layeredProfile.OemProfile.QualityLayers);
|
||||||
layeredProfile.MaterialLayers[layer.Key] = layer.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var layer in layeredProfile.OemProfile.QualityLayers)
|
layeredProfile.OemProfile.MaterialLayers.Clear();
|
||||||
{
|
layeredProfile.OemProfile.QualityLayers.Clear();
|
||||||
layeredProfile.QualityLayers[layer.Key] = layer.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
layeredProfile.Save();
|
layeredProfile.Save();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,27 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
public static class ProfileMigrations
|
public static class ProfileMigrations
|
||||||
{
|
{
|
||||||
public static string MigrateDocument(string filePath, int fromVersion)
|
public static string MigrateDocument(string filePath, int fromVersion = -1)
|
||||||
{
|
{
|
||||||
var jObject = JObject.Parse(File.ReadAllText(filePath));
|
var jObject = JObject.Parse(File.ReadAllText(filePath));
|
||||||
|
|
||||||
|
if (fromVersion < 201606081)
|
||||||
|
{
|
||||||
|
JObject materialLayers, qualityLayers;
|
||||||
|
|
||||||
|
materialLayers = jObject["MaterialLayers"] as JObject;
|
||||||
|
jObject["MaterialLayers"] = new JArray(materialLayers.Properties().ToList().Select(layer => layer.Value).ToArray());
|
||||||
|
|
||||||
|
qualityLayers = jObject["QualityLayers"] as JObject;
|
||||||
|
jObject["QualityLayers"] = new JArray(qualityLayers.Properties().ToList().Select(layer => layer.Value).ToArray());
|
||||||
|
|
||||||
|
var oemProfile = jObject["OemProfile"] as JObject;
|
||||||
|
oemProfile.Property("MaterialLayers").Remove();
|
||||||
|
oemProfile.Property("QualityLayers").Remove();
|
||||||
|
|
||||||
|
jObject["DocumentVersion"] = 201606081;
|
||||||
|
}
|
||||||
|
|
||||||
if (fromVersion < 201605131)
|
if (fromVersion < 201605131)
|
||||||
{
|
{
|
||||||
var materialLayers = jObject["MaterialLayers"] as JObject;
|
var materialLayers = jObject["MaterialLayers"] as JObject;
|
||||||
|
|
@ -109,7 +126,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
public string ID { get; set; }
|
public string ID { get; set; }
|
||||||
|
|
||||||
public static int LatestVersion { get; } = 201605132;
|
// Latest version should be 2016|06|08|1
|
||||||
|
// Year|month|day|versionForDay (to support multiple revisions on a given day)
|
||||||
|
public static int LatestVersion { get; } = 201606081;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
internal SettingsLayer QualityLayer { get; private set; }
|
internal SettingsLayer QualityLayer { get; private set; }
|
||||||
|
|
@ -134,33 +153,19 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
public OemProfile OemProfile { get; set; }
|
public OemProfile OemProfile { get; set; }
|
||||||
|
|
||||||
internal SettingsLayer GetMaterialLayer(string key)
|
internal SettingsLayer GetMaterialLayer(string layerID)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(key))
|
if (string.IsNullOrEmpty(layerID))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the first matching layer in either the user or the OEM layers
|
return MaterialLayers.Where(layer => layer.ID == layerID).FirstOrDefault();
|
||||||
SettingsLayer layer = null;
|
|
||||||
if (!MaterialLayers.TryGetValue(key, out layer))
|
|
||||||
{
|
|
||||||
OemProfile.MaterialLayers.TryGetValue(key, out layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return layer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal SettingsLayer GetQualityLayer(string key)
|
internal SettingsLayer GetQualityLayer(string layerID)
|
||||||
{
|
{
|
||||||
// Find the first matching layer in either the user or the OEM layers
|
return QualityLayers.Where(layer => layer.ID == layerID).FirstOrDefault();
|
||||||
SettingsLayer layer = null;
|
|
||||||
if (key != null && !QualityLayers.TryGetValue(key, out layer))
|
|
||||||
{
|
|
||||||
OemProfile.QualityLayers.TryGetValue(key, out layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return layer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ActiveMaterialKey
|
public string ActiveMaterialKey
|
||||||
|
|
@ -187,7 +192,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
SetActiveValue("MatterControl.ActiveQualityKey", value);
|
SetActiveValue("MatterControl.ActiveQualityKey", value);
|
||||||
QualityLayer = GetQualityLayer(value);
|
QualityLayer = GetQualityLayer(value);
|
||||||
|
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -248,15 +252,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
internal static LayeredProfile LoadFile(string printerProfilePath)
|
internal static LayeredProfile LoadFile(string printerProfilePath)
|
||||||
{
|
{
|
||||||
var layeredProfile = JsonConvert.DeserializeObject<LayeredProfile>(File.ReadAllText(printerProfilePath));
|
var jObject = JObject.Parse(File.ReadAllText(printerProfilePath));
|
||||||
if (layeredProfile.DocumentVersion < LayeredProfile.LatestVersion)
|
int documentVersion = (int) jObject?.GetValue("DocumentVersion")?.Value<int>();
|
||||||
{
|
|
||||||
printerProfilePath = ProfileMigrations.MigrateDocument(printerProfilePath, layeredProfile.DocumentVersion);
|
|
||||||
|
|
||||||
// Reload the document with the new schema
|
if (documentVersion < LayeredProfile.LatestVersion)
|
||||||
layeredProfile = JsonConvert.DeserializeObject<LayeredProfile>(File.ReadAllText(printerProfilePath));
|
{
|
||||||
|
printerProfilePath = ProfileMigrations.MigrateDocument(printerProfilePath, documentVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reload the document with the new schema
|
||||||
|
var layeredProfile = JsonConvert.DeserializeObject<LayeredProfile>(File.ReadAllText(printerProfilePath));
|
||||||
layeredProfile.DocumentPath = printerProfilePath;
|
layeredProfile.DocumentPath = printerProfilePath;
|
||||||
|
|
||||||
return layeredProfile;
|
return layeredProfile;
|
||||||
|
|
@ -266,13 +271,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should contain both user created and oem specified material layers
|
/// Should contain both user created and oem specified material layers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, SettingsLayer> MaterialLayers { get; } = new Dictionary<string, SettingsLayer>();
|
public List<SettingsLayer> MaterialLayers { get; } = new List<SettingsLayer>();
|
||||||
|
|
||||||
// TODO: Hookup OEM layers
|
// TODO: Hookup OEM layers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should contain both user created and oem specified quality layers
|
/// Should contain both user created and oem specified quality layers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, SettingsLayer> QualityLayers { get; } = new Dictionary<string, SettingsLayer>();
|
public List<SettingsLayer> QualityLayers { get; } = new List<SettingsLayer>();
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
///Returns the settings value at the 'top' of the stack
|
///Returns the settings value at the 'top' of the stack
|
||||||
|
|
@ -376,11 +381,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of Material presets from OEM
|
/// List of Material presets from OEM
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, SettingsLayer> MaterialLayers { get; } = new Dictionary<string, SettingsLayer>();
|
public List<SettingsLayer> MaterialLayers { get; } = new List<SettingsLayer>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of Quality presets from OEM
|
/// List of Quality presets from OEM
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, SettingsLayer> QualityLayers { get; } = new Dictionary<string, SettingsLayer>();
|
public List<SettingsLayer> QualityLayers { get; } = new List<SettingsLayer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,9 +105,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
// Commit
|
// Commit
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, SettingsLayer> MaterialLayers => layeredProfile.MaterialLayers;
|
public List<SettingsLayer> MaterialLayers => layeredProfile.MaterialLayers;
|
||||||
|
|
||||||
public Dictionary<string, SettingsLayer> QualityLayers => layeredProfile.QualityLayers;
|
public List<SettingsLayer> QualityLayers => layeredProfile.QualityLayers;
|
||||||
|
|
||||||
public class SettingsConverter
|
public class SettingsConverter
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -102,13 +102,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
if (ApplicationController.Instance.EditMaterialPresetsWindow == null)
|
if (ApplicationController.Instance.EditMaterialPresetsWindow == null)
|
||||||
{
|
{
|
||||||
string presetsKey = ActiveSliceSettings.Instance.MaterialPresetKey(extruderIndex);
|
string presetsID = ActiveSliceSettings.Instance.MaterialPresetKey(extruderIndex);
|
||||||
if (string.IsNullOrEmpty(presetsKey))
|
if (string.IsNullOrEmpty(presetsID))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.MaterialLayers, presetsKey)
|
var layerToEdit = ActiveSliceSettings.Instance.MaterialLayers.Where(layer => layer.ID == presetsID).FirstOrDefault();
|
||||||
|
|
||||||
|
var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.MaterialLayers, layerToEdit)
|
||||||
{
|
{
|
||||||
LayerType = NamedSettingsLayers.Material,
|
LayerType = NamedSettingsLayers.Material,
|
||||||
SetAsActive = (materialKey) =>
|
SetAsActive = (materialKey) =>
|
||||||
|
|
@ -136,13 +138,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
if (ApplicationController.Instance.EditQualityPresetsWindow == null)
|
if (ApplicationController.Instance.EditQualityPresetsWindow == null)
|
||||||
{
|
{
|
||||||
string presetsKey = ActiveSliceSettings.Instance.ActiveQualityKey;
|
string presetsID = ActiveSliceSettings.Instance.ActiveQualityKey;
|
||||||
if (string.IsNullOrEmpty(presetsKey))
|
if (string.IsNullOrEmpty(presetsID))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.QualityLayers, presetsKey)
|
var layerToEdit = ActiveSliceSettings.Instance.QualityLayers.Where(layer => layer.ID == presetsID).FirstOrDefault();
|
||||||
|
|
||||||
|
var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.QualityLayers, layerToEdit)
|
||||||
{
|
{
|
||||||
LayerType = NamedSettingsLayers.Quality,
|
LayerType = NamedSettingsLayers.Quality,
|
||||||
SetAsActive = (qualityKey) => ActiveSliceSettings.Instance.ActiveQualityKey = qualityKey
|
SetAsActive = (qualityKey) => ActiveSliceSettings.Instance.ActiveQualityKey = qualityKey
|
||||||
|
|
@ -212,12 +216,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
var listSource = (layerType == NamedSettingsLayers.Material) ? ActiveSliceSettings.Instance.MaterialLayers : ActiveSliceSettings.Instance.QualityLayers;
|
var listSource = (layerType == NamedSettingsLayers.Material) ? ActiveSliceSettings.Instance.MaterialLayers : ActiveSliceSettings.Instance.QualityLayers;
|
||||||
foreach (var layer in listSource)
|
foreach (var layer in listSource)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(layer.Value.Name))
|
MenuItem menuItem = dropDownList.AddItem(layer.Name, layer.ID);
|
||||||
{
|
|
||||||
layer.Value.Name = layer.Key;
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuItem menuItem = dropDownList.AddItem(layer.Value.Name, layer.Value.ID);
|
|
||||||
menuItem.Selected += MenuItem_Selected;
|
menuItem.Selected += MenuItem_Selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,13 +227,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
if (layerType == NamedSettingsLayers.Quality)
|
if (layerType == NamedSettingsLayers.Quality)
|
||||||
{
|
{
|
||||||
newLayer.Name = "Quality" + ActiveSliceSettings.Instance.QualityLayers.Count;
|
newLayer.Name = "Quality" + ActiveSliceSettings.Instance.QualityLayers.Count;
|
||||||
ActiveSliceSettings.Instance.QualityLayers[newLayer.Name] = newLayer;
|
ActiveSliceSettings.Instance.QualityLayers.Add(newLayer);
|
||||||
ActiveSliceSettings.Instance.ActiveQualityKey = newLayer.ID;
|
ActiveSliceSettings.Instance.ActiveQualityKey = newLayer.ID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newLayer.Name = "Material" + ActiveSliceSettings.Instance.MaterialLayers.Count;
|
newLayer.Name = "Material" + ActiveSliceSettings.Instance.MaterialLayers.Count;
|
||||||
ActiveSliceSettings.Instance.MaterialLayers[newLayer.Name] = newLayer;
|
ActiveSliceSettings.Instance.MaterialLayers.Add(newLayer);
|
||||||
ActiveSliceSettings.Instance.ActiveMaterialKey = newLayer.ID;
|
ActiveSliceSettings.Instance.ActiveMaterialKey = newLayer.ID;
|
||||||
ActiveSliceSettings.Instance.SetMaterialPreset(this.extruderIndex, newLayer.Name);
|
ActiveSliceSettings.Instance.SetMaterialPreset(this.extruderIndex, newLayer.Name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,18 +43,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
public class PresetsContext
|
public class PresetsContext
|
||||||
{
|
{
|
||||||
public Dictionary<string, SettingsLayer> PresetsDictionary { get; }
|
public List<SettingsLayer> PresetLayers { get; }
|
||||||
public SettingsLayer PersistenceLayer { get; set; }
|
public SettingsLayer PersistenceLayer { get; set; }
|
||||||
public Action<string> SetAsActive { get; set; }
|
public Action<string> SetAsActive { get; set; }
|
||||||
public NamedSettingsLayers LayerType { get; set; }
|
public NamedSettingsLayers LayerType { get; set; }
|
||||||
|
|
||||||
private string presetsKey;
|
public PresetsContext(List<SettingsLayer> settingsLayers, SettingsLayer activeLayer)
|
||||||
|
|
||||||
public PresetsContext(Dictionary<string, SettingsLayer> parentDictionary, string presetsKey)
|
|
||||||
{
|
{
|
||||||
this.presetsKey = presetsKey;
|
this.PersistenceLayer = activeLayer;
|
||||||
this.PersistenceLayer = parentDictionary[presetsKey];
|
this.PresetLayers = settingsLayers;
|
||||||
this.PresetsDictionary = parentDictionary;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,11 +195,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
string sanitizedName = numberMatch.Replace(presetNameInput.Text, "").Trim();
|
string sanitizedName = numberMatch.Replace(presetNameInput.Text, "").Trim();
|
||||||
string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetsDictionary.Values.Select(preset => preset.Name));
|
string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault("MatterControl.LayerName")));
|
||||||
|
|
||||||
var clonedLayer = presetsContext.PersistenceLayer.Clone();
|
var clonedLayer = presetsContext.PersistenceLayer.Clone();
|
||||||
clonedLayer.Name = newProfileName;
|
clonedLayer.Name = newProfileName;
|
||||||
presetsContext.PresetsDictionary[clonedLayer.ID] = clonedLayer;
|
presetsContext.PresetLayers.Add(clonedLayer);
|
||||||
|
|
||||||
presetsContext.SetAsActive(clonedLayer.ID);
|
presetsContext.SetAsActive(clonedLayer.ID);
|
||||||
presetsContext.PersistenceLayer = clonedLayer;
|
presetsContext.PersistenceLayer = clonedLayer;
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,22 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
private bool RestoreAllSettingsMenu_Click()
|
private bool RestoreAllSettingsMenu_Click()
|
||||||
{
|
{
|
||||||
|
string warningMessage = "Resetting to default values will remove your current overrides and restore your original printer settings.\r\nAre you sure you want to continue?";
|
||||||
|
StyledMessageBox.ShowMessageBox(
|
||||||
|
revertSettings =>
|
||||||
|
{
|
||||||
|
if (revertSettings)
|
||||||
|
{
|
||||||
|
// TODO: We should offer to export the settings before the purge
|
||||||
|
ActiveSliceSettings.Instance.UserLayer.Clear();
|
||||||
|
ActiveSliceSettings.Instance.SaveChanges();
|
||||||
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
warningMessage.Localize(),
|
||||||
|
"Revert Settings".Localize(),
|
||||||
|
StyledMessageBox.MessageType.YES_NO);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,7 +148,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
{ "Import".Localize(), ImportSettingsMenu_Click },
|
{ "Import".Localize(), ImportSettingsMenu_Click },
|
||||||
{ "Export".Localize(), ExportSettingsMenu_Click },
|
{ "Export".Localize(), ExportSettingsMenu_Click },
|
||||||
{ "Restore All".Localize(), RestoreAllSettingsMenu_Click },
|
{ "Reset to defaults".Localize(), RestoreAllSettingsMenu_Click },
|
||||||
|
#if DEBUG
|
||||||
|
{ "Bake Overrides".Localize(), BakeOverrides_Click },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//Add the menu items to the menu itself
|
//Add the menu items to the menu itself
|
||||||
|
|
@ -142,6 +161,22 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool BakeOverrides_Click()
|
||||||
|
{
|
||||||
|
var activeSettings = ActiveSliceSettings.Instance;
|
||||||
|
foreach(var keyValue in activeSettings.UserLayer)
|
||||||
|
{
|
||||||
|
activeSettings.OemLayer[keyValue.Key] = keyValue.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
activeSettings.UserLayer.Clear();
|
||||||
|
activeSettings.SaveChanges();
|
||||||
|
|
||||||
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void SettingsDetail_SelectionChanged(object sender, EventArgs e)
|
private void SettingsDetail_SelectionChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
RebuildSlicerSettings(null, null);
|
RebuildSlicerSettings(null, null);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue