Migrate SettingChanged event to PrinterSettings
- Issue MatterHackers/MCCentral#4245 Remove ActiveSliceSettings type
This commit is contained in:
parent
98252dff50
commit
0f9042f28d
22 changed files with 35 additions and 34 deletions
|
|
@ -89,7 +89,7 @@ namespace MatterHackers.MatterControl
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
|
|
||||||
var valueField = temperatureRow.Descendants<MHNumberEdit>().FirstOrDefault();
|
var valueField = temperatureRow.Descendants<MHNumberEdit>().FirstOrDefault();
|
||||||
var settingsRow = temperatureRow.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
var settingsRow = temperatureRow.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringEvent)
|
if (e is StringEventArgs stringEvent)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
||||||
var valueField = temperatureRow.Descendants<MHNumberEdit>().FirstOrDefault();
|
var valueField = temperatureRow.Descendants<MHNumberEdit>().FirstOrDefault();
|
||||||
valueField.Name = "Temperature Input";
|
valueField.Name = "Temperature Input";
|
||||||
var settingsRow = temperatureRow.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
var settingsRow = temperatureRow.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringEvent)
|
if (e is StringEventArgs stringEvent)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,7 @@ namespace MatterHackers.MatterControl
|
||||||
/*
|
/*
|
||||||
// TODO: Should we rebroadcast settings changed events for each settings?
|
// TODO: Should we rebroadcast settings changed events for each settings?
|
||||||
bool themeChanged = ActivePrinter.Settings.GetValue(SettingsKey.active_theme_name) != updatedProfile.GetValue(SettingsKey.active_theme_name);
|
bool themeChanged = ActivePrinter.Settings.GetValue(SettingsKey.active_theme_name) != updatedProfile.GetValue(SettingsKey.active_theme_name);
|
||||||
ActiveSliceSettings.SettingChanged.CallEvents(null, new StringEventArgs(SettingsKey.printer_name));
|
PrinterSettings.SettingChanged.CallEvents(null, new StringEventArgs(SettingsKey.printer_name));
|
||||||
|
|
||||||
// TODO: Decide if non-printer contexts should prompt for a printer, if we should have a default printer, or get "ActiveTab printer" working
|
// TODO: Decide if non-printer contexts should prompt for a printer, if we should have a default printer, or get "ActiveTab printer" working
|
||||||
// HACK: short term solution to resolve printer reference for non-printer related contexts
|
// HACK: short term solution to resolve printer reference for non-printer related contexts
|
||||||
|
|
@ -1120,7 +1120,7 @@ namespace MatterHackers.MatterControl
|
||||||
iconCollector: (theme) => AggContext.StaticData.LoadIcon("noun_55060.png", theme.InvertIcons));
|
iconCollector: (theme) => AggContext.StaticData.LoadIcon("noun_55060.png", theme.InvertIcons));
|
||||||
|
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringArg
|
if (e is StringEventArgs stringArg
|
||||||
&& SettingsOrganizer.SettingsData.TryGetValue(stringArg.Data, out SliceSettingData settingsData)
|
&& SettingsOrganizer.SettingsData.TryGetValue(stringArg.Data, out SliceSettingData settingsData)
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
// Make sure we don't have a selection
|
// Make sure we don't have a selection
|
||||||
this.Scene.SelectedItem = null;
|
this.Scene.SelectedItem = null;
|
||||||
|
|
||||||
this.EditContext = editContext;
|
this.EditContext = editContext;
|
||||||
this.ContentType = "mcx";
|
this.ContentType = "mcx";
|
||||||
|
|
||||||
|
|
@ -174,7 +174,7 @@ namespace MatterHackers.MatterControl
|
||||||
Content = new Object3D(),
|
Content = new Object3D(),
|
||||||
ContentStore = historyContainer,
|
ContentStore = historyContainer,
|
||||||
SourceItem = historyContainer.NewPlatingItem()
|
SourceItem = historyContainer.NewPlatingItem()
|
||||||
},
|
},
|
||||||
new Object3D());
|
new Object3D());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -888,7 +888,7 @@ namespace MatterHackers.MatterControl
|
||||||
this.Settings.printer = this;
|
this.Settings.printer = this;
|
||||||
|
|
||||||
// TODO: ActiveSliceSettings is not our Settings! Move SettingsChanged to instance rather than static
|
// TODO: ActiveSliceSettings is not our Settings! Move SettingsChanged to instance rather than static
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent(Printer_SettingChanged, ref unregisterEvents);
|
PrinterSettings.SettingChanged.RegisterEvent(Printer_SettingChanged, ref unregisterEvents);
|
||||||
|
|
||||||
this.Connection.PrintFinished.RegisterEvent((s, e) =>
|
this.Connection.PrintFinished.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
|
|
||||||
// make sure we have good settings
|
// make sure we have good settings
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent(Printer_SettingChanged, ref unregisterEvents);
|
PrinterSettings.SettingChanged.RegisterEvent(Printer_SettingChanged, ref unregisterEvents);
|
||||||
Printer_SettingChanged(this, null);
|
Printer_SettingChanged(this, null);
|
||||||
|
|
||||||
this.gridSizeMm = printer.Settings.GetValue<Vector2>(SettingsKey.bed_size);
|
this.gridSizeMm = printer.Settings.GetValue<Vector2>(SettingsKey.bed_size);
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
var firstSection = this.Children<SectionWidget>().First();
|
var firstSection = this.Children<SectionWidget>().First();
|
||||||
firstSection.BorderColor = Color.Transparent; // Disable top border on first item to produce a more flat, dark top edge
|
firstSection.BorderColor = Color.Transparent; // Disable top border on first item to produce a more flat, dark top edge
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringEvent)
|
if (e is StringEventArgs stringEvent)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
var conditionalCostContainer = costTextWidget.Parent;
|
var conditionalCostContainer = costTextWidget.Parent;
|
||||||
conditionalCostContainer.Visible = gcodeDetails.TotalCost > 0;
|
conditionalCostContainer.Visible = gcodeDetails.TotalCost > 0;
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringEvent)
|
if (e is StringEventArgs stringEvent)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
|
|
||||||
this.AddChild(tabControl);
|
this.AddChild(tabControl);
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
||||||
|
|
||||||
|
|
@ -298,7 +298,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
MinimumSize = new Vector2(120, theme.TabButtonHeight)
|
MinimumSize = new Vector2(120, theme.TabButtonHeight)
|
||||||
};
|
};
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
string settingsName = (e as StringEventArgs)?.Data;
|
string settingsName = (e as StringEventArgs)?.Data;
|
||||||
if (settingsName != null && settingsName == SettingsKey.printer_name)
|
if (settingsName != null && settingsName == SettingsKey.printer_name)
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
UiThread.RunOnIdle(SetButtonStates);
|
UiThread.RunOnIdle(SetButtonStates);
|
||||||
}, ref unregisterEvents);
|
}, ref unregisterEvents);
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringEvent
|
if (e is StringEventArgs stringEvent
|
||||||
&& (stringEvent.Data == SettingsKey.z_probe_z_offset
|
&& (stringEvent.Data == SettingsKey.z_probe_z_offset
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
Padding = theme.TextButtonPadding.Clone(right: 5)
|
Padding = theme.TextButtonPadding.Clone(right: 5)
|
||||||
});
|
});
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringEvent)
|
if (e is StringEventArgs stringEvent)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||||
: base(null)
|
: base(null)
|
||||||
{
|
{
|
||||||
this.printerSettings = printerSettings;
|
this.printerSettings = printerSettings;
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset)
|
if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
settingsRow.AddChild(extrusionValue);
|
settingsRow.AddChild(extrusionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
var eventArgs = e as StringEventArgs;
|
var eventArgs = e as StringEventArgs;
|
||||||
if (eventArgs?.Data == SettingsKey.extrusion_ratio)
|
if (eventArgs?.Data == SettingsKey.extrusion_ratio)
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
||||||
this.HAnchor = HAnchor.Fit;
|
this.HAnchor = HAnchor.Fit;
|
||||||
this.VAnchor = VAnchor.Fit | VAnchor.Center;
|
this.VAnchor = VAnchor.Fit | VAnchor.Center;
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset)
|
if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent(Printer_SettingChanged, ref unregisterEvents);
|
PrinterSettings.SettingChanged.RegisterEvent(Printer_SettingChanged, ref unregisterEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetEnabledLevels(bool enableBabysteppingMode, bool enableEControls)
|
internal void SetEnabledLevels(bool enableBabysteppingMode, bool enableEControls)
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
this.AddChild(pullDownContainer);
|
this.AddChild(pullDownContainer);
|
||||||
|
|
||||||
ActiveSliceSettings.MaterialPresetChanged += ActiveSliceSettings_MaterialPresetChanged;
|
ActiveSliceSettings.MaterialPresetChanged += ActiveSliceSettings_MaterialPresetChanged;
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringEvent
|
if (e is StringEventArgs stringEvent
|
||||||
&& (stringEvent.Data == SettingsKey.default_material_presets
|
&& (stringEvent.Data == SettingsKey.default_material_presets
|
||||||
|
|
@ -366,7 +366,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
{
|
{
|
||||||
if (settingBeforeChange[keyName] != printer.Settings.GetValue(keyName))
|
if (settingBeforeChange[keyName] != printer.Settings.GetValue(keyName))
|
||||||
{
|
{
|
||||||
ActiveSliceSettings.OnSettingChanged(keyName);
|
PrinterSettings.OnSettingChanged(keyName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
public static class ActiveSliceSettings
|
public static class ActiveSliceSettings
|
||||||
{
|
{
|
||||||
public static RootedObjectEventHandler SettingChanged = new RootedObjectEventHandler();
|
|
||||||
|
|
||||||
public static event EventHandler MaterialPresetChanged;
|
public static event EventHandler MaterialPresetChanged;
|
||||||
|
|
||||||
public static void OnSettingChanged(string slicerConfigName)
|
|
||||||
{
|
|
||||||
SettingChanged.CallEvents(null, new StringEventArgs(slicerConfigName));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void OnMaterialPresetChanged()
|
internal static void OnMaterialPresetChanged()
|
||||||
{
|
{
|
||||||
MaterialPresetChanged?.Invoke(null, null);
|
MaterialPresetChanged?.Invoke(null, null);
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
// Year|month|day|versionForDay (to support multiple revisions on a given day)
|
// Year|month|day|versionForDay (to support multiple revisions on a given day)
|
||||||
public static int LatestVersion { get; } = 201606271;
|
public static int LatestVersion { get; } = 201606271;
|
||||||
|
|
||||||
|
// TODO: Change to instance based, revise listeners and register to expect specific printer settings
|
||||||
|
public static RootedObjectEventHandler SettingChanged = new RootedObjectEventHandler();
|
||||||
|
|
||||||
|
public static void OnSettingChanged(string slicerConfigName)
|
||||||
|
{
|
||||||
|
SettingChanged.CallEvents(null, new StringEventArgs(slicerConfigName));
|
||||||
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public RootedObjectEventHandler PrintLevelingEnabledChanged = new RootedObjectEventHandler();
|
public RootedObjectEventHandler PrintLevelingEnabledChanged = new RootedObjectEventHandler();
|
||||||
|
|
||||||
|
|
@ -1299,7 +1307,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
persistenceLayer[settingsKey] = settingsValue;
|
persistenceLayer[settingsKey] = settingsValue;
|
||||||
Save();
|
Save();
|
||||||
|
|
||||||
ActiveSliceSettings.OnSettingChanged(settingsKey);
|
PrinterSettings.OnSettingChanged(settingsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToJson()
|
public string ToJson()
|
||||||
|
|
@ -1342,7 +1350,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
Save();
|
Save();
|
||||||
|
|
||||||
ActiveSliceSettings.OnSettingChanged(settingsKey);
|
PrinterSettings.OnSettingChanged(settingsKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
static ProfileManager()
|
static ProfileManager()
|
||||||
{
|
{
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent(SettingsChanged, ref unregisterEvents);
|
PrinterSettings.SettingChanged.RegisterEvent(SettingsChanged, ref unregisterEvents);
|
||||||
ReloadActiveUser();
|
ReloadActiveUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent(
|
PrinterSettings.SettingChanged.RegisterEvent(
|
||||||
(s, e) =>
|
(s, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringEvent)
|
if (e is StringEventArgs stringEvent)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
|
|
||||||
EventHandler localUnregisterEvents = null;
|
EventHandler localUnregisterEvents = null;
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((sender, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((sender, e) =>
|
||||||
{
|
{
|
||||||
if (e is StringEventArgs stringArgs
|
if (e is StringEventArgs stringArgs
|
||||||
&& stringArgs.Data == settingData.SlicerConfigName)
|
&& stringArgs.Data == settingData.SlicerConfigName)
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
||||||
EventHandler unregisterEvents = null;
|
EventHandler unregisterEvents = null;
|
||||||
int layerHeightChangedCount = 0;
|
int layerHeightChangedCount = 0;
|
||||||
|
|
||||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||||
{
|
{
|
||||||
var stringEvent = e as StringEventArgs;
|
var stringEvent = e as StringEventArgs;
|
||||||
if (stringEvent != null)
|
if (stringEvent != null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue