diff --git a/GsaGH/Components/6_Display/AssemblyResults.cs b/GsaGH/Components/6_Display/AssemblyResults.cs index 2c80f9e30..2ba969e69 100644 --- a/GsaGH/Components/6_Display/AssemblyResults.cs +++ b/GsaGH/Components/6_Display/AssemblyResults.cs @@ -139,7 +139,7 @@ public override void CreateAttributes() { public override void DrawViewportWires(IGH_PreviewArgs args) { base.DrawViewportWires(args); - _contourLegendMenager.DrawLegend(args, _resType, _case, _gradients); + _contourLegendMenager.Legend.DrawLegendRectangle(args, _resType, _case, _gradients); } public override bool Read(GH_IReader reader) { diff --git a/GsaGH/Components/6_Display/Contour1dResults.cs b/GsaGH/Components/6_Display/Contour1dResults.cs index 2d28e6f74..162b7ed2d 100644 --- a/GsaGH/Components/6_Display/Contour1dResults.cs +++ b/GsaGH/Components/6_Display/Contour1dResults.cs @@ -167,7 +167,7 @@ public override void CreateAttributes() { public override void DrawViewportWires(IGH_PreviewArgs args) { base.DrawViewportWires(args); - _contourLegendMenager.DrawLegend(args, _resType, _case, _gradients); + _contourLegendMenager.Legend.DrawLegendRectangle(args, _resType, _case, _gradients); } public override bool Read(GH_IReader reader) { diff --git a/GsaGH/Components/6_Display/Contour2dResults.cs b/GsaGH/Components/6_Display/Contour2dResults.cs index 7ba0f3561..4dc8eac53 100644 --- a/GsaGH/Components/6_Display/Contour2dResults.cs +++ b/GsaGH/Components/6_Display/Contour2dResults.cs @@ -148,7 +148,7 @@ public override void CreateAttributes() { public override void DrawViewportWires(IGH_PreviewArgs args) { base.DrawViewportWires(args); - _contourLegendMenager.DrawLegend(args, _resType, _case, _gradients); + _contourLegendMenager.Legend.DrawLegendRectangle(args, _resType, _case, _gradients); } public override bool Read(GH_IReader reader) { diff --git a/GsaGH/Components/6_Display/Contour3dResults.cs b/GsaGH/Components/6_Display/Contour3dResults.cs index 336521b28..a551069ed 100644 --- a/GsaGH/Components/6_Display/Contour3dResults.cs +++ b/GsaGH/Components/6_Display/Contour3dResults.cs @@ -115,7 +115,7 @@ public override void CreateAttributes() { public override void DrawViewportWires(IGH_PreviewArgs args) { base.DrawViewportWires(args); - _contourLegendMenager.DrawLegend(args, _resType, _case, _gradients); + _contourLegendMenager.Legend.DrawLegendRectangle(args, _resType, _case, _gradients); } public override bool Read(GH_IReader reader) { diff --git a/GsaGH/Components/6_Display/ContourNodeResults.cs b/GsaGH/Components/6_Display/ContourNodeResults.cs index e889331f6..e0b03b042 100644 --- a/GsaGH/Components/6_Display/ContourNodeResults.cs +++ b/GsaGH/Components/6_Display/ContourNodeResults.cs @@ -142,7 +142,7 @@ public override void CreateAttributes() { public override void DrawViewportWires(IGH_PreviewArgs args) { base.DrawViewportWires(args); - _contourLegendMenager.DrawLegend(args, _resType, _case, _gradients); + _contourLegendMenager.Legend.DrawLegendRectangle(args, _resType, _case, _gradients); } public override bool Read(GH_IReader reader) { diff --git a/GsaGH/Helpers/GH/Legend/ContourLegendManager.cs b/GsaGH/Helpers/GH/Legend/ContourLegendManager.cs index 2eecd1ad7..43200be7c 100644 --- a/GsaGH/Helpers/GH/Legend/ContourLegendManager.cs +++ b/GsaGH/Helpers/GH/Legend/ContourLegendManager.cs @@ -1,12 +1,8 @@ using System; -using System.Collections.Generic; -using System.Drawing; using System.Windows.Forms; using GH_IO.Serialization; -using Grasshopper.Kernel; - using GsaGH.Helpers.GH; using OasysGH.Components; @@ -32,13 +28,6 @@ public ContourLegendManager( MenuBuilder = menuBuilder; } - //drawing - public void DrawLegend( - IGH_PreviewArgs args, string title, string bottomText, - List<(int startY, int endY, Color gradientColor)> gradients) { - Legend.DrawLegendRectangle(args, title, bottomText, gradients); - } - //menu public ToolStripMenuItem CreateMenu(GH_OasysDropDownComponent component, Action updateUI) { LegendMenuBuilder.SetLegendScaleDelegate setScaleDelegate = UpdateScale; diff --git a/GsaGHTests/Helpers/GH/Legend/ContourLegendMenagerTests.cs b/GsaGHTests/Helpers/GH/Legend/ContourLegendMenagerTests.cs index 9f39d0303..84a617c09 100644 --- a/GsaGHTests/Helpers/GH/Legend/ContourLegendMenagerTests.cs +++ b/GsaGHTests/Helpers/GH/Legend/ContourLegendMenagerTests.cs @@ -16,16 +16,16 @@ namespace GsaGHTests.Helpers { [Collection("GrasshopperFixture collection")] public class ContourLegendMenagerTests { - private static Mock _mockLegend; - private static Mock _mockConfiguration; + private static ContourLegend _legend; + private static ContourLegendConfiguration _configuration; private static ContourLegendManager _manager; private static Mock _mockArgs; public ContourLegendMenagerTests() { - _mockLegend = new Mock(); - _mockConfiguration = new Mock(); + _configuration = new ContourLegendConfiguration(1, 1, 1.0d); + _legend = new ContourLegend(_configuration); var menuBuilder = new LegendMenuBuilder(); - _manager = new ContourLegendManager(_mockConfiguration.Object, _mockLegend.Object, menuBuilder); + _manager = new ContourLegendManager(_configuration, _legend, menuBuilder); _mockArgs = new Mock(); } @@ -39,9 +39,9 @@ public void DrawLegend_CallsDrawLegendRectangle() { (10, 20, Color.Green), }; - _manager.DrawLegend(_mockArgs.Object, title, bottomText, gradients); + _manager.Legend.DrawLegendRectangle(_mockArgs.Object, title, bottomText, gradients); - _mockLegend.Verify(l => l.DrawLegendRectangle(_mockArgs.Object, title, bottomText, gradients), Times.Once); + Assert.True(_manager.Legend.IsInvalidConfiguration); } [Fact] @@ -58,7 +58,7 @@ ToolStripMenuItem menuItem public void UpdateScale_CallsSetLegendScale() { double scale = 2.5; _manager.UpdateScale(scale); - Assert.Equal(scale, _mockConfiguration.Object.Scale); + Assert.Equal(scale, _configuration.Scale); } } }