Migrate Theme support to Agg.UI

This commit is contained in:
John Lewin 2016-04-29 07:45:15 -07:00
parent 77d3df1d01
commit e5a63b052e
41 changed files with 155 additions and 473 deletions

View file

@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
BedSettings.SetMakeAndModel(activeInstance.Make, activeInstance.Model);
}
ActiveTheme.Instance.SwitchToPrinterThemeWithoutReloadEvent();
SwitchToPrinterThemeWithoutReloadEvent();
if (!MatterControlApplication.IsLoading)
{
@ -85,6 +85,29 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
/// <summary>
/// Switches to the ActivePrinter theme without firing the ThemeChanged event. This is useful when changing printers and
/// allows the theme state to be updated before the ActivePrinterChanged event fires, resulting in a single ReloadAll
/// occurring rather than two
/// </summary>
public static void SwitchToPrinterThemeWithoutReloadEvent()
{
if (ActiveSliceSettings.Instance != null)
{
try
{
int themeIndex = Convert.ToInt32(ActiveSliceSettings.Instance.ActiveValue("MatterControl.ActiveThemeIndex"));
ActiveTheme.SuspendEvents();
ActiveTheme.Instance = ActiveTheme.AvailableThemes[themeIndex];
ActiveTheme.ResumeEvents();
}
catch
{
}
}
}
static ActiveSliceSettings()
{
// Ensure the profiles directory exists