From bbabf95c933ae50c9f40b32aa1851f1fc9eb20d4 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 12 Jul 2018 09:22:28 -0700 Subject: [PATCH] Improve DI, use constructor injection --- AboutPage/AboutPage.cs | 3 -- AboutPage/CheckForUpdatesPage.cs | 4 +- AboutPage/ContactFormPage.cs | 8 +-- ActionBar/TemperatureWidgetBase.cs | 1 + ApplicationView/ApplicationController.cs | 15 +++--- ApplicationView/ThumbnailsConfig.cs | 20 +++++--- ApplicationView/WidescreenPanel.cs | 31 +++--------- .../ApplicationSettingsView.cs | 4 +- CustomWidgets/DockingTabControl.cs | 8 +-- CustomWidgets/InlineTitleEdit.cs | 2 +- CustomWidgets/TreeView/TreeNode.cs | 4 +- DesignTools/PublicPropertyEditor.cs | 8 +-- History/PrintHistoryListItem.cs | 6 --- Library/Providers/SDCard/SDCardContainer.cs | 2 +- Library/Widgets/PrintLibraryWidget.cs | 6 +-- PartPreviewWindow/GCode2DWidget.cs | 4 +- PartPreviewWindow/Object3DTreeBuilder.cs | 4 +- PartPreviewWindow/PartPreviewContent.cs | 4 +- PartPreviewWindow/PopupMenuButton.cs | 15 +++--- PartPreviewWindow/PrinterTabPage.cs | 20 ++++---- PartPreviewWindow/SliceLayerSelector.cs | 4 +- PartPreviewWindow/View3D/GridOptionsPanel.cs | 5 +- PartPreviewWindow/View3D/MeshViewerWidget.cs | 7 +-- .../View3D/PrinterBar/PrintPopupMenu.cs | 1 + .../View3D/PrinterBar/PrinterConnectButton.cs | 3 +- PartPreviewWindow/View3D/View3DWidget.cs | 4 +- .../ControlWidgets/CalibrationControls.cs | 2 +- PrinterControls/EditLevelingSettingsPage.cs | 4 +- PrinterControls/MacroDetailPage.cs | 2 - PrinterControls/ManualPrinterControls.cs | 5 +- .../PrinterConnections/PrinterChooser.cs | 14 ++---- .../SetupStepMakeModelName.cs | 22 ++++---- .../TerminalWindow/TerminalWidget.cs | 14 ++---- SetupWizard/AndroidConnectDevicePage.cs | 5 +- SetupWizard/DialogWindow.cs | 6 ++- SetupWizard/HelpPage.cs | 6 +-- SetupWizard/SetupWizardTroubleshooting.cs | 33 +++++++----- .../SlicePresetsWindow/SlicePresetsWindow.cs | 2 +- SlicerConfiguration/SliceSettingsWidget.cs | 8 +-- .../UIFields/DirectionVectorField.cs | 8 ++- .../UIFields/DropMenuWrappedField.cs | 5 +- SlicerConfiguration/UIFields/EnumField.cs | 6 +-- SlicerConfiguration/UIFields/IconEnumField.cs | 6 +-- SlicerConfiguration/UIFields/IpAddessField.cs | 8 +-- SlicerConfiguration/UIFields/ListField.cs | 7 ++- .../MatterControl/PrinterChooserUnitTests.cs | 7 +-- Utilities/MarkdigAgg/AggCodeBlockRenderer.cs | 25 +++++++--- Utilities/MarkdigAgg/AggHeadingRenderer.cs | 50 +++++++++---------- Utilities/MarkdigAgg/AggListRenderer.cs | 15 +++--- Utilities/MarkdigAgg/AggRenderer.cs | 25 +++++++--- Utilities/MarkdigAgg/MarkdownPage.cs | 1 + Utilities/MarkdigAgg/MarkdownWidget.cs | 10 ++-- 52 files changed, 244 insertions(+), 245 deletions(-) diff --git a/AboutPage/AboutPage.cs b/AboutPage/AboutPage.cs index 3e4779c9c..1f8294a2d 100644 --- a/AboutPage/AboutPage.cs +++ b/AboutPage/AboutPage.cs @@ -48,9 +48,6 @@ namespace MatterHackers.MatterControl : base("Close".Localize()) { this.WindowTitle = "About".Localize() + " " + ApplicationController.Instance.ProductName; - - var theme = ApplicationController.Instance.Theme; - this.MinimumSize = new Vector2(480 * GuiWidget.DeviceScale, 520 * GuiWidget.DeviceScale); this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 550 * GuiWidget.DeviceScale); diff --git a/AboutPage/CheckForUpdatesPage.cs b/AboutPage/CheckForUpdatesPage.cs index a33f498ec..93a68cbdf 100644 --- a/AboutPage/CheckForUpdatesPage.cs +++ b/AboutPage/CheckForUpdatesPage.cs @@ -12,8 +12,6 @@ namespace MatterHackers.MatterControl public CheckForUpdatesPage() : base("Close".Localize()) { - var theme = ApplicationController.Instance.Theme; - this.WindowTitle = this.HeaderText = "Check for Update".Localize(); this.Padding = 0; this.AnchorAll(); @@ -113,7 +111,7 @@ namespace MatterHackers.MatterControl additionalInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { - BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor, + BackgroundColor = theme.Colors.SecondaryBackgroundColor, HAnchor = HAnchor.Stretch, Padding = new BorderDouble(left: 6, top: 6), Visible = false diff --git a/AboutPage/ContactFormPage.cs b/AboutPage/ContactFormPage.cs index 242716416..304a60742 100644 --- a/AboutPage/ContactFormPage.cs +++ b/AboutPage/ContactFormPage.cs @@ -60,10 +60,6 @@ namespace MatterHackers.MatterControl.ContactForm public ContactFormPage() { - var theme = ApplicationController.Instance.Theme; - - AnchorAll(); - this.WindowTitle = "MatterControl : " + "Submit Feedback".Localize(); this.HeaderText = "How can we improve?".Localize(); @@ -106,7 +102,7 @@ namespace MatterHackers.MatterControl.ContactForm { AutoExpandBoundsToText = true, Margin = new BorderDouble(0, 5), - TextColor = ActiveTheme.Instance.PrimaryTextColor, + TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Left }; @@ -154,7 +150,7 @@ namespace MatterHackers.MatterControl.ContactForm labelContainer.AddChild(new TextWidget(labelText, pointSize: fontSize) { - TextColor = ActiveTheme.Instance.PrimaryTextColor, + TextColor = theme.Colors.PrimaryTextColor, VAnchor = VAnchor.Bottom, HAnchor = HAnchor.Left, Margin = new BorderDouble(bottom: 2) diff --git a/ActionBar/TemperatureWidgetBase.cs b/ActionBar/TemperatureWidgetBase.cs index b56bf76ba..6a881893b 100644 --- a/ActionBar/TemperatureWidgetBase.cs +++ b/ActionBar/TemperatureWidgetBase.cs @@ -54,6 +54,7 @@ namespace MatterHackers.MatterControl.ActionBar protected virtual int TargetTemperature { get; } public TemperatureWidgetBase(PrinterConfig printer, string textValue, ThemeConfig theme) + : base(theme) { this.printer = printer; diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index ef877c250..4188cf9ca 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -296,7 +296,7 @@ namespace MatterHackers.MatterControl private List registeredSceneOperations; - public ThumbnailsConfig Thumbnails { get; } = new ThumbnailsConfig(); + public ThumbnailsConfig Thumbnails { get; } private void RebuildSceneOperations(ThemeConfig theme) { @@ -670,6 +670,7 @@ namespace MatterHackers.MatterControl { // Initialize the AppContext theme object which will sync its content with Agg ActiveTheme changes this.Theme = new ThemeConfig(); + this.Thumbnails = new ThumbnailsConfig(this.Theme); this.MenuTheme = new ThemeConfig(); HelpArticle helpArticle = null; @@ -1306,7 +1307,7 @@ namespace MatterHackers.MatterControl GuiWidget.LayoutCount = 0; using (new QuickTimer($"ReloadAll_{reloadCount++}:")) { - MainView = new WidescreenPanel(); + MainView = new WidescreenPanel(ApplicationController.Instance.Theme); this.DoneReloadingAll?.CallEvents(null, null); using (new QuickTimer("Time to AddMainview: ")) @@ -2691,7 +2692,7 @@ namespace MatterHackers.MatterControl UserSettings.Instance.Fields.StartCount = UserSettings.Instance.Fields.StartCount + 1; reporter?.Invoke(0.05, "ApplicationController"); - var na = ApplicationController.Instance; + var applicationController = ApplicationController.Instance; // Accessing any property on ProfileManager will run the static constructor and spin up the ProfileManager instance reporter?.Invoke(0.2, "ProfileManager"); @@ -2700,7 +2701,7 @@ namespace MatterHackers.MatterControl await ProfileManager.Instance.Initialize(); reporter?.Invoke(0.3, "MainView"); - ApplicationController.Instance.MainView = new WidescreenPanel(); + applicationController.MainView = new WidescreenPanel(applicationController.Theme); // now that we are all set up lets load our plugins and allow them their chance to set things up reporter?.Invoke(0.8, "Plugins"); @@ -2710,14 +2711,14 @@ namespace MatterHackers.MatterControl AppContext.Platform.ProcessCommandline(); reporter?.Invoke(0.91, "OnLoadActions"); - ApplicationController.Instance.OnLoadActions(); + applicationController.OnLoadActions(); UiThread.SetInterval(() => { - ApplicationController.Instance.ActivePrinter.Connection.OnIdle(); + applicationController.ActivePrinter.Connection.OnIdle(); }, .1); - return ApplicationController.Instance.MainView; + return applicationController.MainView; } private static void ReportStartupProgress(double progress0To1, string section) diff --git a/ApplicationView/ThumbnailsConfig.cs b/ApplicationView/ThumbnailsConfig.cs index 5065d66e9..45374926e 100644 --- a/ApplicationView/ThumbnailsConfig.cs +++ b/ApplicationView/ThumbnailsConfig.cs @@ -44,9 +44,20 @@ namespace MatterHackers.MatterControl private Queue> queuedThumbCallbacks = new Queue>(); + private AutoResetEvent thumbGenResetEvent = new AutoResetEvent(false); + + private Task thumbnailGenerator = null; + + private ThemeConfig theme; + + public ThumbnailsConfig(ThemeConfig theme) + { + this.theme = theme; + } + public Dictionary OperationIcons { get; internal set; } - public ImageBuffer DefaultThumbnail() => AggContext.StaticData.LoadIcon("cube.png", 16, 16, ApplicationController.Instance.Theme.InvertIcons); + public ImageBuffer DefaultThumbnail() => AggContext.StaticData.LoadIcon("cube.png", 16, 16, theme.InvertIcons); public ImageBuffer LoadCachedImage(string cacheId, int width, int height) { @@ -95,7 +106,7 @@ namespace MatterHackers.MatterControl public string CachePath(string cacheId) { return ApplicationController.CacheablePath( - Path.Combine("Thumbnails", "Content"), + Path.Combine("Thumbnails", "Content"), $"{cacheId}.png"); } @@ -113,10 +124,6 @@ namespace MatterHackers.MatterControl $"{libraryItem.ID}-{width}x{height}.png"); } - private AutoResetEvent thumbGenResetEvent = new AutoResetEvent(false); - - private Task thumbnailGenerator = null; - internal void QueueForGeneration(Func func) { lock (thumbsLock) @@ -176,7 +183,6 @@ namespace MatterHackers.MatterControl thumbnailGenerator = null; } - private static ImageBuffer LoadImage(string filePath) { try diff --git a/ApplicationView/WidescreenPanel.cs b/ApplicationView/WidescreenPanel.cs index 175277869..bbcb3621d 100644 --- a/ApplicationView/WidescreenPanel.cs +++ b/ApplicationView/WidescreenPanel.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014, Kevin Pope +Copyright (c) 2018, Kevin Pope, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -41,8 +41,11 @@ namespace MatterHackers.MatterControl { public class WidescreenPanel : FlowLayoutWidget { - public WidescreenPanel() + private ThemeConfig theme; + + public WidescreenPanel(ThemeConfig theme) { + this.theme = theme; } public override void Initialize() @@ -51,9 +54,7 @@ namespace MatterHackers.MatterControl this.AnchorAll(); this.Name = "WidescreenPanel"; - this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; - - var theme = ApplicationController.Instance.Theme; + this.BackgroundColor = theme.Colors.PrimaryBackgroundColor; // Push TouchScreenMode into GuiWidget GuiWidget.TouchScreenMode = UserSettings.Instance.IsTouchScreen; @@ -74,7 +75,7 @@ namespace MatterHackers.MatterControl this.AddChild(library3DViewSplitter); // put in the right column - var partPreviewContent = new PartPreviewContent() + var partPreviewContent = new PartPreviewContent(theme) { VAnchor = VAnchor.Bottom | VAnchor.Top, HAnchor = HAnchor.Left | HAnchor.Right @@ -137,26 +138,10 @@ namespace MatterHackers.MatterControl Selectable = false }); - row.AddChild(new TextWidget(ApplicationController.Instance.ShortProductName, textColor: ActiveTheme.Instance.PrimaryTextColor) + row.AddChild(new TextWidget(ApplicationController.Instance.ShortProductName, textColor: theme.Colors.PrimaryTextColor) { VAnchor = VAnchor.Center }); } } - - public class UpdateNotificationMark : GuiWidget - { - public UpdateNotificationMark() - : base(12, 12) - { - } - - public override void OnDraw(Graphics2D graphics2D) - { - graphics2D.Circle(Width / 2, Height / 2, Width / 2, Color.White); - graphics2D.Circle(Width / 2, Height / 2, Width / 2 - 1, Color.Red); - graphics2D.FillRectangle(Width / 2 - 1, Height / 2 - 3, Width / 2 + 1, Height / 2 + 3, Color.White); - base.OnDraw(graphics2D); - } - } } diff --git a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs index cd061f26f..587b291f4 100644 --- a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs +++ b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs @@ -305,7 +305,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage this.AddSettingsRow(updateMatterControl); this.AddChild(new SettingsItem("Theme".Localize(), new GuiWidget(), theme)); - this.AddChild(this.GetThemeControl(theme)); + this.AddChild(this.GetThemeControl()); var aboutMatterControl = new SettingsItem("About".Localize() + " " + ApplicationController.Instance.ProductName, theme); if (IntPtr.Size == 8) @@ -353,7 +353,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage widget.Padding = widget.Padding.Clone(right: 10); } - private FlowLayoutWidget GetThemeControl(ThemeConfig theme) + private FlowLayoutWidget GetThemeControl() { var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { diff --git a/CustomWidgets/DockingTabControl.cs b/CustomWidgets/DockingTabControl.cs index 5de09b18b..e886d8e04 100644 --- a/CustomWidgets/DockingTabControl.cs +++ b/CustomWidgets/DockingTabControl.cs @@ -53,10 +53,10 @@ namespace MatterHackers.MatterControl.CustomWidgets private ThemeConfig theme; - public DockingTabControl(GuiWidget widgetTodockTo, DockSide dockSide, PrinterConfig printer) + public DockingTabControl(GuiWidget widgetTodockTo, DockSide dockSide, PrinterConfig printer, ThemeConfig theme) : base (FlowDirection.TopToBottom) { - this.theme = ApplicationController.Instance.Theme; + this.theme = theme; this.printer = printer; this.widgetTodockTo = widgetTodockTo; this.DockSide = dockSide; @@ -334,7 +334,7 @@ namespace MatterHackers.MatterControl.CustomWidgets }); buttonView.AfterDraw += (s, e) => { - e.Graphics2D.Render(rotatedLabel, ActiveTheme.Instance.PrimaryTextColor); + e.Graphics2D.Render(rotatedLabel, theme.Colors.PrimaryTextColor); }; } @@ -370,7 +370,7 @@ namespace MatterHackers.MatterControl.CustomWidgets BackgroundColor = theme.TabBarBackground, }; - titleBar.AddChild(new TextWidget(title, textColor: ActiveTheme.Instance.PrimaryTextColor) + titleBar.AddChild(new TextWidget(title, textColor: theme.Colors.PrimaryTextColor) { Margin = new BorderDouble(left: 8), VAnchor = VAnchor.Center diff --git a/CustomWidgets/InlineTitleEdit.cs b/CustomWidgets/InlineTitleEdit.cs index f0ff917e8..32e2420cf 100644 --- a/CustomWidgets/InlineTitleEdit.cs +++ b/CustomWidgets/InlineTitleEdit.cs @@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl.CustomWidgets Name = automationName + " Save", }; - searchPanel = new SearchInputBox() + searchPanel = new SearchInputBox(theme) { Visible = false, Margin = new BorderDouble(left: 4) diff --git a/CustomWidgets/TreeView/TreeNode.cs b/CustomWidgets/TreeView/TreeNode.cs index 234bf22c1..1b9a7ccf3 100644 --- a/CustomWidgets/TreeView/TreeNode.cs +++ b/CustomWidgets/TreeView/TreeNode.cs @@ -50,11 +50,9 @@ namespace MatterHackers.MatterControl.CustomWidgets private ImageWidget imageWidget; private bool isDirty; - public TreeNode(bool useIcon = true) + public TreeNode(ThemeConfig theme, bool useIcon = true) : base(FlowDirection.TopToBottom) { - var theme = ApplicationController.Instance.Theme; - this.HAnchor = HAnchor.Fit | HAnchor.Left; this.VAnchor = VAnchor.Fit; diff --git a/DesignTools/PublicPropertyEditor.cs b/DesignTools/PublicPropertyEditor.cs index 4ca625d47..2c732ceaa 100644 --- a/DesignTools/PublicPropertyEditor.cs +++ b/DesignTools/PublicPropertyEditor.cs @@ -327,7 +327,7 @@ namespace MatterHackers.MatterControl.DesignTools } else if (propertyValue is DirectionVector directionVector) { - var field = new DirectionVectorField(); + var field = new DirectionVectorField(theme); field.Initialize(0); field.SetValue(directionVector); field.ValueChanged += (s, e) => @@ -347,7 +347,7 @@ namespace MatterHackers.MatterControl.DesignTools Normal = directionAxis.Normal }; var row1 = CreateSettingsRow("Axis".Localize()); - var field1 = new DirectionVectorField(); + var field1 = new DirectionVectorField(theme); field1.Initialize(0); field1.SetValue(newDirectionVector); row1.AddChild(field1.Content); @@ -489,14 +489,14 @@ namespace MatterHackers.MatterControl.DesignTools var iconsAttribute = property.PropertyInfo.GetCustomAttributes(true).OfType().FirstOrDefault(); if (iconsAttribute != null) { - field = new IconEnumField(property, iconsAttribute) + field = new IconEnumField(property, iconsAttribute, theme) { InitialValue = propertyValue.ToString() }; } else { - field = new EnumField(property); + field = new EnumField(property, theme); } field.Initialize(0); diff --git a/History/PrintHistoryListItem.cs b/History/PrintHistoryListItem.cs index 90f47d5e5..7c5dc2b43 100644 --- a/History/PrintHistoryListItem.cs +++ b/History/PrintHistoryListItem.cs @@ -47,12 +47,6 @@ namespace MatterHackers.MatterControl.PrintHistory public int ThumbWidth { get; } = 50; public int ThumbHeight { get; } = 50; - public HistoryListView() - : base(FlowDirection.TopToBottom) - { - this.theme = ApplicationController.Instance.Theme; - } - public HistoryListView(ThemeConfig theme) : base(FlowDirection.TopToBottom) { diff --git a/Library/Providers/SDCard/SDCardContainer.cs b/Library/Providers/SDCard/SDCardContainer.cs index 2b07e06d7..c1047ab4f 100644 --- a/Library/Providers/SDCard/SDCardContainer.cs +++ b/Library/Providers/SDCard/SDCardContainer.cs @@ -104,7 +104,7 @@ namespace MatterHackers.MatterControl.Library { return Task.FromResult( AggContext.StaticData.LoadIcon( - Path.Combine((width > 50 || height > 50) ? "icon_sd_card_115x115.png" : "icon_sd_card_50x50.png"), + Path.Combine((width > 50 || height > 50) ? "icon_sd_card_115x115.png" : "icon_sd_card_50x50.png"), ApplicationController.Instance.Theme.InvertIcons)); } diff --git a/Library/Widgets/PrintLibraryWidget.cs b/Library/Widgets/PrintLibraryWidget.cs index 235332479..6771cc5ee 100644 --- a/Library/Widgets/PrintLibraryWidget.cs +++ b/Library/Widgets/PrintLibraryWidget.cs @@ -269,7 +269,7 @@ namespace MatterHackers.MatterControl.PrintLibrary breadCrumbWidget = new FolderBreadCrumbWidget(libraryView, theme); navBar.AddChild(breadCrumbWidget); - var searchPanel = new SearchInputBox() + var searchPanel = new SearchInputBox(theme) { Visible = false, Margin = new BorderDouble(10, 0, 5, 0), @@ -986,7 +986,7 @@ namespace MatterHackers.MatterControl.PrintLibrary internal MHTextEditWidget searchInput; public Button ResetButton { get; } - public SearchInputBox() + public SearchInputBox(ThemeConfig theme) { this.VAnchor = VAnchor.Center | VAnchor.Fit; this.HAnchor = HAnchor.Stretch; @@ -999,7 +999,7 @@ namespace MatterHackers.MatterControl.PrintLibrary }; this.AddChild(searchInput); - var resetButton = ApplicationController.Instance.Theme.CreateSmallResetButton(); + var resetButton = theme.CreateSmallResetButton(); resetButton.HAnchor = HAnchor.Right | HAnchor.Fit; resetButton.VAnchor = VAnchor.Center | VAnchor.Fit; resetButton.Name = "Close Search"; diff --git a/PartPreviewWindow/GCode2DWidget.cs b/PartPreviewWindow/GCode2DWidget.cs index 1c7e73213..118683db4 100644 --- a/PartPreviewWindow/GCode2DWidget.cs +++ b/PartPreviewWindow/GCode2DWidget.cs @@ -65,13 +65,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private EventHandler unregisterEvents; private ImageBuffer bedImage; - public GCode2DWidget(PrinterConfig printer) + public GCode2DWidget(PrinterConfig printer, ThemeConfig theme) { this.printer = printer; options = printer.Bed.RendererOptions; - var theme = ApplicationController.Instance.Theme; - this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.LocalBounds = new RectangleDouble(0, 0, 100, 100); diff --git a/PartPreviewWindow/Object3DTreeBuilder.cs b/PartPreviewWindow/Object3DTreeBuilder.cs index fd5c7be05..e98eb6907 100644 --- a/PartPreviewWindow/Object3DTreeBuilder.cs +++ b/PartPreviewWindow/Object3DTreeBuilder.cs @@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if(item.Source is InsertionGroupObject3D insertionGroup) { - return new TreeNode() + return new TreeNode(theme) { Text = "Loading".Localize(), Tag = item.Source, @@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; } - var node = new TreeNode() + var node = new TreeNode(theme) { Text = GetName(item), Tag = item.Source, diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index 4a9917210..2b40b0f30 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -46,11 +46,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private ChromeTab printerTab = null; private ChromeTabs tabControl; - public PartPreviewContent() + public PartPreviewContent(ThemeConfig theme) : base(FlowDirection.TopToBottom) { - var theme = ApplicationController.Instance.Theme; - this.AnchorAll(); var extensionArea = new LeftClipFlowLayoutWidget() diff --git a/PartPreviewWindow/PopupMenuButton.cs b/PartPreviewWindow/PopupMenuButton.cs index f1e3df953..8ec21d929 100644 --- a/PartPreviewWindow/PopupMenuButton.cs +++ b/PartPreviewWindow/PopupMenuButton.cs @@ -36,9 +36,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public class PopupMenuButton : PopupButton { - public PopupMenuButton() + private ThemeConfig theme; + + public PopupMenuButton(ThemeConfig theme) { - var theme = ApplicationController.Instance.Theme; + this.theme = theme; this.DisabledColor = new Color(theme.Colors.SecondaryTextColor, 50); this.HoverColor = theme.MinimalShade; } @@ -49,7 +51,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow viewWidget.Selectable = false; viewWidget.BackgroundColor = Color.Transparent; - this.DisabledColor = new Color(ActiveTheme.Instance.SecondaryTextColor, 50); + this.theme = theme; + this.DisabledColor = new Color(theme.Colors.SecondaryTextColor, 50); this.HoverColor = theme.ToolbarButtonHover; this.BackgroundColor = theme.ToolbarButtonBackground; @@ -71,8 +74,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public Color DisabledColor { get; set; } - public Color HoverColor { get; set; } = Color.Transparent; - public Color MouseDownColor { get; set;} = Color.Transparent; private bool _drawArrow = false; @@ -103,10 +104,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { // Draw directional arrow graphics2D.Render( - dropArrow, + dropArrow, LocalBounds.Right - DropArrow.ArrowHeight * 2 - 2, LocalBounds.Center.Y + DropArrow.ArrowHeight / 2, - this.Enabled ? ActiveTheme.Instance.SecondaryTextColor : this.DisabledColor); + this.Enabled ? theme.Colors.SecondaryTextColor : this.DisabledColor); } } diff --git a/PartPreviewWindow/PrinterTabPage.cs b/PartPreviewWindow/PrinterTabPage.cs index ecf961147..72f5c8023 100644 --- a/PartPreviewWindow/PrinterTabPage.cs +++ b/PartPreviewWindow/PrinterTabPage.cs @@ -93,7 +93,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow printer.ViewState.ViewModeChanged += ViewState_ViewModeChanged; - LayerScrollbar = new SliceLayerSelector(printer, sceneContext) + LayerScrollbar = new SliceLayerSelector(printer, sceneContext, theme) { VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Right | HAnchor.Fit, @@ -199,7 +199,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }); // Create and append new widget - gcode2DWidget = new GCode2DWidget(printer) + gcode2DWidget = new GCode2DWidget(printer, theme) { Visible = (printer.ViewState.ViewMode == PartViewMode.Layers2D) }; @@ -395,14 +395,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void AddSettingsTabBar(GuiWidget parent, GuiWidget widgetTodockTo) { - sideBar = new DockingTabControl(widgetTodockTo, DockSide.Right, ApplicationController.Instance.ActivePrinter) + sideBar = new DockingTabControl(widgetTodockTo, DockSide.Right, printer, theme) { Name = "DockingTabControl", - ControlIsPinned = ApplicationController.Instance.ActivePrinter.ViewState.SliceSettingsTabPinned + ControlIsPinned = printer.ViewState.SliceSettingsTabPinned }; sideBar.PinStatusChanged += (s, e) => { - ApplicationController.Instance.ActivePrinter.ViewState.SliceSettingsTabPinned = sideBar.ControlIsPinned; + printer.ViewState.SliceSettingsTabPinned = sideBar.ControlIsPinned; }; parent.AddChild(sideBar); @@ -416,9 +416,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow NamedSettingsLayers.All), theme)); - sideBar.AddPage("Controls".Localize(), new ManualPrinterControls(printer)); + sideBar.AddPage("Controls".Localize(), new ManualPrinterControls(printer, theme)); - sideBar.AddPage("Terminal".Localize(), new TerminalWidget(printer) + sideBar.AddPage("Terminal".Localize(), new TerminalWidget(printer, theme) { VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Stretch @@ -429,7 +429,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void ProcessOptionalTab() { - if (ApplicationController.Instance.ActivePrinter.ViewState.ConfigurePrinterVisible) + if (printer.ViewState.ConfigurePrinterVisible) { sideBar.AddPage( "Printer".Localize(), @@ -451,7 +451,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { HAnchor = HAnchor.Fit | HAnchor.Center, VAnchor = VAnchor.Top | VAnchor.Fit, - //BackgroundColor = new Color(ActiveTheme.Instance.PrimaryBackgroundColor, 128), + //BackgroundColor = new Color(theme.Colors.PrimaryBackgroundColor, 128), MinimumSize = new Vector2(275, 140), Selectable = false }; @@ -491,7 +491,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Center }); - var timeWidget = new TextWidget("", pointSize: 22, textColor: ActiveTheme.Instance.PrimaryTextColor) + var timeWidget = new TextWidget("", pointSize: 22, textColor: theme.Colors.PrimaryTextColor) { AutoExpandBoundsToText = true, Margin = new BorderDouble(10, 0, 0, 0), diff --git a/PartPreviewWindow/SliceLayerSelector.cs b/PartPreviewWindow/SliceLayerSelector.cs index b77cca925..fce788055 100644 --- a/PartPreviewWindow/SliceLayerSelector.cs +++ b/PartPreviewWindow/SliceLayerSelector.cs @@ -48,10 +48,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private SolidSlider layerSlider; private double layerInfoHalfHeight; - public SliceLayerSelector(PrinterConfig printer, BedConfig sceneContext) + public SliceLayerSelector(PrinterConfig printer, BedConfig sceneContext, ThemeConfig theme) { - var theme = ApplicationController.Instance.Theme; - this.sceneContext = sceneContext; this.AddChild(layerScrollbar = new LayerScrollbar(printer, sceneContext) diff --git a/PartPreviewWindow/View3D/GridOptionsPanel.cs b/PartPreviewWindow/View3D/GridOptionsPanel.cs index 8ca28eacd..ff5289935 100644 --- a/PartPreviewWindow/View3D/GridOptionsPanel.cs +++ b/PartPreviewWindow/View3D/GridOptionsPanel.cs @@ -35,10 +35,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public class GridOptionsPanel : FlowLayoutWidget, IIgnoredPopupChild { - public GridOptionsPanel(InteractionLayer interactionLayer) : base(FlowDirection.TopToBottom) + public GridOptionsPanel(InteractionLayer interactionLayer, ThemeConfig theme) + : base(FlowDirection.TopToBottom) { - var theme = ApplicationController.Instance.Theme; - this.HAnchor = HAnchor.MaxFitOrStretch; this.AddChild(new TextWidget("Snap Grid".Localize()) diff --git a/PartPreviewWindow/View3D/MeshViewerWidget.cs b/PartPreviewWindow/View3D/MeshViewerWidget.cs index 3f72a854a..e225b2488 100644 --- a/PartPreviewWindow/View3D/MeshViewerWidget.cs +++ b/PartPreviewWindow/View3D/MeshViewerWidget.cs @@ -284,11 +284,9 @@ namespace MatterHackers.MeshVisualizer private BedConfig sceneContext; - private double selectionHighlightWidth = 5; - private Color debugBorderColor = Color.Green; - public MeshViewerWidget(BedConfig sceneContext, InteractionLayer interactionLayer, string startingTextMessage = "", EditorType editorType = EditorType.Part) + public MeshViewerWidget(BedConfig sceneContext, InteractionLayer interactionLayer, ThemeConfig theme, EditorType editorType = EditorType.Part) { this.EditorMode = editorType; this.scene = sceneContext.Scene; @@ -296,8 +294,6 @@ namespace MatterHackers.MeshVisualizer this.interactionLayer = interactionLayer; this.World = interactionLayer.World; - var theme = ApplicationController.Instance.Theme; - gridColors = new GridColors() { Gray = theme.ResolveColor(theme.ActiveTabColor, theme.GetBorderColor((theme.Colors.IsDarkTheme ? 35 : 55))), @@ -634,7 +630,6 @@ namespace MatterHackers.MeshVisualizer double secondsSinceSelectionChanged = (UiThread.CurrentTimerMs - lastSelectionChangedMs) / 1000.0; if (secondsSinceSelectionChanged < .5) { - //var accentColor = ApplicationController.Instance.Theme.Colors.PrimaryAccentColor; var accentColor = Color.LightGray; if (secondsSinceSelectionChanged < .25) { diff --git a/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs b/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs index 824e4dd1e..9ab50a058 100644 --- a/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs +++ b/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs @@ -48,6 +48,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private SettingsContext settingsContext; public PrintPopupMenu(PrinterConfig printer, ThemeConfig theme) + : base(theme) { this.printer = printer; this.DrawArrow = true; diff --git a/PartPreviewWindow/View3D/PrinterBar/PrinterConnectButton.cs b/PartPreviewWindow/View3D/PrinterBar/PrinterConnectButton.cs index 721ba8acc..fcc44443e 100644 --- a/PartPreviewWindow/View3D/PrinterBar/PrinterConnectButton.cs +++ b/PartPreviewWindow/View3D/PrinterBar/PrinterConnectButton.cs @@ -201,7 +201,8 @@ namespace MatterHackers.MatterControl.ActionBar private static void RunTroubleShooting() { - DialogWindow.Show(); + DialogWindow.Show( + new SetupWizardTroubleshooting(ApplicationController.Instance.ActivePrinter)); } private void SetChildVisible(GuiWidget visibleChild, bool enabled) diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 078bdba7e..e090ba0ce 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -112,7 +112,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow viewControls3D.TransformStateChanged += ViewControls3D_TransformStateChanged; // MeshViewer - meshViewerWidget = new MeshViewerWidget(sceneContext, this.InteractionLayer, editorType: editorType); + meshViewerWidget = new MeshViewerWidget(sceneContext, this.InteractionLayer, theme, editorType: editorType); meshViewerWidget.AnchorAll(); this.AddChild(meshViewerWidget); @@ -1265,7 +1265,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { this.ShowBedViewOptions(popupMenu); - popupMenu.AddChild(new GridOptionsPanel(this.InteractionLayer)); + popupMenu.AddChild(new GridOptionsPanel(this.InteractionLayer, theme)); return popupMenu; } diff --git a/PrinterControls/ControlWidgets/CalibrationControls.cs b/PrinterControls/ControlWidgets/CalibrationControls.cs index 46db71613..0ec729e2d 100644 --- a/PrinterControls/ControlWidgets/CalibrationControls.cs +++ b/PrinterControls/ControlWidgets/CalibrationControls.cs @@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl.PrinterControls var editButton = new IconButton(AggContext.StaticData.LoadIcon("icon_edit.png", 16, 16, theme.InvertIcons), theme); editButton.Click += (s, e) => { - DialogWindow.Show(new EditLevelingSettingsPage(printer)); + DialogWindow.Show(new EditLevelingSettingsPage(printer, theme)); }; return new SectionWidget( diff --git a/PrinterControls/EditLevelingSettingsPage.cs b/PrinterControls/EditLevelingSettingsPage.cs index c2aa4636c..9f6551612 100644 --- a/PrinterControls/EditLevelingSettingsPage.cs +++ b/PrinterControls/EditLevelingSettingsPage.cs @@ -39,10 +39,8 @@ namespace MatterHackers.MatterControl { public class EditLevelingSettingsPage : DialogPage { - public EditLevelingSettingsPage(PrinterConfig printer) + public EditLevelingSettingsPage(PrinterConfig printer, ThemeConfig theme) { - var theme = ApplicationController.Instance.Theme; - this.WindowTitle = "Leveling Settings".Localize(); this.HeaderText = "Sampled Positions".Localize(); diff --git a/PrinterControls/MacroDetailPage.cs b/PrinterControls/MacroDetailPage.cs index 1198fb3cd..1c76bcd4a 100644 --- a/PrinterControls/MacroDetailPage.cs +++ b/PrinterControls/MacroDetailPage.cs @@ -44,8 +44,6 @@ namespace MatterHackers.MatterControl public MacroDetailPage(GCodeMacro gcodeMacro, PrinterSettings printerSettings) { - var theme = ApplicationController.Instance.Theme; - // Form validation fields MHTextEditWidget macroNameInput; MHTextEditWidget macroCommandInput; diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index 117fb2edf..939070494 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -61,10 +61,9 @@ namespace MatterHackers.MatterControl private PrinterConfig printer; private FlowLayoutWidget column; - public ManualPrinterControls(PrinterConfig printer) + public ManualPrinterControls(PrinterConfig printer, ThemeConfig theme) { - this.theme = ApplicationController.Instance.Theme; - + this.theme = theme; this.printer = printer; this.ScrollArea.HAnchor |= HAnchor.Stretch; this.AnchorAll(); diff --git a/PrinterControls/PrinterConnections/PrinterChooser.cs b/PrinterControls/PrinterConnections/PrinterChooser.cs index 23c8b1ace..5a448a70e 100644 --- a/PrinterControls/PrinterConnections/PrinterChooser.cs +++ b/PrinterControls/PrinterConnections/PrinterChooser.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2015, Kevin Pope +Copyright (c) 2018, Kevin Pope, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -37,18 +37,15 @@ namespace MatterHackers.MatterControl { private List> listSource; - public BoundDropList(string noSelectionString, int maxHeight = 0) - : base(noSelectionString, ActiveTheme.Instance.PrimaryTextColor, maxHeight: maxHeight, pointSize: ApplicationController.Instance.Theme.DefaultFontSize) + public BoundDropList(string noSelectionString, ThemeConfig theme, int maxHeight = 0) + : base(noSelectionString, theme.Colors.PrimaryTextColor, maxHeight: maxHeight, pointSize: theme.DefaultFontSize) { - this.BorderColor = ApplicationController.Instance.Theme.GetBorderColor(75); + this.BorderColor = theme.GetBorderColor(75); } public List> ListSource { - get - { - return listSource; - } + get => listSource; set { if (listSource == value) @@ -81,4 +78,3 @@ namespace MatterHackers.MatterControl } } } - \ No newline at end of file diff --git a/PrinterControls/PrinterConnections/SetupStepMakeModelName.cs b/PrinterControls/PrinterConnections/SetupStepMakeModelName.cs index 24420d988..d5c865ce9 100644 --- a/PrinterControls/PrinterConnections/SetupStepMakeModelName.cs +++ b/PrinterControls/PrinterConnections/SetupStepMakeModelName.cs @@ -66,7 +66,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections { this.WindowTitle = "Setup Wizard".Localize(); - printerManufacturerSelector = new BoundDropList(string.Format("- {0} -", "Select Make".Localize()), maxHeight: 200) + printerManufacturerSelector = new BoundDropList(string.Format("- {0} -", "Select Make".Localize()), theme, maxHeight: 200) { HAnchor = HAnchor.Stretch, Margin = elementMargin, @@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections "Select the printer manufacturer".Localize(), printerManufacturerSelector); - printerModelSelector = new BoundDropList(string.Format("- {0} -", "Select Model".Localize()), maxHeight: 200) + printerModelSelector = new BoundDropList(string.Format("- {0} -", "Select Model".Localize()), theme, maxHeight: 200) { Name = "Select Model", HAnchor = HAnchor.Stretch, @@ -148,7 +148,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections { TextWidget printerNameLabel = new TextWidget("Name".Localize() + ":", 0, 0, 12) { - TextColor = ActiveTheme.Instance.PrimaryTextColor, + TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(0, 4, 0, 1) }; @@ -161,33 +161,35 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections printerNameError = new TextWidget("", 0, 0, 10) { - TextColor = ActiveTheme.Instance.PrimaryTextColor, + TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(top: 3) }; - FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); - container.Margin = new BorderDouble(0, 5); + var container = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + Margin = new BorderDouble(0, 5), + HAnchor = HAnchor.Stretch + }; container.AddChild(printerNameLabel); container.AddChild(printerNameInput); container.AddChild(printerNameError); - container.HAnchor = HAnchor.Stretch; return container; } - private FlowLayoutWidget CreateSelectionContainer(string labelText, string validationMessage, Agg.UI.DropDownList selector) + private FlowLayoutWidget CreateSelectionContainer(string labelText, string validationMessage, DropDownList selector) { var sectionLabel = new TextWidget(labelText, 0, 0, 12) { - TextColor = ActiveTheme.Instance.PrimaryTextColor, + TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Stretch, Margin = elementMargin }; var validationTextWidget = new TextWidget(validationMessage, 0, 0, 10) { - TextColor = ActiveTheme.Instance.PrimaryAccentColor, + TextColor = theme.Colors.PrimaryAccentColor, HAnchor = HAnchor.Stretch, Margin = elementMargin }; diff --git a/PrinterControls/TerminalWindow/TerminalWidget.cs b/PrinterControls/TerminalWindow/TerminalWidget.cs index ae44b4077..522182d04 100644 --- a/PrinterControls/TerminalWindow/TerminalWidget.cs +++ b/PrinterControls/TerminalWindow/TerminalWidget.cs @@ -46,15 +46,11 @@ namespace MatterHackers.MatterControl private TextScrollWidget textScrollWidget; private PrinterConfig printer; - public TerminalWidget(PrinterConfig printer) + public TerminalWidget(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; - - var theme = ApplicationController.Instance.Theme; - this.Name = "TerminalWidget"; - this.BackgroundColor = theme.TabBodyBackground; this.Padding = new BorderDouble(5, 0); // Header @@ -67,7 +63,7 @@ namespace MatterHackers.MatterControl filterOutput = new CheckBox("Filter Output".Localize(), textSize: theme.DefaultFontSize) { - TextColor = ActiveTheme.Instance.PrimaryTextColor, + TextColor = theme.Colors.PrimaryTextColor, VAnchor = VAnchor.Bottom, }; filterOutput.CheckedStateChanged += (s, e) => @@ -89,7 +85,7 @@ namespace MatterHackers.MatterControl { Margin = new BorderDouble(left: 25), Checked = UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalAutoUppercase, true), - TextColor = ActiveTheme.Instance.PrimaryTextColor, + TextColor = theme.Colors.PrimaryTextColor, VAnchor = VAnchor.Bottom }; autoUppercase.CheckedStateChanged += (s, e) => @@ -105,8 +101,8 @@ namespace MatterHackers.MatterControl textScrollWidget = new TextScrollWidget(printer, printer.Connection.TerminalLog.PrinterLines) { - BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor, - TextColor = ActiveTheme.Instance.PrimaryTextColor, + BackgroundColor = theme.Colors.SecondaryBackgroundColor, + TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = 0, diff --git a/SetupWizard/AndroidConnectDevicePage.cs b/SetupWizard/AndroidConnectDevicePage.cs index a57cf32cb..f3c4f5a36 100644 --- a/SetupWizard/AndroidConnectDevicePage.cs +++ b/SetupWizard/AndroidConnectDevicePage.cs @@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl public AndroidConnectDevicePage() { - TextWidget printerNameLabel = new TextWidget("Connect Your Device".Localize() + ":", 0, 0, labelFontSize) + var printerNameLabel = new TextWidget("Connect Your Device".Localize() + ":", 0, 0, labelFontSize) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(bottom: 10) @@ -110,7 +110,8 @@ namespace MatterHackers.MatterControl troubleshootButton = theme.CreateLightDialogButton("Troubleshoot".Localize()); troubleshootButton.Click += (s, e) => UiThread.RunOnIdle(() => { - DialogWindow.ChangeToPage(); + DialogWindow.ChangeToPage( + new SetupWizardTroubleshooting(ApplicationController.Instance.ActivePrinter)); }); retryButtonContainer = new FlowLayoutWidget() diff --git a/SetupWizard/DialogWindow.cs b/SetupWizard/DialogWindow.cs index e2c9c1990..b2f449f8e 100644 --- a/SetupWizard/DialogWindow.cs +++ b/SetupWizard/DialogWindow.cs @@ -46,11 +46,13 @@ namespace MatterHackers.MatterControl private DialogWindow() : base(500 * GuiWidget.DeviceScale, 500 * GuiWidget.DeviceScale) { + var theme = ApplicationController.Instance.Theme; + this.AlwaysOnTopOfMain = true; this.MinimumSize = new Vector2(200, 200); - this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + this.BackgroundColor = theme.Colors.PrimaryBackgroundColor; - var defaultPadding = ApplicationController.Instance.Theme.DefaultContainerPadding; + var defaultPadding = theme.DefaultContainerPadding; this.Padding = new BorderDouble(defaultPadding, defaultPadding, defaultPadding, 2); } diff --git a/SetupWizard/HelpPage.cs b/SetupWizard/HelpPage.cs index b56daaf37..96500fdf8 100644 --- a/SetupWizard/HelpPage.cs +++ b/SetupWizard/HelpPage.cs @@ -225,7 +225,7 @@ namespace MatterHackers.MatterControl sequence.AddImage(new ImageBuffer(1, 1)); var description = new GuiWidget(); - var markdownWidget = new MarkdownWidget() + var markdownWidget = new MarkdownWidget(theme) { BackgroundColor = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.White, 20)), Padding = new BorderDouble(left: theme.DefaultContainerPadding / 2) @@ -302,7 +302,7 @@ namespace MatterHackers.MatterControl private TreeNode ProcessTree(HelpArticle container) { - var treeNode = new TreeNode(false) + var treeNode = new TreeNode(theme, false) { Text = container.Name, Tag = container @@ -316,7 +316,7 @@ namespace MatterHackers.MatterControl } else { - treeNode.Nodes.Add(new TreeNode(false) + treeNode.Nodes.Add(new TreeNode(theme, false) { Text = item.Name, Tag = item diff --git a/SetupWizard/SetupWizardTroubleshooting.cs b/SetupWizard/SetupWizardTroubleshooting.cs index 7367e8719..60154fcb7 100644 --- a/SetupWizard/SetupWizardTroubleshooting.cs +++ b/SetupWizard/SetupWizardTroubleshooting.cs @@ -30,6 +30,7 @@ namespace MatterHackers.MatterControl // Used in Android private System.Threading.Timer checkForPermissionTimer; + private PrinterConfig printer; #if __ANDROID__ private static UsbManager usbManager @@ -38,9 +39,10 @@ namespace MatterHackers.MatterControl } #endif - public SetupWizardTroubleshooting() + public SetupWizardTroubleshooting(PrinterConfig printer) { this.WindowTitle = "Troubleshooting".Localize(); + this.printer = printer; RefreshStatus(); @@ -51,12 +53,12 @@ namespace MatterHackers.MatterControl this.AddPageAction(nextButton); // Register for connection notifications - ApplicationController.Instance.ActivePrinter.Connection.CommunicationStateChanged.RegisterEvent(ConnectionStatusChanged, ref unregisterEvents); + printer.Connection.CommunicationStateChanged.RegisterEvent(ConnectionStatusChanged, ref unregisterEvents); } public void ConnectionStatusChanged(object test, EventArgs args) { - if(ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Connected && connectToPrinterRow != null) + if(printer.Connection.CommunicationState == CommunicationStates.Connected && connectToPrinterRow != null) { connectToPrinterRow.SetSuccessful(); nextButton.Visible = true; @@ -92,9 +94,11 @@ namespace MatterHackers.MatterControl contentRow.CloseAllChildren(); // Regen and refresh the troubleshooting criteria - TextWidget printerNameLabel = new TextWidget(string.Format ("{0}:", "Connection Troubleshooting".Localize()), 0, 0, labelFontSize); - printerNameLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; - printerNameLabel.Margin = new BorderDouble(bottom: 10); + var printerNameLabel = new TextWidget(string.Format("{0}:", "Connection Troubleshooting".Localize()), 0, 0, labelFontSize) + { + TextColor = theme.Colors.PrimaryTextColor, + Margin = new BorderDouble(bottom: 10) + }; #if __ANDROID__ IUsbSerialPort serialPort = FrostedSerialPort.LoadSerialDriver(null); @@ -181,19 +185,22 @@ namespace MatterHackers.MatterControl "Connect".Localize(), "Click the 'Connect' button to retry the original connection attempt".Localize(), false, - () => ApplicationController.Instance.ActivePrinter.Connection.Connect()); + () => printer.Connection.Connect(), + theme); contentRow.AddChild(connectToPrinterRow); if (CriteriaRow.ActiveErrorItem != null) { - FlowLayoutWidget errorText = new FlowLayoutWidget () { + var errorText = new FlowLayoutWidget () { Padding = new BorderDouble (0, 15) }; - errorText.AddChild(new TextWidget(CriteriaRow.ActiveErrorItem.ErrorText) { - TextColor = ActiveTheme.Instance.PrimaryAccentColor - }); + errorText.AddChild( + new TextWidget(CriteriaRow.ActiveErrorItem.ErrorText) + { + TextColor = theme.Colors.PrimaryAccentColor + }); contentRow.AddChild(errorText); } @@ -213,7 +220,7 @@ namespace MatterHackers.MatterControl private static Color disabledBackColor = new Color(0.22, 0.22, 0.22); private static Color toggleColor = new Color(Color.Gray.red + 2, Color.Gray.green + 2, Color.Gray.blue + 2); - public CriteriaRow (string itemText, string fixitText, string errorText, bool succeeded, Action fixAction) + public CriteriaRow (string itemText, string fixitText, string errorText, bool succeeded, Action fixAction, ThemeConfig theme) : base(FlowDirection.LeftToRight) { HAnchor = HAnchor.Stretch; @@ -242,7 +249,7 @@ namespace MatterHackers.MatterControl AddSuccessIcon(); } else { // Add Fix button - var button = ApplicationController.Instance.Theme.CreateDialogButton(fixitText); + var button = theme.CreateDialogButton(fixitText); button.VAnchor = VAnchor.Center; button.Padding = new BorderDouble(3, 8); button.Click += (s, e) => fixAction?.Invoke(); diff --git a/SlicerConfiguration/SlicePresetsWindow/SlicePresetsWindow.cs b/SlicerConfiguration/SlicePresetsWindow/SlicePresetsWindow.cs index f6691455d..9077a9467 100644 --- a/SlicerConfiguration/SlicePresetsWindow/SlicePresetsWindow.cs +++ b/SlicerConfiguration/SlicePresetsWindow/SlicePresetsWindow.cs @@ -140,7 +140,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration }, presetsContext.LayerType); - return new SliceSettingsWidget(printer, settingsContext, ApplicationController.Instance.Theme) + return new SliceSettingsWidget(printer, settingsContext, theme) { ShowControlBar = false }; diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 08eebd79b..6b340495c 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -202,7 +202,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.TabBar.Padding = this.TabBar.Margin.Clone(right: theme.ToolbarPadding.Right); - searchPanel = new SearchInputBox() + searchPanel = new SearchInputBox(theme) { Visible = false, BackgroundColor = theme.TabBarBackground, @@ -788,7 +788,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration break; case SliceSettingData.DataEditTypes.LIST: - uiField = new ListField() + uiField = new ListField(theme) { ListItems = settingData.ListValues.Split(',').ToList() }; @@ -808,7 +808,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration break; #if !__ANDROID__ case SliceSettingData.DataEditTypes.IP_LIST: - uiField = new IpAddessField(printer); + uiField = new IpAddessField(printer, theme); break; #endif @@ -857,7 +857,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (settingData.QuickMenuSettings.Count > 0 && settingData.SlicerConfigName == "baud_rate") { - var dropMenu = new DropMenuWrappedField(uiField, settingData, theme.Colors.PrimaryTextColor); + var dropMenu = new DropMenuWrappedField(uiField, settingData, theme.Colors.PrimaryTextColor, theme); dropMenu.Initialize(tabIndexForItem); settingsRow.AddContent(dropMenu.Content); diff --git a/SlicerConfiguration/UIFields/DirectionVectorField.cs b/SlicerConfiguration/UIFields/DirectionVectorField.cs index 3f89a6117..8bcf4a94e 100644 --- a/SlicerConfiguration/UIFields/DirectionVectorField.cs +++ b/SlicerConfiguration/UIFields/DirectionVectorField.cs @@ -38,11 +38,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public class DirectionVectorField : UIField { private DropDownList dropDownList; + private ThemeConfig theme; + + public DirectionVectorField(ThemeConfig theme) + { + this.theme = theme; + } public override void Initialize(int tabIndex) { - var theme = ApplicationController.Instance.Theme; - dropDownList = new DropDownList("Name".Localize(), theme.Colors.PrimaryTextColor, Direction.Down, pointSize: theme.DefaultFontSize) { BorderColor = theme.GetBorderColor(75) diff --git a/SlicerConfiguration/UIFields/DropMenuWrappedField.cs b/SlicerConfiguration/UIFields/DropMenuWrappedField.cs index c662e2716..a56d68b82 100644 --- a/SlicerConfiguration/UIFields/DropMenuWrappedField.cs +++ b/SlicerConfiguration/UIFields/DropMenuWrappedField.cs @@ -37,13 +37,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { private UIField uiField; private Color textColor; + private ThemeConfig theme; private SliceSettingData settingData; - public DropMenuWrappedField(UIField uiField, SliceSettingData settingData, Color textColor) + public DropMenuWrappedField(UIField uiField, SliceSettingData settingData, Color textColor, ThemeConfig theme) { this.settingData = settingData; this.uiField = uiField; this.textColor = textColor; + this.theme = theme; } public void SetValue(string newValue, bool userInitiated) @@ -60,7 +62,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public void Initialize(int tabIndex) { var totalContent = new FlowLayoutWidget(); - var theme = ApplicationController.Instance.Theme; var selectableOptions = new DropDownList("Custom", textColor, maxHeight: 200, pointSize: theme.DefaultFontSize) { diff --git a/SlicerConfiguration/UIFields/EnumField.cs b/SlicerConfiguration/UIFields/EnumField.cs index c68760fad..b9d9ffa2b 100644 --- a/SlicerConfiguration/UIFields/EnumField.cs +++ b/SlicerConfiguration/UIFields/EnumField.cs @@ -38,17 +38,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public class EnumField : UIField { private EditableProperty property; + private ThemeConfig theme; private DropDownList dropDownList; - public EnumField(EditableProperty property) + public EnumField(EditableProperty property, ThemeConfig theme) { this.property = property; + this.theme = theme; } public override void Initialize(int tabIndex) { - var theme = ApplicationController.Instance.Theme; - // Enum keyed on name to friendly name var enumItems = Enum.GetNames(property.PropertyType).Select(enumName => { diff --git a/SlicerConfiguration/UIFields/IconEnumField.cs b/SlicerConfiguration/UIFields/IconEnumField.cs index 076a11cab..cfd115734 100644 --- a/SlicerConfiguration/UIFields/IconEnumField.cs +++ b/SlicerConfiguration/UIFields/IconEnumField.cs @@ -43,11 +43,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { private EditableProperty property; private IconsAttribute iconsAttribute; + private ThemeConfig theme; - public IconEnumField(EditableProperty property, IconsAttribute iconsAttribute) + public IconEnumField(EditableProperty property, IconsAttribute iconsAttribute, ThemeConfig theme) { this.property = property; this.iconsAttribute = iconsAttribute; + this.theme = theme; } // TODO: Violates UIField norms but consistent with past behavior - state is only correct at construction time, often reconstructed @@ -55,8 +57,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public override void Initialize(int tabIndex) { - var theme = ApplicationController.Instance.Theme; - // Enum keyed on name to friendly name var enumItems = Enum.GetNames(property.PropertyType).Select(enumName => { diff --git a/SlicerConfiguration/UIFields/IpAddessField.cs b/SlicerConfiguration/UIFields/IpAddessField.cs index a899f47f2..6e98cfc87 100644 --- a/SlicerConfiguration/UIFields/IpAddessField.cs +++ b/SlicerConfiguration/UIFields/IpAddessField.cs @@ -20,18 +20,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration private IconButton refreshButton; private PrinterConfig printer; + private ThemeConfig theme; - public IpAddessField(PrinterConfig printer) + public IpAddessField(PrinterConfig printer, ThemeConfig theme) { this.printer = printer; + this.theme = theme; } public override void Initialize(int tabIndex) { EventHandler unregisterEvents = null; - var theme = ApplicationController.Instance.Theme; - base.Initialize(tabIndex); bool canChangeComPort = !printer.Connection.IsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; //This setting defaults to Manual @@ -72,7 +72,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var widget = new FlowLayoutWidget(); widget.AddChild(dropdownList); - refreshButton = new IconButton(AggContext.StaticData.LoadIcon("fa-refresh_14.png", theme.InvertIcons), ApplicationController.Instance.Theme) + refreshButton = new IconButton(AggContext.StaticData.LoadIcon("fa-refresh_14.png", theme.InvertIcons), theme) { Margin = new BorderDouble(left: 5) }; diff --git a/SlicerConfiguration/UIFields/ListField.cs b/SlicerConfiguration/UIFields/ListField.cs index b7196f0d0..e12317e6d 100644 --- a/SlicerConfiguration/UIFields/ListField.cs +++ b/SlicerConfiguration/UIFields/ListField.cs @@ -38,12 +38,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public class ListField : UIField { private DropDownList dropdownList; + private ThemeConfig theme; public List ListItems { get; set; } + public ListField(ThemeConfig theme) + { + this.theme = theme; + } + public override void Initialize(int tabIndex) { - var theme = ApplicationController.Instance.Theme; dropdownList = new DropDownList("None".Localize(), theme.Colors.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize) { ToolTipText = this.HelpText, diff --git a/Tests/MatterControl.Tests/MatterControl/PrinterChooserUnitTests.cs b/Tests/MatterControl.Tests/MatterControl/PrinterChooserUnitTests.cs index da7823f1d..a1df4d987 100644 --- a/Tests/MatterControl.Tests/MatterControl/PrinterChooserUnitTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/PrinterChooserUnitTests.cs @@ -23,8 +23,9 @@ namespace MatterControl.Tests.MatterControl BoundDropList dropList; + var theme = new ThemeConfig(); // Whitelist on non-OEM builds should contain all printers - dropList = new BoundDropList("Test"); + dropList = new BoundDropList("Test", theme); dropList.ListSource = allManufacturers; Assert.Greater(dropList.MenuItems.Count, 20); @@ -32,14 +33,14 @@ namespace MatterControl.Tests.MatterControl OemSettings.Instance.SetManufacturers(allManufacturers, whitelist); - dropList = new BoundDropList("Test"); + dropList = new BoundDropList("Test", theme); dropList.ListSource = OemSettings.Instance.AllOems; Assert.AreEqual(1, dropList.MenuItems.Count); whitelist.Add("Airwolf 3D"); OemSettings.Instance.SetManufacturers(allManufacturers, whitelist); - dropList = new BoundDropList("Test"); + dropList = new BoundDropList("Test", theme); dropList.ListSource = OemSettings.Instance.AllOems; Assert.AreEqual(2, dropList.MenuItems.Count); diff --git a/Utilities/MarkdigAgg/AggCodeBlockRenderer.cs b/Utilities/MarkdigAgg/AggCodeBlockRenderer.cs index a640c49de..ce25f96d6 100644 --- a/Utilities/MarkdigAgg/AggCodeBlockRenderer.cs +++ b/Utilities/MarkdigAgg/AggCodeBlockRenderer.cs @@ -11,25 +11,34 @@ namespace Markdig.Renderers.Agg { public class CodeBlockX : FlowLeftRightWithWrapping { - public CodeBlockX() + private ThemeConfig theme; + + public CodeBlockX(ThemeConfig theme) { - var theme = ApplicationController.Instance.Theme; - HAnchor = HAnchor.Stretch; - VAnchor = VAnchor.Fit; - Margin = 12; - Padding = 6; - BackgroundColor = theme.MinimalShade; + this.theme = theme; + this.HAnchor = HAnchor.Stretch; + this.VAnchor = VAnchor.Fit; + this.Margin = 12; + this.Padding = 6; + this.BackgroundColor = theme.MinimalShade; } } public class AggCodeBlockRenderer : AggObjectRenderer { + private ThemeConfig theme; + + public AggCodeBlockRenderer(ThemeConfig theme) + { + this.theme = theme; + } + protected override void Write(AggRenderer renderer, CodeBlock obj) { //var paragraph = new Paragraph(); //paragraph.SetResourceReference(FrameworkContentElement.StyleProperty, Styles.CodeBlockStyleKey); - renderer.Push(new CodeBlockX()); + renderer.Push(new CodeBlockX(theme)); renderer.WriteLeafRawLines(obj); renderer.Pop(); } diff --git a/Utilities/MarkdigAgg/AggHeadingRenderer.cs b/Utilities/MarkdigAgg/AggHeadingRenderer.cs index 73f95e768..6cf386559 100644 --- a/Utilities/MarkdigAgg/AggHeadingRenderer.cs +++ b/Utilities/MarkdigAgg/AggHeadingRenderer.cs @@ -1,21 +1,17 @@ // Copyright (c) 2016-2017 Nicolas Musset. All rights reserved. -// This file is licensed under the MIT license. +// This file is licensed under the MIT license. // See the LICENSE.md file in the project root for more information. using Markdig.Syntax; using MatterHackers.Agg; using MatterHackers.Agg.UI; -using MatterHackers.MatterControl; namespace Markdig.Renderers.Agg { public class HeadingRowX : FlowLeftRightWithWrapping { - public override HAnchor HAnchor { get => base.HAnchor; set => base.HAnchor = value; } public HeadingRowX() { - var theme = ApplicationController.Instance.Theme; - this.VAnchor = VAnchor.Fit; this.HAnchor = HAnchor.Stretch; this.Margin = new BorderDouble(0, 4, 0, 12); @@ -34,30 +30,30 @@ namespace Markdig.Renderers.Agg } public class AggHeadingRenderer : AggObjectRenderer - { - protected override void Write(AggRenderer renderer, HeadingBlock obj) - { - //var paragraph = new Paragraph(); - //ComponentResourceKey styleKey = null; + { + protected override void Write(AggRenderer renderer, HeadingBlock obj) + { + //var paragraph = new Paragraph(); + //ComponentResourceKey styleKey = null; - //switch (obj.Level) - //{ - // case 1: styleKey = Styles.Heading1StyleKey; break; - // case 2: styleKey = Styles.Heading2StyleKey; break; - // case 3: styleKey = Styles.Heading3StyleKey; break; - // case 4: styleKey = Styles.Heading4StyleKey; break; - // case 5: styleKey = Styles.Heading5StyleKey; break; - // case 6: styleKey = Styles.Heading6StyleKey; break; - //} + //switch (obj.Level) + //{ + // case 1: styleKey = Styles.Heading1StyleKey; break; + // case 2: styleKey = Styles.Heading2StyleKey; break; + // case 3: styleKey = Styles.Heading3StyleKey; break; + // case 4: styleKey = Styles.Heading4StyleKey; break; + // case 5: styleKey = Styles.Heading5StyleKey; break; + // case 6: styleKey = Styles.Heading6StyleKey; break; + //} - //if (styleKey != null) - //{ - // paragraph.SetResourceReference(FrameworkContentElement.StyleProperty, styleKey); - //} + //if (styleKey != null) + //{ + // paragraph.SetResourceReference(FrameworkContentElement.StyleProperty, styleKey); + //} renderer.Push(new HeadingRowX()); // paragraph); - renderer.WriteLeafInline(obj); - renderer.Pop(); - } - } + renderer.WriteLeafInline(obj); + renderer.Pop(); + } + } } diff --git a/Utilities/MarkdigAgg/AggListRenderer.cs b/Utilities/MarkdigAgg/AggListRenderer.cs index 1b8d24024..236fc57e3 100644 --- a/Utilities/MarkdigAgg/AggListRenderer.cs +++ b/Utilities/MarkdigAgg/AggListRenderer.cs @@ -15,8 +15,6 @@ namespace Markdig.Renderers.Agg public ListX() : base(FlowDirection.TopToBottom) { - var theme = ApplicationController.Instance.Theme; - this.VAnchor = VAnchor.Fit; this.HAnchor = HAnchor.Stretch; } @@ -36,10 +34,8 @@ namespace Markdig.Renderers.Agg public class ListItemX : FlowLayoutWidget { private FlowLayoutWidget content; - public ListItemX() + public ListItemX(ThemeConfig theme) { - var theme = ApplicationController.Instance.Theme; - this.VAnchor = VAnchor.Fit; this.HAnchor = HAnchor.Stretch; @@ -64,6 +60,13 @@ namespace Markdig.Renderers.Agg public class AggListRenderer : AggObjectRenderer { + private ThemeConfig theme; + + public AggListRenderer(ThemeConfig theme) + { + this.theme = theme; + } + protected override void Write(AggRenderer renderer, ListBlock listBlock) { //var list = new List(); @@ -86,7 +89,7 @@ namespace Markdig.Renderers.Agg foreach (var item in listBlock) { - renderer.Push(new ListItemX()); + renderer.Push(new ListItemX(theme)); renderer.WriteChildren(item as ListItemBlock); renderer.Pop(); } diff --git a/Utilities/MarkdigAgg/AggRenderer.cs b/Utilities/MarkdigAgg/AggRenderer.cs index 3ba205dd1..60a21b66c 100644 --- a/Utilities/MarkdigAgg/AggRenderer.cs +++ b/Utilities/MarkdigAgg/AggRenderer.cs @@ -18,8 +18,8 @@ namespace Markdig.Renderers { public class TextWordX : TextWidget { - public TextWordX() - : base("", pointSize: 10, textColor: ApplicationController.Instance.Theme.Colors.PrimaryTextColor) + public TextWordX(ThemeConfig theme) + : base("", pointSize: 10, textColor: theme.Colors.PrimaryTextColor) { this.AutoExpandBoundsToText = true; } @@ -49,12 +49,18 @@ namespace Markdig.Renderers { private readonly Stack stack = new Stack(); private char[] buffer; + private ThemeConfig theme; public GuiWidget RootWidget { get; } public Uri BaseUri { get; set; } public List ChildLinks { get; internal set; } + public AggRenderer(ThemeConfig theme) + { + this.theme = theme; + } + public AggRenderer(GuiWidget rootWidget) { buffer = new char[1024]; @@ -63,8 +69,8 @@ namespace Markdig.Renderers stack.Push(rootWidget); // Default block renderers - ObjectRenderers.Add(new AggCodeBlockRenderer()); - ObjectRenderers.Add(new AggListRenderer()); + ObjectRenderers.Add(new AggCodeBlockRenderer(theme)); + ObjectRenderers.Add(new AggListRenderer(theme)); ObjectRenderers.Add(new AggHeadingRenderer()); ObjectRenderers.Add(new AggParagraphRenderer()); ObjectRenderers.Add(new AggQuoteBlockRenderer()); @@ -174,16 +180,21 @@ namespace Markdig.Renderers [MethodImpl(MethodImplOptions.AggressiveInlining)] internal void WriteText(string text) { - // TODO: Is this debugging? Debug.WriteLine()? var words = text.Split(' '); bool first = true; + foreach (var word in words) { if(!first) { WriteInline(new TextSpaceX { Text = " " }); } - WriteInline(new TextWordX { Text = word }); + + WriteInline(new TextWordX (theme) + { + Text = word + }); + first = false; } } @@ -191,7 +202,9 @@ namespace Markdig.Renderers internal void WriteText(string text, int offset, int length) { if (text == null) + { return; + } if (offset == 0 && text.Length == length) { diff --git a/Utilities/MarkdigAgg/MarkdownPage.cs b/Utilities/MarkdigAgg/MarkdownPage.cs index 491a1ef11..5bb5e0dae 100644 --- a/Utilities/MarkdigAgg/MarkdownPage.cs +++ b/Utilities/MarkdigAgg/MarkdownPage.cs @@ -39,6 +39,7 @@ namespace Markdig.Agg this.WindowTitle = this.HeaderText = "Markdown Tests"; contentRow.AddChild( new MarkdownWidget( + theme, new Uri("https://raw.githubusercontent.com/lunet-io/markdig/master/readme.md"))); } } diff --git a/Utilities/MarkdigAgg/MarkdownWidget.cs b/Utilities/MarkdigAgg/MarkdownWidget.cs index 3995519ae..f3d140247 100644 --- a/Utilities/MarkdigAgg/MarkdownWidget.cs +++ b/Utilities/MarkdigAgg/MarkdownWidget.cs @@ -43,20 +43,22 @@ namespace Markdig.Agg private FlowLayoutWidget contentPanel; private AggMarkdownDocument markdownDocument; + private ThemeConfig theme; - public MarkdownWidget(Uri contentUri, bool scrollContent = true) - : this(scrollContent) + public MarkdownWidget(ThemeConfig theme, Uri contentUri, bool scrollContent = true) + : this(theme, scrollContent) { markdownDocument.BaseUri = contentUri; this.LoadUri(contentUri); } - public MarkdownWidget(bool scrollContent = true) + public MarkdownWidget(ThemeConfig theme, bool scrollContent = true) : base(scrollContent) { markdownDocument = new AggMarkdownDocument(); + this.theme = theme; this.HAnchor = HAnchor.Stretch; this.ScrollArea.HAnchor = HAnchor.Stretch; @@ -114,8 +116,6 @@ namespace Markdig.Agg this.Width = 10; this.ScrollPositionFromTop = Vector2.Zero; - var theme = ApplicationController.Instance.Theme; - // Add header/edit button for HelpArticle pages if (sourceArticle != null) {