From 562121fd2ba1c602000de7fa178cdc74effa3ee2 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Sat, 7 Apr 2018 12:17:23 -0700 Subject: [PATCH] Isolate Theme syncing with ActiveTheme to AppController instance only --- ApplicationView/ApplicationController.cs | 12 +++++++++++- ApplicationView/ThemeConfig.cs | 6 ++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index f4105d4e6..8669ddccd 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl { private Dictionary> objectEditorsByType; - public ThemeConfig Theme { get; set; } = new ThemeConfig(); + public ThemeConfig Theme { get; set; } public RunningTasksConfig Tasks { get; set; } = new RunningTasksConfig(); @@ -689,6 +689,16 @@ namespace MatterHackers.MatterControl public ApplicationController() { + // Initialize the AppContext theme object which will sync its content with Agg ActiveTheme changes + this.Theme = new ThemeConfig(); + + ActiveTheme.ThemeChanged.RegisterEvent((s, e) => + { + this.Theme.RebuildTheme(ActiveTheme.Instance); + }, ref unregisterEvents); + + this.Theme.RebuildTheme(ActiveTheme.Instance); + Object3D.AssetsPath = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, "Assets"); ScrollBar.DefaultMargin = new BorderDouble(right: 1); diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index 2fb5e43de..bb722cc71 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -138,13 +138,11 @@ namespace MatterHackers.MatterControl public ThemeConfig() { - ActiveTheme.ThemeChanged.RegisterEvent((s, e) => RebuildTheme(), ref unregisterEvents); - RebuildTheme(); } - public void RebuildTheme() + public void RebuildTheme(IThemeColors colors) { - var colors = this.Colors = ActiveTheme.Instance; + this.Colors = colors; DefaultThumbView.ThumbColor = new Color(colors.PrimaryTextColor, 30);