瀏覽代碼

Tidy up LineCanvas
Rename Drawing Scenario
Make API simpler by directly referencing Application.Driver

Thomas 2 年之前
父節點
當前提交
8f41296e78
共有 3 個文件被更改,包括 7 次插入13 次删除
  1. 2 8
      Terminal.Gui/Core/Graphs/LineCanvas.cs
  2. 4 4
      UICatalog/Scenarios/LineDrawing.cs
  3. 1 1
      UnitTests/LineCanvasTests.cs

+ 2 - 8
Terminal.Gui/Core/Graphs/LineCanvas.cs

@@ -13,12 +13,6 @@ namespace Terminal.Gui.Graphs {
 
 		
 		private List<StraightLine> lines = new List<StraightLine> ();
-		private ConsoleDriver driver;
-
-		public LineCanvas (ConsoleDriver driver)
-		{
-			this.driver = driver;
-		}
 
 		/// <summary>
 		/// Add a new line to the canvas starting at <paramref name="from"/>.
@@ -60,7 +54,7 @@ namespace Terminal.Gui.Graphs {
 						.ToArray ();
 
 					// TODO: use Driver and LineStyle to map
-					canvas [y, x] = GetRuneForIntersects (intersects);
+					canvas [y, x] = GetRuneForIntersects (Application.Driver, intersects);
 
 				}
 			}
@@ -90,7 +84,7 @@ namespace Terminal.Gui.Graphs {
 			}
 		}
 
-		private Rune? GetRuneForIntersects (IntersectionDefinition [] intersects)
+		private Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects)
 		{
 			if (!intersects.Any ())
 				return null;

+ 4 - 4
UICatalog/Scenarios/Drawing.cs → UICatalog/Scenarios/LineDrawing.cs

@@ -6,10 +6,10 @@ using Terminal.Gui.Graphs;
 
 namespace UICatalog.Scenarios {
 
-	[ScenarioMetadata (Name: "Drawing", Description: "Demonstrates LineCanvas.")]
+	[ScenarioMetadata (Name: "Line Drawing", Description: "Demonstrates LineCanvas.")]
 	[ScenarioCategory ("Controls")]
 	[ScenarioCategory ("Layout")]
-	public class Drawing : Scenario {
+	public class LineDrawing : Scenario {
 
 		public override void Setup ()
 		{
@@ -52,7 +52,7 @@ namespace UICatalog.Scenarios {
 
 			public ToolsView (int width)
 			{
-				grid = new LineCanvas (Application.Driver);
+				grid = new LineCanvas ();
 
 				grid.AddLine (new Point (0, 0), int.MaxValue, Orientation.Vertical, BorderStyle.Single);
 				grid.AddLine (new Point (0, 0), width, Orientation.Horizontal, BorderStyle.Single);
@@ -139,7 +139,7 @@ namespace UICatalog.Scenarios {
 					return;
 				}
 
-				canvases.Add (new LineCanvas (Application.Driver));
+				canvases.Add (new LineCanvas ());
 				colorLayers.Add (c, canvases.Count - 1);
 				currentColor = canvases.Count - 1;
 			}

+ 1 - 1
UnitTests/LineCanvasTests.cs

@@ -226,7 +226,7 @@ namespace Terminal.Gui.Core {
 				Bounds = new Rect (0, 0, 10, 5)
 			};
 
-			var canvasCopy = canvas =  new LineCanvas (Application.Driver);
+			var canvasCopy = canvas =  new LineCanvas ();
 			v.DrawContentComplete += (r)=> canvasCopy.Draw (v, v.Bounds);
 
 			return v;