Merge branch '1.7'
# Conflicts: # StaticData/SliceSettings/Properties.json
This commit is contained in:
commit
0b6c4e94f1
83 changed files with 2568 additions and 673 deletions
|
|
@ -98,7 +98,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
static ActiveSliceSettings()
|
||||
{
|
||||
string propertiesFileContents = StaticData.Instance.ReadAllText(Path.Combine("SliceSettings", "Properties.json"));
|
||||
SettingsData = JsonConvert.DeserializeObject<List<SliceSettingData>>(propertiesFileContents) as List<SliceSettingData>;
|
||||
SettingsData = JsonConvert.DeserializeObject<List<SliceSettingData>>(propertiesFileContents);
|
||||
|
||||
activeInstance = PrinterSettings.Empty;
|
||||
|
||||
settingsByName = new Dictionary<string, SliceSettingData>();
|
||||
foreach (var settingsData in ActiveSliceSettings.SettingsData)
|
||||
|
|
|
|||
|
|
@ -531,6 +531,44 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
return "";
|
||||
}
|
||||
|
||||
public Tuple<string, string> GetValueAndLayerName(string sliceSetting, IEnumerable<PrinterSettingsLayer> layerCascade = null)
|
||||
{
|
||||
if (layerCascade == null)
|
||||
{
|
||||
layerCascade = defaultLayerCascade;
|
||||
}
|
||||
|
||||
foreach (PrinterSettingsLayer layer in layerCascade)
|
||||
{
|
||||
string value;
|
||||
if (layer.TryGetValue(sliceSetting, out value))
|
||||
{
|
||||
string layerName = "User";
|
||||
|
||||
if (layer == this.BaseLayer)
|
||||
{
|
||||
layerName = "Base";
|
||||
}
|
||||
else if (layer == this.OemLayer)
|
||||
{
|
||||
layerName = "Oem";
|
||||
}
|
||||
else if (layer == this.MaterialLayer)
|
||||
{
|
||||
layerName = "Material";
|
||||
}
|
||||
else if (layer == this.QualityLayer)
|
||||
{
|
||||
layerName = "Quality";
|
||||
}
|
||||
|
||||
return new Tuple<string, string>(value, layerName);
|
||||
}
|
||||
}
|
||||
|
||||
return new Tuple<string, string>("", "");
|
||||
}
|
||||
|
||||
public bool Contains(string sliceSetting, IEnumerable<PrinterSettingsLayer> layerCascade = null)
|
||||
{
|
||||
if (layerCascade == null)
|
||||
|
|
@ -550,7 +588,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
[JsonIgnore]
|
||||
public PrinterSettingsLayer BaseLayer { get; set; } = SliceSettingsOrganizer.Instance.GetDefaultSettings();
|
||||
|
||||
private IEnumerable<PrinterSettingsLayer> defaultLayerCascade
|
||||
internal IEnumerable<PrinterSettingsLayer> defaultLayerCascade
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -700,14 +738,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
return (T)(object)(GetValue<double>(SettingsKey.layer_height) * ratio);
|
||||
}
|
||||
else if (settingsKey == SettingsKey.first_layer_extrusion_width)
|
||||
else if (settingsKey == SettingsKey.first_layer_extrusion_width
|
||||
|| settingsKey == SettingsKey.external_perimeter_extrusion_width)
|
||||
{
|
||||
return (T)(object)(GetValue<double>(SettingsKey.nozzle_diameter) * ratio);
|
||||
}
|
||||
|
||||
return (T)(object)(ratio);
|
||||
}
|
||||
else if (settingsKey == SettingsKey.first_layer_extrusion_width)
|
||||
else if (settingsKey == SettingsKey.first_layer_extrusion_width
|
||||
|| settingsKey == SettingsKey.external_perimeter_extrusion_width)
|
||||
{
|
||||
double extrusionResult;
|
||||
double.TryParse(this.GetValue(settingsKey), out extrusionResult);
|
||||
|
|
|
|||
|
|
@ -511,7 +511,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
// The collector specifically returns null to ensure LoadCacheable skips writing the
|
||||
// result to the cache. After this result is returned, it will attempt to load from
|
||||
// the local cache if the collector yielded no result
|
||||
if(File.Exists(cachePath))
|
||||
if(File.Exists(cachePath)
|
||||
|| ApplicationController.DownloadPublicProfileAsync == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,6 +262,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
// Ensure that activated or deactivated user overrides are always persisted to disk
|
||||
activeSettings.Save();
|
||||
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||
foreach (var keyName in PrinterSettings.KnownSettings)
|
||||
{
|
||||
if (settingBeforeChange[keyName] != ActiveSliceSettings.Instance.GetValue(keyName))
|
||||
{
|
||||
ActiveSliceSettings.OnSettingChanged(keyName);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editButton.Enabled = item.Text != defaultMenuItemText;
|
||||
}
|
||||
|
||||
|
|
@ -375,30 +387,23 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
//Add Each SliceEngineInfo Objects to DropMenu
|
||||
foreach (SliceEngineInfo engineMenuItem in SlicingQueue.AvailableSliceEngines)
|
||||
{
|
||||
bool engineAllowed = true;
|
||||
if (ActiveSliceSettings.Instance.GetValue<int>(SettingsKey.extruder_count) > 1 && engineMenuItem.Name != "MatterSlice")
|
||||
{
|
||||
engineAllowed = false;
|
||||
}
|
||||
MenuItem item = AddItem(engineMenuItem.Name);
|
||||
item.Enabled = ActiveSliceSettings.Instance.GetValue<int>(SettingsKey.extruder_count) < 2 || engineMenuItem.Name == "MatterSlice";
|
||||
|
||||
if (engineAllowed)
|
||||
SlicingEngineTypes itemEngineType = engineMenuItem.GetSliceEngineType();
|
||||
item.Selected += (sender, e) =>
|
||||
{
|
||||
MenuItem item = AddItem(engineMenuItem.Name);
|
||||
SlicingEngineTypes itemEngineType = engineMenuItem.GetSliceEngineType();
|
||||
item.Selected += (sender, e) =>
|
||||
if (ActiveSliceSettings.Instance.Helpers.ActiveSliceEngineType() != itemEngineType)
|
||||
{
|
||||
if (ActiveSliceSettings.Instance.Helpers.ActiveSliceEngineType() != itemEngineType)
|
||||
{
|
||||
ActiveSliceSettings.Instance.Helpers.ActiveSliceEngineType(itemEngineType);
|
||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||
}
|
||||
};
|
||||
|
||||
//Set item as selected if it matches the active slice engine
|
||||
if (engineMenuItem.GetSliceEngineType() == ActiveSliceSettings.Instance.Helpers.ActiveSliceEngineType())
|
||||
{
|
||||
SelectedLabel = engineMenuItem.Name;
|
||||
ActiveSliceSettings.Instance.Helpers.ActiveSliceEngineType(itemEngineType);
|
||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||
}
|
||||
};
|
||||
|
||||
//Set item as selected if it matches the active slice engine
|
||||
if (itemEngineType == ActiveSliceSettings.Instance.Helpers.ActiveSliceEngineType())
|
||||
{
|
||||
SelectedLabel = engineMenuItem.Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
private CheckBox showHelpBox;
|
||||
private TupleList<string, Func<bool>> slicerOptionsMenuItems;
|
||||
|
||||
private static string resetToDefaultsMessage = "Resetting to default values will remove your current overrides and restore your original printer settings.\nAre you sure you want to continue?".Localize();
|
||||
private static string resetToDefaultsWindowTitle = "Revert Settings".Localize();
|
||||
string resetToDefaultsMessage = "Resetting to default values will remove your current overrides and restore your original printer settings.\nAre you sure you want to continue?".Localize();
|
||||
string resetToDefaultsWindowTitle = "Revert Settings".Localize();
|
||||
bool primarySettingsView;
|
||||
|
||||
public SliceSettingsDetailControl(List<PrinterSettingsLayer> layerCascade)
|
||||
|
|
|
|||
|
|
@ -403,6 +403,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
foreach (SliceSettingData settingData in subGroup.SettingDataList)
|
||||
{
|
||||
// Note: tab sections may disappear if they when they are empty, as controlled by:
|
||||
// settingShouldBeShown / addedSettingToSubGroup / needToAddSubGroup
|
||||
bool settingShouldBeShown = CheckIfShouldBeShown(settingData);
|
||||
|
||||
if (sliceEngineMapping.MapContains(settingData.SlicerConfigName)
|
||||
|
|
@ -491,7 +493,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
if(group.Name == "Connection")
|
||||
{
|
||||
subGroupLayoutTopToBottom.AddChild(SliceSettingsWidget.CreatePrinterExtraControls());
|
||||
subGroupLayoutTopToBottom.AddChild(SliceSettingsWidget.CreatePrinterExtraControls(isPrimaryView: true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -722,39 +724,67 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
return ActiveSliceSettings.Instance.GetValue(slicerConfigName, layerCascade);
|
||||
}
|
||||
|
||||
public static GuiWidget CreatePrinterExtraControls()
|
||||
public static GuiWidget CreatePrinterExtraControls(bool isPrimaryView = false)
|
||||
{
|
||||
var dataArea = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
};
|
||||
|
||||
// OEM_LAYER_DATE:
|
||||
string lastUpdateTime = "March 1, 2016";
|
||||
if (ActiveSliceSettings.Instance?.OemLayer != null)
|
||||
if (isPrimaryView)
|
||||
{
|
||||
string fromCreatedDate = ActiveSliceSettings.Instance.OemLayer.ValueOrDefault(SettingsKey.created_date);
|
||||
try
|
||||
// OEM_LAYER_DATE:
|
||||
string lastUpdateTime = "March 1, 2016";
|
||||
if (ActiveSliceSettings.Instance?.OemLayer != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fromCreatedDate))
|
||||
string fromCreatedDate = ActiveSliceSettings.Instance.OemLayer.ValueOrDefault(SettingsKey.created_date);
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fromCreatedDate))
|
||||
{
|
||||
DateTime time = Convert.ToDateTime(fromCreatedDate).ToLocalTime();
|
||||
lastUpdateTime = time.ToString("MMMM d, yyyy h:mm tt");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
DateTime time = Convert.ToDateTime(fromCreatedDate).ToLocalTime();
|
||||
lastUpdateTime = time.ToString("MMMM d, yyyy ") + time.ToString("h:mm tt");
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
var row = new FlowLayoutWidget()
|
||||
{
|
||||
BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor,
|
||||
Padding = new BorderDouble(5),
|
||||
Margin = new BorderDouble(3, 20, 3, 0),
|
||||
HAnchor = HAnchor.ParentLeftRight
|
||||
};
|
||||
|
||||
string make = ActiveSliceSettings.Instance.GetValue(SettingsKey.make);
|
||||
string model = ActiveSliceSettings.Instance.GetValue(SettingsKey.model);
|
||||
|
||||
string title = $"{make} {model}";
|
||||
if (title == "Other Other")
|
||||
{
|
||||
title = "Custom Profile".Localize();
|
||||
}
|
||||
|
||||
row.AddChild(new TextWidget(title, pointSize: 9)
|
||||
{
|
||||
Margin = new BorderDouble(0, 4, 10, 4),
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
});
|
||||
|
||||
row.AddChild(new HorizontalSpacer());
|
||||
|
||||
row.AddChild(new TextWidget(lastUpdateTime, pointSize: 9)
|
||||
{
|
||||
Margin = new BorderDouble(0, 4, 10, 4),
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
});
|
||||
|
||||
dataArea.AddChild(row);
|
||||
}
|
||||
|
||||
lastUpdateTime = "Default settings updated: {0} ".Localize().FormatWith(lastUpdateTime);
|
||||
|
||||
dataArea.AddChild(new TextWidget(lastUpdateTime, textColor: ActiveTheme.Instance.SecondaryTextColor)
|
||||
{
|
||||
HAnchor= HAnchor.ParentCenter,
|
||||
Margin = new BorderDouble(0, 15),
|
||||
});
|
||||
|
||||
// DELETE_PRINTER:
|
||||
{
|
||||
// This is a place holder type to allow us to put in the control that will allow the deletion of a printer profile
|
||||
|
|
@ -1217,19 +1247,25 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
};
|
||||
checkBoxWidget.Click += (sender, e) =>
|
||||
{
|
||||
bool isChecked = ((CheckBox)sender).Checked;
|
||||
ActiveSliceSettings.Instance.SetValue(settingData.SlicerConfigName, isChecked ? "1" : "0", persistenceLayer);
|
||||
foreach(var setSettingsData in settingData.SetSettingsOnChange)
|
||||
// SetValue should only be called when the checkbox is clicked. If this code makes its way into checkstatechanged
|
||||
// we end up adding a key back into the dictionary after we call .ClearValue, resulting in the blue override bar reappearing after
|
||||
// clearing a useroverride with the red x
|
||||
ActiveSliceSettings.Instance.SetValue(settingData.SlicerConfigName, checkBoxWidget.Checked ? "1" : "0", persistenceLayer);
|
||||
};
|
||||
checkBoxWidget.CheckedStateChanged += (s, e) =>
|
||||
{
|
||||
// Linked settings should be updated in all cases (user clicked checkbox, user clicked clear)
|
||||
foreach (var setSettingsData in settingData.SetSettingsOnChange)
|
||||
{
|
||||
string targetValue;
|
||||
if(setSettingsData.TryGetValue(isChecked?"OnValue": "OffValue", out targetValue))
|
||||
if (setSettingsData.TryGetValue(checkBoxWidget.Checked ? "OnValue" : "OffValue", out targetValue))
|
||||
{
|
||||
ActiveSliceSettings.Instance.SetValue(setSettingsData["TargetSetting"], targetValue, persistenceLayer);
|
||||
}
|
||||
}
|
||||
|
||||
settingsRow.UpdateStyle();
|
||||
};
|
||||
|
||||
dataArea.AddChild(checkBoxWidget);
|
||||
|
||||
settingsRow.ValueChanged = (text) =>
|
||||
|
|
@ -1590,18 +1626,49 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
case NamedSettingsLayers.All:
|
||||
if (settingData.ShowAsOverride)
|
||||
{
|
||||
settingsRow.BackgroundColor = userSettingBackgroundColor;
|
||||
var defaultCascade = ActiveSliceSettings.Instance.defaultLayerCascade;
|
||||
var firstParentValue = ActiveSliceSettings.Instance.GetValueAndLayerName(settingData.SlicerConfigName, defaultCascade.Skip(1));
|
||||
var currentValueAndLayerName = ActiveSliceSettings.Instance.GetValueAndLayerName(settingData.SlicerConfigName, defaultCascade);
|
||||
|
||||
var currentValue = currentValueAndLayerName.Item1;
|
||||
var layerName = currentValueAndLayerName.Item2;
|
||||
|
||||
if (firstParentValue.Item1 == currentValue)
|
||||
{
|
||||
if (layerName.StartsWith("Material"))
|
||||
{
|
||||
settingsRow.BackgroundColor = materialSettingBackgroundColor;
|
||||
}
|
||||
else if (layerName.StartsWith("Quality"))
|
||||
{
|
||||
settingsRow.BackgroundColor = qualitySettingBackgroundColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsRow.BackgroundColor = RGBA_Bytes.Transparent;
|
||||
}
|
||||
|
||||
if (restoreButton != null)
|
||||
{
|
||||
restoreButton.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsRow.BackgroundColor = userSettingBackgroundColor;
|
||||
if (restoreButton != null) restoreButton.Visible = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NamedSettingsLayers.Material:
|
||||
settingsRow.BackgroundColor = materialSettingBackgroundColor;
|
||||
if (restoreButton != null) restoreButton.Visible = true;
|
||||
break;
|
||||
case NamedSettingsLayers.Quality:
|
||||
settingsRow.BackgroundColor = qualitySettingBackgroundColor;
|
||||
if (restoreButton != null) restoreButton.Visible = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(restoreButton != null) restoreButton.Visible = true;
|
||||
}
|
||||
else if (layerCascade == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue