/// <summary> /// Adds the dynamic gridlines to GridLines list. /// They are created active as default, but the optional param can set this to false /// </summary> /// <param name="isactive"></param> public void AddDynamicGridLines(bool isactive = true) { SolidColorBrush color = Brushes.Blue; for (int i = 0; i <= MaxSize * 2; i++) { DWGridLine xline = new DWGridLine(new DWVector(MaxSize - i, MaxSize), new DWVector(MaxSize - i, -MaxSize), new DWLine ( 0, 0, LineType.GRID, new Line { Stroke = color, StrokeThickness = 0.5, X1 = UnitLength * i, Y1 = 0, X2 = UnitLength * i, Y2 = CanvasHeight }, color, isactive )); DWGridLine yline = new DWGridLine(new DWVector(-MaxSize, MaxSize - i), new DWVector(MaxSize, MaxSize - i), new DWLine ( 0, 0, LineType.GRID, new Line { Stroke = color, StrokeThickness = 0.5, X1 = 0, Y1 = UnitLength * i, X2 = CanvasWidth, Y2 = UnitLength * i }, color, isactive )); DynamicGridLines.Add(xline); DynamicGridLines.Add(yline); } }
// VECTOR METHODS /// <summary> /// Adds or removes active or inactive lines, respectively, to/from the canvas. /// Loops through both DWLines and DWGridLines /// </summary> /// <param name="plane"></param> public void ShowActiveLines(Canvas plane) { List <DWLine> dwlines = new List <DWLine>(); dwlines.AddRange(VectorLines); dwlines.AddRange(StaticGridLines); dwlines.AddRange(BasisVectors); dwlines.AddRange(DynamicGridLines.Select(x => x.DWLine)); foreach (DWLine dwline in dwlines) { if (dwline.IsActive) { if (!plane.Children.Contains(dwline.Line)) { plane.Children.Add(dwline.Line); } } else { plane.Children.Remove(dwline.Line); } } }